From 8e39d4a7447fc02a470008905b89a8dd61eb2bf4 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 19 Aug 2003 16:18:48 +0000 Subject: fix AVFrame.reference (the frames are used for decoding future frames so it should be !=0) fix some assert in utils.c (no bug but its saver if the released pointers are NULL) fix double release_buffer() at the end Originally committed as revision 2126 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/vp3.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'libavcodec') diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index c46b0bc6da..0a564b32b6 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -2699,10 +2699,10 @@ static int vp3_decode_frame(AVCodecContext *avctx, debug_vp3(", keyframe\n"); /* skip the other 2 header bytes for now */ skip_bits(&gb, 16); - if (s->last_frame.data[0] == s->golden_frame.data[0]) { if (s->golden_frame.data[0]) avctx->release_buffer(avctx, &s->golden_frame); + s->last_frame= s->golden_frame; /* ensure that we catch any access to this released frame */ } else { if (s->golden_frame.data[0]) avctx->release_buffer(avctx, &s->golden_frame); @@ -2710,7 +2710,7 @@ static int vp3_decode_frame(AVCodecContext *avctx, avctx->release_buffer(avctx, &s->last_frame); } - s->golden_frame.reference = 0; + s->golden_frame.reference = 3; if(avctx->get_buffer(avctx, &s->golden_frame) < 0) { printf("vp3: get_buffer() failed\n"); return -1; @@ -2728,7 +2728,7 @@ static int vp3_decode_frame(AVCodecContext *avctx, debug_vp3("\n"); /* allocate a new current frame */ - s->current_frame.reference = 0; + s->current_frame.reference = 3; if(avctx->get_buffer(avctx, &s->current_frame) < 0) { printf("vp3: get_buffer() failed\n"); return -1; @@ -2789,6 +2789,7 @@ if (!s->keyframe) { /* shuffle frames (last = current) */ memcpy(&s->last_frame, &s->current_frame, sizeof(AVFrame)); + s->current_frame.data[0]= NULL; /* ensure that we catch any access to this released frame */ return buf_size; } @@ -2806,9 +2807,9 @@ static int vp3_decode_end(AVCodecContext *avctx) av_free(s->superblock_macroblocks); av_free(s->macroblock_fragments); av_free(s->macroblock_coding); - + /* release all frames */ - if (s->golden_frame.data[0]) + if (s->golden_frame.data[0] && s->golden_frame.data[0] != s->last_frame.data[0]) avctx->release_buffer(avctx, &s->golden_frame); if (s->last_frame.data[0]) avctx->release_buffer(avctx, &s->last_frame); -- cgit v1.2.3