From c5fac0c2b048b695bf217ae77530269605eebfb9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 1 Dec 2017 06:47:37 +0100 Subject: vd_lavc: move entrypoint for hwframes_refine The idea is to get rid of vd_lavc_hwdec, so special functionality like this has to go somewhere else. At this point, hwframes_refine is only needed for d3d11, and it doesn't do much, so for now the new callback has no context. In can be made more fancy if really needed. --- video/decode/d3d.c | 3 ++- video/decode/d3d.h | 2 -- video/decode/hw_d3d11va.c | 2 -- video/decode/hw_dxva2.c | 2 -- video/decode/lavc.h | 2 -- video/decode/vd_lavc.c | 7 +++++-- 6 files changed, 7 insertions(+), 11 deletions(-) (limited to 'video/decode') diff --git a/video/decode/d3d.c b/video/decode/d3d.c index dcaa0008b2..cab878bafe 100644 --- a/video/decode/d3d.c +++ b/video/decode/d3d.c @@ -80,7 +80,7 @@ bool d3d11_check_decoding(ID3D11Device *dev) return !FAILED(hr) && (supported & D3D11_BIND_DECODER); } -void d3d_hwframes_refine(struct lavc_ctx *ctx, AVBufferRef *hw_frames_ctx) +static void d3d11_refine_hwframes(AVBufferRef *hw_frames_ctx) { AVHWFramesContext *fctx = (void *)hw_frames_ctx->data; @@ -127,4 +127,5 @@ static void d3d11_complete_image_params(struct mp_image *img) const struct hwcontext_fns hwcontext_fns_d3d11 = { .av_hwdevice_type = AV_HWDEVICE_TYPE_D3D11VA, .complete_image_params = d3d11_complete_image_params, + .refine_hwframes = d3d11_refine_hwframes, }; diff --git a/video/decode/d3d.h b/video/decode/d3d.h index efac35dd76..2da349a27a 100644 --- a/video/decode/d3d.h +++ b/video/decode/d3d.h @@ -38,8 +38,6 @@ bool d3d11_check_decoding(ID3D11Device *dev); struct AVBufferRef; struct IDirect3DDevice9; -void d3d_hwframes_refine(struct lavc_ctx *ctx, struct AVBufferRef *hw_frames_ctx); - struct AVBufferRef *d3d11_wrap_device_ref(ID3D11Device *device); struct AVBufferRef *d3d9_wrap_device_ref(struct IDirect3DDevice9 *device); diff --git a/video/decode/hw_d3d11va.c b/video/decode/hw_d3d11va.c index eabb984dec..cc1d122f59 100644 --- a/video/decode/hw_d3d11va.c +++ b/video/decode/hw_d3d11va.c @@ -83,7 +83,6 @@ const struct vd_lavc_hwdec mp_vd_lavc_d3d11va = { .image_format = IMGFMT_D3D11VA, .generic_hwaccel = true, .set_hwframes = true, - .hwframes_refine = d3d_hwframes_refine, }; const struct vd_lavc_hwdec mp_vd_lavc_d3d11va_copy = { @@ -93,6 +92,5 @@ const struct vd_lavc_hwdec mp_vd_lavc_d3d11va_copy = { .generic_hwaccel = true, .create_dev = d3d11_create_dev, .set_hwframes = true, - .hwframes_refine = d3d_hwframes_refine, .delay_queue = HWDEC_DELAY_QUEUE_COUNT, }; diff --git a/video/decode/hw_dxva2.c b/video/decode/hw_dxva2.c index ebfa12d1e1..37b2b78003 100644 --- a/video/decode/hw_dxva2.c +++ b/video/decode/hw_dxva2.c @@ -171,7 +171,6 @@ const struct vd_lavc_hwdec mp_vd_lavc_dxva2 = { .image_format = IMGFMT_DXVA2, .generic_hwaccel = true, .set_hwframes = true, - .hwframes_refine = d3d_hwframes_refine, }; const struct vd_lavc_hwdec mp_vd_lavc_dxva2_copy = { @@ -181,6 +180,5 @@ const struct vd_lavc_hwdec mp_vd_lavc_dxva2_copy = { .generic_hwaccel = true, .create_dev = d3d9_create_dev, .set_hwframes = true, - .hwframes_refine = d3d_hwframes_refine, .delay_queue = HWDEC_DELAY_QUEUE_COUNT, }; diff --git a/video/decode/lavc.h b/video/decode/lavc.h index caa6200121..b427ae17a2 100644 --- a/video/decode/lavc.h +++ b/video/decode/lavc.h @@ -101,8 +101,6 @@ struct vd_lavc_hwdec { // The returned device will be freed with mp_hwdec_ctx->destroy. struct mp_hwdec_ctx *(*create_dev)(struct mpv_global *global, struct mp_log *log, bool probing); - // Optional. Fill in special hwaccel- and codec-specific requirements. - void (*hwframes_refine)(struct lavc_ctx *ctx, AVBufferRef *hw_frames_ctx); // Suffix for libavcodec decoder. If non-NULL, the codec is overridden // with hwdec_find_decoder. // Intuitively, this will force the corresponding wrapper decoder. diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index 5b5a7c47fb..90217f5b8d 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -754,8 +754,11 @@ static int init_generic_hwaccel(struct dec_video *vd, enum AVPixelFormat hw_fmt) if (new_fctx->initial_pool_size) new_fctx->initial_pool_size += HWDEC_EXTRA_SURFACES - 1; - if (ctx->hwdec->hwframes_refine) - ctx->hwdec->hwframes_refine(ctx, new_frames_ctx); + const struct hwcontext_fns *fns = + hwdec_get_hwcontext_fns(new_fctx->device_ctx->type); + + if (fns && fns->refine_hwframes) + fns->refine_hwframes(new_frames_ctx); // We might be able to reuse a previously allocated frame pool. if (ctx->cached_hw_frames_ctx) { -- cgit v1.2.3