From 1587989518cd61bae3d1b234efd82cd3b11580dd Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 2 Sep 2014 05:15:30 +0200 Subject: avcodec/rawdec: Support CODEC_CAP_PARAM_CHANGE Reviewed-by: Paul B Mahol Signed-off-by: Michael Niedermayer --- libavcodec/rawdec.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'libavcodec/rawdec.c') diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c index 305c13e5e4..28792a1688 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, }; -- cgit v1.2.3