[FFmpeg-devel] [PATCH] RoQ video encoder (take 4)

Vitor vitor1001
Fri Jun 15 10:08:41 CEST 2007


Hi

Michael Niedermayer wrote:
> Hi
>
>   
> On Wed, Jun 13, 2007 at 11:31:28PM -0400, Eric Lasota wrote:
> [...]
>   
> IIRC theres a used count and if its 0 we drop a codebook
> so if we just consider codebooks with a small used value (like 1)
> for droping then there shouldnt be much reindexing needed
>
> also we could keep a heap (as in heap sort) structure for each macroblock
> to keep a sorted list of possibilities, with that removial of the best
> encoding possibility would not need reindexing
> all just some ideas for future patches
>   

At least in the case of a 4x4 codebook, a codebook with only one use 
(and that is not used enlarged) should _always_ be dropped since the 
block could be coded by 2x2 codebooks with the same distortion and 
consuming 2 less bits.

>> Best way to do it would be to just figure out a way to estimate ideal 
>> codebook size, which will probably be difficult because smaller 
>> codebooks result in more codebook entries just being unused because 
>> they're not accurate enough.
>>     
>
> codebook size estimation probably would have to be done after decidng
> the macroblock types ...
> which might lead to a iterative loop of codebook generation and macroblock
> type decission)
>
>   

Maybe doing the following would be optimal:

for (block in blocks) {
    decide best encoding(block);
    if (best encoding == 2x2 codebook) {
       usedCB2[cb]++;
       // Here second best don't use any CB
       CB2gain[cb] = best_distortion + lambda*bit_use - 
second_best_distortion - lambda*bit_use_second;
    }
    same for CB4;
    ...etc..
}

for every codebook
    if usedCBgain < lambda*cost_cb_encoding
       drop cb;

reindex everything;

-Vitor




More information about the ffmpeg-devel mailing list