comparison alsdec.c @ 11189:638415aafbda libavcodec

Limit the Rice parameter used for progressive decoding in ALS.
author thilo.borgmann
date Tue, 16 Feb 2010 14:48:01 +0000
parents 625a076b8038
children 00854e4457f2
comparison
equal deleted inserted replaced
11188:c2951c6d76ef 11189:638415aafbda
190 GetBitContext gb; 190 GetBitContext gb;
191 unsigned int cur_frame_length; ///< length of the current frame to decode 191 unsigned int cur_frame_length; ///< length of the current frame to decode
192 unsigned int frame_id; ///< the frame ID / number of the current frame 192 unsigned int frame_id; ///< the frame ID / number of the current frame
193 unsigned int js_switch; ///< if true, joint-stereo decoding is enforced 193 unsigned int js_switch; ///< if true, joint-stereo decoding is enforced
194 unsigned int num_blocks; ///< number of blocks used in the current frame 194 unsigned int num_blocks; ///< number of blocks used in the current frame
195 unsigned int s_max; ///< maximum Rice parameter allowed in entropy coding
195 uint8_t *bgmc_lut; ///< pointer at lookup tables used for BGMC 196 uint8_t *bgmc_lut; ///< pointer at lookup tables used for BGMC
196 unsigned int *bgmc_lut_status; ///< pointer at lookup table status flags used for BGMC 197 unsigned int *bgmc_lut_status; ///< pointer at lookup table status flags used for BGMC
197 int ltp_lag_length; ///< number of bits used for ltp lag value 198 int ltp_lag_length; ///< number of bits used for ltp lag value
198 int *use_ltp; ///< contains use_ltp flags for all channels 199 int *use_ltp; ///< contains use_ltp flags for all channels
199 int *ltp_lag; ///< contains ltp lag values for all channels 200 int *ltp_lag; ///< contains ltp lag values for all channels
718 // read first value and residuals in case of a random access block 719 // read first value and residuals in case of a random access block
719 if (bd->ra_block) { 720 if (bd->ra_block) {
720 if (opt_order) 721 if (opt_order)
721 bd->raw_samples[0] = decode_rice(gb, avctx->bits_per_raw_sample - 4); 722 bd->raw_samples[0] = decode_rice(gb, avctx->bits_per_raw_sample - 4);
722 if (opt_order > 1) 723 if (opt_order > 1)
723 bd->raw_samples[1] = decode_rice(gb, s[0] + 3); 724 bd->raw_samples[1] = decode_rice(gb, FFMIN(s[0] + 3, ctx->s_max));
724 if (opt_order > 2) 725 if (opt_order > 2)
725 bd->raw_samples[2] = decode_rice(gb, s[0] + 1); 726 bd->raw_samples[2] = decode_rice(gb, FFMIN(s[0] + 1, ctx->s_max));
726 727
727 start = FFMIN(opt_order, 3); 728 start = FFMIN(opt_order, 3);
728 } 729 }
729 730
730 // read all residuals 731 // read all residuals
1506 avctx->sample_fmt = sconf->resolution > 1 1507 avctx->sample_fmt = sconf->resolution > 1
1507 ? SAMPLE_FMT_S32 : SAMPLE_FMT_S16; 1508 ? SAMPLE_FMT_S32 : SAMPLE_FMT_S16;
1508 avctx->bits_per_raw_sample = (sconf->resolution + 1) * 8; 1509 avctx->bits_per_raw_sample = (sconf->resolution + 1) * 8;
1509 } 1510 }
1510 1511
1512 // set maximum Rice parameter for progressive decoding based on resolution
1513 // This is not specified in 14496-3 but actually done by the reference
1514 // codec RM22 revision 2.
1515 ctx->s_max = sconf->resolution > 1 ? 31 : 15;
1516
1511 // set lag value for long-term prediction 1517 // set lag value for long-term prediction
1512 ctx->ltp_lag_length = 8 + (avctx->sample_rate >= 96000) + 1518 ctx->ltp_lag_length = 8 + (avctx->sample_rate >= 96000) +
1513 (avctx->sample_rate >= 192000); 1519 (avctx->sample_rate >= 192000);
1514 1520
1515 // allocate quantized parcor coefficient buffer 1521 // allocate quantized parcor coefficient buffer