From 37cc8600d0313838cab5b886b9d373e5819aa24f Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Tue, 6 Mar 2012 13:45:32 -0800 Subject: [PATCH] cook: extend channel uncoupling tables so the full bit range is covered. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org --- libavcodec/cook.c | 4 ++-- libavcodec/cookdata.h | 27 ++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/libavcodec/cook.c b/libavcodec/cook.c index bc262f19b0..65e16e4077 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -832,8 +832,8 @@ static void joint_decode(COOKContext *q, COOKSubpacket *p, float *mlt_buffer1, cpl_tmp = cplband[i]; idx -= decouple_tab[cpl_tmp]; cplscale = q->cplscales[p->js_vlc_bits - 2]; // choose decoupler table - f1 = cplscale[decouple_tab[cpl_tmp]]; - f2 = cplscale[idx - 1]; + f1 = cplscale[decouple_tab[cpl_tmp] + 1]; + f2 = cplscale[idx]; q->decouple(q, p, i, f1, f2, decode_buffer, mlt_buffer1, mlt_buffer2); idx = (1 << p->js_vlc_bits) - 1; } diff --git a/libavcodec/cookdata.h b/libavcodec/cookdata.h index e8d6ebfcb3..126010a985 100644 --- a/libavcodec/cookdata.h +++ b/libavcodec/cookdata.h @@ -510,23 +510,37 @@ static const int cplband[51] = { 19, }; -static const float cplscale2[3] = { +// The 1 and 0 at the beginning/end are to prevent overflows with +// bitstream-read indexes. E.g. if n_bits=5, we can access any +// index from [1, (1<