X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fnuv.c;h=3ba12fd8e6514c5a05ac52f8c58d3a371a566b1f;hb=a247ac640df3da573cd661065bf53f37863e2b46;hp=32ed65899b13ddcf2b018a8dc829b994c4e5c7c6;hpb=762c2b5dcd99a08452299cd1f83070f88115f1f3;p=ffmpeg diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c index 32ed65899b1..3ba12fd8e65 100644 --- a/libavcodec/nuv.c +++ b/libavcodec/nuv.c @@ -126,15 +126,15 @@ static int codec_reinit(AVCodecContext *avctx, int width, int height, get_quant_quality(c, quality); if (width != c->width || height != c->height) { // also reserve space for a possible additional header - int buf_size = height * width * 3 / 2 + int64_t buf_size = height * (int64_t)width * 3 / 2 + FFMAX(AV_LZO_OUTPUT_PADDING, AV_INPUT_BUFFER_PADDING_SIZE) + RTJPEG_HEADER_SIZE; if (buf_size > INT_MAX/8) return -1; - if ((ret = av_image_check_size(height, width, 0, avctx)) < 0) + if ((ret = ff_set_dimensions(avctx, width, height)) < 0) return ret; - avctx->width = c->width = width; - avctx->height = c->height = height; + c->width = width; + c->height = height; av_fast_malloc(&c->decomp_buf, &c->decomp_size, buf_size); if (!c->decomp_buf) { @@ -162,6 +162,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, int keyframe, ret; int size_change = 0; int minsize = 0; + int flags = 0; int result, init_frame = !avctx->frame_number; enum { NUV_UNCOMPRESSED = '0', @@ -204,6 +205,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, } break; case NUV_COPY_LAST: + flags |= FF_REGET_BUFFER_FLAG_READONLY; keyframe = 0; break; default: @@ -217,6 +219,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, case NUV_RTJPEG: minsize = c->width/16 * (c->height/16) * 6; break; + case NUV_BLACK: + case NUV_COPY_LAST: + case NUV_LZO: + case NUV_RTJPEG_IN_LZO: + break; + default: + av_log(avctx, AV_LOG_ERROR, "unknown compression\n"); + return AVERROR_INVALIDDATA; } if (buf_size < minsize / 4) return AVERROR_INVALIDDATA; @@ -268,7 +278,7 @@ retry: init_frame = 1; } - if ((result = ff_reget_buffer(avctx, c->pic)) < 0) + if ((result = ff_reget_buffer(avctx, c->pic, flags)) < 0) return result; if (init_frame) { memset(c->pic->data[0], 0, avctx->height * c->pic->linesize[0]); @@ -305,9 +315,6 @@ retry: case NUV_COPY_LAST: /* nothing more to do here */ break; - default: - av_log(avctx, AV_LOG_ERROR, "unknown compression\n"); - return AVERROR_INVALIDDATA; } if ((result = av_frame_ref(picture, c->pic)) < 0) @@ -355,7 +362,7 @@ static av_cold int decode_end(AVCodecContext *avctx) return 0; } -AVCodec ff_nuv_decoder = { +const AVCodec ff_nuv_decoder = { .name = "nuv", .long_name = NULL_IF_CONFIG_SMALL("NuppelVideo/RTJPEG"), .type = AVMEDIA_TYPE_VIDEO, @@ -365,4 +372,5 @@ AVCodec ff_nuv_decoder = { .close = decode_end, .decode = decode_frame, .capabilities = AV_CODEC_CAP_DR1, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, };