mirror of
https://github.com/mpv-player/mpv
synced 2024-12-27 17:42:17 +00:00
vo_opengl: allow hwdec interops to support multiple image formats
This commit is contained in:
parent
2f1af04745
commit
2aba6972cf
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user