[Ffmpeg-devel] improved [PATCH] fix DV encoder VLC bit accounting
Dan Maas
dmaas
Sat Feb 25 19:43:37 CET 2006
Hi Michael - I like your version of the dv_guess_qnos() fix, it's a
lot simpler. However, it is not quite correct (it triggers asserts and
AC overflows on my test video). The attached patch fixes two things:
1. 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.
2. 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.
With this patch, I no longer get any asserts or AC overflows.
Regards,
Dan
* Michael Niedermayer (michaelni at gmx.at) wrote:
> Hi
>
> On Wed, Feb 22, 2006 at 06:40:58PM -0500, Dan Maas wrote:
> > Here is an updated patch. I believe this addresses all of Michael's
> > concerns. It only updates the single affected coefficient. The results
> > are identical to my previous patch, but the performance hit is more
> > like 1.5% now.
>
> i belive this can be solved with less speedloss and complexity, if iam
> wrong than iam not against applying this assuming it works and romain
> wants to apply it
>
> [...]
>
> --
> Michael
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> http://mplayerhq.hu/mailman/listinfo/ffmpeg-devel
>
>
-------------- next part --------------
Index: libavcodec/dv.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/dv.c,v
retrieving revision 1.75
diff -u -p -u -r1.75 dv.c
--- libavcodec/dv.c 24 Feb 2006 09:16:26 -0000 1.75
+++ libavcodec/dv.c 25 Feb 2006 18:41:26 -0000
@@ -731,7 +731,7 @@ static inline void dv_guess_qnos(EncBloc
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 @@ static inline void dv_guess_qnos(EncBloc
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];
}
More information about the ffmpeg-devel
mailing list