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

Vitor Sessak vitor1001
Wed Feb 9 21:54:00 CET 2011


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...

-Vitor



More information about the ffmpeg-devel mailing list