src/main/java/net/sourceforge/jaad/aac/sbr/SBR.java
private int sbr_single_channel_element(IBitStream ld) throws AACException {
		int result;

		if(ld.readBool()) {
			ld.readBits(4); //reserved
		}

		if((result = sbr_grid(ld, 0))>0)
			return result;

		sbr_dtdf(ld, 0);
		invf_mode(ld, 0);
		sbr_envelope(ld, 0);
		sbr_noise(ld, 0);

		NoiseEnvelope.dequantChannel(this, 0);

		Arrays.fill(bs_add_harmonic[0], 0, 64, 0);
		Arrays.fill(bs_add_harmonic[1], 0, 64, 0);

		this.bs_add_harmonic_flag[0] = ld.readBool();
		if(this.bs_add_harmonic_flag[0])
			sinusoidal_coding(ld, 0);

		this.bs_extended_data = ld.readBool();

		if(this.bs_extended_data) {
			int nr_bits_left;
			int ps_ext_read = 0;
			int cnt = ld.readBits(4);
			if(cnt==15) {
				cnt += ld.readBits(8);
			}

			nr_bits_left = 8*cnt;
			while(nr_bits_left>7) {
				int tmp_nr_bits = 0;

				this.bs_extension_id = ld.readBits(2);
				tmp_nr_bits += 2;

				/* allow only 1 PS extension element per extension data */
				if(this.bs_extension_id==EXTENSION_ID_PS) {
					if(ps_ext_read==0) {
						ps_ext_read = 1;
					}
					else {
						/* to be safe make it 3, will switch to "default"
						 * in sbr_extension() */
						this.bs_extension_id = 3;
					}
				}

				tmp_nr_bits += sbr_extension(ld, this.bs_extension_id, nr_bits_left);

				/* check if the data read is bigger than the number of available bits */
				if(tmp_nr_bits>nr_bits_left)
					return 1;

				nr_bits_left -= tmp_nr_bits;
			}

			/* Corrigendum */
			if(nr_bits_left>0) {
				ld.readBits(nr_bits_left);
			}
		}

		return 0;
	}
private int sbr_single_channel_element(IBitStream ld) throws AACException {
		int result;

		if(ld.readBool()) {
			ld.readBits(4); //reserved
		}

		if((result = sbr_grid(ld, 0))>0)
			return result;

		sbr_dtdf(ld, 0);
		invf_mode(ld, 0);
		sbr_envelope(ld, 0);
		sbr_noise(ld, 0);

		NoiseEnvelope.dequantChannel(this, 0);

		Arrays.fill(bs_add_harmonic[0], 0, 64, 0);
		Arrays.fill(bs_add_harmonic[1], 0, 64, 0);

		this.bs_add_harmonic_flag[0] = ld.readBool();
		if(this.bs_add_harmonic_flag[0])
			sinusoidal_coding(ld, 0);

		this.bs_extended_data = ld.readBool();

		if(this.bs_extended_data) {
			int nr_bits_left;
			int ps_ext_read = 0;
			int cnt = ld.readBits(4);
			if(cnt==15) {
				cnt += ld.readBits(8);
			}

			nr_bits_left = 8*cnt;
			while(nr_bits_left>7) {
				int tmp_nr_bits = 0;

				this.bs_extension_id = ld.readBits(2);
				tmp_nr_bits += 2;

				/* allow only 1 PS extension element per extension data */
				if(this.bs_extension_id==EXTENSION_ID_PS) {
					if(ps_ext_read==0) {
						ps_ext_read = 1;
					}
					else {
						/* to be safe make it 3, will switch to "default"
						 * in sbr_extension() */
						this.bs_extension_id = 3;
					}
				}

				tmp_nr_bits += sbr_extension(ld, this.bs_extension_id, nr_bits_left);

				/* check if the data read is bigger than the number of available bits */
				if(tmp_nr_bits>nr_bits_left)
					return 1;

				nr_bits_left -= tmp_nr_bits;
			}

			/* Corrigendum */
			if(nr_bits_left>0) {
				ld.readBits(nr_bits_left);
			}
		}

		return 0;
	}
private int sbr_single_channel_element ( IBitStream ld ) throws AACException { int result ; if ( ld . readBool ( ) ) { ld . readBits ( 4 ) ; //reserved } if ( ( result = sbr_grid ( ld , 0 ) ) > 0 ) return result ; sbr_dtdf ( ld , 0 ) ; invf_mode ( ld , 0 ) ; sbr_envelope ( ld , 0 ) ; sbr_noise ( ld , 0 ) ; NoiseEnvelope . dequantChannel ( this , 0 ) ; Arrays . fill ( bs_add_harmonic [ 0 ] , 0 , 64 , 0 ) ; Arrays . fill ( bs_add_harmonic [ 1 ] , 0 , 64 , 0 ) ; this . bs_add_harmonic_flag [ 0 ] = ld . readBool ( ) ; if ( this . bs_add_harmonic_flag [ 0 ] ) sinusoidal_coding ( ld , 0 ) ; this . bs_extended_data = ld . readBool ( ) ; if ( this . bs_extended_data ) { int nr_bits_left ; int ps_ext_read = 0 ; int cnt = ld . readBits ( 4 ) ; if ( cnt == 15 ) { cnt += ld . readBits ( 8 ) ; } nr_bits_left = 8 * cnt ; while ( nr_bits_left > 7 ) { int tmp_nr_bits = 0 ; this . bs_extension_id = ld . readBits ( 2 ) ; tmp_nr_bits += 2 ; /* allow only 1 PS extension element per extension data */ if ( this . bs_extension_id == EXTENSION_ID_PS ) { if ( ps_ext_read == 0 ) { ps_ext_read = 1 ; } else { /* to be safe make it 3, will switch to "default"
						 * in sbr_extension() */ this . bs_extension_id = 3 ; } } tmp_nr_bits += sbr_extension ( ld , this . bs_extension_id , nr_bits_left ) ; /* check if the data read is bigger than the number of available bits */ if ( tmp_nr_bits > nr_bits_left ) return 1 ; nr_bits_left -= tmp_nr_bits ; } /* Corrigendum */ if ( nr_bits_left > 0 ) { ld . readBits ( nr_bits_left ) ; } } return 0 ; }
/* table 5
/ * table 5