Commit 23153921 authored by Peter Ross's avatar Peter Ross Committed by Mans Rullgard

bink: permute Bink version 'b' quant matrices by inverse scan order

This fixes visual glitches in Bink version 'b' files, as the quantization
tables were not being permuted.
Signed-off-by: 's avatarMans Rullgard <mans@mansr.com>
parent cb62510c
...@@ -1210,6 +1210,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac ...@@ -1210,6 +1210,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
*/ */
static av_cold void binkb_calc_quant() static av_cold void binkb_calc_quant()
{ {
uint8_t inv_bink_scan[64];
double s[64]; double s[64];
int i, j; int i, j;
...@@ -1228,17 +1229,21 @@ static av_cold void binkb_calc_quant() ...@@ -1228,17 +1229,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 (j = 0; j < 16; j++) {
for (i = 0; i < 64; i++) { for (i = 0; i < 64; i++) {
int k = inv_bink_scan[i];
if (s[i] == 1.0) { 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_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]; binkb_num[j]/binkb_den[j];
} else { } 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_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]; binkb_num[j]/(double)binkb_den[j];
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment