[FFmpeg-devel] [PATCH 1/2] Bink version 'b' video decoder

Vitor Sessak vitor1001
Thu Feb 10 20:16:18 CET 2011


On 02/10/2011 05:26 AM, Peter Ross wrote:
> On Wed, Feb 09, 2011 at 09:54:00PM +0100, Vitor Sessak wrote:
>> On 02/09/2011 01:04 PM, Peter Ross wrote:
>>> Based on original patch by Kostya Shishkov
>>> ---
>>>   libavcodec/bink.c     |  340 ++++++++++++++++++++++++++++++++++++++++++++++---
>>>   libavcodec/binkdata.h |   41 ++++++
>>>   2 files changed, 364 insertions(+), 17 deletions(-)
>>>
>>> diff --git a/libavcodec/bink.c b/libavcodec/bink.c
>>> index 64a10b7..32330fe 100644
>>
>> [...]
>>
>>> +/**
>>> + * Caclulate quantization tables for version b
>>> + */
>>> +static av_cold void binkb_calc_quant()
>>> +{
>>> +    float s[64];
>>> +    int i, j;
>>> +
>>> +    for (j = 0; j<   8; j++) {
>>> +        for (i = 0; i<   8; i++) {
>>> +            if (j&&   j != 4)
>>> +               if (i&&   i != 4)
>>> +                   s[j*8 + i] = cos(j * M_PI/16.0f) * cos(i * M_PI/16.0f) * 2.0f;
>>> +               else
>>> +                   s[j*8 + i] = cos(j * M_PI/16.0f) * sqrt(2.0f);
>>> +            else
>>> +               if (i&&   i != 4)
>>> +                   s[j*8 + i] = cos(i * M_PI/16.0f) * sqrt(2.0f);
>>> +               else
>>> +                   s[j*8 + i] = 1.0f;
>>> +        }
>>> +    }
>>> +
>>> +    for (j = 0; j<   16; j++) {
>>> +        for (i = 0; i<   64; i++) {
>>> +            binkb_intra_quant[j][i] = (1L<<12) * binkb_intra_seed[i] * binkb_num[j]/(float)binkb_den[j] * s[i];
>>> +            binkb_inter_quant[j][i] = (1L<<12) * binkb_inter_seed[i] * binkb_num[j]/(float)binkb_den[j] * s[i];
>>> +        }
>>> +    }
>>> +}
>>
>> Can you run the following test:
>>
>>
>>      for (j = 0; j<   16; j++) {
>>          for (i = 0; i<   64; i++) {
>>              int x = ( 1 + (1<<20))/((float)(1<<20))) * (1L<<12) *
>> binkb_intra_seed[i] * binkb_num[j]/(float)binkb_den[j] * s[i];
>>              int y = (-1 + (1<<20))/((float)(1<<20))) * (1L<<12) *
>> binkb_intra_seed[i] * binkb_num[j]/(float)binkb_den[j] * s[i];
>>              if (i != y)
>>                  av_log(NULL, "%d %d\n", i, j);
>>          }
>>     }
>>
>> and analogously for binkb_inter_quant? If there are any values that
>> are not stable to fp rounding, it is enough to hardcode them...
>
> Hard coding the quant tables will add 8k to libavcodec. Anyway heres the output:

I was thinking more of hardcoding only the values that were printed, but 
I didn't expect them to be so many.

> av_log(0,0, "intra\n");
> for (j = 0; j<  16; j++) {
>      for (i = 0; i<  64; i++) {
>          int x = ( 1 + (1<<20))/((float)(1<<20)) * (1L<<12) * binkb_intra_seed[i] * binkb_num[j]/(float)binkb_den[j] * s[i];
>          int y = (-1 + (1<<20))/((float)(1<<20)) * (1L<<12) * binkb_intra_seed[i] * binkb_num[j]/(float)binkb_den[j] * s[i];
>          if (x != y)
>              av_log(0, 0, "%d %d\n", i, j);
>      }
> }
>
> av_log(0,0, "inter\n");
> for (j = 0; j<  16; j++) {
>      for (i = 0; i<  64; i++) {
>          int x = ( 1 + (1<<20))/((float)(1<<20)) * (1L<<12) * binkb_inter_seed[i] * binkb_num[j]/(float)binkb_den[j] * s[i];
>          int y = (-1 + (1<<20))/((float)(1<<20)) * (1L<<12) * binkb_inter_seed[i] * binkb_num[j]/(float)binkb_den[j] * s[i];
>          if (x != y)
>              av_log(0, 0, "%d %d\n", i, j);
>      }
> }

What if you use doubles and replace 1<<20 by 1<<48?

-Vitor



More information about the ffmpeg-devel mailing list