[FFmpeg-devel] [PATCH] Mimic decoder

Ramiro Polla ramiro
Mon May 19 19:24:28 CEST 2008


Michael Niedermayer wrote:
> On Thu, May 15, 2008 at 04:06:03AM +0100, Ramiro Polla wrote:
>>>>>> Attached are the 2 patches I used to test. (lut_calc.diff and 
>>>>>> lut_static.diff). Anyways, most FFmpeg stuff introduced a considerable 
>>>>>> speedup over the original code, so I'm tempted to apply one of these 
>>>>>> two.
>>>>>> Could I use the hardcoded tables ifdef there?
>>>>> I dont see much sense in it. I mean the calc code doesnt need the table 
>>>>> at
>>>>> all and needs around 100 byte while the table needs 1024.
>>>> If it's ok I'd prefer to keep the current code with vlcdec_lookup in 
>>>> MimicContext.
>>> You can keep it if you merge the *qscale into the table as its not
>>> const then anymore ...
>> Oh, now I get it... Attached patch speeds up by 31%. The official encoder 
                                                    ^^^

I have no idea how I got this on my first benchmarks. I can no longer 
get anything above 5% speedup on samples that have lots of intra frames 
and lots of coeffs. On real samples the speedup is about 2%.

>> and libmimic too IIRC do not change the quality between frames. If there 
>> are quality changes then this new code probably slows down since it'll have 
>> to update the table all the time. If I find a case where that'll be needed, 
>> then I can probably have more tables in the context, keep the most recent 
>> ones and overwrite old ones. But that's for later.
> [...]
>> @@ -103,6 +106,24 @@
>>      53, 60, 61, 54, 47, 55, 62, 63,
>>  };
>>  
>> +static void initialize_vlcdec_lookup12(int16_t vlcdec_lookup[9][64])
>> +{
>> +    int i, j;
>> +
>> +    for(i = 1 ; i < 8 ; i++) {
>> +        int cur = (1<<i)-1;
>> +        int last = 1<<(i-1);
>> +
>> +        for(j = 0 ; cur >= last ; cur--) {
>> +            const int cur4 = cur << 4;
>> +            vlcdec_lookup[i][j++] = -cur4;
>> +            vlcdec_lookup[i][j++] =  cur4;
>> +        }
>> +    }
>> +}
>> +
>> +static int16_t vlcdec_lookup12[9][64];
>> +
>>  static av_cold int mimic_decode_init(AVCodecContext *avctx)
>>  {
>>      MimicContext *ctx = avctx->priv_data;
>> @@ -117,48 +138,12 @@
>>      }
>>      dsputil_init(&ctx->dsp, avctx);
>>      ff_init_scantable(ctx->dsp.idct_permutation, &ctx->scantable, col_zag);
>> +    initialize_vlcdec_lookup12(vlcdec_lookup12);
>>  
>>      return 0;
>>  }
>>  
>> -const static int8_t vlcdec_lookup[9][64] = {
>> -    {    0, },
> 
> why?
> const static tables can be shared between processes, non const tables
> can not also what do you gain be mergin the <<4 in the table? Is it really
> worth the *2 size ?
> 
> and anyway this would be a seperate change & patch if we would decide that
> it is a good idea ...

New patch attached just for the record. The speedup is so small I don't 
think it's worth the complexity and memory usage. Also it'd probably 
slow down on samples that change quality between frames (I don't know of 
any encoder that supports that, but it's a possibility).

Ramiro Polla
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mimic_vlcdec2.diff
Type: text/x-patch
Size: 3722 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080519/2c7a6001/attachment.bin>



More information about the ffmpeg-devel mailing list