[FFmpeg-devel] [PATCH v4 1/3] avcodec/bitpacked: move ff_get_buffer

Patrick Keroulas patrick.keroulas at savoirfairelinux.com
Thu Apr 26 00:22:49 EEST 2018


From: Damien Riegel <damien.riegel at savoirfairelinux.com>

ff_get_buffer is used to allocate a buffer to hold frame's content. This
function was called in the function in charge of decoding an AVPacket
containing raw video with the yuv422 pixel format and a depth of 10-bit.

RFC4175 supports both progressive and interlaced mode. But the
interlaced mode doesn't consist of interlaced frames, only of fields.
FFmpeg cannot handle fields on their own, so the codec has to recreate
interlaced frames based on two consecutive fields.

As the function `bitpacked_decode_yuv422p10` will need to be called
twice to do that, it cannot be in charge of the buffer allocation, so
move it into its caller.

Signed-off-by: Damien Riegel <damien.riegel at savoirfairelinux.com>
---
 libavcodec/bitpacked.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavcodec/bitpacked.c b/libavcodec/bitpacked.c
index f0b417d..85d4bdd 100644
--- a/libavcodec/bitpacked.c
+++ b/libavcodec/bitpacked.c
@@ -64,9 +64,6 @@ static int bitpacked_decode_yuv422p10(AVCodecContext *avctx, AVFrame *frame,
     uint16_t *y, *u, *v;
     int ret, i, j;
 
-    ret = ff_get_buffer(avctx, frame, 0);
-    if (ret < 0)
-        return ret;
 
     if (frame_size > packet_size)
         return AVERROR_INVALIDDATA;
@@ -128,6 +125,12 @@ static int bitpacked_decode(AVCodecContext *avctx, void *data, int *got_frame,
     frame->pict_type = AV_PICTURE_TYPE_I;
     frame->key_frame = 1;
 
+    if (avctx->pix_fmt == AV_PIX_FMT_YUV422P10) {
+        res = ff_get_buffer(avctx, frame, 0);
+        if (res < 0)
+            return res;
+    }
+
     res = bc->decode(avctx, frame, avpkt);
     if (res)
         return res;
-- 
2.7.4



More information about the ffmpeg-devel mailing list