diff dv.c @ 3146:dcae1bde37ac libavcodec

size[0-3] are not initialized (and can get random negative trash values), so the comparison with vs_total_ac_bits is messed up on the first couple loop iterations, leading to AC underflows. the b->prev[] pointers were not being maintained correctly. We potentially have to update b->prev[] both before and after the area whose VLC length is getting adjusted. this also might fix the ppc regression failure? patch by (Dan Maas <dmaas maasdigital com>)
author michael
date Sat, 25 Feb 2006 22:58:26 +0000
parents ef36cc95e4ab
children 99263b3a00e1
line wrap: on
line diff
--- a/dv.c	Sat Feb 25 22:41:31 2006 +0000
+++ b/dv.c	Sat Feb 25 22:58:26 2006 +0000
@@ -731,7 +731,7 @@
     int i, j, k, a, prev, a2;
     EncBlockInfo* b;
 
-    size[4]= 1<<24;
+    size[0] = size[1] = size[2] = size[3] = size[4] = 1<<24;
     do {
        b = blks;
        for (i=0; i<5; i++) {
@@ -753,11 +753,14 @@
                            prev= k;
                        } else {
                            if(b->next[k] >= mb_area_start[a+1] && b->next[k]<64){
-                                for(a2=a+1; b->next[k] >= mb_area_start[a2+1]; a2++);
+                                for(a2=a+1; b->next[k] >= mb_area_start[a2+1]; a2++)
+                                    b->prev[a2] = prev;
                                 assert(a2<4);
                                 assert(b->mb[b->next[k]]);
                                 b->bit_size[a2] += dv_rl2vlc_size(b->next[k] - prev - 1, b->mb[b->next[k]])
                                                   -dv_rl2vlc_size(b->next[k] -    k - 1, b->mb[b->next[k]]);
+                                for(; (b->prev[a2]==k) && (a2<4); a2++)
+                                        b->prev[a2] = prev;
                            }
                            b->next[prev] = b->next[k];
                        }