[soc]: r4491 - in wmapro: wma3data.h wma3dec.c
Author: faust3 Date: Sat Jun 20 13:24:19 2009 New Revision: 4491 Log: Use the shared wma run level decoding function Modified: wmapro/wma3data.h wmapro/wma3dec.c Modified: wmapro/wma3data.h ============================================================================== --- wmapro/wma3data.h Fri Jun 19 15:38:27 2009 (r4490) +++ wmapro/wma3data.h Sat Jun 20 13:24:19 2009 (r4491) @@ -326,7 +326,7 @@ static const uint8_t coef1_huffbits[HUFF }; -static const uint8_t coef0_run[HUFF_COEF0_SIZE] = { +static const uint16_t coef0_run[HUFF_COEF0_SIZE] = { 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, @@ -349,7 +349,7 @@ static const uint8_t coef0_run[HUFF_COEF 1, 0, 1, 0, 1, 0, }; -static const uint8_t coef0_level[HUFF_COEF0_SIZE] = { +static const uint16_t coef0_level[HUFF_COEF0_SIZE] = { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -373,7 +373,7 @@ static const uint8_t coef0_level[HUFF_CO }; -static const uint8_t coef1_run[HUFF_COEF1_SIZE] = { +static const uint16_t coef1_run[HUFF_COEF1_SIZE] = { 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, @@ -390,7 +390,7 @@ static const uint8_t coef1_run[HUFF_COEF 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, }; -static const uint8_t coef1_level[HUFF_COEF1_SIZE] = { +static const uint16_t coef1_level[HUFF_COEF1_SIZE] = { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, Modified: wmapro/wma3dec.c ============================================================================== --- wmapro/wma3dec.c Fri Jun 19 15:38:27 2009 (r4490) +++ wmapro/wma3dec.c Sat Jun 20 13:24:19 2009 (r4491) @@ -819,28 +819,6 @@ static int decode_channel_transform(WMA3 } /** - *@brief Decode an uncompressed coefficient. - *@param s codec context - *@return the decoded coefficient - */ -static unsigned int get_large_val(WMA3DecodeContext* s) -{ - /** consumes up to 34 bits */ - int n_bits = 8; - /** decode length */ - if (get_bits1(&s->gb)) { - n_bits += 8; - if (get_bits1(&s->gb)) { - n_bits += 8; - if (get_bits1(&s->gb)) { - n_bits += 7; - } - } - } - return get_bits_long(&s->gb,n_bits); -} - -/** *@brief Extract the coefficients from the bitstream. *@param s codec context *@param c current channel number @@ -855,8 +833,8 @@ static int decode_coeffs(WMA3DecodeConte int rl_mode = 0; int cur_coeff = 0; int num_zeros = 0; - const uint8_t* run; - const uint8_t* level; + const uint16_t* run; + const uint16_t* level; int zero_init = 0; int rl_switchmask = (s->subframe_len>>8); @@ -896,10 +874,10 @@ static int decode_coeffs(WMA3DecodeConte if ( idx == HUFF_VEC2_SIZE - 1 ) { vals[i] = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH); if (vals[i] == HUFF_VEC1_SIZE - 1) - vals[i] += get_large_val(s); + vals[i] += ff_wma_get_large_val(&s->gb); vals[i+1] = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH); if (vals[i+1] == HUFF_VEC1_SIZE - 1) - vals[i+1] += get_large_val(s); + vals[i+1] += ff_wma_get_large_val(&s->gb); } else { vals[i] = (symbol_to_vec2[idx] >> 4) & 0xF; vals[i+1] = symbol_to_vec2[idx] & 0xF; @@ -930,38 +908,11 @@ static int decode_coeffs(WMA3DecodeConte /** decode run level coded coefficients */ if (rl_mode) { - const unsigned int coeff_mask = s->subframe_len - 1; - while (cur_coeff < s->subframe_len) { - unsigned int idx; - int sign; - int val; - idx = get_vlc2(&s->gb, vlc->table, VLCBITS, vlcmax); - - if ( idx > 1) { - cur_coeff += run[idx]; - val = level[idx]; - } else if ( idx == 1) { - break; - } else { - val = get_large_val(s); - /** escape decode */ - if (get_bits1(&s->gb)) { - if (get_bits1(&s->gb)) { - if (get_bits1(&s->gb)) { - av_log(s->avctx,AV_LOG_ERROR, - "broken escape sequence\n"); - return 0; - } else - cur_coeff += get_bits(&s->gb,s->esc_len) + 4; - } else - cur_coeff += get_bits(&s->gb,2) + 1; - } - } - /** decode sign */ - sign = get_bits1(&s->gb) - 1; - ci->coeffs[cur_coeff & coeff_mask] = (val^sign) - sign; - ++cur_coeff; - } + if(ff_wma_run_level_decode(s->avctx, &s->gb, vlc, + level, run, 1, ci->coeffs, + cur_coeff, s->subframe_len, s->subframe_len, + s->esc_len, 0)) + return -1; } return 1;
participants (1)
-
faust3