[FFmpeg-cvslog] ffv1: refactor slice decoding init loop so that the first is less a special case

Michael Niedermayer git at videolan.org
Fri Apr 20 15:43:16 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Apr 20 14:57:03 2012 +0200| [9408316a85f7e237889435834db369b05a8e0862] | committer: Michael Niedermayer

ffv1: refactor slice decoding init loop so that the first is less a special case

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9408316a85f7e237889435834db369b05a8e0862
---

 libavcodec/ffv1.c |   33 ++++++++++++++++++---------------
 1 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
index 7d985f0..1b0e874 100644
--- a/libavcodec/ffv1.c
+++ b/libavcodec/ffv1.c
@@ -1862,28 +1862,31 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
     if(avctx->debug&FF_DEBUG_PICT_INFO)
         av_log(avctx, AV_LOG_ERROR, "keyframe:%d coder:%d\n", p->key_frame, f->ac);
 
-    if(!f->ac){
-        bytes_read = c->bytestream - c->bytestream_start - 1;
-        if(bytes_read ==0) av_log(avctx, AV_LOG_ERROR, "error at end of AC stream\n"); //FIXME
-//printf("pos=%d\n", bytes_read);
-        init_get_bits(&f->slice_context[0]->gb, buf + bytes_read, (buf_size - bytes_read) * 8);
-    } else {
-        bytes_read = 0; /* avoid warning */
-    }
-
     buf_p= buf + buf_size;
-    for(i=f->slice_count-1; i>0; i--){
+    for(i=f->slice_count-1; i>=0; i--){
         FFV1Context *fs= f->slice_context[i];
-        int v= AV_RB24(buf_p-3)+3;
-        if(buf_p - buf <= v){
+        int v;
+
+        if(i) v = AV_RB24(buf_p-3)+3;
+        else  v = buf_p - c->bytestream_start;
+        if(buf_p - c->bytestream_start < v){
             av_log(avctx, AV_LOG_ERROR, "Slice pointer chain broken\n");
             return -1;
         }
         buf_p -= v;
-        if(fs->ac){
-            ff_init_range_decoder(&fs->c, buf_p, v);
+
+        if(i){
+            if(fs->ac){
+                ff_init_range_decoder(&fs->c, buf_p, v);
+            }else{
+                init_get_bits(&fs->gb, buf_p, v * 8);
+            }
         }else{
-            init_get_bits(&fs->gb, buf_p, v * 8);
+            if(!f->ac){
+                bytes_read = c->bytestream - c->bytestream_start - 1;
+                if(bytes_read ==0) av_log(avctx, AV_LOG_ERROR, "error at end of AC stream\n"); //FIXME
+                init_get_bits(&fs->gb, buf + bytes_read, (buf_size - bytes_read) * 8);
+            }
         }
     }
 



More information about the ffmpeg-cvslog mailing list