diff options
Diffstat (limited to 'lib/rbcodec')
-rwxr-xr-x[-rw-r--r--] | lib/rbcodec/codecs/libwmapro/wmaprodec.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/rbcodec/codecs/libwmapro/wmaprodec.c b/lib/rbcodec/codecs/libwmapro/wmaprodec.c index 9d42c6de0f..62a12738a5 100644..100755 --- a/lib/rbcodec/codecs/libwmapro/wmaprodec.c +++ b/lib/rbcodec/codecs/libwmapro/wmaprodec.c | |||
@@ -192,6 +192,7 @@ typedef struct { | |||
192 | int* scale_factors; ///< pointer to the scale factor values used for decoding | 192 | int* scale_factors; ///< pointer to the scale factor values used for decoding |
193 | uint8_t table_idx; ///< index in sf_offsets for the scale factor reference block | 193 | uint8_t table_idx; ///< index in sf_offsets for the scale factor reference block |
194 | int32_t* coeffs; ///< pointer to the subframe decode buffer | 194 | int32_t* coeffs; ///< pointer to the subframe decode buffer |
195 | uint16_t num_vec_coeffs; ///< number of vector coded coefficients | ||
195 | int32_t* out; ///< output buffer | 196 | int32_t* out; ///< output buffer |
196 | } WMAProChannelCtx; | 197 | } WMAProChannelCtx; |
197 | 198 | ||
@@ -260,6 +261,7 @@ typedef struct WMAProDecodeCtx { | |||
260 | int8_t channels_for_cur_subframe; ///< number of channels that contain the subframe | 261 | int8_t channels_for_cur_subframe; ///< number of channels that contain the subframe |
261 | int8_t channel_indexes_for_cur_subframe[WMAPRO_MAX_CHANNELS]; | 262 | int8_t channel_indexes_for_cur_subframe[WMAPRO_MAX_CHANNELS]; |
262 | int8_t num_bands; ///< number of scale factor bands | 263 | int8_t num_bands; ///< number of scale factor bands |
264 | int8_t transmit_num_vec_coeffs; ///< number of vector coded coefficients is part of the bitstream | ||
263 | int16_t* cur_sfb_offsets; ///< sfb offsets for the current block | 265 | int16_t* cur_sfb_offsets; ///< sfb offsets for the current block |
264 | uint8_t table_idx; ///< index for the num_sfb, sfb_offsets, sf_offsets and subwoofer_cutoffs tables | 266 | uint8_t table_idx; ///< index for the num_sfb, sfb_offsets, sf_offsets and subwoofer_cutoffs tables |
265 | int8_t esc_len; ///< length of escaped coefficients | 267 | int8_t esc_len; ///< length of escaped coefficients |
@@ -845,7 +847,8 @@ static int decode_coeffs(WMAProDecodeCtx *s, int c) | |||
845 | 847 | ||
846 | /** decode vector coefficients (consumes up to 167 bits per iteration for | 848 | /** decode vector coefficients (consumes up to 167 bits per iteration for |
847 | 4 vector coded large values) */ | 849 | 4 vector coded large values) */ |
848 | while (!rl_mode && cur_coeff + 3 < s->subframe_len) { | 850 | while ((s->transmit_num_vec_coeffs || !rl_mode) && |
851 | (cur_coeff + 3 < ci->num_vec_coeffs)) { | ||
849 | int32_t vals[4]; | 852 | int32_t vals[4]; |
850 | int i; | 853 | int i; |
851 | unsigned int idx; | 854 | unsigned int idx; |
@@ -902,7 +905,7 @@ static int decode_coeffs(WMAProDecodeCtx *s, int c) | |||
902 | } | 905 | } |
903 | 906 | ||
904 | /** decode run level coded coefficients */ | 907 | /** decode run level coded coefficients */ |
905 | if (rl_mode) { | 908 | if (cur_coeff < s->subframe_len) { |
906 | memset(&ci->coeffs[cur_coeff], 0, | 909 | memset(&ci->coeffs[cur_coeff], 0, |
907 | sizeof(*ci->coeffs) * (s->subframe_len - cur_coeff)); | 910 | sizeof(*ci->coeffs) * (s->subframe_len - cur_coeff)); |
908 | 911 | ||
@@ -1210,10 +1213,19 @@ static int decode_subframe(WMAProDecodeCtx *s) | |||
1210 | if (transmit_coeffs) { | 1213 | if (transmit_coeffs) { |
1211 | int step; | 1214 | int step; |
1212 | int quant_step = 90 * s->bits_per_sample >> 4; | 1215 | int quant_step = 90 * s->bits_per_sample >> 4; |
1213 | if ((get_bits1(&s->gb))) { | 1216 | |
1214 | /** FIXME: might change run level mode decision */ | 1217 | /** decode number of vector coded coefficients */ |
1215 | DEBUGF("unsupported quant step coding\n"); | 1218 | if ((s->transmit_num_vec_coeffs = get_bits1(&s->gb))) { |
1216 | return AVERROR_INVALIDDATA; | 1219 | int num_bits = av_log2((s->subframe_len + 3)/4) + 1; |
1220 | for (i = 0; i < s->channels_for_cur_subframe; i++) { | ||
1221 | int c = s->channel_indexes_for_cur_subframe[i]; | ||
1222 | s->channel[c].num_vec_coeffs = get_bits(&s->gb, num_bits) << 2; | ||
1223 | } | ||
1224 | } else { | ||
1225 | for (i = 0; i < s->channels_for_cur_subframe; i++) { | ||
1226 | int c = s->channel_indexes_for_cur_subframe[i]; | ||
1227 | s->channel[c].num_vec_coeffs = s->subframe_len; | ||
1228 | } | ||
1217 | } | 1229 | } |
1218 | /** decode quantization step */ | 1230 | /** decode quantization step */ |
1219 | step = get_sbits(&s->gb, 6); | 1231 | step = get_sbits(&s->gb, 6); |