On Sat, Mar 10, 2012 at 02:28:35PM -0800, Ronald S. Bultje wrote: > MPC8 allows indices of mpc_CC up to -1, and mpc_SCF up to -6, thus pad > the tables by that much on the left end. > > Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind > CC: [email protected] > --- > libavcodec/mpc.c | 6 +++--- > libavcodec/mpc7.c | 4 ++-- > libavcodec/mpcdata.h | 10 +++++++--- > 3 files changed, 12 insertions(+), 8 deletions(-) > > diff --git a/libavcodec/mpc.c b/libavcodec/mpc.c > index 4573860..6b15a33 100644 > --- a/libavcodec/mpc.c > +++ b/libavcodec/mpc.c > @@ -78,13 +78,13 @@ void ff_mpc_dequantize_and_synth(MPCContext * c, int > maxband, void *data, int ch > for(ch = 0; ch < 2; ch++){ > if(bands[i].res[ch]){ > j = 0; > - mul = mpc_CC[bands[i].res[ch]] * > mpc_SCF[bands[i].scf_idx[ch][0]]; > + mul = mpc_CC[bands[i].res[ch] + 1] * > mpc_SCF[bands[i].scf_idx[ch][0]+6]; > for(; j < 12; j++) > 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]]; > + mul = mpc_CC[bands[i].res[ch] + 1] * > mpc_SCF[bands[i].scf_idx[ch][1]+6]; > for(; j < 24; j++) > 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]]; > + mul = mpc_CC[bands[i].res[ch] + 1] * > mpc_SCF[bands[i].scf_idx[ch][2]+6]; > for(; j < 36; j++) > c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off]; > } > diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c > index 2e8271a..4e75841 100644 > --- a/libavcodec/mpc7.c > +++ b/libavcodec/mpc7.c > @@ -193,7 +193,7 @@ static int get_scale_idx(GetBitContext *gb, int ref) > int t = get_vlc2(gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7; > if (t == 8) > return get_bits(gb, 6); > - return ref + t; > + return av_clip_uintp2(ref + t, 7); > } > > static int mpc7_decode_frame(AVCodecContext * avctx, void *data, > @@ -247,7 +247,7 @@ static int mpc7_decode_frame(AVCodecContext * avctx, void > *data, > int t = 4; > if(i) t = get_vlc2(&gb, hdr_vlc.table, MPC7_HDR_BITS, 1) - 5; > if(t == 4) bands[i].res[ch] = get_bits(&gb, 4); > - else bands[i].res[ch] = bands[i-1].res[ch] + t; > + else bands[i].res[ch] = av_clip(bands[i-1].res[ch] + t, 0, 17); > } > > if(bands[i].res[0] || bands[i].res[1]){ > diff --git a/libavcodec/mpcdata.h b/libavcodec/mpcdata.h > index 397dad5..15724f3 100644 > --- a/libavcodec/mpcdata.h > +++ b/libavcodec/mpcdata.h > @@ -22,13 +22,17 @@ > #ifndef AVCODEC_MPCDATA_H > #define AVCODEC_MPCDATA_H > > -static const float mpc_CC[18] = { > - 65536.0000, 21845.3333, 13107.2000, 9362.2857, 7281.7778, 4369.0667, > 2114.0645, > +static const float mpc_CC[18+1] = { > + 111.285962475327f, // 32768/2/255*sqrt(3) > + 65536.0000 /* this value is never used */,
If someone wonders - those numbers were stolen from libmpcdec. Patch looks OK to me. _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
