diff options
Diffstat (limited to 'video')
-rw-r--r-- | video/decode/d3d11va.c | 1 | ||||
-rw-r--r-- | video/decode/dxva2.c | 1 | ||||
-rw-r--r-- | video/decode/lavc.h | 2 | ||||
-rw-r--r-- | video/decode/vaapi.c | 1 | ||||
-rw-r--r-- | video/decode/vd_lavc.c | 12 | ||||
-rw-r--r-- | video/hwdec.h | 5 | ||||
-rw-r--r-- | video/out/opengl/hwdec.c | 2 |
7 files changed, 19 insertions, 5 deletions
diff --git a/video/decode/d3d11va.c b/video/decode/d3d11va.c index 9e300b1620..d631fff479 100644 --- a/video/decode/d3d11va.c +++ b/video/decode/d3d11va.c @@ -583,6 +583,7 @@ const struct vd_lavc_hwdec mp_vd_lavc_d3d11va = { const struct vd_lavc_hwdec mp_vd_lavc_d3d11va_copy = { .type = HWDEC_D3D11VA_COPY, + .copying = true, .image_format = IMGFMT_D3D11VA, .probe = d3d11va_probe, .init = d3d11va_init, diff --git a/video/decode/dxva2.c b/video/decode/dxva2.c index 5d3afda86c..fe78a52e8c 100644 --- a/video/decode/dxva2.c +++ b/video/decode/dxva2.c @@ -499,6 +499,7 @@ const struct vd_lavc_hwdec mp_vd_lavc_dxva2 = { const struct vd_lavc_hwdec mp_vd_lavc_dxva2_copy = { .type = HWDEC_DXVA2_COPY, + .copying = true, .image_format = IMGFMT_DXVA2, .probe = dxva2_probe, .init = dxva2_init, diff --git a/video/decode/lavc.h b/video/decode/lavc.h index dbefe79ad9..689222d872 100644 --- a/video/decode/lavc.h +++ b/video/decode/lavc.h @@ -49,6 +49,8 @@ struct vd_lavc_hwdec { // If not-0: the IMGFMT_ format that should be accepted in the libavcodec // get_format callback. int image_format; + // Always returns a non-hwaccel image format. + bool copying; // Setting this will queue the given number of frames before calling // process_image() or returning them to the renderer. This can increase // efficiency by not blocking on the hardware pipeline by reading back diff --git a/video/decode/vaapi.c b/video/decode/vaapi.c index 4b098a8804..d108d50a8b 100644 --- a/video/decode/vaapi.c +++ b/video/decode/vaapi.c @@ -507,6 +507,7 @@ const struct vd_lavc_hwdec mp_vd_lavc_vaapi = { const struct vd_lavc_hwdec mp_vd_lavc_vaapi_copy = { .type = HWDEC_VAAPI_COPY, + .copying = true, .image_format = IMGFMT_VAAPI, .probe = probe_copy, .init = init_copy, diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index 75ca1f0229..fbb04d1abd 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -138,6 +138,7 @@ static const struct vd_lavc_hwdec mp_vd_lavc_rpi = { static const struct vd_lavc_hwdec mp_vd_lavc_mediacodec = { .type = HWDEC_MEDIACODEC, .lavc_suffix = "_mediacodec", + .copying = true, }; static const struct vd_lavc_hwdec *const hwdec_list[] = { @@ -347,7 +348,8 @@ static void reinit(struct dec_video *vd) struct vd_lavc_hwdec *hwdec = NULL; if (hwdec_codec_allowed(vd, codec)) { - if (vd->opts->hwdec_api == HWDEC_AUTO) { + int api = vd->opts->hwdec_api; + if (HWDEC_IS_AUTO(api)) { // If a specific decoder is forced, we should try a hwdec method // that works with it, instead of simply failing later at runtime. // This is good for avoiding trying "normal" hwaccels on wrapper @@ -369,11 +371,15 @@ static void reinit(struct dec_video *vd) MP_VERBOSE(vd, "This hwaccel is not compatible.\n"); continue; } + if (api == HWDEC_AUTO_COPY && !hwdec->copying) { + MP_VERBOSE(vd, "Not using this for auto-copy mode.\n"); + continue; + } break; } } - } else if (vd->opts->hwdec_api != HWDEC_NONE) { - hwdec = probe_hwdec(vd, false, vd->opts->hwdec_api, codec); + } else if (api != HWDEC_NONE) { + hwdec = probe_hwdec(vd, false, api, codec); } } else { MP_VERBOSE(vd, "Not trying to use hardware decoding: codec %s is not " diff --git a/video/hwdec.h b/video/hwdec.h index 48ec6a2a21..5d563c983b 100644 --- a/video/hwdec.h +++ b/video/hwdec.h @@ -9,6 +9,7 @@ struct mp_image_pool; enum hwdec_type { HWDEC_NONE = 0, HWDEC_AUTO, + HWDEC_AUTO_COPY, HWDEC_VDPAU, HWDEC_VIDEOTOOLBOX, HWDEC_VAAPI, @@ -21,11 +22,13 @@ enum hwdec_type { HWDEC_MEDIACODEC, }; +#define HWDEC_IS_AUTO(x) ((x) == HWDEC_AUTO || (x) == HWDEC_AUTO_COPY) + // hwdec_type names (options.c) extern const struct m_opt_choice_alternatives mp_hwdec_names[]; struct mp_hwdec_ctx { - enum hwdec_type type; // (never HWDEC_NONE or HWDEC_AUTO) + enum hwdec_type type; // (never HWDEC_NONE or HWDEC_IS_AUTO) const char *driver_name; // NULL if unknown/not loaded // This is never NULL. Its meaning depends on the .type field: diff --git a/video/out/opengl/hwdec.c b/video/out/opengl/hwdec.c index 1f654fc1ec..fac0c3ff9a 100644 --- a/video/out/opengl/hwdec.c +++ b/video/out/opengl/hwdec.c @@ -88,7 +88,7 @@ struct gl_hwdec *gl_hwdec_load_api(struct mp_log *log, GL *gl, struct mp_hwdec_devices *devs, enum hwdec_type api) { - bool is_auto = api == HWDEC_AUTO; + bool is_auto = HWDEC_IS_AUTO(api); for (int n = 0; mpgl_hwdec_drivers[n]; n++) { const struct gl_hwdec_driver *drv = mpgl_hwdec_drivers[n]; if (is_auto || api == drv->api) { |