0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 03:52:22 +02:00

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.
This commit is contained in:
wm4 2017-12-01 06:47:37 +01:00
parent 643a1fc7de
commit c5fac0c2b0
7 changed files with 9 additions and 11 deletions

View File

@ -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,
};

View File

@ -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);

View File

@ -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,
};

View File

@ -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,
};

View File

@ -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.

View File

@ -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) {

View File

@ -122,6 +122,8 @@ struct hwcontext_fns {
// AVFrame, with all other fields already set. img.hwctx will be set, and
// use the correct AV_HWDEVICE_TYPE_.
void (*complete_image_params)(struct mp_image *img);
// Fill in special format-specific requirements.
void (*refine_hwframes)(struct AVBufferRef *hw_frames_ctx);
};
// The parameter is of type enum AVHWDeviceType (as in int to avoid extensive