Commit b2a7c017 authored by Michael Niedermayer's avatar Michael Niedermayer

mpc: Fix mpc_CC table and use.

This is based on the reference implementation and fixes
a global out of array read.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent b84211ac
...@@ -78,13 +78,13 @@ void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, void *data, int ch ...@@ -78,13 +78,13 @@ void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, void *data, int ch
for(ch = 0; ch < 2; ch++){ for(ch = 0; ch < 2; ch++){
if(bands[i].res[ch]){ if(bands[i].res[ch]){
j = 0; j = 0;
mul = mpc_CC[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][0] & 0xFF]; mul = (mpc_CC+1)[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][0] & 0xFF];
for(; j < 12; j++) for(; j < 12; j++)
c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off]; c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off];
mul = mpc_CC[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][1] & 0xFF]; mul = (mpc_CC+1)[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][1] & 0xFF];
for(; j < 24; j++) for(; j < 24; j++)
c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off]; c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off];
mul = mpc_CC[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][2] & 0xFF]; mul = (mpc_CC+1)[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][2] & 0xFF];
for(; j < 36; j++) for(; j < 36; j++)
c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off]; c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off];
} }
......
...@@ -22,7 +22,8 @@ ...@@ -22,7 +22,8 @@
#ifndef AVCODEC_MPCDATA_H #ifndef AVCODEC_MPCDATA_H
#define AVCODEC_MPCDATA_H #define AVCODEC_MPCDATA_H
static const float mpc_CC[18] = { static const float mpc_CC[1+18] = {
111.285962475327f,
65536.0000, 21845.3333, 13107.2000, 9362.2857, 7281.7778, 4369.0667, 2114.0645, 65536.0000, 21845.3333, 13107.2000, 9362.2857, 7281.7778, 4369.0667, 2114.0645,
1040.2539, 516.0315, 257.0039, 128.2505, 64.0626, 32.0156, 16.0039, 8.0010, 1040.2539, 516.0315, 257.0039, 128.2505, 64.0626, 32.0156, 16.0039, 8.0010,
4.0002, 2.0001, 1.0000 4.0002, 2.0001, 1.0000
......
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