From 1c70fb229a0f6f9637040acf59f23ce629b5e07a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= Date: Mon, 3 Aug 2015 21:40:12 -0400 Subject: avviddec: Use caps-like size in get_buffer2() The size in the AVFrame in get_buffer2 don't match the output size, instead they match ffmpeg's memory requirements, so we can't compare them from the values of the output AVFrame. Those are comparable to the values in the passed AVCodecContext. --- ext/libav/gstavviddec.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/ext/libav/gstavviddec.c b/ext/libav/gstavviddec.c index 03a7334..51de756 100644 --- a/ext/libav/gstavviddec.c +++ b/ext/libav/gstavviddec.c @@ -660,20 +660,16 @@ gst_ffmpegviddec_get_buffer2 (AVCodecContext * context, AVFrame * picture, /* If the picture format changed but we already negotiated before, * we will have to do fallback allocation until output and input * formats are in sync again. We will renegotiate on the output + * We use the info from the context which correspond to the input format, + * the info from the picture correspond to memory requires, not to the actual + * image size. */ - if (ffmpegdec->pic_width != 0 && picture_changed (ffmpegdec, picture)) + if (ffmpegdec->pic_width != 0 && + !(ffmpegdec->pic_width == context->width + && ffmpegdec->pic_height == context->height + && ffmpegdec->pic_pix_fmt == picture->format)) goto fallback; - /* see if we need renegotiation */ - /* Disabled for now as ffmpeg doesn't give us the output dimensions - * in the getbuffer2 callback. The real dimensions are only available - * when a buffer is produced. - */ - if (FALSE - && G_UNLIKELY (!gst_ffmpegviddec_negotiate (ffmpegdec, context, picture, - FALSE))) - goto negotiate_failed; - if (!ffmpegdec->current_dr) goto no_dr; @@ -745,11 +741,6 @@ gst_ffmpegviddec_get_buffer2 (AVCodecContext * context, AVFrame * picture, return 0; /* fallbacks */ -negotiate_failed: - { - GST_DEBUG_OBJECT (ffmpegdec, "negotiate failed"); - goto fallback; - } no_dr: { GST_LOG_OBJECT (ffmpegdec, "direct rendering disabled, fallback alloc"); -- cgit v1.2.1