[FFmpeg-devel] [PATCH 1/2] avcodec/rawdec: Support CODEC_CAP_PARAM_CHANGE

Michael Niedermayer michaelni at gmx.at
Tue Sep 2 05:42:07 CEST 2014


Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavcodec/rawdec.c |   30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index 305c13e..28792a1 100644
--- a/libavcodec/rawdec.c
+++ b/libavcodec/rawdec.c
@@ -98,19 +98,6 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
             memset(context->palette->data, 0, AVPALETTE_SIZE);
     }
 
-    if ((avctx->bits_per_coded_sample == 4 || avctx->bits_per_coded_sample == 2) &&
-        avctx->pix_fmt == AV_PIX_FMT_PAL8 &&
-       (!avctx->codec_tag || avctx->codec_tag == MKTAG('r','a','w',' '))) {
-        context->is_2_4_bpp = 1;
-        context->frame_size = avpicture_get_size(avctx->pix_fmt,
-                                                 FFALIGN(avctx->width, 16),
-                                                 avctx->height);
-    } else {
-        context->is_lt_16bpp = av_get_bits_per_pixel(desc) == 16 && avctx->bits_per_coded_sample && avctx->bits_per_coded_sample < 16;
-        context->frame_size = avpicture_get_size(avctx->pix_fmt, avctx->width,
-                                                 avctx->height);
-    }
-
     if ((avctx->extradata_size >= 9 &&
          !memcmp(avctx->extradata + avctx->extradata_size - 9, "BottomUp", 9)) ||
         avctx->codec_tag == MKTAG('c','y','u','v') ||
@@ -168,11 +155,25 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
     int buf_size                   = avpkt->size;
     int linesize_align             = 4;
     int res, len;
-    int need_copy                  = !avpkt->buf || context->is_2_4_bpp || context->is_yuv2 || context->is_lt_16bpp;
+    int need_copy;
 
     AVFrame   *frame   = data;
     AVPicture *picture = data;
 
+    if ((avctx->bits_per_coded_sample == 4 || avctx->bits_per_coded_sample == 2) &&
+        avctx->pix_fmt == AV_PIX_FMT_PAL8 &&
+       (!avctx->codec_tag || avctx->codec_tag == MKTAG('r','a','w',' '))) {
+        context->is_2_4_bpp = 1;
+        context->frame_size = avpicture_get_size(avctx->pix_fmt,
+                                                 FFALIGN(avctx->width, 16),
+                                                 avctx->height);
+    } else {
+        context->is_lt_16bpp = av_get_bits_per_pixel(desc) == 16 && avctx->bits_per_coded_sample && avctx->bits_per_coded_sample < 16;
+        context->frame_size = avpicture_get_size(avctx->pix_fmt, avctx->width,
+                                                 avctx->height);
+    }
+    need_copy = !avpkt->buf || context->is_2_4_bpp || context->is_yuv2 || context->is_lt_16bpp;
+
     frame->pict_type        = AV_PICTURE_TYPE_I;
     frame->key_frame        = 1;
 
@@ -368,4 +369,5 @@ AVCodec ff_rawvideo_decoder = {
     .close          = raw_close_decoder,
     .decode         = raw_decode,
     .priv_class     = &rawdec_class,
+    .capabilities   = CODEC_CAP_PARAM_CHANGE,
 };
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list