Index: apps/codecs/codecs.make =================================================================== --- apps/codecs/codecs.make (revision 27301) +++ apps/codecs/codecs.make (working copy) @@ -37,6 +37,7 @@ include $(APPSDIR)/codecs/libtremor/libtremor.make include $(APPSDIR)/codecs/libwavpack/libwavpack.make include $(APPSDIR)/codecs/libwma/libwma.make +include $(APPSDIR)/codecs/libwmapro/libwmapro.make include $(APPSDIR)/codecs/libcook/libcook.make include $(APPSDIR)/codecs/librm/librm.make include $(APPSDIR)/codecs/libatrac/libatrac.make @@ -58,7 +59,7 @@ CODECLIBS := $(DEMACLIB) $(A52LIB) $(ALACLIB) $(ASAPLIB) \ $(FAADLIB) $(FFMPEGFLACLIB) $(M4ALIB) $(MADLIB) $(MUSEPACKLIB) \ $(SPCLIB) $(SPEEXLIB) $(TREMORLIB) $(WAVPACKLIB) $(WMALIB) $(COOKLIB) \ - $(ATRACLIB) \ + $(ATRACLIB) $(WMAPROLIB) \ $(CODECLIB) $(CODECS): $(CODEC_CRT0) $(CODECLINK_LDS) @@ -83,6 +84,7 @@ $(CODECDIR)/ape-pre.map : $(CODECDIR)/libdemac-pre.a $(CODECDIR)/ape.codec : $(CODECDIR)/libdemac.a $(CODECDIR)/wma.codec : $(CODECDIR)/libwma.a $(CODECDIR)/libasf.a +$(CODECDIR)/wmapro.codec : $(CODECDIR)/libwmapro.a $(CODECDIR)/libasf.a $(CODECDIR)/wavpack_enc.codec: $(CODECDIR)/libwavpack.a $(CODECDIR)/asap.codec : $(CODECDIR)/libasap.a $(CODECDIR)/cook.codec : $(CODECDIR)/libcook.a $(CODECDIR)/librm.a Index: apps/codecs/SOURCES =================================================================== --- apps/codecs/SOURCES (revision 27301) +++ apps/codecs/SOURCES (working copy) @@ -16,6 +16,7 @@ atrac3_oma.c mpc.c wma.c +wmapro.c sid.c ape.c nsf.c Index: apps/codecs/libwmapro/wmaprodata.h =================================================================== --- apps/codecs/libwmapro/wmaprodata.h (revision 27301) +++ apps/codecs/libwmapro/wmaprodata.h (working copy) @@ -31,6 +31,15 @@ #include #include +const int32_t fixed_sin64[33] = { + 0x00000000, 0xF9B82685, 0xF3742CA3, 0xED37EF92, 0xE70747C5, 0xE0E60686, + 0xDAD7F3A3, 0xD4E0CB16, 0xCF043AB4, 0xC945DFED, 0xC3A94591, 0xBE31E19C, + 0xB8E3131A, 0xB3C0200D, 0xAECC336D, 0xAA0A5B2F, 0xA57D8667, 0xA1288377, + 0x9D0DFE55, 0x99307EE1, 0x9592675D, 0x9235F2ED, 0x8F1D343B, 0x8C4A1430, + 0x89BE50C4, 0x877B7BED, 0x8582FAA6, 0x83D60413, 0x8275A0C1, 0x8162AA05, + 0x809DC972, 0x80277873, 0x80000001, +}; + /** * @brief frequencies to divide the frequency spectrum into scale factor bands */ @@ -375,7 +384,30 @@ 25, 26, 26, 27, 27, 28, }; +static const int32_t fixcoef0_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, + 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, 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, 1, 1, 1, 1, 1, 1, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, + 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, + 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, + 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, + 25, 26, 26, 27, 27, 28, +}; + 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, @@ -409,6 +441,23 @@ 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 51, 52, }; + +static const int32_t fixcoef1_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, + 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, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, + 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 10, + 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, + 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, + 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, + 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, + 46, 47, 47, 48, 48, 49, 49, 50, 51, 52, +}; /** @} */ Index: apps/codecs/libwmapro/wmaprodec.c =================================================================== --- apps/codecs/libwmapro/wmaprodec.c (revision 27302) +++ apps/codecs/libwmapro/wmaprodec.c (working copy) @@ -168,6 +168,8 @@ int8_t transform_band[MAX_BANDS]; ///< controls if the transform is enabled for a certain band float decorrelation_matrix[WMAPRO_MAX_CHANNELS*WMAPRO_MAX_CHANNELS]; float* channel_data[WMAPRO_MAX_CHANNELS]; ///< transformation coefficients + FIXED fixdecorrelation_matrix[WMAPRO_MAX_CHANNELS*WMAPRO_MAX_CHANNELS]; + FIXED* fixchannel_data[WMAPRO_MAX_CHANNELS]; ///< transformation coefficients } WMAProChannelGrp; /** @@ -629,9 +631,15 @@ for (i = 0; i < chgroup->num_channels * (chgroup->num_channels - 1) >> 1; i++) rotation_offset[i] = get_bits(&s->gb, 6); - for (i = 0; i < chgroup->num_channels; i++) + for (i = 0; i < chgroup->num_channels; i++) { chgroup->decorrelation_matrix[chgroup->num_channels * i + i] = get_bits1(&s->gb) ? 1.0 : -1.0; + + if(chgroup->decorrelation_matrix[chgroup->num_channels * i + i] > 0) + chgroup->fixdecorrelation_matrix[chgroup->num_channels * i + i] = 0x10000; + else + chgroup->fixdecorrelation_matrix[chgroup->num_channels * i + i] = -0x10000; + } for (i = 1; i < chgroup->num_channels; i++) { int x; @@ -640,22 +648,38 @@ for (y = 0; y < i + 1; y++) { float v1 = chgroup->decorrelation_matrix[x * chgroup->num_channels + y]; float v2 = chgroup->decorrelation_matrix[i * chgroup->num_channels + y]; + FIXED f1 = chgroup->fixdecorrelation_matrix[x * chgroup->num_channels + y]; + FIXED f2 = chgroup->fixdecorrelation_matrix[i * chgroup->num_channels + y]; int n = rotation_offset[offset + x]; float sinv; float cosv; + FIXED fixsinv; + FIXED fixcosv; if (n < 32) { sinv = sin64[n]; cosv = sin64[32 - n]; + fixsinv = fixed_sin64[n]; + fixcosv = fixed_sin64[32-n]; } else { sinv = sin64[64 - n]; cosv = -sin64[n - 32]; + fixsinv = fixed_sin64[64-n]; + fixcosv = -fixed_sin64[n-32]; } + float a,b; + FIXED c,d; - chgroup->decorrelation_matrix[y + x * chgroup->num_channels] = + a = chgroup->decorrelation_matrix[y + x * chgroup->num_channels] = (v1 * sinv) - (v2 * cosv); - chgroup->decorrelation_matrix[y + i * chgroup->num_channels] = + b = chgroup->decorrelation_matrix[y + i * chgroup->num_channels] = (v1 * cosv) + (v2 * sinv); + c = chgroup->fixdecorrelation_matrix[y + x * chgroup->num_channels] = + fixmulshift(f1, fixsinv, 31) - fixmulshift(f2, fixcosv, 31); + d = chgroup->fixdecorrelation_matrix[y + i * chgroup->num_channels] = + fixmulshift(f1, fixcosv, 31) + fixmulshift(f2, fixsinv, 31); + +//zprintf("a = %f, b = %f\nc = %f, d = %f", a,b, fixtof16(c/(1<<15)), fixtof16(d/(1<<15)));getchar(); } } offset += i; @@ -690,6 +714,7 @@ s->num_chgroups < s->channels_for_cur_subframe; s->num_chgroups++) { WMAProChannelGrp* chgroup = &s->chgroup[s->num_chgroups]; float** channel_data = chgroup->channel_data; + FIXED** fixchdata = chgroup->fixchannel_data; chgroup->num_channels = 0; chgroup->transform = 0; @@ -702,14 +727,17 @@ ++chgroup->num_channels; s->channel[channel_idx].grouped = 1; *channel_data++ = s->channel[channel_idx].coeffs; + *fixchdata++ = s->channel[channel_idx].fixcoeffs; } } } else { chgroup->num_channels = remaining_channels; for (i = 0; i < s->channels_for_cur_subframe; i++) { int channel_idx = s->channel_indexes_for_cur_subframe[i]; - if (!s->channel[channel_idx].grouped) + if (!s->channel[channel_idx].grouped) { *channel_data++ = s->channel[channel_idx].coeffs; + *fixchdata++ = s->channel[channel_idx].fixcoeffs; + } s->channel[channel_idx].grouped = 1; } } @@ -728,12 +756,22 @@ chgroup->decorrelation_matrix[1] = -1.0; chgroup->decorrelation_matrix[2] = 1.0; chgroup->decorrelation_matrix[3] = 1.0; + + chgroup->fixdecorrelation_matrix[0] = 0x10000; + chgroup->fixdecorrelation_matrix[1] = -0x10000; + chgroup->fixdecorrelation_matrix[2] = 0x10000; + chgroup->fixdecorrelation_matrix[3] = 0x10000; } else { /** cos(pi/4) */ chgroup->decorrelation_matrix[0] = 0.70703125; chgroup->decorrelation_matrix[1] = -0.70703125; chgroup->decorrelation_matrix[2] = 0.70703125; chgroup->decorrelation_matrix[3] = 0.70703125; + + chgroup->fixdecorrelation_matrix[0] = 0xB500; + chgroup->fixdecorrelation_matrix[1] = -0xB500; + chgroup->fixdecorrelation_matrix[2] = 0xB500; + chgroup->fixdecorrelation_matrix[3] = 0xB500; } } } else if (chgroup->num_channels > 2) { @@ -799,6 +837,7 @@ int num_zeros = 0; const uint16_t* run; const float* level; + const FIXED* fixlevel; dprintf(s->avctx, "decode coefficients for channel %i\n", c); @@ -808,15 +847,18 @@ if (vlctable) { run = coef1_run; level = coef1_level; + fixlevel = fixcoef1_level; } else { run = coef0_run; level = coef0_level; + fixlevel = fixcoef0_level; } /** decode vector coefficients (consumes up to 167 bits per iteration for 4 vector coded large values) */ while (!rl_mode && cur_coeff + 3 < s->subframe_len) { int vals[4]; + int32_t fixvals[4]; int i; unsigned int idx; @@ -835,9 +877,13 @@ v1 += ff_wma_get_large_val(&s->gb); ((float*)vals)[i ] = v0; ((float*)vals)[i+1] = v1; + fixvals[i] = v0; + fixvals[i+1] = v1; } else { vals[i] = fval_tab[symbol_to_vec2[idx] >> 4 ]; vals[i+1] = fval_tab[symbol_to_vec2[idx] & 0xF]; + fixvals[i] = symbol_to_vec2[idx] >> 4; + fixvals[i+1] = symbol_to_vec2[idx] & 0xF; } } } else { @@ -845,6 +891,11 @@ vals[1] = fval_tab[(symbol_to_vec4[idx] >> 8) & 0xF]; vals[2] = fval_tab[(symbol_to_vec4[idx] >> 4) & 0xF]; vals[3] = fval_tab[ symbol_to_vec4[idx] & 0xF]; + + fixvals[0] = symbol_to_vec4[idx] >> 12; + fixvals[1] = (symbol_to_vec4[idx] >> 8) & 0xF; + fixvals[2] = (symbol_to_vec4[idx] >> 4) & 0xF; + fixvals[3] = symbol_to_vec4[idx] & 0xF; } /** decode sign */ @@ -852,9 +903,12 @@ if (vals[i]) { int sign = get_bits1(&s->gb) - 1; *(uint32_t*)&ci->coeffs[cur_coeff] = vals[i] ^ sign<<31; + ci->fixcoeffs[cur_coeff] = (sign == -1)? -fixvals[i]<<16 : fixvals[i]<<16; + //printf("coeff = %f, fixcoeff = %f\n", ci->coeffs[cur_coeff], fixtof16(ci->fixcoeffs[cur_coeff]));getchar(); num_zeros = 0; } else { ci->coeffs[cur_coeff] = 0; + ci->fixcoeffs[cur_coeff] = 0; /** switch to run level mode when subframe_len / 128 zeros were found in a row */ rl_mode |= (++num_zeros > s->subframe_len >> 8); @@ -867,13 +921,37 @@ if (rl_mode) { memset(&ci->coeffs[cur_coeff], 0, sizeof(*ci->coeffs) * (s->subframe_len - cur_coeff)); - if (ff_wma_run_level_decode(s->avctx, &s->gb, vlc, + memset(&ci->fixcoeffs[cur_coeff], 0, + sizeof(*ci->fixcoeffs) * (s->subframe_len - cur_coeff)); + +/************************************************************************************************************************************************************************* + {int j; + for(j = 0; j < WMAPRO_BLOCK_MAX_SIZE + WMAPRO_BLOCK_MAX_SIZE/2; j++){ + s->channel[0].out[j] = fixtof16(s->channel[0].fixout[j]); + s->channel[1].out[j] = fixtof16(s->channel[1].fixout[j]); + } + } +/*************************************************************************************************************************************************************************/ + /*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 AVERROR_INVALIDDATA; + return AVERROR_INVALIDDATA;*/ +/************************************************************************************************************************************************************************* + { int j; + for(j = 0; j < WMAPRO_BLOCK_MAX_SIZE + WMAPRO_BLOCK_MAX_SIZE/2; j++){ + s->channel[0].fixout[j] = ftofix16(s->channel[0].out[j]); + s->channel[1].fixout[j] = ftofix16(s->channel[1].out[j]); + } + } +/*************************************************************************************************************************************************************************/ + if (ff_wma_fix_run_level_decode(s->avctx, &s->gb, vlc, + fixlevel, run, 1, ci->fixcoeffs, + cur_coeff, s->subframe_len, + s->subframe_len, s->esc_len, 0)) + return AVERROR_INVALIDDATA; + } - return 0; } @@ -952,6 +1030,7 @@ return AVERROR_INVALIDDATA; } s->channel[c].scale_factors[i] += (val ^ sign) - sign; + //s->channel[c].scale_factors[i] += (sign == -1)? -val : val; } } /** swap buffers */ @@ -985,6 +1064,9 @@ const int num_channels = s->chgroup[i].num_channels; float** ch_data = s->chgroup[i].channel_data; float** ch_end = ch_data + num_channels; + FIXED fixdata[WMAPRO_MAX_CHANNELS]; + FIXED** fixchdata = s->chgroup[i].fixchannel_data; + FIXED** fixchend = fixchdata + num_channels; const int8_t* tb = s->chgroup[i].transform_band; int16_t* sfb; @@ -999,17 +1081,32 @@ const float* data_end = data + num_channels; float* data_ptr = data; float** ch; - - for (ch = ch_data; ch < ch_end; ch++) + const FIXED* fixmat = s->chgroup[i].fixdecorrelation_matrix; + const FIXED* fixdata_end = fixdata + num_channels; + FIXED* fixdata_ptr = fixdata; + FIXED** fixch; + for (ch = ch_data, fixch = fixchdata; ch < ch_end && fixch < fixchend; ch++, fixch++) { *data_ptr++ = (*ch)[y]; + *fixdata_ptr++ = (*fixch)[y]; + //printf("1sum = %f, 1fixsum = %f", (*ch)[y], fixtof16((*fixch)[y]));getchar(); + } - for (ch = ch_data; ch < ch_end; ch++) { + for (ch = ch_data, fixch = fixchdata; ch < ch_end && fixch < fixchend; ch++, fixch++) { float sum = 0; + FIXED fixsum = 0; data_ptr = data; - while (data_ptr < data_end) + fixdata_ptr = fixdata; + while (data_ptr < data_end) { sum += *data_ptr++ * *mat++; + //printf("mat = %f, fixmat = %f", *mat, fixtof16(*++fixmat));getchar(); + } + + while (fixdata_ptr < fixdata_end) + fixsum += fixmulshift(*fixdata_ptr++, *fixmat++, 16); (*ch)[y] = sum; + (*fixch)[y] = fixsum; + //printf("sum = %d, fixsum = %d", (FIXED)sum, fixsum);getchar(); } } } else if (s->num_channels == 2) { @@ -1020,6 +1117,13 @@ s->dsp.vector_fmul_scalar(ch_data[1] + sfb[0], ch_data[1] + sfb[0], 181.0 / 128, len); + vector_fixmul_scalar(fixchdata[0] + sfb[0], + fixchdata[0] + sfb[0], + 0x00016A00, len, 16); + vector_fixmul_scalar(fixchdata[1] + sfb[0], + fixchdata[1] + sfb[0], + 0x00016A00, len, 16); + } } } @@ -1165,11 +1269,9 @@ return AVERROR_INVALIDDATA; } - if (decode_channel_transform(s) < 0) return AVERROR_INVALIDDATA; - for (i = 0; i < s->channels_for_cur_subframe; i++) { int c = s->channel_indexes_for_cur_subframe[i]; if ((s->channel[c].transmit_coefs = get_bits1(&s->gb))) @@ -1232,9 +1334,12 @@ if (s->channel[c].transmit_coefs && get_bits_count(&s->gb) < s->num_saved_bits) { decode_coeffs(s, c); - } else + } else { memset(s->channel[c].coeffs, 0, sizeof(*s->channel[c].coeffs) * subframe_len); + memset(s->channel[c].fixcoeffs, 0, + sizeof(*s->channel[c].fixcoeffs) * subframe_len); + } } dprintf(s->avctx, "BITSTREAM: subframe length was %i\n", @@ -1269,16 +1374,21 @@ const FIXED fixquant = QUANT(exp); int start = s->cur_sfb_offsets[b]; - int j; - for(j = 0; j < WMAPRO_BLOCK_MAX_SIZE + WMAPRO_BLOCK_MAX_SIZE/2; j++) - s->channel[c].fixout[j] = ftofix16(s->channel[c].out[j]); + /*int j; + for(j = 0; j < WMAPRO_BLOCK_MAX_SIZE + WMAPRO_BLOCK_MAX_SIZE/2; j++){ + //s->channel[c].fixout[j] = ftofix16(s->channel[c].out[j]); + if(s->channel[c].out[j] > 0.000001) { + printf("fix = %d, float = %d\n", s->channel[c].fixout[j], ftofix16(s->channel[c].out[j])); + getchar(); + } + }*/ s->dsp.vector_fmul_scalar(s->tmp + start, s->channel[c].coeffs + start, quant, end - start); vector_fixmul_scalar(s->fixtmp+start, s->channel[c].fixcoeffs + start, - fixquant, end-start); + fixquant, end-start, 32); } @@ -1415,6 +1525,10 @@ memcpy(&s->channel[i].out[0], &s->channel[i].out[s->samples_per_frame], s->samples_per_frame * sizeof(*s->channel[i].out) >> 1); + + memcpy(&s->channel[i].fixout[0], + &s->channel[i].fixout[s->samples_per_frame], + s->samples_per_frame * sizeof(*s->channel[i].fixout) >> 1); } if (s->skip_frame) { Index: apps/codecs/libwmapro/wmapro_math.h =================================================================== --- apps/codecs/libwmapro/wmapro_math.h (revision 27302) +++ apps/codecs/libwmapro/wmapro_math.h (working copy) @@ -2,6 +2,7 @@ #include "types.h" #define fixtof16(x) (float)((float)(x) / (float)(1 << 16)) +#define fixtof31(x) (float)((float)(x) / (float)(1 << 31)) #define ftofix16(x) ((int32_t)((x) * (float)(1 << 16) + ((x) < 0 ? -0.5:0.5))) static inline FIXED fixmulshift(FIXED x, FIXED y, int shamt) @@ -36,11 +37,11 @@ } static inline void vector_fixmul_scalar(FIXED *dst, const FIXED *src, FIXED mul, - int len) + int len, int shift) { int i; for(i=0; itable, VLCBITS, VLCMAX); + if (code > 1) { + /** normal code */ + offset += run_table[code]; + sign = !get_bits1(gb); + ptr[offset & coef_mask] = sign ? -level_table[code]<<16 : level_table[code]<<16; + //printf("iptr = %f, ilvl = %d, sign = %d", (float)(iptr[offset & coef_mask]>>16), ilvl[code], sign);getchar(); + } else if (code == 1) { + /** EOB */ + break; + } else { + /** escape */ + if (!version) { + level = get_bits(gb, coef_nb_bits); + /** NOTE: this is rather suboptimal. reading + block_len_bits would be better */ + offset += get_bits(gb, frame_len_bits); + } else { + level = ff_wma_get_large_val(gb); + /** escape decode */ + if (get_bits1(gb)) { + if (get_bits1(gb)) { + if (get_bits1(gb)) { + av_log(avctx,AV_LOG_ERROR, + "broken escape sequence\n"); + return -1; + } else + offset += get_bits(gb, frame_len_bits) + 4; + } else + offset += get_bits(gb, 2) + 1; + } + } + sign = !get_bits1(gb); + ptr[offset & coef_mask] = sign ? -level<<16 : level<<16; + //printf("iptr = %f, lvl = %d, sign = %d", (float)(ptr[offset & coef_mask]>>16), level, sign);getchar(); + } + } + /** NOTE: EOB can be omitted */ + if (offset > num_coefs) { + av_log(avctx, AV_LOG_ERROR, "overflow in spectral RLE, ignoring\n"); + return -1; + } + + return 0; +} Index: apps/codecs/libwmapro/wma.h =================================================================== --- apps/codecs/libwmapro/wma.h (revision 27301) +++ apps/codecs/libwmapro/wma.h (working copy) @@ -159,5 +159,11 @@ int version, WMACoef *ptr, int offset, int num_coefs, int block_len, int frame_len_bits, int coef_nb_bits); +int ff_wma_fix_run_level_decode(AVCodecContext* avctx, GetBitContext* gb, + VLC *vlc, + const int32_t *level_table, const uint16_t *run_table, + int version, int32_t *ptr, int offset, + int num_coefs, int block_len, int frame_len_bits, + int coef_nb_bits); #endif /* AVCODEC_WMA_H */