aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/nuv.c
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2013-08-13 07:01:40 +0200
committerLuca Barbato <lu_zero@gentoo.org>2013-10-16 23:05:51 +0200
commitc1ebdef01b016b24b8ec322efdbc31da2639addd (patch)
treeaa9ef02a9530a21fb4bd90c86713f413fdef6ea8 /libavcodec/nuv.c
parentd2eddcfc833fc55dfa447376f4c30e46851c3242 (diff)
downloadffmpeg-c1ebdef01b016b24b8ec322efdbc31da2639addd.tar.gz
nuv: Use av_fast_realloc
The decompressed buffer can be used after codec_reinit, so it must be preserved. Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org (cherry picked from commit 2df0776c2293efb0ac12c003843ce19332342e01) Signed-off-by: Luca Barbato <lu_zero@gentoo.org> Conflicts: libavcodec/nuv.c
Diffstat (limited to 'libavcodec/nuv.c')
-rw-r--r--libavcodec/nuv.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c
index 9b275e8637..8545d863d9 100644
--- a/libavcodec/nuv.c
+++ b/libavcodec/nuv.c
@@ -114,16 +114,20 @@ static int codec_reinit(AVCodecContext *avctx, int width, int height, int qualit
if (quality >= 0)
get_quant_quality(c, quality);
if (width != c->width || height != c->height) {
+ void *ptr;
if ((ret = av_image_check_size(height, width, 0, avctx)) < 0)
return ret;
avctx->width = c->width = width;
avctx->height = c->height = height;
- av_fast_malloc(&c->decomp_buf, &c->decomp_size, c->height * c->width * 3 / 2 +
- FF_INPUT_BUFFER_PADDING_SIZE);
- if (!c->decomp_buf) {
+ ptr = av_fast_realloc(c->decomp_buf, &c->decomp_size,
+ c->height * c->width * 3 / 2 +
+ FF_INPUT_BUFFER_PADDING_SIZE +
+ RTJPEG_HEADER_SIZE);
+ if (!ptr) {
av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
return AVERROR(ENOMEM);
- }
+ } else
+ c->decomp_buf = ptr;
rtjpeg_decode_init(&c->rtj, &c->dsp, c->width, c->height, c->lq, c->cq);
} else if (quality != c->quality)
rtjpeg_decode_init(&c->rtj, &c->dsp, c->width, c->height, c->lq, c->cq);
@@ -200,6 +204,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
q = buf[10];
if ((result = codec_reinit(avctx, w, h, q)) < 0)
return result;
+ if (comptype == NUV_RTJPEG_IN_LZO || comptype == NUV_LZO)
+ buf = c->decomp_buf;
buf = &buf[RTJPEG_HEADER_SIZE];
buf_size -= RTJPEG_HEADER_SIZE;
}