avcodec/rawdec: Support CODEC_CAP_PARAM_CHANGE
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 2 Sep 2014 03:15:30 +0000 (05:15 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 2 Sep 2014 11:35:36 +0000 (13:35 +0200)
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/rawdec.c

index 305c13e..28792a1 100644 (file)
@@ -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,
 };