diff options
author | wm4 <wm4@nowhere> | 2016-09-30 13:46:27 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-09-30 13:46:27 +0200 |
commit | 2aba6972cf9e07fe2817ff072e5e82756d80d795 (patch) | |
tree | 81f1216b5a4f5bb961dfafbd5b7b0af0c1326ee3 /video | |
parent | 2f1af04745191250cb833704ffa55a47e1ee563b (diff) |
vo_opengl: allow hwdec interops to support multiple image formats
Diffstat (limited to 'video')
-rw-r--r-- | video/out/opengl/hwdec.c | 9 | ||||
-rw-r--r-- | video/out/opengl/hwdec.h | 6 | ||||
-rw-r--r-- | video/out/opengl/video.c | 4 |
3 files changed, 17 insertions, 2 deletions
diff --git a/video/out/opengl/hwdec.c b/video/out/opengl/hwdec.c index 7d47e152b5..261931a8d4 100644 --- a/video/out/opengl/hwdec.c +++ b/video/out/opengl/hwdec.c @@ -116,3 +116,12 @@ void gl_hwdec_uninit(struct gl_hwdec *hwdec) hwdec->driver->destroy(hwdec); talloc_free(hwdec); } + +bool gl_hwdec_test_format(struct gl_hwdec *hwdec, int imgfmt) +{ + if (!imgfmt) + return false; + if (hwdec->driver->test_format) + return hwdec->driver->test_format(hwdec, imgfmt); + return hwdec->driver->imgfmt == imgfmt; +} diff --git a/video/out/opengl/hwdec.h b/video/out/opengl/hwdec.h index ce59b67e58..6a1bb98bff 100644 --- a/video/out/opengl/hwdec.h +++ b/video/out/opengl/hwdec.h @@ -38,6 +38,7 @@ struct gl_hwdec_driver { // Used to explicitly request a specific API. enum hwdec_type api; // The hardware surface IMGFMT_ that must be passed to map_image later. + // If the test_format callback is set, this field is ignored! int imgfmt; // Create the hwdec device. It must add it to hw->devs, if applicable. int (*create)(struct gl_hwdec *hw); @@ -56,6 +57,9 @@ struct gl_hwdec_driver { void (*destroy)(struct gl_hwdec *hw); + // Optional callback for checking input format support. + bool (*test_format)(struct gl_hwdec *hw, int imgfmt); + // The following functions provide an alternative API. Each gl_hwdec_driver // must have either map_frame or overlay_frame set (not both or none), and // if overlay_frame is set, it operates in overlay mode. In this mode, @@ -79,4 +83,6 @@ struct gl_hwdec *gl_hwdec_load_api(struct mp_log *log, GL *gl, void gl_hwdec_uninit(struct gl_hwdec *hwdec); +bool gl_hwdec_test_format(struct gl_hwdec *hwdec, int imgfmt); + #endif diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c index ab799f3583..99b0d8273c 100644 --- a/video/out/opengl/video.c +++ b/video/out/opengl/video.c @@ -829,7 +829,7 @@ static void init_video(struct gl_video *p) { GL *gl = p->gl; - if (p->hwdec && p->hwdec->driver->imgfmt == p->image_params.imgfmt) { + if (p->hwdec && gl_hwdec_test_format(p->hwdec, p->image_params.imgfmt)) { if (p->hwdec->driver->reinit(p->hwdec, &p->image_params) < 0) MP_ERR(p, "Initializing texture for hardware decoding failed.\n"); init_image_desc(p, p->image_params.imgfmt); @@ -3397,7 +3397,7 @@ bool gl_video_check_format(struct gl_video *p, int mp_format) { if (init_format(p, mp_format, true)) return true; - if (p->hwdec && p->hwdec->driver->imgfmt == mp_format) + if (p->hwdec && gl_hwdec_test_format(p->hwdec, mp_format)) return true; return false; } |