[FFmpeg-devel] [PATCH] bink: permutate Bink version 'b' quantization matrices by inverse of bink_scan order

Kostya kostya.shishkov
Sun Feb 13 14:30:19 CET 2011


On Sun, Feb 13, 2011 at 08:36:29PM +1100, Peter Ross wrote:
> This fixes visual glitches in Bink version 'b' files, as the quantization tables                                               were not being permutated.
> ---
>  libavcodec/bink.c |   13 +++++++++----
>  1 files changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/bink.c b/libavcodec/bink.c
> index 928bf53..f88051b 100644
> --- a/libavcodec/bink.c
> +++ b/libavcodec/bink.c
> @@ -1217,6 +1217,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
>   */
>  static av_cold void binkb_calc_quant()
>  {
> +    uint8_t inv_bink_scan[64];
>      double s[64];
>      int i, j;
>  
> @@ -1235,17 +1236,21 @@ static av_cold void binkb_calc_quant()
>          }
>      }
>  
> +    for (i = 0; i < 64; i++)
> +        inv_bink_scan[bink_scan[i]] = i;
> +
>      for (j = 0; j < 16; j++) {
>          for (i = 0; i < 64; i++) {
> +            int k = inv_bink_scan[i];
>              if (s[i] == 1.0) {
> -                binkb_intra_quant[j][i] = (1L << 12) * binkb_intra_seed[i] *
> +                binkb_intra_quant[j][k] = (1L << 12) * binkb_intra_seed[i] *
>                                            binkb_num[j]/binkb_den[j];
> -                binkb_inter_quant[j][i] = (1L << 12) * binkb_inter_seed[i] *
> +                binkb_inter_quant[j][k] = (1L << 12) * binkb_inter_seed[i] *
>                                            binkb_num[j]/binkb_den[j];
>              } else {
> -                binkb_intra_quant[j][i] = (1L << 12) * binkb_intra_seed[i] * s[i] *
> +                binkb_intra_quant[j][k] = (1L << 12) * binkb_intra_seed[i] * s[i] *
>                                            binkb_num[j]/(double)binkb_den[j];
> -                binkb_inter_quant[j][i] = (1L << 12) * binkb_inter_seed[i] * s[i] *
> +                binkb_inter_quant[j][k] = (1L << 12) * binkb_inter_seed[i] * s[i] *
>                                            binkb_num[j]/(double)binkb_den[j];
>              }
>          }
> -- 
> 1.7.1

looks ok



More information about the ffmpeg-devel mailing list