changeset 1405:e69f99ade5b0 libavcodec

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
author michaelni
date Tue, 19 Aug 2003 16:18:48 +0000
parents 321fd44a1e3e
children ae5524a3cd08
files vp3.c
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/vp3.c	Mon Aug 18 09:20:02 2003 +0000
+++ b/vp3.c	Tue Aug 19 16:18:48 2003 +0000
@@ -2699,10 +2699,10 @@
         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 @@
                 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 @@
         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 @@
 
     /* 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 @@
     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);