1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-28 10:02:17 +00:00

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.
This commit is contained in:
wm4 2016-04-07 18:26:58 +02:00
parent f009d16f36
commit 8a67606c20
5 changed files with 9 additions and 4 deletions

View File

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

View File

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

View File

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

View File

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

View File

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