From 8a67606c20958fa21db0b5ba9a17f379bc01786c Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 7 Apr 2016 18:26:58 +0200 Subject: vd_lavc: let hardware decoder request delaying frames explicitly Until now, the presence of the process_image() callback was used to set a delay queue with a hardcoded size. Change this to a vd_lavc_hwdec field instead, so the decoder can explicitly set this if it's really needed. Do this so process_image() can be used in the VideoToolbox glue code for something entirely unrelated. --- video/decode/d3d11va.c | 1 + video/decode/dxva2.c | 1 + video/decode/lavc.h | 5 +++++ video/decode/vaapi.c | 1 + video/decode/vd_lavc.c | 5 +---- 5 files changed, 9 insertions(+), 4 deletions(-) (limited to 'video/decode') diff --git a/video/decode/d3d11va.c b/video/decode/d3d11va.c index bf59c0f49b..622a28981d 100644 --- a/video/decode/d3d11va.c +++ b/video/decode/d3d11va.c @@ -495,4 +495,5 @@ const struct vd_lavc_hwdec mp_vd_lavc_d3d11va_copy = { .init_decoder = d3d11va_init_decoder, .allocate_image = d3d11va_allocate_image, .process_image = d3d11va_retrieve_image, + .delay_queue = HWDEC_DELAY_QUEUE_COUNT, }; diff --git a/video/decode/dxva2.c b/video/decode/dxva2.c index 50eee69d2a..c90fa76885 100644 --- a/video/decode/dxva2.c +++ b/video/decode/dxva2.c @@ -516,4 +516,5 @@ const struct vd_lavc_hwdec mp_vd_lavc_dxva2_copy = { .init_decoder = dxva2_init_decoder, .allocate_image = dxva2_allocate_image, .process_image = dxva2_retrieve_image, + .delay_queue = HWDEC_DELAY_QUEUE_COUNT, }; diff --git a/video/decode/lavc.h b/video/decode/lavc.h index 44c5c27a0f..826edbff83 100644 --- a/video/decode/lavc.h +++ b/video/decode/lavc.h @@ -49,6 +49,11 @@ struct vd_lavc_hwdec { // If not-0: the IMGFMT_ format that should be accepted in the libavcodec // get_format callback. int image_format; + // 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 + // immediately after decoding. + int delay_queue; int (*probe)(struct vd_lavc_hwdec *hwdec, struct mp_hwdec_info *info, const char *codec); int (*init)(struct lavc_ctx *ctx); diff --git a/video/decode/vaapi.c b/video/decode/vaapi.c index 97fe59c889..2682225876 100644 --- a/video/decode/vaapi.c +++ b/video/decode/vaapi.c @@ -508,4 +508,5 @@ const struct vd_lavc_hwdec mp_vd_lavc_vaapi_copy = { .init_decoder = init_decoder, .allocate_image = allocate_image, .process_image = copy_image, + .delay_queue = HWDEC_DELAY_QUEUE_COUNT, }; diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index 175df0bc6e..a444f88c10 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -401,10 +401,7 @@ static void init_avctx(struct dec_video *vd, const char *decoder, avctx->get_buffer2 = get_buffer2_hwdec; if (ctx->hwdec->init(ctx) < 0) goto error; - // This can increase efficiency by not blocking on the hardware - // pipeline by reading back immediately after decoding. - if (ctx->hwdec->process_image) - ctx->max_delay_queue = HWDEC_DELAY_QUEUE_COUNT; + ctx->max_delay_queue = ctx->hwdec->delay_queue; } else { mp_set_avcodec_threads(vd->log, avctx, lavc_param->threads); } -- cgit v1.2.3