summaryrefslogtreecommitdiff
path: root/libavcodec/mlpdec.c
diff options
context:
space:
mode:
authorNick Brereton <nick@nbrereton.net>2010-05-11 01:44:52 +0000
committerRamiro Polla <ramiro.polla@gmail.com>2010-05-11 01:44:52 +0000
commit22fb814c2f46c30e8ae134c0f96432764fa343d5 (patch)
treee5eef8261d3550898fff8ab1b766d7d97d36f0ba /libavcodec/mlpdec.c
parentd9d14dc6074200a4d2e6b8bf02376d785178ae82 (diff)
downloadffmpeg-22fb814c2f46c30e8ae134c0f96432764fa343d5.tar.gz
mlpdec: Allocate channel decoding parameters for each substream. Some file
was encountered with a channel range that overlapped the previous substreams, and the code assumed no such overlap was possible. Patch by Nick Brereton <nick at nbrereton dot net> Originally committed as revision 23084 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mlpdec.c')
-rw-r--r--libavcodec/mlpdec.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index 9169948f51..508be6f768 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -62,6 +62,8 @@ typedef struct SubStream {
//! For each channel output by the matrix, the output channel to map it to
uint8_t ch_assign[MAX_CHANNELS];
+ ChannelParams channel_params[MAX_CHANNELS];
+
//! The left shift applied to random noise in 0x31ea substreams.
uint8_t noise_shift;
//! The current seed value for the pseudorandom noise generator(s).
@@ -137,8 +139,6 @@ typedef struct MLPDecodeContext {
SubStream substream[MAX_SUBSTREAMS];
- ChannelParams channel_params[MAX_CHANNELS];
-
int matrix_changed;
int filter_changed[MAX_CHANNELS][NUM_FILTERS];
@@ -173,8 +173,8 @@ static av_cold void init_static(void)
static inline int32_t calculate_sign_huff(MLPDecodeContext *m,
unsigned int substr, unsigned int ch)
{
- ChannelParams *cp = &m->channel_params[ch];
SubStream *s = &m->substream[substr];
+ ChannelParams *cp = &s->channel_params[ch];
int lsb_bits = cp->huff_lsbs - s->quant_step_size[ch];
int sign_shift = lsb_bits + (cp->codebook ? 2 - cp->codebook : -1);
int32_t sign_huff_offset = cp->huff_offset;
@@ -202,7 +202,7 @@ static inline int read_huff_channels(MLPDecodeContext *m, GetBitContext *gbp,
m->bypassed_lsbs[pos + s->blockpos][mat] = get_bits1(gbp);
for (channel = s->min_channel; channel <= s->max_channel; channel++) {
- ChannelParams *cp = &m->channel_params[channel];
+ ChannelParams *cp = &s->channel_params[channel];
int codebook = cp->codebook;
int quant_step_size = s->quant_step_size[channel];
int lsb_bits = cp->huff_lsbs - quant_step_size;
@@ -450,7 +450,7 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,
memset(s->quant_step_size, 0, sizeof(s->quant_step_size));
for (ch = s->min_channel; ch <= s->max_channel; ch++) {
- ChannelParams *cp = &m->channel_params[ch];
+ ChannelParams *cp = &s->channel_params[ch];
cp->filter_params[FIR].order = 0;
cp->filter_params[IIR].order = 0;
cp->filter_params[FIR].shift = 0;
@@ -472,9 +472,11 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,
/** Read parameters for one of the prediction filters. */
static int read_filter_params(MLPDecodeContext *m, GetBitContext *gbp,
- unsigned int channel, unsigned int filter)
+ unsigned int substr, unsigned int channel,
+ unsigned int filter)
{
- FilterParams *fp = &m->channel_params[channel].filter_params[filter];
+ SubStream *s = &m->substream[substr];
+ FilterParams *fp = &s->channel_params[channel].filter_params[filter];
const int max_order = filter ? MAX_IIR_ORDER : MAX_FIR_ORDER;
const char fchar = filter ? 'I' : 'F';
int i, order;
@@ -497,7 +499,7 @@ static int read_filter_params(MLPDecodeContext *m, GetBitContext *gbp,
fp->order = order;
if (order > 0) {
- int32_t *fcoeff = m->channel_params[channel].coeff[filter];
+ int32_t *fcoeff = s->channel_params[channel].coeff[filter];
int coeff_bits, coeff_shift;
fp->shift = get_bits(gbp, 4);
@@ -610,19 +612,19 @@ static int read_matrix_params(MLPDecodeContext *m, unsigned int substr, GetBitCo
static int read_channel_params(MLPDecodeContext *m, unsigned int substr,
GetBitContext *gbp, unsigned int ch)
{
- ChannelParams *cp = &m->channel_params[ch];
+ SubStream *s = &m->substream[substr];
+ ChannelParams *cp = &s->channel_params[ch];
FilterParams *fir = &cp->filter_params[FIR];
FilterParams *iir = &cp->filter_params[IIR];
- SubStream *s = &m->substream[substr];
if (s->param_presence_flags & PARAM_FIR)
if (get_bits1(gbp))
- if (read_filter_params(m, gbp, ch, FIR) < 0)
+ if (read_filter_params(m, gbp, substr, ch, FIR) < 0)
return -1;
if (s->param_presence_flags & PARAM_IIR)
if (get_bits1(gbp))
- if (read_filter_params(m, gbp, ch, IIR) < 0)
+ if (read_filter_params(m, gbp, substr, ch, IIR) < 0)
return -1;
if (fir->order + iir->order > 8) {
@@ -697,7 +699,7 @@ static int read_decoding_params(MLPDecodeContext *m, GetBitContext *gbp,
if (s->param_presence_flags & PARAM_QUANTSTEP)
if (get_bits1(gbp))
for (ch = 0; ch <= s->max_channel; ch++) {
- ChannelParams *cp = &m->channel_params[ch];
+ ChannelParams *cp = &s->channel_params[ch];
s->quant_step_size[ch] = get_bits(gbp, 4);
@@ -721,12 +723,12 @@ static void filter_channel(MLPDecodeContext *m, unsigned int substr,
unsigned int channel)
{
SubStream *s = &m->substream[substr];
- const int32_t *fircoeff = m->channel_params[channel].coeff[FIR];
+ const int32_t *fircoeff = s->channel_params[channel].coeff[FIR];
int32_t state_buffer[NUM_FILTERS][MAX_BLOCKSIZE + MAX_FIR_ORDER];
int32_t *firbuf = state_buffer[FIR] + MAX_BLOCKSIZE;
int32_t *iirbuf = state_buffer[IIR] + MAX_BLOCKSIZE;
- FilterParams *fir = &m->channel_params[channel].filter_params[FIR];
- FilterParams *iir = &m->channel_params[channel].filter_params[IIR];
+ FilterParams *fir = &s->channel_params[channel].filter_params[FIR];
+ FilterParams *iir = &s->channel_params[channel].filter_params[IIR];
unsigned int filter_shift = fir->shift;
int32_t mask = MSB_MASK(s->quant_step_size[channel]);