public ToyMP3Frame() { // initialize CRC_check = 0; for(int i = 0; i < 2; i++) { for(int j = 0; j < 2; j++) { granule[i,j] = new GranuleInfo(); } } }
private void DecodeScalefactor(GranuleInfo granule, int ch, int gr) { int Slen1 = granule.Slen[0]; int Slen2 = granule.Slen[1]; // Mixed Block if(granule.IsMixedBlock) { for(int sfb=0; sfb<8; sfb++) { Scf[ch,gr].LongBlock[sfb]=bs.GetByInt(Slen1); } for(int sfb=3; sfb<6; sfb++) { for(int w=0; w<3; w++) { Scf[ch,gr].ShortBlock[w,sfb] = bs.GetByInt(Slen1); } } for(int sfb=6; sfb<12; sfb++) { for(int w=0; w<3; w++) { Scf[ch,gr].ShortBlock[w,sfb] = bs.GetByInt(Slen2); } } } // Short Block else if(granule.IsShortBlock) { for(int sfb=0; sfb<6; sfb++) { for(int w=0; w<3; w++) { Scf[ch,gr].ShortBlock[w,sfb] = bs.GetByInt(Slen1); } } for(int sfb=6; sfb<12; sfb++) { for(int w=0; w<3; w++) { Scf[ch,gr].ShortBlock[w,sfb] = bs.GetByInt(Slen2); } } } // Long Block else if(granule.IsLongBlock) { // In case granule0, // without exception, data should be taken from bitstream. if(gr == 0) { for(int sfb=0; sfb<11; sfb++) { Scf[ch,gr].LongBlock[sfb] = bs.GetByInt(Slen1); } for(int sfb=11; sfb<21; sfb++) { Scf[ch,gr].LongBlock[sfb] = bs.GetByInt(Slen2); } } else { // When processing granule1 and SCFSI is 1, // sdalefactor will shared with granule0. // Else, scalefactor should be got from bitstream. if(frame.GetScfsi(ch,0) == 1) { for(int sfb=0; sfb<6; sfb++) { Scf[ch,gr].LongBlock[sfb] = Scf[ch,0].LongBlock[sfb]; } } else { for(int sfb=0; sfb<6; sfb++) { Scf[ch,gr].LongBlock[sfb] = bs.GetByInt(Slen1); } } if(frame.GetScfsi(ch,1) == 1) { for(int sfb=6; sfb<11; sfb++) { Scf[ch,gr].LongBlock[sfb] = Scf[ch,0].LongBlock[sfb]; } } else { for(int sfb=6; sfb<11; sfb++) { Scf[ch, gr].LongBlock[sfb] = bs.GetByInt(Slen1); } } if(frame.GetScfsi(ch,2) == 1) { for(int sfb=11; sfb<16; sfb++) { Scf[ch,gr].LongBlock[sfb] = Scf[ch,0].LongBlock[sfb]; } } else { for(int sfb=11; sfb<16; sfb++) { Scf[ch, gr].LongBlock[sfb] = bs.GetByInt(Slen2); } } if(frame.GetScfsi(ch, 3) == 1) { for(int sfb=16; sfb<21; sfb++) { Scf[ch,gr].LongBlock[sfb] = Scf[ch, 0].LongBlock[sfb]; } } else { for(int sfb=16; sfb<21; sfb++) { Scf[ch,gr].LongBlock[sfb] = bs.GetByInt(Slen2); } } } } }