[Ffmpeg-devel] Re: [PATCH] fix DV encoder VLC bit accounting

Dan Maas dmaas
Wed Feb 22 20:19:36 CET 2006

Thanks for the comments Michael.

> also note that the patch is full of tabs and cosmetical changes ...

Can you send me the emacs settings to produce clean code? (I remember
seeing a coding standards document somewhere, but I can't find it atm).
I am working on some more substantial patches so I'd like to get this

> and last the patch recalculates all coefficients of all areas
> after any !0 -> 0 change, while only a single coefficient would
> need to be checked and only if the change was the last non zero
> coeff of an area, ugh this is inefficient code
> so either
> * recalc only the single coeff and only when needed
> * find the worst case bitsize increase and and add that to the amount of
>   bits needed in case a !0->0 chnange at an area end happens
> * detect during final encoding that too many bits are there and simply
>   redo the whole with higher quantization

I'd prefer the first option, since it preserves the accuracy of AC bit
consumption tracking. But, I will have to think about how to implement
this efficiently.

Roman, do you have any ideas?

The "only when needed part" could be accomplished by keeping track of
the last non-zero coefficient for each area. But I don't see how to
recalculate only a single coefficient, other than keeping a
per-coefficient array of VLC lenghts, which seems like it would defeat
the purpose of this optimization.

> The fixed encoder is about 6% slower than the unmodified encoder.
> rejected

Note that the unmodified encoder produces visible image
corruption. This is a correctness issue.


More information about the ffmpeg-devel mailing list