diff options
author | Ramiro Polla <ramiro.polla@gmail.com> | 2009-03-27 23:32:32 +0000 |
---|---|---|
committer | Ramiro Polla <ramiro.polla@gmail.com> | 2009-03-27 23:32:32 +0000 |
commit | f8e6293bdefb4e3ba2b105aac7984c37dae41316 (patch) | |
tree | 9bda05ba73db576839272dde1de4260d477efd9b /libavcodec/mlpdec.c | |
parent | 17a86e87abcd3e39bd2380c25868146922e80feb (diff) | |
download | ffmpeg-streaming-f8e6293bdefb4e3ba2b105aac7984c37dae41316.zip ffmpeg-streaming-f8e6293bdefb4e3ba2b105aac7984c37dae41316.tar.gz |
mlpdec: Split read_matrix_params() into its own function.
Originally committed as revision 18206 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mlpdec.c')
-rw-r--r-- | libavcodec/mlpdec.c | 88 |
1 files changed, 50 insertions, 38 deletions
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c index c5a97ac..fee4ff7d 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c @@ -498,6 +498,53 @@ static int read_filter_params(MLPDecodeContext *m, GetBitContext *gbp, return 0; } +/** Read parameters for primitive matrices. */ + +static int read_matrix_params(MLPDecodeContext *m, SubStream *s, GetBitContext *gbp) +{ + unsigned int mat, ch; + + s->num_primitive_matrices = get_bits(gbp, 4); + + for (mat = 0; mat < s->num_primitive_matrices; mat++) { + int frac_bits, max_chan; + s->matrix_out_ch[mat] = get_bits(gbp, 4); + frac_bits = get_bits(gbp, 4); + s->lsb_bypass [mat] = get_bits1(gbp); + + if (s->matrix_out_ch[mat] > s->max_channel) { + av_log(m->avctx, AV_LOG_ERROR, + "Invalid channel %d specified as output from matrix.\n", + s->matrix_out_ch[mat]); + return -1; + } + if (frac_bits > 14) { + av_log(m->avctx, AV_LOG_ERROR, + "Too many fractional bits specified.\n"); + return -1; + } + + max_chan = s->max_matrix_channel; + if (!s->noise_type) + max_chan+=2; + + for (ch = 0; ch <= max_chan; ch++) { + int coeff_val = 0; + if (get_bits1(gbp)) + coeff_val = get_sbits(gbp, frac_bits + 2); + + s->matrix_coeff[mat][ch] = coeff_val << (14 - frac_bits); + } + + if (s->noise_type) + s->matrix_noise_shift[mat] = get_bits(gbp, 4); + else + s->matrix_noise_shift[mat] = 0; + } + + return 0; +} + /** Read decoding parameters that change more often than those in the restart * header. */ @@ -505,7 +552,7 @@ static int read_decoding_params(MLPDecodeContext *m, GetBitContext *gbp, unsigned int substr) { SubStream *s = &m->substream[substr]; - unsigned int mat, ch; + unsigned int ch; if (s->param_presence_flags & PARAM_PRESENCE) if (get_bits1(gbp)) @@ -523,43 +570,8 @@ static int read_decoding_params(MLPDecodeContext *m, GetBitContext *gbp, if (s->param_presence_flags & PARAM_MATRIX) if (get_bits1(gbp)) { - s->num_primitive_matrices = get_bits(gbp, 4); - - for (mat = 0; mat < s->num_primitive_matrices; mat++) { - int frac_bits, max_chan; - s->matrix_out_ch[mat] = get_bits(gbp, 4); - frac_bits = get_bits(gbp, 4); - s->lsb_bypass [mat] = get_bits1(gbp); - - if (s->matrix_out_ch[mat] > s->max_channel) { - av_log(m->avctx, AV_LOG_ERROR, - "Invalid channel %d specified as output from matrix.\n", - s->matrix_out_ch[mat]); - return -1; - } - if (frac_bits > 14) { - av_log(m->avctx, AV_LOG_ERROR, - "Too many fractional bits specified.\n"); - return -1; - } - - max_chan = s->max_matrix_channel; - if (!s->noise_type) - max_chan+=2; - - for (ch = 0; ch <= max_chan; ch++) { - int coeff_val = 0; - if (get_bits1(gbp)) - coeff_val = get_sbits(gbp, frac_bits + 2); - - s->matrix_coeff[mat][ch] = coeff_val << (14 - frac_bits); - } - - if (s->noise_type) - s->matrix_noise_shift[mat] = get_bits(gbp, 4); - else - s->matrix_noise_shift[mat] = 0; - } + if (read_matrix_params(m, s, gbp) < 0) + return -1; } if (s->param_presence_flags & PARAM_OUTSHIFT) |