summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-12-01 06:47:37 +0100
committerwm4 <wm4@nowhere>2017-12-01 08:01:41 +0100
commitc5fac0c2b048b695bf217ae77530269605eebfb9 (patch)
treee2ce5d58346a93173b1e1ee4d1fda152261a54b8 /video
parent643a1fc7de84b234d5a4723fa0ec31f9351e770b (diff)
downloadmpv-c5fac0c2b048b695bf217ae77530269605eebfb9.tar.bz2
mpv-c5fac0c2b048b695bf217ae77530269605eebfb9.tar.xz
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.
Diffstat (limited to 'video')
-rw-r--r--video/decode/d3d.c3
-rw-r--r--video/decode/d3d.h2
-rw-r--r--video/decode/hw_d3d11va.c2
-rw-r--r--video/decode/hw_dxva2.c2
-rw-r--r--video/decode/lavc.h2
-rw-r--r--video/decode/vd_lavc.c7
-rw-r--r--video/hwdec.h2
7 files changed, 9 insertions, 11 deletions
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) {
diff --git a/video/hwdec.h b/video/hwdec.h
index 3a551ef6f7..f8a77465f3 100644
--- a/video/hwdec.h
+++ b/video/hwdec.h
@@ -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