X-Git-Url: http://plrg.eecs.uci.edu/git/?p=IRC.git;a=blobdiff_plain;f=Robust%2Fsrc%2FTests%2FssJava%2Fmp3decoder%2FLayerIIIDecoder.java;h=48b0d1b2729ece17813be6fb41ad933c4ab8dde7;hp=83cc3bf7b1b7e705171916ab6cc1c87422be7dca;hb=b1691dd3c0567c74ea99a7d4d2dcdb94c9ba85ba;hpb=6477c0df8e86be6e2a690cbdb23c482e027891f2 diff --git a/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java b/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java index 83cc3bf7..48b0d1b2 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java +++ b/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java @@ -4,7 +4,7 @@ * 18/06/01 Michael Scheerer, Fixed bugs which causes * negative indexes in method huffmann_decode and in method * dequanisize_sample. - * + * * 16/07/01 Michael Scheerer, Catched a bug in method * huffmann_decode, which causes an outOfIndexException. * Cause : Indexnumber of 24 at SfBandIndex, @@ -32,66 +32,93 @@ *---------------------------------------------------------------------- */ - /** * Class Implementing Layer 3 Decoder. * * @since 0.0 */ -@LATTICE("FS>> 3; // of previous frame - + main_data_end = br.hsstell() >>> 3; if ((flush_main = (br.hsstell() & 7)) != 0) { // flush_main < br br.hgetbits(8 - flush_main); // br < flush_main - main_data_end++; // main_data_end* + main_data_end++; // main_data_end* } // bytes_to_discard < GLB(frame_start,main_data_end,si) - // TODO does bytes_to_discard need to go back to si??? bytes_to_discard = frame_start - main_data_end - si.main_data_begin; // frame_start should be * frame_start += nSlots; - if (bytes_to_discard < 0) + if (bytes_to_discard < 0) { return; + } - if (main_data_end > 4096) { // main_data_end should be > than 'frame_start' and 'br' + if (main_data_end > 4096) { // main_data_end should be > than 'frame_start' + // and 'br' frame_start -= 4096; br.rewindNbytes(4096); } - for (; bytes_to_discard > 0; bytes_to_discard--) // bytes_to_discard > br + for (; bytes_to_discard > 0; bytes_to_discard--) { + // bytes_to_discard > br br.hgetbits(8); - + } + // doing something from here - + // here 'gr' and 'max_gr' should be higher than 'ch','channels', and more - for (gr = 0; gr < max_gr; gr++) { // two granules per channel - // in the loop body, access set={part2_start} - + for (gr = 0; gr < max_gr; gr++) { // two granules per channel + // in the loop body, access set={part2_start} + // 'ch', 'channels' should be higher than all locs in the below body - for (ch = 0; ch < channels; ch++) { + for (ch = 0; ch < channels; ch++) { part2_start = br.hsstell(); // part2_start < br - // grab scale factors from the main data. + // grab scale factors from the main data. // following the scale factors is the actual compressed data if (header.version() == Header.MPEG1) get_scale_factors(ch, gr); // no need to care from this side - // here move scale factor data from 'br' buffer to 'scalefac' field + // here move scale factor data from 'br' buffer to 'scalefac' field else // MPEG-2 LSF, SZD: MPEG-2.5 LSF get_LSF_scale_factors(ch, gr); // no need to care from this side - // here, decoding the compressed audio data + // here, decoding the compressed audio data huffman_decode(ch, gr); // no need to care from this side // System.out.println("CheckSum HuffMan = " + CheckSumHuff); - dequantize_sample(ro[ch], ch, gr); // no need to care from this side + dequantize_sample(/* ro[ch], */ch, gr); // no need to care from this + // side } stereo(gr); // no need to care from this side - if ((which_channels == OutputChannels.DOWNMIX_CHANNELS) && (channels > 1)) + if ((which_channels == OutputChannels.DOWNMIX_CHANNELS) && (channels > 1)) { do_downmix(); + } - for (ch = first_channel; ch <= last_channel; ch++) { // 'ch' and 'first_channel' > the body + for (ch = first_channel; ch <= last_channel; ch++) { // 'ch' and + // 'first_channel' > + // the body // in the body // read set= lr,ch,gr,out_1d, sb18, ss, SSLIMIT, out_1d // write set= out_1d - - reorder(lr[ch], ch, gr); + + reorder(/* lr[ch], */ch, gr); antialias(ch, gr); // for (int hb = 0;hb<576;hb++) CheckSumOut1d = CheckSumOut1d + // out_1d[hb]; @@ -359,14 +398,18 @@ final class LayerIIIDecoder implements FrameDecoder { // out_1d[hb]; // System.out.println("CheckSumOut1d = "+CheckSumOut1d); - for (sb18 = 18; sb18 < 576; sb18 += 36) // sb18 > ss, SSLIMIT, out1d + for (sb18 = 18; sb18 < 576; sb18 += 36) { + // sb18 > ss, SSLIMIT, out1d // Frequency inversion - for (ss = 1; ss < SSLIMIT; ss += 2) // 'ss','SSLIMIT' > out_1d + for (ss = 1; ss < SSLIMIT; ss += 2) { + // 'ss','SSLIMIT' > out_1d out_1d[sb18 + ss] = -out_1d[sb18 + ss]; // out1d* + } + } // 'ch', 'which_channels' should be higher than if/else body! - // location set written by if/else body - // = {samples1, samples2, filter1, filter2} + // location set written by if/else body + // = {samples1, samples2, filter1, filter2} if ((ch == 0) || (which_channels == OutputChannels.RIGHT_CHANNEL)) { for (ss = 0; ss < SSLIMIT; ss++) { // Polyphase synthesis sb = 0; @@ -415,7 +458,7 @@ final class LayerIIIDecoder implements FrameDecoder { * Reads the side info from the stream, assuming the entire. frame has been * read already. Mono : 136 bits (= 17 bytes) Stereo : 256 bits (= 32 bytes) */ - @RETURNLOC("OUT") + @RETURNLOC("OUT") private boolean get_side_info() { @LOC("IN") int ch; @LOC("IN") int gr; @@ -536,7 +579,9 @@ final class LayerIIIDecoder implements FrameDecoder { * */ @LATTICE("THIS 0) - xr[quotien][reste] = g_gain * t_43[abv]; + ro[ch][quotien][reste] = g_gain * t_43[abv]; else { if (-abv < t_43.length) - xr[quotien][reste] = -g_gain * t_43[-abv]; + ro[ch][quotien][reste] = -g_gain * t_43[-abv]; else - xr[quotien][reste] = -g_gain * (float) Math.pow(-abv, d43); + ro[ch][quotien][reste] = -g_gain * (float) Math.pow(-abv, d43); } } else { if (is_1d[j] > 0) - xr[quotien][reste] = g_gain * (float) Math.pow(abv, d43); + ro[ch][quotien][reste] = g_gain * (float) Math.pow(abv, d43); else - xr[quotien][reste] = -g_gain * (float) Math.pow(-abv, d43); + ro[ch][quotien][reste] = -g_gain * (float) Math.pow(-abv, d43); } } } @@ -984,12 +1049,12 @@ final class LayerIIIDecoder implements FrameDecoder { // apply formula per block type for (j = 0; j < nonzero[ch]; j++) { // Modif E.B 02/22/99 - @LOC("REST") int reste = j % SSLIMIT; - @LOC("QUO") int quotien = (int) ((j - reste) / SSLIMIT); + @LOC("THIS,LayerIIIDecoder.NZ") int reste = j % SSLIMIT; + @LOC("THIS,LayerIIIDecoder.NZ") int quotien = (int) ((j - reste) / SSLIMIT); if (index == next_cb_boundary) { /* Adjust critical band boundary */ - if ((gr_info.window_switching_flag != 0) && (gr_info.block_type == 2)) { - if (gr_info.mixed_block_flag != 0) { + if ((si.ch[ch].gr[gr].window_switching_flag != 0) && (si.ch[ch].gr[gr].block_type == 2)) { + if (si.ch[ch].gr[gr].mixed_block_flag != 0) { if (index == sfBandIndex[sfreq].l[8]) { next_cb_boundary = sfBandIndex[sfreq].s[4]; @@ -1033,45 +1098,46 @@ final class LayerIIIDecoder implements FrameDecoder { // Do long/short dependent scaling operations - if ((gr_info.window_switching_flag != 0) - && (((gr_info.block_type == 2) && (gr_info.mixed_block_flag == 0)) || ((gr_info.block_type == 2) - && (gr_info.mixed_block_flag != 0) && (j >= 36)))) { + if ((si.ch[ch].gr[gr].window_switching_flag != 0) + && (((si.ch[ch].gr[gr].block_type == 2) && (si.ch[ch].gr[gr].mixed_block_flag == 0)) || ((si.ch[ch].gr[gr].block_type == 2) + && (si.ch[ch].gr[gr].mixed_block_flag != 0) && (j >= 36)))) { t_index = (index - cb_begin) / cb_width; /* * xr[sb][ss] *= pow(2.0, ((-2.0 * gr_info.subblock_gain[t_index]) -(0.5 * * (1.0 + gr_info.scalefac_scale) scalefac[ch].s[t_index][cb]))); */ - @LOC("IDX") int idx = scalefac[ch].s[t_index][cb] << gr_info.scalefac_scale; - idx += (gr_info.subblock_gain[t_index] << 2); + @LOC("THIS,LayerIIIDecoder.SI1") int idx = + scalefac[ch].s[t_index][cb] << si.ch[ch].gr[gr].scalefac_scale; + idx += (si.ch[ch].gr[gr].subblock_gain[t_index] << 2); - xr[quotien][reste] *= two_to_negative_half_pow[idx]; + ro[ch][quotien][reste] *= two_to_negative_half_pow[idx]; } else { // LONG block types 0,1,3 & 1st 2 subbands of switched blocks /* * xr[sb][ss] *= pow(2.0, -0.5 * (1.0+gr_info.scalefac_scale) * (scalefac[ch].l[cb] + gr_info.preflag * pretab[cb])); */ - @LOC("IDX") int idx = scalefac[ch].l[cb]; + @LOC("THIS,LayerIIIDecoder.SI1") int idx = scalefac[ch].l[cb]; - if (gr_info.preflag != 0) + if (si.ch[ch].gr[gr].preflag != 0) idx += pretab[cb]; - idx = idx << gr_info.scalefac_scale; - xr[quotien][reste] *= two_to_negative_half_pow[idx]; + idx = idx << si.ch[ch].gr[gr].scalefac_scale; + ro[ch][quotien][reste] *= two_to_negative_half_pow[idx]; } index++; } for (j = nonzero[ch]; j < 576; j++) { // Modif E.B 02/22/99 - @LOC("REST") int reste = j % SSLIMIT; - @LOC("QUO") int quotien = (int) ((j - reste) / SSLIMIT); + @LOC("THIS,LayerIIIDecoder.NZ") int reste = j % SSLIMIT; + @LOC("THIS,LayerIIIDecoder.NZ") int quotien = (int) ((j - reste) / SSLIMIT); if (reste < 0) reste = 0; if (quotien < 0) quotien = 0; - xr[quotien][reste] = 0.0f; + ro[ch][quotien][reste] = 0.0f; } return; @@ -1081,13 +1147,16 @@ final class LayerIIIDecoder implements FrameDecoder { * */ @LATTICE("THIS= 3; sfb--) { i = sfBandIndex[sfreq].s[sfb]; @@ -1322,8 +1396,8 @@ final class LayerIIIDecoder implements FrameDecoder { } // for (; sfb<8 ... } // for (j=0 ... } else { // if (gr_info.mixed_block_flag) - for (@LOC("THIS,LayerIIIDecoder.J") int j = 0; j < 3; j++) { - @LOC("THIS,LayerIIIDecoder.SH") int sfbcnt; + for (@LOC("THIS,LayerIIIDecoder.J") int j = 0; j < 3; j++) { + @LOC("THIS,LayerIIIDecoder.SH") int sfbcnt; sfbcnt = -1; for (sfb = 12; sfb >= 0; sfb--) { temp = sfBandIndex[sfreq].s[sfb]; @@ -1464,12 +1538,17 @@ final class LayerIIIDecoder implements FrameDecoder { /** * */ - @LATTICE("THIS