Input: / * table 6 [CODESPLIT] private int sbr_channel_pair_element ( IBitStream ld ) throws AACException { int n , result ; if ( ld . readBool ( ) ) { //reserved ld . readBits ( 4 ) ; ld . readBits ( 4 ) ; } this . bs_coupling = ld . readBool ( ) ; if ( this . bs_coupling ) { if ( ( result = sbr_grid ( ld , 0 ) ) > 0 ) return result ; /* need to copy some data from left to right */ this . bs_frame_class [ 1 ] = this . bs_frame_class [ 0 ] ; this . L_E [ 1 ] = this . L_E [ 0 ] ; this . L_Q [ 1 ] = this . L_Q [ 0 ] ; this . bs_pointer [ 1 ] = this . bs_pointer [ 0 ] ; for ( n = 0 ; n <= this . L_E [ 0 ] ; n ++ ) { this . t_E [ 1 ] [ n ] = this . t_E [ 0 ] [ n ] ; this . f [ 1 ] [ n ] = this . f [ 0 ] [ n ] ; } for ( n = 0 ; n <= this . L_Q [ 0 ] ; n ++ ) { this . t_Q [ 1 ] [ n ] = this . t_Q [ 0 ] [ n ] ; } sbr_dtdf ( ld , 0 ) ; sbr_dtdf ( ld , 1 ) ; invf_mode ( ld , 0 ) ; /* more copying */ for ( n = 0 ; n < this . N_Q ; n ++ ) { this . bs_invf_mode [ 1 ] [ n ] = this . bs_invf_mode [ 0 ] [ n ] ; } sbr_envelope ( ld , 0 ) ; sbr_noise ( ld , 0 ) ; sbr_envelope ( ld , 1 ) ; sbr_noise ( ld , 1 ) ; 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_add_harmonic_flag [ 1 ] = ld . readBool ( ) ; if ( this . bs_add_harmonic_flag [ 1 ] ) sinusoidal_coding ( ld , 1 ) ; } else { int [ ] saved_t_E = new int [ 6 ] , saved_t_Q = new int [ 3 ] ; int saved_L_E = this . L_E [ 0 ] ; int saved_L_Q = this . L_Q [ 0 ] ; int saved_frame_class = this . bs_frame_class [ 0 ] ; for ( n = 0 ; n < saved_L_E ; n ++ ) { saved_t_E [ n ] = this . t_E [ 0 ] [ n ] ; } for ( n = 0 ; n < saved_L_Q ; n ++ ) { saved_t_Q [ n ] = this . t_Q [ 0 ] [ n ] ; } if ( ( result = sbr_grid ( ld , 0 ) ) > 0 ) return result ; if ( ( result = sbr_grid ( ld , 1 ) ) > 0 ) { /* restore first channel data as well */ this . bs_frame_class [ 0 ] = saved_frame_class ; this . L_E [ 0 ] = saved_L_E ; this . L_Q [ 0 ] = saved_L_Q ; for ( n = 0 ; n < 6 ; n ++ ) { this . t_E [ 0 ] [ n ] = saved_t_E [ n ] ; } for ( n = 0 ; n < 3 ; n ++ ) { this . t_Q [ 0 ] [ n ] = saved_t_Q [ n ] ; } return result ; } sbr_dtdf ( ld , 0 ) ; sbr_dtdf ( ld , 1 ) ; invf_mode ( ld , 0 ) ; invf_mode ( ld , 1 ) ; sbr_envelope ( ld , 0 ) ; sbr_envelope ( ld , 1 ) ; sbr_noise ( ld , 0 ) ; sbr_noise ( ld , 1 ) ; 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_add_harmonic_flag [ 1 ] = ld . readBool ( ) ; if ( this . bs_add_harmonic_flag [ 1 ] ) sinusoidal_coding ( ld , 1 ) ; } NoiseEnvelope . dequantChannel ( this , 0 ) ; NoiseEnvelope . dequantChannel ( this , 1 ) ; if ( this . bs_coupling ) NoiseEnvelope . unmap ( this ) ; this . bs_extended_data = ld . readBool ( ) ; if ( this . bs_extended_data ) { int nr_bits_left ; 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 ; 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 ; }


Input: / * table 7 [CODESPLIT] private int sbr_grid ( IBitStream ld , int ch ) throws AACException { int i , env , rel , result ; int bs_abs_bord , bs_abs_bord_1 ; int bs_num_env = 0 ; int saved_L_E = this . L_E [ ch ] ; int saved_L_Q = this . L_Q [ ch ] ; int saved_frame_class = this . bs_frame_class [ ch ] ; this . bs_frame_class [ ch ] = ld . readBits ( 2 ) ; switch ( this . bs_frame_class [ ch ] ) { case FIXFIX : i = ld . readBits ( 2 ) ; bs_num_env = Math . min ( 1 << i , 5 ) ; i = ld . readBit ( ) ; for ( env = 0 ; env < bs_num_env ; env ++ ) { this . f [ ch ] [ env ] = i ; } this . abs_bord_lead [ ch ] = 0 ; this . abs_bord_trail [ ch ] = this . numTimeSlots ; this . n_rel_lead [ ch ] = bs_num_env - 1 ; this . n_rel_trail [ ch ] = 0 ; break ; case FIXVAR : bs_abs_bord = ld . readBits ( 2 ) + this . numTimeSlots ; bs_num_env = ld . readBits ( 2 ) + 1 ; for ( rel = 0 ; rel < bs_num_env - 1 ; rel ++ ) { this . bs_rel_bord [ ch ] [ rel ] = 2 * ld . readBits ( 2 ) + 2 ; } i = sbr_log2 ( bs_num_env + 1 ) ; this . bs_pointer [ ch ] = ld . readBits ( i ) ; for ( env = 0 ; env < bs_num_env ; env ++ ) { this . f [ ch ] [ bs_num_env - env - 1 ] = ld . readBit ( ) ; } this . abs_bord_lead [ ch ] = 0 ; this . abs_bord_trail [ ch ] = bs_abs_bord ; this . n_rel_lead [ ch ] = 0 ; this . n_rel_trail [ ch ] = bs_num_env - 1 ; break ; case VARFIX : bs_abs_bord = ld . readBits ( 2 ) ; bs_num_env = ld . readBits ( 2 ) + 1 ; for ( rel = 0 ; rel < bs_num_env - 1 ; rel ++ ) { this . bs_rel_bord [ ch ] [ rel ] = 2 * ld . readBits ( 2 ) + 2 ; } i = sbr_log2 ( bs_num_env + 1 ) ; this . bs_pointer [ ch ] = ld . readBits ( i ) ; for ( env = 0 ; env < bs_num_env ; env ++ ) { this . f [ ch ] [ env ] = ld . readBit ( ) ; } this . abs_bord_lead [ ch ] = bs_abs_bord ; this . abs_bord_trail [ ch ] = this . numTimeSlots ; this . n_rel_lead [ ch ] = bs_num_env - 1 ; this . n_rel_trail [ ch ] = 0 ; break ; case VARVAR : bs_abs_bord = ld . readBits ( 2 ) ; bs_abs_bord_1 = ld . readBits ( 2 ) + this . numTimeSlots ; this . bs_num_rel_0 [ ch ] = ld . readBits ( 2 ) ; this . bs_num_rel_1 [ ch ] = ld . readBits ( 2 ) ; bs_num_env = Math . min ( 5 , this . bs_num_rel_0 [ ch ] + this . bs_num_rel_1 [ ch ] + 1 ) ; for ( rel = 0 ; rel < this . bs_num_rel_0 [ ch ] ; rel ++ ) { this . bs_rel_bord_0 [ ch ] [ rel ] = 2 * ld . readBits ( 2 ) + 2 ; } for ( rel = 0 ; rel < this . bs_num_rel_1 [ ch ] ; rel ++ ) { this . bs_rel_bord_1 [ ch ] [ rel ] = 2 * ld . readBits ( 2 ) + 2 ; } i = sbr_log2 ( this . bs_num_rel_0 [ ch ] + this . bs_num_rel_1 [ ch ] + 2 ) ; this . bs_pointer [ ch ] = ld . readBits ( i ) ; for ( env = 0 ; env < bs_num_env ; env ++ ) { this . f [ ch ] [ env ] = ld . readBit ( ) ; } this . abs_bord_lead [ ch ] = bs_abs_bord ; this . abs_bord_trail [ ch ] = bs_abs_bord_1 ; this . n_rel_lead [ ch ] = this . bs_num_rel_0 [ ch ] ; this . n_rel_trail [ ch ] = this . bs_num_rel_1 [ ch ] ; break ; } if ( this . bs_frame_class [ ch ] == VARVAR ) this . L_E [ ch ] = Math . min ( bs_num_env , 5 ) ; else this . L_E [ ch ] = Math . min ( bs_num_env , 4 ) ; if ( this . L_E [ ch ] <= 0 ) return 1 ; if ( this . L_E [ ch ] > 1 ) this . L_Q [ ch ] = 2 ; else this . L_Q [ ch ] = 1 ; /* TODO: this code can probably be integrated into the code above! */ if ( ( result = TFGrid . envelope_time_border_vector ( this , ch ) ) > 0 ) { this . bs_frame_class [ ch ] = saved_frame_class ; this . L_E [ ch ] = saved_L_E ; this . L_Q [ ch ] = saved_L_Q ; return result ; } TFGrid . noise_floor_time_border_vector ( this , ch ) ; return 0 ; }


Input: / * table 8 [CODESPLIT] private void sbr_dtdf ( IBitStream ld , int ch ) throws AACException { int i ; for ( i = 0 ; i < this . L_E [ ch ] ; i ++ ) { this . bs_df_env [ ch ] [ i ] = ld . readBit ( ) ; } for ( i = 0 ; i < this . L_Q [ ch ] ; i ++ ) { this . bs_df_noise [ ch ] [ i ] = ld . readBit ( ) ; } }


Input: / * table 9 [CODESPLIT] private void invf_mode ( IBitStream ld , int ch ) throws AACException { int n ; for ( n = 0 ; n < this . N_Q ; n ++ ) { this . bs_invf_mode [ ch ] [ n ] = ld . readBits ( 2 ) ; } }


Input: / * table 12 [CODESPLIT] private void sinusoidal_coding ( IBitStream ld , int ch ) throws AACException { int n ; for ( n = 0 ; n < this . N_high ; n ++ ) { this . bs_add_harmonic [ ch ] [ n ] = ld . readBit ( ) ; } }


Input: / * table 10 [CODESPLIT] private void sbr_envelope ( IBitStream ld , int ch ) throws AACException { int env , band ; int delta = 0 ; int [ ] [ ] t_huff , f_huff ; if ( ( this . L_E [ ch ] == 1 ) && ( this . bs_frame_class [ ch ] == FIXFIX ) ) this . amp_res [ ch ] = false ; else this . amp_res [ ch ] = this . bs_amp_res ; if ( ( this . bs_coupling ) && ( ch == 1 ) ) { delta = 1 ; if ( this . amp_res [ ch ] ) { t_huff = T_HUFFMAN_ENV_BAL_3_0DB ; f_huff = F_HUFFMAN_ENV_BAL_3_0DB ; } else { t_huff = T_HUFFMAN_ENV_BAL_1_5DB ; f_huff = F_HUFFMAN_ENV_BAL_1_5DB ; } } else { delta = 0 ; if ( this . amp_res [ ch ] ) { t_huff = T_HUFFMAN_ENV_3_0DB ; f_huff = F_HUFFMAN_ENV_3_0DB ; } else { t_huff = T_HUFFMAN_ENV_1_5DB ; f_huff = F_HUFFMAN_ENV_1_5DB ; } } for ( env = 0 ; env < this . L_E [ ch ] ; env ++ ) { if ( this . bs_df_env [ ch ] [ env ] == 0 ) { if ( this . bs_coupling && ( ch == 1 ) ) { if ( this . amp_res [ ch ] ) { this . E [ ch ] [ 0 ] [ env ] = ld . readBits ( 5 ) << delta ; } else { this . E [ ch ] [ 0 ] [ env ] = ld . readBits ( 6 ) << delta ; } } else { if ( this . amp_res [ ch ] ) { this . E [ ch ] [ 0 ] [ env ] = ld . readBits ( 6 ) << delta ; } else { this . E [ ch ] [ 0 ] [ env ] = ld . readBits ( 7 ) << delta ; } } for ( band = 1 ; band < this . n [ this . f [ ch ] [ env ] ] ; band ++ ) { this . E [ ch ] [ band ] [ env ] = ( decodeHuffman ( ld , f_huff ) << delta ) ; } } else { for ( band = 0 ; band < this . n [ this . f [ ch ] [ env ] ] ; band ++ ) { this . E [ ch ] [ band ] [ env ] = ( decodeHuffman ( ld , t_huff ) << delta ) ; } } } NoiseEnvelope . extract_envelope_data ( this , ch ) ; }


Input: / * table 11 [CODESPLIT] private void sbr_noise ( IBitStream ld , int ch ) throws AACException { int noise , band ; int delta = 0 ; int [ ] [ ] t_huff , f_huff ; if ( this . bs_coupling && ( ch == 1 ) ) { delta = 1 ; t_huff = T_HUFFMAN_NOISE_BAL_3_0DB ; f_huff = F_HUFFMAN_ENV_BAL_3_0DB ; } else { delta = 0 ; t_huff = T_HUFFMAN_NOISE_3_0DB ; f_huff = F_HUFFMAN_ENV_3_0DB ; } for ( noise = 0 ; noise < this . L_Q [ ch ] ; noise ++ ) { if ( this . bs_df_noise [ ch ] [ noise ] == 0 ) { if ( this . bs_coupling && ( ch == 1 ) ) { this . Q [ ch ] [ 0 ] [ noise ] = ld . readBits ( 5 ) << delta ; } else { this . Q [ ch ] [ 0 ] [ noise ] = ld . readBits ( 5 ) << delta ; } for ( band = 1 ; band < this . N_Q ; band ++ ) { this . Q [ ch ] [ band ] [ noise ] = ( decodeHuffman ( ld , f_huff ) << delta ) ; } } else { for ( band = 0 ; band < this . N_Q ; band ++ ) { this . Q [ ch ] [ band ] [ noise ] = ( decodeHuffman ( ld , t_huff ) << delta ) ; } } } NoiseEnvelope . extract_noise_floor_data ( this , ch ) ; }


Input: Parses PAT ( Program Association Table ) [CODESPLIT] @ Deprecated public static int parsePAT ( ByteBuffer data ) { PATSection pat = PATSection . parsePAT ( data ) ; if ( pat . getPrograms ( ) . size ( ) > 0 ) return pat . getPrograms ( ) . values ( ) [ 0 ] ; else return - 1 ; }


Input: Add a packet to the underlying file [CODESPLIT] public void addPacket ( FLVTag pkt ) throws IOException { if ( ! writePacket ( writeBuf , pkt ) ) { writeBuf . flip ( ) ; startOfLastPacket -= out . write ( writeBuf ) ; writeBuf . clear ( ) ; if ( ! writePacket ( writeBuf , pkt ) ) throw new RuntimeException ( "Unexpected" ) ; } }


Input: Reads an EBML id from the channel . EBML ids have length encoded inside of them For instance all one - byte ids have first byte set to 1 like 0xA3 or 0xE7 whereas the two - byte ids have first byte set to 0 and second byte set to 1 thus : 0x42 0x86 or 0x42 0xF7 [CODESPLIT] static public byte [ ] readEbmlId ( SeekableByteChannel source ) throws IOException { if ( source . position ( ) == source . size ( ) ) return null ; ByteBuffer buffer = ByteBuffer . allocate ( 8 ) ; buffer . limit ( 1 ) ; source . read ( buffer ) ; buffer . flip ( ) ; byte firstByte = buffer . get ( ) ; int numBytes = EbmlUtil . computeLength ( firstByte ) ; if ( numBytes == 0 ) return null ; if ( numBytes > 1 ) { buffer . limit ( numBytes ) ; source . read ( buffer ) ; } buffer . flip ( ) ; ByteBuffer val = ByteBuffer . allocate ( buffer . remaining ( ) ) ; val . put ( buffer ) ; return val . array ( ) ; }


Input: Searching for the next tag in a file after corrupt segment [CODESPLIT] public boolean repositionFile ( ) throws IOException { int payloadSize = 0 ; for ( int i = 0 ; i < REPOSITION_BUFFER_READS ; i ++ ) { while ( readBuf . hasRemaining ( ) ) { payloadSize = ( ( payloadSize & 0xffff ) << 8 ) | ( readBuf . get ( ) & 0xff ) ; int pointerPos = readBuf . position ( ) + 7 + payloadSize ; if ( readBuf . position ( ) >= 8 && pointerPos < readBuf . limit ( ) - 4 && readBuf . getInt ( pointerPos ) - payloadSize == 11 ) { readBuf . position ( readBuf . position ( ) - 8 ) ; return true ; } } initialRead ( ch ) ; if ( ! readBuf . hasRemaining ( ) ) break ; } return false ; }


Input:
/ * furthermore we scale the results by 2PASS1_BITS . [CODESPLIT] private final static void pass1 ( ShortBuffer data ) { int z1 ; int tmp2 ; int tmp3 ; int tmp0 ; int tmp1 ; int tmp10 ; int tmp13 ; int tmp11 ; int tmp12 ; int z2 ; int z3 ; int z4 ; int z5 ; ShortBuffer dataptr = data . duplicate ( ) ; for ( int rowctr = DCTSIZE - 1 ; rowctr >= 0 ; rowctr -- ) { /*
             * Due to quantization, we will usually find that many of the input
             * coefficients are zero, especially the AC terms. We can exploit
             * this by short-circuiting the IDCT calculation for any row in
             * which all the AC terms are zero. In that case each output is
             * equal to the DC coefficient (with scale factor as needed). With
             * typical images and quantization tables, half or more of the row
             * DCT calculations can be simplified this way.
             */ // register int *idataptr = (int*)dataptr; /*
             * WARNING: we do the same permutation as MMX idct to simplify the
             * video core
             */ int d0 = dataptr . get ( 0 ) ; int d2 = dataptr . get ( 1 ) ; int d4 = dataptr . get ( 2 ) ; int d6 = dataptr . get ( 3 ) ; int d1 = dataptr . get ( 4 ) ; int d3 = dataptr . get ( 5 ) ; int d5 = dataptr . get ( 6 ) ; int d7 = dataptr . get ( 7 ) ; if ( ( d1 | d2 | d3 | d4 | d5 | d6 | d7 ) == 0 ) { /* AC terms all zero */ if ( d0 != 0 ) { /* Compute a 32 bit value to assign. */ int dcval = ( int ) ( d0 << PASS1_BITS ) ; for ( int i = 0 ; i < 8 ; i ++ ) { dataptr . put ( i , ( short ) dcval ) ; } } /*
                 * advance pointer to next row
                 */ dataptr = advance ( dataptr , DCTSIZE ) ; continue ; } /* Even part: reverse the even part of the forward DCT. */ /* The rotator is sqrt(2)c(-6). */ if ( d6 != 0 ) { if ( d2 != 0 ) { /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */ z1 = MULTIPLY ( d2 + d6 , FIX_0_541196100 ) ; tmp2 = z1 + MULTIPLY ( - d6 , FIX_1_847759065 ) ; tmp3 = z1 + MULTIPLY ( d2 , FIX_0_765366865 ) ; tmp0 = ( d0 + d4 ) << CONST_BITS ; tmp1 = ( d0 - d4 ) << CONST_BITS ; tmp10 = tmp0 + tmp3 ; tmp13 = tmp0 - tmp3 ; tmp11 = tmp1 + tmp2 ; tmp12 = tmp1 - tmp2 ; } else { /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */ tmp2 = MULTIPLY ( - d6 , FIX_1_306562965 ) ; tmp3 = MULTIPLY ( d6 , FIX_0_541196100 ) ; tmp0 = ( d0 + d4 ) << CONST_BITS ; tmp1 = ( d0 - d4 ) << CONST_BITS ; tmp10 = tmp0 + tmp3 ; tmp13 = tmp0 - tmp3 ; tmp11 = tmp1 + tmp2 ; tmp12 = tmp1 - tmp2 ; } } else { if ( d2 != 0 ) { /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */ tmp2 = MULTIPLY ( d2 , FIX_0_541196100 ) ; tmp3 = MULTIPLY ( d2 , FIX_1_306562965 ) ; tmp0 = ( d0 + d4 ) << CONST_BITS ; tmp1 = ( d0 - d4 ) << CONST_BITS ; tmp10 = tmp0 + tmp3 ; tmp13 = tmp0 - tmp3 ; tmp11 = tmp1 + tmp2 ; tmp12 = tmp1 - tmp2 ; } else { /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */ tmp10 = tmp13 = ( d0 + d4 ) << CONST_BITS ; tmp11 = tmp12 = ( d0 - d4 ) << CONST_BITS ; } } /*
             * Odd part per figure 8; the matrix is unitary and hence its
             * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
             */ if ( d7 != 0 ) { if ( d5 != 0 ) { if ( d3 != 0 ) { if ( d1 != 0 ) { /* d1 != 0, d3 != 0, d5 != 0, d7 != 0 */ z1 = d7 + d1 ; z2 = d5 + d3 ; z3 = d7 + d3 ; z4 = d5 + d1 ; z5 = MULTIPLY ( z3 + z4 , FIX_1_175875602 ) ; tmp0 = MULTIPLY ( d7 , FIX_0_298631336 ) ; tmp1 = MULTIPLY ( d5 , FIX_2_053119869 ) ; tmp2 = MULTIPLY ( d3 , FIX_3_072711026 ) ; tmp3 = MULTIPLY ( d1 , FIX_1_501321110 ) ; z1 = MULTIPLY ( - z1 , FIX_0_899976223 ) ; z2 = MULTIPLY ( - z2 , FIX_2_562915447 ) ; z3 = MULTIPLY ( - z3 , FIX_1_961570560 ) ; z4 = MULTIPLY ( - z4 , FIX_0_390180644 ) ; z3 += z5 ; z4 += z5 ; tmp0 += z1 + z3 ; tmp1 += z2 + z4 ; tmp2 += z2 + z3 ; tmp3 += z1 + z4 ; } else { /* d1 == 0, d3 != 0, d5 != 0, d7 != 0 */ z2 = d5 + d3 ; z3 = d7 + d3 ; z5 = MULTIPLY ( z3 + d5 , FIX_1_175875602 ) ; tmp0 = MULTIPLY ( d7 , FIX_0_298631336 ) ; tmp1 = MULTIPLY ( d5 , FIX_2_053119869 ) ; tmp2 = MULTIPLY ( d3 , FIX_3_072711026 ) ; z1 = MULTIPLY ( - d7 , FIX_0_899976223 ) ; z2 = MULTIPLY ( - z2 , FIX_2_562915447 ) ; z3 = MULTIPLY ( - z3 , FIX_1_961570560 ) ; z4 = MULTIPLY ( - d5 , FIX_0_390180644 ) ; z3 += z5 ; z4 += z5 ; tmp0 += z1 + z3 ; tmp1 += z2 + z4 ; tmp2 += z2 + z3 ; tmp3 = z1 + z4 ; } } else { if ( d1 != 0 ) { /* d1 != 0, d3 == 0, d5 != 0, d7 != 0 */ z1 = d7 + d1 ; z4 = d5 + d1 ; z5 = MULTIPLY ( d7 + z4 , FIX_1_175875602 ) ; tmp0 = MULTIPLY ( d7 , FIX_0_298631336 ) ; tmp1 = MULTIPLY ( d5 , FIX_2_053119869 ) ; tmp3 = MULTIPLY ( d1 , FIX_1_501321110 ) ; z1 = MULTIPLY ( - z1 , FIX_0_899976223 ) ; z2 = MULTIPLY ( - d5 , FIX_2_562915447 ) ; z3 = MULTIPLY ( - d7 , FIX_1_961570560 ) ; z4 = MULTIPLY ( - z4 , FIX_0_390180644 ) ; z3 += z5 ; z4 += z5 ; tmp0 += z1 + z3 ; tmp1 += z2 + z4 ; tmp2 = z2 + z3 ; tmp3 += z1 + z4 ; } else { /* d1 == 0, d3 == 0, d5 != 0, d7 != 0 */ tmp0 = MULTIPLY ( - d7 , FIX_0_601344887 ) ; z1 = MULTIPLY ( - d7 , FIX_0_899976223 ) ; z3 = MULTIPLY ( - d7 , FIX_1_961570560 ) ; tmp1 = MULTIPLY ( - d5 , FIX_0_509795579 ) ; z2 = MULTIPLY ( - d5 , FIX_2_562915447 ) ; z4 = MULTIPLY ( - d5 , FIX_0_390180644 ) ; z5 = MULTIPLY ( d5 + d7 , FIX_1_175875602 ) ; z3 += z5 ; z4 += z5 ; tmp0 += z3 ; tmp1 += z4 ; tmp2 = z2 + z3 ; tmp3 = z1 + z4 ; } } } else { if ( d3 != 0 ) { if ( d1 != 0 ) { /* d1 != 0, d3 != 0, d5 == 0, d7 != 0 */ z1 = d7 + d1 ; z3 = d7 + d3 ; z5 = MULTIPLY ( z3 + d1 , FIX_1_175875602 ) ; tmp0 = MULTIPLY ( d7 , FIX_0_298631336 ) ; tmp2 = MULTIPLY ( d3 , FIX_3_072711026 ) ; tmp3 = MULTIPLY ( d1 , FIX_1_501321110 ) ; z1 = MULTIPLY ( - z1 , FIX_0_899976223 ) ; z2 = MULTIPLY ( - d3 , FIX_2_562915447 ) ; z3 = MULTIPLY ( - z3 , FIX_1_961570560 ) ; z4 = MULTIPLY ( - d1 , FIX_0_390180644 ) ; z3 += z5 ; z4 += z5 ; tmp0 += z1 + z3 ; tmp1 = z2 + z4 ; tmp2 += z2 + z3 ; tmp3 += z1 + z4 ; } else { /* d1 == 0, d3 != 0, d5 == 0, d7 != 0 */ z3 = d7 + d3 ; tmp0 = MULTIPLY ( - d7 , FIX_0_601344887 ) ; z1 = MULTIPLY ( - d7 , FIX_0_899976223 ) ; tmp2 = MULTIPLY ( d3 , FIX_0_509795579 ) ; z2 = MULTIPLY ( - d3 , FIX_2_562915447 ) ; z5 = MULTIPLY ( z3 , FIX_1_175875602 ) ; z3 = MULTIPLY ( - z3 , FIX_0_785694958 ) ; tmp0 += z3 ; tmp1 = z2 + z5 ; tmp2 += z3 ; tmp3 = z1 + z5 ; } } else { if ( d1 != 0 ) { /* d1 != 0, d3 == 0, d5 == 0, d7 != 0 */ z1 = d7 + d1 ; z5 = MULTIPLY ( z1 , FIX_1_175875602 ) ; z1 = MULTIPLY ( z1 , FIX_0_275899380 ) ; z3 = MULTIPLY ( - d7 , FIX_1_961570560 ) ; tmp0 = MULTIPLY ( - d7 , FIX_1_662939225 ) ; z4 = MULTIPLY ( - d1 , FIX_0_390180644 ) ; tmp3 = MULTIPLY ( d1 , FIX_1_111140466 ) ; tmp0 += z1 ; tmp1 = z4 + z5 ; tmp2 = z3 + z5 ; tmp3 += z1 ; } else { /* d1 == 0, d3 == 0, d5 == 0, d7 != 0 */ tmp0 = MULTIPLY ( - d7 , FIX_1_387039845 ) ; tmp1 = MULTIPLY ( d7 , FIX_1_175875602 ) ; tmp2 = MULTIPLY ( - d7 , FIX_0_785694958 ) ; tmp3 = MULTIPLY ( d7 , FIX_0_275899380 ) ; } } } } else { if ( d5 != 0 ) { if ( d3 != 0 ) { if ( d1 != 0 ) { /* d1 != 0, d3 != 0, d5 != 0, d7 == 0 */ z2 = d5 + d3 ; z4 = d5 + d1 ; z5 = MULTIPLY ( d3 + z4 , FIX_1_175875602 ) ; tmp1 = MULTIPLY ( d5 , FIX_2_053119869 ) ; tmp2 = MULTIPLY ( d3 , FIX_3_072711026 ) ; tmp3 = MULTIPLY ( d1 , FIX_1_501321110 ) ; z1 = MULTIPLY ( - d1 , FIX_0_899976223 ) ; z2 = MULTIPLY ( - z2 , FIX_2_562915447 ) ; z3 = MULTIPLY ( - d3 , FIX_1_961570560 ) ; z4 = MULTIPLY ( - z4 , FIX_0_390180644 ) ; z3 += z5 ; z4 += z5 ; tmp0 = z1 + z3 ; tmp1 += z2 + z4 ; tmp2 += z2 + z3 ; tmp3 += z1 + z4 ; } else { /* d1 == 0, d3 != 0, d5 != 0, d7 == 0 */ z2 = d5 + d3 ; z5 = MULTIPLY ( z2 , FIX_1_175875602 ) ; tmp1 = MULTIPLY ( d5 , FIX_1_662939225 ) ; z4 = MULTIPLY ( - d5 , FIX_0_390180644 ) ; z2 = MULTIPLY ( - z2 , FIX_1_387039845 ) ; tmp2 = MULTIPLY ( d3 , FIX_1_111140466 ) ; z3 = MULTIPLY ( - d3 , FIX_1_961570560 ) ; tmp0 = z3 + z5 ; tmp1 += z2 ; tmp2 += z2 ; tmp3 = z4 + z5 ; } } else { if ( d1 != 0 ) { /* d1 != 0, d3 == 0, d5 != 0, d7 == 0 */ z4 = d5 + d1 ; z5 = MULTIPLY ( z4 , FIX_1_175875602 ) ; z1 = MULTIPLY ( - d1 , FIX_0_899976223 ) ; tmp3 = MULTIPLY ( d1 , FIX_0_601344887 ) ; tmp1 = MULTIPLY ( - d5 , FIX_0_509795579 ) ; z2 = MULTIPLY ( - d5 , FIX_2_562915447 ) ; z4 = MULTIPLY ( z4 , FIX_0_785694958 ) ; tmp0 = z1 + z5 ; tmp1 += z4 ; tmp2 = z2 + z5 ; tmp3 += z4 ; } else { /* d1 == 0, d3 == 0, d5 != 0, d7 == 0 */ tmp0 = MULTIPLY ( d5 , FIX_1_175875602 ) ; tmp1 = MULTIPLY ( d5 , FIX_0_275899380 ) ; tmp2 = MULTIPLY ( - d5 , FIX_1_387039845 ) ; tmp3 = MULTIPLY ( d5 , FIX_0_785694958 ) ; } } } else { if ( d3 != 0 ) { if ( d1 != 0 ) { /* d1 != 0, d3 != 0, d5 == 0, d7 == 0 */ z5 = d1 + d3 ; tmp3 = MULTIPLY ( d1 , FIX_0_211164243 ) ; tmp2 = MULTIPLY ( - d3 , FIX_1_451774981 ) ; z1 = MULTIPLY ( d1 , FIX_1_061594337 ) ; z2 = MULTIPLY ( - d3 , FIX_2_172734803 ) ; z4 = MULTIPLY ( z5 , FIX_0_785694958 ) ; z5 = MULTIPLY ( z5 , FIX_1_175875602 ) ; tmp0 = z1 - z4 ; tmp1 = z2 + z4 ; tmp2 += z5 ; tmp3 += z5 ; } else { /* d1 == 0, d3 != 0, d5 == 0, d7 == 0 */ tmp0 = MULTIPLY ( - d3 , FIX_0_785694958 ) ; tmp1 = MULTIPLY ( - d3 , FIX_1_387039845 ) ; tmp2 = MULTIPLY ( - d3 , FIX_0_275899380 ) ; tmp3 = MULTIPLY ( d3 , FIX_1_175875602 ) ; } } else { if ( d1 != 0 ) { /* d1 != 0, d3 == 0, d5 == 0, d7 == 0 */ tmp0 = MULTIPLY ( d1 , FIX_0_275899380 ) ; tmp1 = MULTIPLY ( d1 , FIX_0_785694958 ) ; tmp2 = MULTIPLY ( d1 , FIX_1_175875602 ) ; tmp3 = MULTIPLY ( d1 , FIX_1_387039845 ) ; } else { /* d1 == 0, d3 == 0, d5 == 0, d7 == 0 */ tmp0 = tmp1 = tmp2 = tmp3 = 0 ; } } } } /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ dataptr . put ( 0 , DESCALE11 ( tmp10 + tmp3 ) ) ; dataptr . put ( 7 , DESCALE11 ( tmp10 - tmp3 ) ) ; dataptr . put ( 1 , DESCALE11 ( tmp11 + tmp2 ) ) ; dataptr . put ( 6 , DESCALE11 ( tmp11 - tmp2 ) ) ; dataptr . put ( 2 , DESCALE11 ( tmp12 + tmp1 ) ) ; dataptr . put ( 5 , DESCALE11 ( tmp12 - tmp1 ) ) ; dataptr . put ( 3 , DESCALE11 ( tmp13 + tmp0 ) ) ; dataptr . put ( 4 , DESCALE11 ( tmp13 - tmp0 ) ) ; dataptr = advance ( dataptr , DCTSIZE ) ; /* advance pointer to next row */ } }


Input:
Perform the inverse DCT on one block of coefficients . [CODESPLIT] private final static void pass2 ( ShortBuffer data ) { int tmp0 , tmp1 , tmp2 , tmp3 ; int tmp10 , tmp11 , tmp12 , tmp13 ; int z1 , z2 , z3 , z4 , z5 ; int d0 , d1 , d2 , d3 , d4 , d5 , d6 , d7 ; ShortBuffer dataptr = data . duplicate ( ) ; /* Pass 2: process columns. */ /* Note that we must descale the results by a factor of 8 == 23, */ /* and also undo the PASS1_BITS scaling. */ for ( int rowctr = DCTSIZE - 1 ; rowctr >= 0 ; rowctr -- ) { /*
             * Columns of zeroes can be exploited in the same way as we did with
             * rows. However, the row calculation has created many nonzero AC
             * terms, so the simplification applies less often (typically 5% to
             * 10% of the time). On machines with very fast multiplication, it's
             * possible that the test takes more time than it's worth. In that
             * case this section may be commented out.
             */ d0 = dataptr . get ( DCTSIZE_0 ) ; d1 = dataptr . get ( DCTSIZE_1 ) ; d2 = dataptr . get ( DCTSIZE_2 ) ; d3 = dataptr . get ( DCTSIZE_3 ) ; d4 = dataptr . get ( DCTSIZE_4 ) ; d5 = dataptr . get ( DCTSIZE_5 ) ; d6 = dataptr . get ( DCTSIZE_6 ) ; d7 = dataptr . get ( DCTSIZE_7 ) ; /* Even part: reverse the even part of the forward DCT. */ /* The rotator is sqrt(2)c(-6). */ if ( d6 != 0 ) { if ( d2 != 0 ) { /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */ z1 = MULTIPLY ( d2 + d6 , FIX_0_541196100 ) ; tmp2 = z1 + MULTIPLY ( - d6 , FIX_1_847759065 ) ; tmp3 = z1 + MULTIPLY ( d2 , FIX_0_765366865 ) ; tmp0 = ( d0 + d4 ) << CONST_BITS ; tmp1 = ( d0 - d4 ) << CONST_BITS ; tmp10 = tmp0 + tmp3 ; tmp13 = tmp0 - tmp3 ; tmp11 = tmp1 + tmp2 ; tmp12 = tmp1 - tmp2 ; } else { /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */ tmp2 = MULTIPLY ( - d6 , FIX_1_306562965 ) ; tmp3 = MULTIPLY ( d6 , FIX_0_541196100 ) ; tmp0 = ( d0 + d4 ) << CONST_BITS ; tmp1 = ( d0 - d4 ) << CONST_BITS ; tmp10 = tmp0 + tmp3 ; tmp13 = tmp0 - tmp3 ; tmp11 = tmp1 + tmp2 ; tmp12 = tmp1 - tmp2 ; } } else { if ( d2 != 0 ) { /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */ tmp2 = MULTIPLY ( d2 , FIX_0_541196100 ) ; tmp3 = MULTIPLY ( d2 , FIX_1_306562965 ) ; tmp0 = ( d0 + d4 ) << CONST_BITS ; tmp1 = ( d0 - d4 ) << CONST_BITS ; tmp10 = tmp0 + tmp3 ; tmp13 = tmp0 - tmp3 ; tmp11 = tmp1 + tmp2 ; tmp12 = tmp1 - tmp2 ; } else { /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */ tmp10 = tmp13 = ( d0 + d4 ) << CONST_BITS ; tmp11 = tmp12 = ( d0 - d4 ) << CONST_BITS ; } } /*
             * Odd part per figure 8; the matrix is unitary and hence its
             * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
             */ if ( d7 != 0 ) { if ( d5 != 0 ) { if ( d3 != 0 ) { if ( d1 != 0 ) { /* d1 != 0, d3 != 0, d5 != 0, d7 != 0 */ z1 = d7 + d1 ; z2 = d5 + d3 ; z3 = d7 + d3 ; z4 = d5 + d1 ; z5 = MULTIPLY ( z3 + z4 , FIX_1_175875602 ) ; tmp0 = MULTIPLY ( d7 , FIX_0_298631336 ) ; tmp1 = MULTIPLY ( d5 , FIX_2_053119869 ) ; tmp2 = MULTIPLY ( d3 , FIX_3_072711026 ) ; tmp3 = MULTIPLY ( d1 , FIX_1_501321110 ) ; z1 = MULTIPLY ( - z1 , FIX_0_899976223 ) ; z2 = MULTIPLY ( - z2 , FIX_2_562915447 ) ; z3 = MULTIPLY ( - z3 , FIX_1_961570560 ) ; z4 = MULTIPLY ( - z4 , FIX_0_390180644 ) ; z3 += z5 ; z4 += z5 ; tmp0 += z1 + z3 ; tmp1 += z2 + z4 ; tmp2 += z2 + z3 ; tmp3 += z1 + z4 ; } else { /* d1 == 0, d3 != 0, d5 != 0, d7 != 0 */ z1 = d7 ; z2 = d5 + d3 ; z3 = d7 + d3 ; z5 = MULTIPLY ( z3 + d5 , FIX_1_175875602 ) ; tmp0 = MULTIPLY ( d7 , FIX_0_298631336 ) ; tmp1 = MULTIPLY ( d5 , FIX_2_053119869 ) ; tmp2 = MULTIPLY ( d3 , FIX_3_072711026 ) ; z1 = MULTIPLY ( - d7 , FIX_0_899976223 ) ; z2 = MULTIPLY ( - z2 , FIX_2_562915447 ) ; z3 = MULTIPLY ( - z3 , FIX_1_961570560 ) ; z4 = MULTIPLY ( - d5 , FIX_0_390180644 ) ; z3 += z5 ; z4 += z5 ; tmp0 += z1 + z3 ; tmp1 += z2 + z4 ; tmp2 += z2 + z3 ; tmp3 = z1 + z4 ; } } else { if ( d1 != 0 ) { /* d1 != 0, d3 == 0, d5 != 0, d7 != 0 */ z1 = d7 + d1 ; z2 = d5 ; z3 = d7 ; z4 = d5 + d1 ; z5 = MULTIPLY ( z3 + z4 , FIX_1_175875602 ) ; tmp0 = MULTIPLY ( d7 , FIX_0_298631336 ) ; tmp1 = MULTIPLY ( d5 , FIX_2_053119869 ) ; tmp3 = MULTIPLY ( d1 , FIX_1_501321110 ) ; z1 = MULTIPLY ( - z1 , FIX_0_899976223 ) ; z2 = MULTIPLY ( - d5 , FIX_2_562915447 ) ; z3 = MULTIPLY ( - d7 , FIX_1_961570560 ) ; z4 = MULTIPLY ( - z4 , FIX_0_390180644 ) ; z3 += z5 ; z4 += z5 ; tmp0 += z1 + z3 ; tmp1 += z2 + z4 ; tmp2 = z2 + z3 ; tmp3 += z1 + z4 ; } else { /* d1 == 0, d3 == 0, d5 != 0, d7 != 0 */ tmp0 = MULTIPLY ( - d7 , FIX_0_601344887 ) ; z1 = MULTIPLY ( - d7 , FIX_0_899976223 ) ; z3 = MULTIPLY ( - d7 , FIX_1_961570560 ) ; tmp1 = MULTIPLY ( - d5 , FIX_0_509795579 ) ; z2 = MULTIPLY ( - d5 , FIX_2_562915447 ) ; z4 = MULTIPLY ( - d5 , FIX_0_390180644 ) ; z5 = MULTIPLY ( d5 + d7 , FIX_1_175875602 ) ; z3 += z5 ; z4 += z5 ; tmp0 += z3 ; tmp1 += z4 ; tmp2 = z2 + z3 ; tmp3 = z1 + z4 ; } } } else { if ( d3 != 0 ) { if ( d1 != 0 ) { /* d1 != 0, d3 != 0, d5 == 0, d7 != 0 */ z1 = d7 + d1 ; z3 = d7 + d3 ; z5 = MULTIPLY ( z3 + d1 , FIX_1_175875602 ) ; tmp0 = MULTIPLY ( d7 , FIX_0_298631336 ) ; tmp2 = MULTIPLY ( d3 , FIX_3_072711026 ) ; tmp3 = MULTIPLY ( d1 , FIX_1_501321110 ) ; z1 = MULTIPLY ( - z1 , FIX_0_899976223 ) ; z2 = MULTIPLY ( - d3 , FIX_2_562915447 ) ; z3 = MULTIPLY ( - z3 , FIX_1_961570560 ) ; z4 = MULTIPLY ( - d1 , FIX_0_390180644 ) ; z3 += z5 ; z4 += z5 ; tmp0 += z1 + z3 ; tmp1 = z2 + z4 ; tmp2 += z2 + z3 ; tmp3 += z1 + z4 ; } else { /* d1 == 0, d3 != 0, d5 == 0, d7 != 0 */ z3 = d7 + d3 ; tmp0 = MULTIPLY ( - d7 , FIX_0_601344887 ) ; z1 = MULTIPLY ( - d7 , FIX_0_899976223 ) ; tmp2 = MULTIPLY ( d3 , FIX_0_509795579 ) ; z2 = MULTIPLY ( - d3 , FIX_2_562915447 ) ; z5 = MULTIPLY ( z3 , FIX_1_175875602 ) ; z3 = MULTIPLY ( - z3 , FIX_0_785694958 ) ; tmp0 += z3 ; tmp1 = z2 + z5 ; tmp2 += z3 ; tmp3 = z1 + z5 ; } } else { if ( d1 != 0 ) { /* d1 != 0, d3 == 0, d5 == 0, d7 != 0 */ z1 = d7 + d1 ; z5 = MULTIPLY ( z1 , FIX_1_175875602 ) ; z1 = MULTIPLY ( z1 , FIX_0_275899380 ) ; z3 = MULTIPLY ( - d7 , FIX_1_961570560 ) ; tmp0 = MULTIPLY ( - d7 , FIX_1_662939225 ) ; z4 = MULTIPLY ( - d1 , FIX_0_390180644 ) ; tmp3 = MULTIPLY ( d1 , FIX_1_111140466 ) ; tmp0 += z1 ; tmp1 = z4 + z5 ; tmp2 = z3 + z5 ; tmp3 += z1 ; } else { /* d1 == 0, d3 == 0, d5 == 0, d7 != 0 */ tmp0 = MULTIPLY ( - d7 , FIX_1_387039845 ) ; tmp1 = MULTIPLY ( d7 , FIX_1_175875602 ) ; tmp2 = MULTIPLY ( - d7 , FIX_0_785694958 ) ; tmp3 = MULTIPLY ( d7 , FIX_0_275899380 ) ; } } } } else { if ( d5 != 0 ) { if ( d3 != 0 ) { if ( d1 != 0 ) { /* d1 != 0, d3 != 0, d5 != 0, d7 == 0 */ z2 = d5 + d3 ; z4 = d5 + d1 ; z5 = MULTIPLY ( d3 + z4 , FIX_1_175875602 ) ; tmp1 = MULTIPLY ( d5 , FIX_2_053119869 ) ; tmp2 = MULTIPLY ( d3 , FIX_3_072711026 ) ; tmp3 = MULTIPLY ( d1 , FIX_1_501321110 ) ; z1 = MULTIPLY ( - d1 , FIX_0_899976223 ) ; z2 = MULTIPLY ( - z2 , FIX_2_562915447 ) ; z3 = MULTIPLY ( - d3 , FIX_1_961570560 ) ; z4 = MULTIPLY ( - z4 , FIX_0_390180644 ) ; z3 += z5 ; z4 += z5 ; tmp0 = z1 + z3 ; tmp1 += z2 + z4 ; tmp2 += z2 + z3 ; tmp3 += z1 + z4 ; } else { /* d1 == 0, d3 != 0, d5 != 0, d7 == 0 */ z2 = d5 + d3 ; z5 = MULTIPLY ( z2 , FIX_1_175875602 ) ; tmp1 = MULTIPLY ( d5 , FIX_1_662939225 ) ; z4 = MULTIPLY ( - d5 , FIX_0_390180644 ) ; z2 = MULTIPLY ( - z2 , FIX_1_387039845 ) ; tmp2 = MULTIPLY ( d3 , FIX_1_111140466 ) ; z3 = MULTIPLY ( - d3 , FIX_1_961570560 ) ; tmp0 = z3 + z5 ; tmp1 += z2 ; tmp2 += z2 ; tmp3 = z4 + z5 ; } } else { if ( d1 != 0 ) { /* d1 != 0, d3 == 0, d5 != 0, d7 == 0 */ z4 = d5 + d1 ; z5 = MULTIPLY ( z4 , FIX_1_175875602 ) ; z1 = MULTIPLY ( - d1 , FIX_0_899976223 ) ; tmp3 = MULTIPLY ( d1 , FIX_0_601344887 ) ; tmp1 = MULTIPLY ( - d5 , FIX_0_509795579 ) ; z2 = MULTIPLY ( - d5 , FIX_2_562915447 ) ; z4 = MULTIPLY ( z4 , FIX_0_785694958 ) ; tmp0 = z1 + z5 ; tmp1 += z4 ; tmp2 = z2 + z5 ; tmp3 += z4 ; } else { /* d1 == 0, d3 == 0, d5 != 0, d7 == 0 */ tmp0 = MULTIPLY ( d5 , FIX_1_175875602 ) ; tmp1 = MULTIPLY ( d5 , FIX_0_275899380 ) ; tmp2 = MULTIPLY ( - d5 , FIX_1_387039845 ) ; tmp3 = MULTIPLY ( d5 , FIX_0_785694958 ) ; } } } else { if ( d3 != 0 ) { if ( d1 != 0 ) { /* d1 != 0, d3 != 0, d5 == 0, d7 == 0 */ z5 = d1 + d3 ; tmp3 = MULTIPLY ( d1 , FIX_0_211164243 ) ; tmp2 = MULTIPLY ( - d3 , FIX_1_451774981 ) ; z1 = MULTIPLY ( d1 , FIX_1_061594337 ) ; z2 = MULTIPLY ( - d3 , FIX_2_172734803 ) ; z4 = MULTIPLY ( z5 , FIX_0_785694958 ) ; z5 = MULTIPLY ( z5 , FIX_1_175875602 ) ; tmp0 = z1 - z4 ; tmp1 = z2 + z4 ; tmp2 += z5 ; tmp3 += z5 ; } else { /* d1 == 0, d3 != 0, d5 == 0, d7 == 0 */ tmp0 = MULTIPLY ( - d3 , FIX_0_785694958 ) ; tmp1 = MULTIPLY ( - d3 , FIX_1_387039845 ) ; tmp2 = MULTIPLY ( - d3 , FIX_0_275899380 ) ; tmp3 = MULTIPLY ( d3 , FIX_1_175875602 ) ; } } else { if ( d1 != 0 ) { /* d1 != 0, d3 == 0, d5 == 0, d7 == 0 */ tmp0 = MULTIPLY ( d1 , FIX_0_275899380 ) ; tmp1 = MULTIPLY ( d1 , FIX_0_785694958 ) ; tmp2 = MULTIPLY ( d1 , FIX_1_175875602 ) ; tmp3 = MULTIPLY ( d1 , FIX_1_387039845 ) ; } else { /* d1 == 0, d3 == 0, d5 == 0, d7 == 0 */ tmp0 = tmp1 = tmp2 = tmp3 = 0 ; } } } } /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ dataptr . put ( DCTSIZE_0 , DESCALE18 ( tmp10 + tmp3 ) ) ; dataptr . put ( DCTSIZE_7 , DESCALE18 ( tmp10 - tmp3 ) ) ; dataptr . put ( DCTSIZE_1 , DESCALE18 ( tmp11 + tmp2 ) ) ; dataptr . put ( DCTSIZE_6 , DESCALE18 ( tmp11 - tmp2 ) ) ; dataptr . put ( DCTSIZE_2 , DESCALE18 ( tmp12 + tmp1 ) ) ; dataptr . put ( DCTSIZE_5 , DESCALE18 ( tmp12 - tmp1 ) ) ; dataptr . put ( DCTSIZE_3 , DESCALE18 ( tmp13 + tmp0 ) ) ; dataptr . put ( DCTSIZE_4 , DESCALE18 ( tmp13 - tmp0 ) ) ; dataptr = advance ( dataptr , 1 ) ; /* advance pointer to next column */ } }


Input: Decodes one bin from arithmetice code word [CODESPLIT] public int decodeBin ( int m ) { int bin ; int qIdx = ( range >> 6 ) & 0x3 ; int rLPS = MConst . rangeLPS [ qIdx ] [ cm [ 0 ] [ m ] ] ; range -= rLPS ; int rs8 = range << 8 ; if ( code < rs8 ) { // MPS if ( cm [ 0 ] [ m ] < 62 ) cm [ 0 ] [ m ] ++ ; renormalize ( ) ; bin = cm [ 1 ] [ m ] ; } else { // LPS range = rLPS ; code -= rs8 ; renormalize ( ) ; bin = 1 - cm [ 1 ] [ m ] ; if ( cm [ 0 ] [ m ] == 0 ) cm [ 1 ] [ m ] = 1 - cm [ 1 ] [ m ] ; cm [ 0 ] [ m ] = MConst . transitLPS [ cm [ 0 ] [ m ] ] ; } //        System.out.println("CABAC BIT [" + m + "]: " + bin); return bin ; }


Input: Special decoding process for symbols with uniform distribution [CODESPLIT] public int decodeBinBypass ( ) { code <<= 1 ; -- nBitsPending ; if ( nBitsPending <= 0 ) readOneByte ( ) ; int tmp = code - ( range << 8 ) ; if ( tmp < 0 ) { //            System.out.println("CABAC BIT [-1]: 0"); return 0 ; } else { //            System.out.println("CABAC BIT [-1]: 1"); code = tmp ; return 1 ; } }


Input: Finds next Nth MPEG bitstream marker 0x000001xx and returns the data that preceeds it as a ByteBuffer slice [CODESPLIT] public static final ByteBuffer gotoMarker ( ByteBuffer buf , int n , int mmin , int mmax ) { if ( ! buf . hasRemaining ( ) ) return null ; int from = buf . position ( ) ; ByteBuffer result = buf . slice ( ) ; result . order ( ByteOrder . BIG_ENDIAN ) ; int val = 0xffffffff ; while ( buf . hasRemaining ( ) ) { val = ( val << 8 ) | ( buf . get ( ) & 0xff ) ; if ( val >= mmin && val <= mmax ) { if ( n == 0 ) { buf . position ( buf . position ( ) - 4 ) ; result . limit ( buf . position ( ) - from ) ; break ; } -- n ; } } return result ; }


Input: / * first build into temp vector to be able to use previous vector on error [CODESPLIT] public static int envelope_time_border_vector ( SBR sbr , int ch ) { int l , border , temp ; int [ ] t_E_temp = new int [ 6 ] ; t_E_temp [ 0 ] = sbr . rate * sbr . abs_bord_lead [ ch ] ; t_E_temp [ sbr . L_E [ ch ] ] = sbr . rate * sbr . abs_bord_trail [ ch ] ; switch ( sbr . bs_frame_class [ ch ] ) { case FIXFIX : switch ( sbr . L_E [ ch ] ) { case 4 : temp = ( sbr . numTimeSlots / 4 ) ; t_E_temp [ 3 ] = sbr . rate * 3 * temp ; t_E_temp [ 2 ] = sbr . rate * 2 * temp ; t_E_temp [ 1 ] = sbr . rate * temp ; break ; case 2 : t_E_temp [ 1 ] = sbr . rate * ( sbr . numTimeSlots / 2 ) ; break ; default : break ; } break ; case FIXVAR : if ( sbr . L_E [ ch ] > 1 ) { int i = sbr . L_E [ ch ] ; border = sbr . abs_bord_trail [ ch ] ; for ( l = 0 ; l < ( sbr . L_E [ ch ] - 1 ) ; l ++ ) { if ( border < sbr . bs_rel_bord [ ch ] [ l ] ) return 1 ; border -= sbr . bs_rel_bord [ ch ] [ l ] ; t_E_temp [ -- i ] = sbr . rate * border ; } } break ; case VARFIX : if ( sbr . L_E [ ch ] > 1 ) { int i = 1 ; border = sbr . abs_bord_lead [ ch ] ; for ( l = 0 ; l < ( sbr . L_E [ ch ] - 1 ) ; l ++ ) { border += sbr . bs_rel_bord [ ch ] [ l ] ; if ( sbr . rate * border + sbr . tHFAdj > sbr . numTimeSlotsRate + sbr . tHFGen ) return 1 ; t_E_temp [ i ++ ] = sbr . rate * border ; } } break ; case VARVAR : if ( sbr . bs_num_rel_0 [ ch ] != 0 ) { int i = 1 ; border = sbr . abs_bord_lead [ ch ] ; for ( l = 0 ; l < sbr . bs_num_rel_0 [ ch ] ; l ++ ) { border += sbr . bs_rel_bord_0 [ ch ] [ l ] ; if ( sbr . rate * border + sbr . tHFAdj > sbr . numTimeSlotsRate + sbr . tHFGen ) return 1 ; t_E_temp [ i ++ ] = sbr . rate * border ; } } if ( sbr . bs_num_rel_1 [ ch ] != 0 ) { int i = sbr . L_E [ ch ] ; border = sbr . abs_bord_trail [ ch ] ; for ( l = 0 ; l < sbr . bs_num_rel_1 [ ch ] ; l ++ ) { if ( border < sbr . bs_rel_bord_1 [ ch ] [ l ] ) return 1 ; border -= sbr . bs_rel_bord_1 [ ch ] [ l ] ; t_E_temp [ -- i ] = sbr . rate * border ; } } break ; } /* no error occured, we can safely use this t_E vector */ for ( l = 0 ; l < 6 ; l ++ ) { sbr . t_E [ ch ] [ l ] = t_E_temp [ l ] ; } return 0 ; }


Input: / * real filter size 2 [CODESPLIT] static void channel_filter2 ( int frame_len , float [ ] filter , float [ ] [ ] buffer , float [ ] [ ] [ ] X_hybrid ) { int i ; for ( i = 0 ; i < frame_len ; i ++ ) { float r0 = ( filter [ 0 ] * ( buffer [ 0 + i ] [ 0 ] + buffer [ 12 + i ] [ 0 ] ) ) ; float r1 = ( filter [ 1 ] * ( buffer [ 1 + i ] [ 0 ] + buffer [ 11 + i ] [ 0 ] ) ) ; float r2 = ( filter [ 2 ] * ( buffer [ 2 + i ] [ 0 ] + buffer [ 10 + i ] [ 0 ] ) ) ; float r3 = ( filter [ 3 ] * ( buffer [ 3 + i ] [ 0 ] + buffer [ 9 + i ] [ 0 ] ) ) ; float r4 = ( filter [ 4 ] * ( buffer [ 4 + i ] [ 0 ] + buffer [ 8 + i ] [ 0 ] ) ) ; float r5 = ( filter [ 5 ] * ( buffer [ 5 + i ] [ 0 ] + buffer [ 7 + i ] [ 0 ] ) ) ; float r6 = ( filter [ 6 ] * buffer [ 6 + i ] [ 0 ] ) ; float i0 = ( filter [ 0 ] * ( buffer [ 0 + i ] [ 1 ] + buffer [ 12 + i ] [ 1 ] ) ) ; float i1 = ( filter [ 1 ] * ( buffer [ 1 + i ] [ 1 ] + buffer [ 11 + i ] [ 1 ] ) ) ; float i2 = ( filter [ 2 ] * ( buffer [ 2 + i ] [ 1 ] + buffer [ 10 + i ] [ 1 ] ) ) ; float i3 = ( filter [ 3 ] * ( buffer [ 3 + i ] [ 1 ] + buffer [ 9 + i ] [ 1 ] ) ) ; float i4 = ( filter [ 4 ] * ( buffer [ 4 + i ] [ 1 ] + buffer [ 8 + i ] [ 1 ] ) ) ; float i5 = ( filter [ 5 ] * ( buffer [ 5 + i ] [ 1 ] + buffer [ 7 + i ] [ 1 ] ) ) ; float i6 = ( filter [ 6 ] * buffer [ 6 + i ] [ 1 ] ) ; /* q = 0 */ X_hybrid [ i ] [ 0 ] [ 0 ] = r0 + r1 + r2 + r3 + r4 + r5 + r6 ; X_hybrid [ i ] [ 0 ] [ 1 ] = i0 + i1 + i2 + i3 + i4 + i5 + i6 ; /* q = 1 */ X_hybrid [ i ] [ 1 ] [ 0 ] = r0 - r1 + r2 - r3 + r4 - r5 + r6 ; X_hybrid [ i ] [ 1 ] [ 1 ] = i0 - i1 + i2 - i3 + i4 - i5 + i6 ; } }


Input: / * complex filter size 4 [CODESPLIT] static void channel_filter4 ( int frame_len , float [ ] filter , float [ ] [ ] buffer , float [ ] [ ] [ ] X_hybrid ) { int i ; float [ ] input_re1 = new float [ 2 ] , input_re2 = new float [ 2 ] ; float [ ] input_im1 = new float [ 2 ] , input_im2 = new float [ 2 ] ; for ( i = 0 ; i < frame_len ; i ++ ) { input_re1 [ 0 ] = - ( filter [ 2 ] * ( buffer [ i + 2 ] [ 0 ] + buffer [ i + 10 ] [ 0 ] ) ) + ( filter [ 6 ] * buffer [ i + 6 ] [ 0 ] ) ; input_re1 [ 1 ] = ( - 0.70710678118655f * ( ( filter [ 1 ] * ( buffer [ i + 1 ] [ 0 ] + buffer [ i + 11 ] [ 0 ] ) ) + ( filter [ 3 ] * ( buffer [ i + 3 ] [ 0 ] + buffer [ i + 9 ] [ 0 ] ) ) - ( filter [ 5 ] * ( buffer [ i + 5 ] [ 0 ] + buffer [ i + 7 ] [ 0 ] ) ) ) ) ; input_im1 [ 0 ] = ( filter [ 0 ] * ( buffer [ i + 0 ] [ 1 ] - buffer [ i + 12 ] [ 1 ] ) ) - ( filter [ 4 ] * ( buffer [ i + 4 ] [ 1 ] - buffer [ i + 8 ] [ 1 ] ) ) ; input_im1 [ 1 ] = ( 0.70710678118655f * ( ( filter [ 1 ] * ( buffer [ i + 1 ] [ 1 ] - buffer [ i + 11 ] [ 1 ] ) ) - ( filter [ 3 ] * ( buffer [ i + 3 ] [ 1 ] - buffer [ i + 9 ] [ 1 ] ) ) - ( filter [ 5 ] * ( buffer [ i + 5 ] [ 1 ] - buffer [ i + 7 ] [ 1 ] ) ) ) ) ; input_re2 [ 0 ] = ( filter [ 0 ] * ( buffer [ i + 0 ] [ 0 ] - buffer [ i + 12 ] [ 0 ] ) ) - ( filter [ 4 ] * ( buffer [ i + 4 ] [ 0 ] - buffer [ i + 8 ] [ 0 ] ) ) ; input_re2 [ 1 ] = ( 0.70710678118655f * ( ( filter [ 1 ] * ( buffer [ i + 1 ] [ 0 ] - buffer [ i + 11 ] [ 0 ] ) ) - ( filter [ 3 ] * ( buffer [ i + 3 ] [ 0 ] - buffer [ i + 9 ] [ 0 ] ) ) - ( filter [ 5 ] * ( buffer [ i + 5 ] [ 0 ] - buffer [ i + 7 ] [ 0 ] ) ) ) ) ; input_im2 [ 0 ] = - ( filter [ 2 ] * ( buffer [ i + 2 ] [ 1 ] + buffer [ i + 10 ] [ 1 ] ) ) + ( filter [ 6 ] * buffer [ i + 6 ] [ 1 ] ) ; input_im2 [ 1 ] = ( - 0.70710678118655f * ( ( filter [ 1 ] * ( buffer [ i + 1 ] [ 1 ] + buffer [ i + 11 ] [ 1 ] ) ) + ( filter [ 3 ] * ( buffer [ i + 3 ] [ 1 ] + buffer [ i + 9 ] [ 1 ] ) ) - ( filter [ 5 ] * ( buffer [ i + 5 ] [ 1 ] + buffer [ i + 7 ] [ 1 ] ) ) ) ) ; /* q == 0 */ X_hybrid [ i ] [ 0 ] [ 0 ] = input_re1 [ 0 ] + input_re1 [ 1 ] + input_im1 [ 0 ] + input_im1 [ 1 ] ; X_hybrid [ i ] [ 0 ] [ 1 ] = - input_re2 [ 0 ] - input_re2 [ 1 ] + input_im2 [ 0 ] + input_im2 [ 1 ] ; /* q == 1 */ X_hybrid [ i ] [ 1 ] [ 0 ] = input_re1 [ 0 ] - input_re1 [ 1 ] - input_im1 [ 0 ] + input_im1 [ 1 ] ; X_hybrid [ i ] [ 1 ] [ 1 ] = input_re2 [ 0 ] - input_re2 [ 1 ] + input_im2 [ 0 ] - input_im2 [ 1 ] ; /* q == 2 */ X_hybrid [ i ] [ 2 ] [ 0 ] = input_re1 [ 0 ] - input_re1 [ 1 ] + input_im1 [ 0 ] - input_im1 [ 1 ] ; X_hybrid [ i ] [ 2 ] [ 1 ] = - input_re2 [ 0 ] + input_re2 [ 1 ] + input_im2 [ 0 ] - input_im2 [ 1 ] ; /* q == 3 */ X_hybrid [ i ] [ 3 ] [ 0 ] = input_re1 [ 0 ] + input_re1 [ 1 ] - input_im1 [ 0 ] - input_im1 [ 1 ] ; X_hybrid [ i ] [ 3 ] [ 1 ] = input_re2 [ 0 ] + input_re2 [ 1 ] + input_im2 [ 0 ] + input_im2 [ 1 ] ; } }


Input: / * complex filter size 8 [CODESPLIT] void channel_filter8 ( int frame_len , float [ ] filter , float [ ] [ ] buffer , float [ ] [ ] [ ] X_hybrid ) { int i , n ; float [ ] input_re1 = new float [ 4 ] , input_re2 = new float [ 4 ] ; float [ ] input_im1 = new float [ 4 ] , input_im2 = new float [ 4 ] ; float [ ] x = new float [ 4 ] ; for ( i = 0 ; i < frame_len ; i ++ ) { input_re1 [ 0 ] = ( filter [ 6 ] * buffer [ 6 + i ] [ 0 ] ) ; input_re1 [ 1 ] = ( filter [ 5 ] * ( buffer [ 5 + i ] [ 0 ] + buffer [ 7 + i ] [ 0 ] ) ) ; input_re1 [ 2 ] = - ( filter [ 0 ] * ( buffer [ 0 + i ] [ 0 ] + buffer [ 12 + i ] [ 0 ] ) ) + ( filter [ 4 ] * ( buffer [ 4 + i ] [ 0 ] + buffer [ 8 + i ] [ 0 ] ) ) ; input_re1 [ 3 ] = - ( filter [ 1 ] * ( buffer [ 1 + i ] [ 0 ] + buffer [ 11 + i ] [ 0 ] ) ) + ( filter [ 3 ] * ( buffer [ 3 + i ] [ 0 ] + buffer [ 9 + i ] [ 0 ] ) ) ; input_im1 [ 0 ] = ( filter [ 5 ] * ( buffer [ 7 + i ] [ 1 ] - buffer [ 5 + i ] [ 1 ] ) ) ; input_im1 [ 1 ] = ( filter [ 0 ] * ( buffer [ 12 + i ] [ 1 ] - buffer [ 0 + i ] [ 1 ] ) ) + ( filter [ 4 ] * ( buffer [ 8 + i ] [ 1 ] - buffer [ 4 + i ] [ 1 ] ) ) ; input_im1 [ 2 ] = ( filter [ 1 ] * ( buffer [ 11 + i ] [ 1 ] - buffer [ 1 + i ] [ 1 ] ) ) + ( filter [ 3 ] * ( buffer [ 9 + i ] [ 1 ] - buffer [ 3 + i ] [ 1 ] ) ) ; input_im1 [ 3 ] = ( filter [ 2 ] * ( buffer [ 10 + i ] [ 1 ] - buffer [ 2 + i ] [ 1 ] ) ) ; for ( n = 0 ; n < 4 ; n ++ ) { x [ n ] = input_re1 [ n ] - input_im1 [ 3 - n ] ; } DCT3_4_unscaled ( x , x ) ; X_hybrid [ i ] [ 7 ] [ 0 ] = x [ 0 ] ; X_hybrid [ i ] [ 5 ] [ 0 ] = x [ 2 ] ; X_hybrid [ i ] [ 3 ] [ 0 ] = x [ 3 ] ; X_hybrid [ i ] [ 1 ] [ 0 ] = x [ 1 ] ; for ( n = 0 ; n < 4 ; n ++ ) { x [ n ] = input_re1 [ n ] + input_im1 [ 3 - n ] ; } DCT3_4_unscaled ( x , x ) ; X_hybrid [ i ] [ 6 ] [ 0 ] = x [ 1 ] ; X_hybrid [ i ] [ 4 ] [ 0 ] = x [ 3 ] ; X_hybrid [ i ] [ 2 ] [ 0 ] = x [ 2 ] ; X_hybrid [ i ] [ 0 ] [ 0 ] = x [ 0 ] ; input_im2 [ 0 ] = ( filter [ 6 ] * buffer [ 6 + i ] [ 1 ] ) ; input_im2 [ 1 ] = ( filter [ 5 ] * ( buffer [ 5 + i ] [ 1 ] + buffer [ 7 + i ] [ 1 ] ) ) ; input_im2 [ 2 ] = - ( filter [ 0 ] * ( buffer [ 0 + i ] [ 1 ] + buffer [ 12 + i ] [ 1 ] ) ) + ( filter [ 4 ] * ( buffer [ 4 + i ] [ 1 ] + buffer [ 8 + i ] [ 1 ] ) ) ; input_im2 [ 3 ] = - ( filter [ 1 ] * ( buffer [ 1 + i ] [ 1 ] + buffer [ 11 + i ] [ 1 ] ) ) + ( filter [ 3 ] * ( buffer [ 3 + i ] [ 1 ] + buffer [ 9 + i ] [ 1 ] ) ) ; input_re2 [ 0 ] = ( filter [ 5 ] * ( buffer [ 7 + i ] [ 0 ] - buffer [ 5 + i ] [ 0 ] ) ) ; input_re2 [ 1 ] = ( filter [ 0 ] * ( buffer [ 12 + i ] [ 0 ] - buffer [ 0 + i ] [ 0 ] ) ) + ( filter [ 4 ] * ( buffer [ 8 + i ] [ 0 ] - buffer [ 4 + i ] [ 0 ] ) ) ; input_re2 [ 2 ] = ( filter [ 1 ] * ( buffer [ 11 + i ] [ 0 ] - buffer [ 1 + i ] [ 0 ] ) ) + ( filter [ 3 ] * ( buffer [ 9 + i ] [ 0 ] - buffer [ 3 + i ] [ 0 ] ) ) ; input_re2 [ 3 ] = ( filter [ 2 ] * ( buffer [ 10 + i ] [ 0 ] - buffer [ 2 + i ] [ 0 ] ) ) ; for ( n = 0 ; n < 4 ; n ++ ) { x [ n ] = input_im2 [ n ] + input_re2 [ 3 - n ] ; } DCT3_4_unscaled ( x , x ) ; X_hybrid [ i ] [ 7 ] [ 1 ] = x [ 0 ] ; X_hybrid [ i ] [ 5 ] [ 1 ] = x [ 2 ] ; X_hybrid [ i ] [ 3 ] [ 1 ] = x [ 3 ] ; X_hybrid [ i ] [ 1 ] [ 1 ] = x [ 1 ] ; for ( n = 0 ; n < 4 ; n ++ ) { x [ n ] = input_im2 [ n ] - input_re2 [ 3 - n ] ; } DCT3_4_unscaled ( x , x ) ; X_hybrid [ i ] [ 6 ] [ 1 ] = x [ 1 ] ; X_hybrid [ i ] [ 4 ] [ 1 ] = x [ 3 ] ; X_hybrid [ i ] [ 2 ] [ 1 ] = x [ 2 ] ; X_hybrid [ i ] [ 0 ] [ 1 ] = x [ 0 ] ; } }


Input: / * complex filter size 12 [CODESPLIT] void channel_filter12 ( int frame_len , float [ ] filter , float [ ] [ ] buffer , float [ ] [ ] [ ] X_hybrid ) { int i , n ; float [ ] input_re1 = new float [ 6 ] , input_re2 = new float [ 6 ] ; float [ ] input_im1 = new float [ 6 ] , input_im2 = new float [ 6 ] ; float [ ] out_re1 = new float [ 6 ] , out_re2 = new float [ 6 ] ; float [ ] out_im1 = new float [ 6 ] , out_im2 = new float [ 6 ] ; for ( i = 0 ; i < frame_len ; i ++ ) { for ( n = 0 ; n < 6 ; n ++ ) { if ( n == 0 ) { input_re1 [ 0 ] = ( buffer [ 6 + i ] [ 0 ] * filter [ 6 ] ) ; input_re2 [ 0 ] = ( buffer [ 6 + i ] [ 1 ] * filter [ 6 ] ) ; } else { input_re1 [ 6 - n ] = ( ( buffer [ n + i ] [ 0 ] + buffer [ 12 - n + i ] [ 0 ] ) * filter [ n ] ) ; input_re2 [ 6 - n ] = ( ( buffer [ n + i ] [ 1 ] + buffer [ 12 - n + i ] [ 1 ] ) * filter [ n ] ) ; } input_im2 [ n ] = ( ( buffer [ n + i ] [ 0 ] - buffer [ 12 - n + i ] [ 0 ] ) * filter [ n ] ) ; input_im1 [ n ] = ( ( buffer [ n + i ] [ 1 ] - buffer [ 12 - n + i ] [ 1 ] ) * filter [ n ] ) ; } DCT3_6_unscaled ( out_re1 , input_re1 ) ; DCT3_6_unscaled ( out_re2 , input_re2 ) ; DCT3_6_unscaled ( out_im1 , input_im1 ) ; DCT3_6_unscaled ( out_im2 , input_im2 ) ; for ( n = 0 ; n < 6 ; n += 2 ) { X_hybrid [ i ] [ n ] [ 0 ] = out_re1 [ n ] - out_im1 [ n ] ; X_hybrid [ i ] [ n ] [ 1 ] = out_re2 [ n ] + out_im2 [ n ] ; X_hybrid [ i ] [ n + 1 ] [ 0 ] = out_re1 [ n + 1 ] + out_im1 [ n + 1 ] ; X_hybrid [ i ] [ n + 1 ] [ 1 ] = out_re2 [ n + 1 ] - out_im2 [ n + 1 ] ; X_hybrid [ i ] [ 10 - n ] [ 0 ] = out_re1 [ n + 1 ] - out_im1 [ n + 1 ] ; X_hybrid [ i ] [ 10 - n ] [ 1 ] = out_re2 [ n + 1 ] + out_im2 [ n + 1 ] ; X_hybrid [ i ] [ 11 - n ] [ 0 ] = out_re1 [ n ] + out_im1 [ n ] ; X_hybrid [ i ] [ 11 - n ] [ 1 ] = out_re2 [ n ] - out_im2 [ n ] ; } } }


Input: / * read huffman data coded in either the frequency or the time direction [CODESPLIT] private void huff_data ( IBitStream ld , boolean dt , int nr_par , int [ ] [ ] t_huff , int [ ] [ ] f_huff , int [ ] par ) throws AACException { int n ; if ( dt ) { /* coded in time direction */ for ( n = 0 ; n < nr_par ; n ++ ) { par [ n ] = ps_huff_dec ( ld , t_huff ) ; } } else { /* coded in frequency direction */ par [ 0 ] = ps_huff_dec ( ld , f_huff ) ; for ( n = 1 ; n < nr_par ; n ++ ) { par [ n ] = ps_huff_dec ( ld , f_huff ) ; } } }


Input: / * binary search huffman decoding [CODESPLIT] private int ps_huff_dec ( IBitStream ld , int [ ] [ ] t_huff ) throws AACException { int bit ; int index = 0 ; while ( index >= 0 ) { bit = ld . readBit ( ) ; index = t_huff [ index ] [ bit ] ; } return index + 31 ; }


Input: / * limits the value i to the range [ min max ] [CODESPLIT] private int delta_clip ( int i , int min , int max ) { if ( i < min ) return min ; else if ( i > max ) return max ; else return i ; }


Input: / * delta decode array [CODESPLIT] private void delta_decode ( boolean enable , int [ ] index , int [ ] index_prev , boolean dt_flag , int nr_par , int stride , int min_index , int max_index ) { int i ; if ( enable ) { if ( ! dt_flag ) { /* delta coded in frequency direction */ index [ 0 ] = 0 + index [ 0 ] ; index [ 0 ] = delta_clip ( index [ 0 ] , min_index , max_index ) ; for ( i = 1 ; i < nr_par ; i ++ ) { index [ i ] = index [ i - 1 ] + index [ i ] ; index [ i ] = delta_clip ( index [ i ] , min_index , max_index ) ; } } else { /* delta coded in time direction */ for ( i = 0 ; i < nr_par ; i ++ ) { //int8_t tmp2; //int8_t tmp = index[i]; //printf("%d %d\n", index_prev[i*stride], index[i]); //printf("%d\n", index[i]); index [ i ] = index_prev [ i * stride ] + index [ i ] ; //tmp2 = index[i]; index [ i ] = delta_clip ( index [ i ] , min_index , max_index ) ; //if (iid) //{ //    if (index[i] == 7) //    { //        printf("%d %d %d\n", index_prev[i*stride], tmp, tmp2); //    } //} } } } else { /* set indices to zero */ for ( i = 0 ; i < nr_par ; i ++ ) { index [ i ] = 0 ; } } /* coarse */ if ( stride == 2 ) { for ( i = ( nr_par << 1 ) - 1 ; i > 0 ; i -- ) { index [ i ] = index [ i >> 1 ] ; } } }


Input: / * in : log2 value of the modulo value to allow using AND instead of MOD [CODESPLIT] private void delta_modulo_decode ( boolean enable , int [ ] index , int [ ] index_prev , boolean dt_flag , int nr_par , int stride , int and_modulo ) { int i ; if ( enable ) { if ( ! dt_flag ) { /* delta coded in frequency direction */ index [ 0 ] = 0 + index [ 0 ] ; index [ 0 ] &= and_modulo ; for ( i = 1 ; i < nr_par ; i ++ ) { index [ i ] = index [ i - 1 ] + index [ i ] ; index [ i ] &= and_modulo ; } } else { /* delta coded in time direction */ for ( i = 0 ; i < nr_par ; i ++ ) { index [ i ] = index_prev [ i * stride ] + index [ i ] ; index [ i ] &= and_modulo ; } } } else { /* set indices to zero */ for ( i = 0 ; i < nr_par ; i ++ ) { index [ i ] = 0 ; } } /* coarse */ if ( stride == 2 ) { index [ 0 ] = 0 ; for ( i = ( nr_par << 1 ) - 1 ; i > 0 ; i -- ) { index [ i ] = index [ i >> 1 ] ; } } }


Input:
/ * parse the bitstream data decoded in ps_data () [CODESPLIT] private void ps_data_decode ( ) { int env , bin ; /* ps data not available, use data from previous frame */ if ( this . ps_data_available == 0 ) { this . num_env = 0 ; } for ( env = 0 ; env < this . num_env ; env ++ ) { int [ ] iid_index_prev ; int [ ] icc_index_prev ; int [ ] ipd_index_prev ; int [ ] opd_index_prev ; int num_iid_steps = ( this . iid_mode < 3 ) ? 7 : 15 /*fine quant*/ ; if ( env == 0 ) { /* take last envelope from previous frame */ iid_index_prev = this . iid_index_prev ; icc_index_prev = this . icc_index_prev ; ipd_index_prev = this . ipd_index_prev ; opd_index_prev = this . opd_index_prev ; } else { /* take index values from previous envelope */ iid_index_prev = this . iid_index [ env - 1 ] ; icc_index_prev = this . icc_index [ env - 1 ] ; ipd_index_prev = this . ipd_index [ env - 1 ] ; opd_index_prev = this . opd_index [ env - 1 ] ; } //        iid = 1; /* delta decode iid parameters */ delta_decode ( this . enable_iid , this . iid_index [ env ] , iid_index_prev , this . iid_dt [ env ] , this . nr_iid_par , ( this . iid_mode == 0 || this . iid_mode == 3 ) ? 2 : 1 , - num_iid_steps , num_iid_steps ) ; //        iid = 0; /* delta decode icc parameters */ delta_decode ( this . enable_icc , this . icc_index [ env ] , icc_index_prev , this . icc_dt [ env ] , this . nr_icc_par , ( this . icc_mode == 0 || this . icc_mode == 3 ) ? 2 : 1 , 0 , 7 ) ; /* delta modulo decode ipd parameters */ delta_modulo_decode ( this . enable_ipdopd , this . ipd_index [ env ] , ipd_index_prev , this . ipd_dt [ env ] , this . nr_ipdopd_par , 1 , 7 ) ; /* delta modulo decode opd parameters */ delta_modulo_decode ( this . enable_ipdopd , this . opd_index [ env ] , opd_index_prev , this . opd_dt [ env ] , this . nr_ipdopd_par , 1 , 7 ) ; } /* handle error case */ if ( this . num_env == 0 ) { /* force to 1 */ this . num_env = 1 ; if ( this . enable_iid ) { for ( bin = 0 ; bin < 34 ; bin ++ ) { this . iid_index [ 0 ] [ bin ] = this . iid_index_prev [ bin ] ; } } else { for ( bin = 0 ; bin < 34 ; bin ++ ) { this . iid_index [ 0 ] [ bin ] = 0 ; } } if ( this . enable_icc ) { for ( bin = 0 ; bin < 34 ; bin ++ ) { this . icc_index [ 0 ] [ bin ] = this . icc_index_prev [ bin ] ; } } else { for ( bin = 0 ; bin < 34 ; bin ++ ) { this . icc_index [ 0 ] [ bin ] = 0 ; } } if ( this . enable_ipdopd ) { for ( bin = 0 ; bin < 17 ; bin ++ ) { this . ipd_index [ 0 ] [ bin ] = this . ipd_index_prev [ bin ] ; this . opd_index [ 0 ] [ bin ] = this . opd_index_prev [ bin ] ; } } else { for ( bin = 0 ; bin < 17 ; bin ++ ) { this . ipd_index [ 0 ] [ bin ] = 0 ; this . opd_index [ 0 ] [ bin ] = 0 ; } } } /* update previous indices */ for ( bin = 0 ; bin < 34 ; bin ++ ) { this . iid_index_prev [ bin ] = this . iid_index [ this . num_env - 1 ] [ bin ] ; } for ( bin = 0 ; bin < 34 ; bin ++ ) { this . icc_index_prev [ bin ] = this . icc_index [ this . num_env - 1 ] [ bin ] ; } for ( bin = 0 ; bin < 17 ; bin ++ ) { this . ipd_index_prev [ bin ] = this . ipd_index [ this . num_env - 1 ] [ bin ] ; this . opd_index_prev [ bin ] = this . opd_index [ this . num_env - 1 ] [ bin ] ; } this . ps_data_available = 0 ; if ( this . frame_class == 0 ) { this . border_position [ 0 ] = 0 ; for ( env = 1 ; env < this . num_env ; env ++ ) { this . border_position [ env ] = ( env * this . numTimeSlotsRate ) / this . num_env ; } this . border_position [ this . num_env ] = this . numTimeSlotsRate ; } else { this . border_position [ 0 ] = 0 ; if ( this . border_position [ this . num_env ] < this . numTimeSlotsRate ) { for ( bin = 0 ; bin < 34 ; bin ++ ) { this . iid_index [ this . num_env ] [ bin ] = this . iid_index [ this . num_env - 1 ] [ bin ] ; this . icc_index [ this . num_env ] [ bin ] = this . icc_index [ this . num_env - 1 ] [ bin ] ; } for ( bin = 0 ; bin < 17 ; bin ++ ) { this . ipd_index [ this . num_env ] [ bin ] = this . ipd_index [ this . num_env - 1 ] [ bin ] ; this . opd_index [ this . num_env ] [ bin ] = this . opd_index [ this . num_env - 1 ] [ bin ] ; } this . num_env ++ ; this . border_position [ this . num_env ] = this . numTimeSlotsRate ; } for ( env = 1 ; env < this . num_env ; env ++ ) { int thr = this . numTimeSlotsRate - ( this . num_env - env ) ; if ( this . border_position [ env ] > thr ) { this . border_position [ env ] = thr ; } else { thr = this . border_position [ env - 1 ] + 1 ; if ( this . border_position [ env ] < thr ) { this . border_position [ env ] = thr ; } } } } /* make sure that the indices of all parameters can be mapped
		 * to the same hybrid synthesis filterbank
		 */ if ( this . use34hybrid_bands ) { for ( env = 0 ; env < this . num_env ; env ++ ) { if ( this . iid_mode != 2 && this . iid_mode != 5 ) map20indexto34 ( this . iid_index [ env ] , 34 ) ; if ( this . icc_mode != 2 && this . icc_mode != 5 ) map20indexto34 ( this . icc_index [ env ] , 34 ) ; if ( this . ipd_mode != 2 && this . ipd_mode != 5 ) { map20indexto34 ( this . ipd_index [ env ] , 17 ) ; map20indexto34 ( this . opd_index [ env ] , 17 ) ; } } } }


Input: / * decorrelate the mono signal using an allpass filter [CODESPLIT] private void ps_decorrelate ( float [ ] [ ] [ ] X_left , float [ ] [ ] [ ] X_right , float [ ] [ ] [ ] X_hybrid_left , float [ ] [ ] [ ] X_hybrid_right ) { int gr , n , m , bk ; int temp_delay = 0 ; int sb , maxsb ; int [ ] temp_delay_ser = new int [ NO_ALLPASS_LINKS ] ; float P_SmoothPeakDecayDiffNrg , nrg ; float [ ] [ ] P = new float [ 32 ] [ 34 ] ; float [ ] [ ] G_TransientRatio = new float [ 32 ] [ 34 ] ; float [ ] inputLeft = new float [ 2 ] ; /* chose hybrid filterbank: 20 or 34 band case */ float [ ] [ ] Phi_Fract_SubQmf ; if ( this . use34hybrid_bands ) { Phi_Fract_SubQmf = Phi_Fract_SubQmf34 ; } else { Phi_Fract_SubQmf = Phi_Fract_SubQmf20 ; } /* clear the energy values */ for ( n = 0 ; n < 32 ; n ++ ) { for ( bk = 0 ; bk < 34 ; bk ++ ) { P [ n ] [ bk ] = 0 ; } } /* calculate the energy in each parameter band b(k) */ for ( gr = 0 ; gr < this . num_groups ; gr ++ ) { /* select the parameter index b(k) to which this group belongs */ bk = ( ~ NEGATE_IPD_MASK ) & this . map_group2bk [ gr ] ; /* select the upper subband border for this group */ maxsb = ( gr < this . num_hybrid_groups ) ? this . group_border [ gr ] + 1 : this . group_border [ gr + 1 ] ; for ( sb = this . group_border [ gr ] ; sb < maxsb ; sb ++ ) { for ( n = this . border_position [ 0 ] ; n < this . border_position [ this . num_env ] ; n ++ ) { /* input from hybrid subbands or QMF subbands */ if ( gr < this . num_hybrid_groups ) { inputLeft [ 0 ] = X_hybrid_left [ n ] [ sb ] [ 0 ] ; inputLeft [ 1 ] = X_hybrid_left [ n ] [ sb ] [ 1 ] ; } else { inputLeft [ 0 ] = X_left [ n ] [ sb ] [ 0 ] ; inputLeft [ 1 ] = X_left [ n ] [ sb ] [ 1 ] ; } /* accumulate energy */ P [ n ] [ bk ] += ( inputLeft [ 0 ] * inputLeft [ 0 ] ) + ( inputLeft [ 1 ] * inputLeft [ 1 ] ) ; } } } /* calculate transient reduction ratio for each parameter band b(k) */ for ( bk = 0 ; bk < this . nr_par_bands ; bk ++ ) { for ( n = this . border_position [ 0 ] ; n < this . border_position [ this . num_env ] ; n ++ ) { float gamma = 1.5f ; this . P_PeakDecayNrg [ bk ] = ( this . P_PeakDecayNrg [ bk ] * this . alpha_decay ) ; if ( this . P_PeakDecayNrg [ bk ] < P [ n ] [ bk ] ) this . P_PeakDecayNrg [ bk ] = P [ n ] [ bk ] ; /* apply smoothing filter to peak decay energy */ P_SmoothPeakDecayDiffNrg = this . P_SmoothPeakDecayDiffNrg_prev [ bk ] ; P_SmoothPeakDecayDiffNrg += ( ( this . P_PeakDecayNrg [ bk ] - P [ n ] [ bk ] - this . P_SmoothPeakDecayDiffNrg_prev [ bk ] ) * alpha_smooth ) ; this . P_SmoothPeakDecayDiffNrg_prev [ bk ] = P_SmoothPeakDecayDiffNrg ; /* apply smoothing filter to energy */ nrg = this . P_prev [ bk ] ; nrg += ( ( P [ n ] [ bk ] - this . P_prev [ bk ] ) * this . alpha_smooth ) ; this . P_prev [ bk ] = nrg ; /* calculate transient ratio */ if ( ( P_SmoothPeakDecayDiffNrg * gamma ) <= nrg ) { G_TransientRatio [ n ] [ bk ] = 1.0f ; } else { G_TransientRatio [ n ] [ bk ] = ( nrg / ( P_SmoothPeakDecayDiffNrg * gamma ) ) ; } } } /* apply stereo decorrelation filter to the signal */ for ( gr = 0 ; gr < this . num_groups ; gr ++ ) { if ( gr < this . num_hybrid_groups ) maxsb = this . group_border [ gr ] + 1 ; else maxsb = this . group_border [ gr + 1 ] ; /* QMF channel */ for ( sb = this . group_border [ gr ] ; sb < maxsb ; sb ++ ) { float g_DecaySlope ; float [ ] g_DecaySlope_filt = new float [ NO_ALLPASS_LINKS ] ; /* g_DecaySlope: [0..1] */ if ( gr < this . num_hybrid_groups || sb <= this . decay_cutoff ) { g_DecaySlope = 1.0f ; } else { int decay = this . decay_cutoff - sb ; if ( decay <= - 20 /* -1/DECAY_SLOPE */ ) { g_DecaySlope = 0 ; } else { /* decay(int)*decay_slope(frac) = g_DecaySlope(frac) */ g_DecaySlope = 1.0f + DECAY_SLOPE * decay ; } } /* calculate g_DecaySlope_filt for every m multiplied by filter_a[m] */ for ( m = 0 ; m < NO_ALLPASS_LINKS ; m ++ ) { g_DecaySlope_filt [ m ] = g_DecaySlope * filter_a [ m ] ; } /* set delay indices */ temp_delay = this . saved_delay ; for ( n = 0 ; n < NO_ALLPASS_LINKS ; n ++ ) { temp_delay_ser [ n ] = this . delay_buf_index_ser [ n ] ; } for ( n = this . border_position [ 0 ] ; n < this . border_position [ this . num_env ] ; n ++ ) { float [ ] tmp = new float [ 2 ] , tmp0 = new float [ 2 ] , R0 = new float [ 2 ] ; if ( gr < this . num_hybrid_groups ) { /* hybrid filterbank input */ inputLeft [ 0 ] = X_hybrid_left [ n ] [ sb ] [ 0 ] ; inputLeft [ 1 ] = X_hybrid_left [ n ] [ sb ] [ 1 ] ; } else { /* QMF filterbank input */ inputLeft [ 0 ] = X_left [ n ] [ sb ] [ 0 ] ; inputLeft [ 1 ] = X_left [ n ] [ sb ] [ 1 ] ; } if ( sb > this . nr_allpass_bands && gr >= this . num_hybrid_groups ) { /* delay */ /* never hybrid subbands here, always QMF subbands */ tmp [ 0 ] = this . delay_Qmf [ this . delay_buf_index_delay [ sb ] ] [ sb ] [ 0 ] ; tmp [ 1 ] = this . delay_Qmf [ this . delay_buf_index_delay [ sb ] ] [ sb ] [ 1 ] ; R0 [ 0 ] = tmp [ 0 ] ; R0 [ 1 ] = tmp [ 1 ] ; this . delay_Qmf [ this . delay_buf_index_delay [ sb ] ] [ sb ] [ 0 ] = inputLeft [ 0 ] ; this . delay_Qmf [ this . delay_buf_index_delay [ sb ] ] [ sb ] [ 1 ] = inputLeft [ 1 ] ; } else { /* allpass filter */ //int m; float [ ] Phi_Fract = new float [ 2 ] ; /* fetch parameters */ if ( gr < this . num_hybrid_groups ) { /* select data from the hybrid subbands */ tmp0 [ 0 ] = this . delay_SubQmf [ temp_delay ] [ sb ] [ 0 ] ; tmp0 [ 1 ] = this . delay_SubQmf [ temp_delay ] [ sb ] [ 1 ] ; this . delay_SubQmf [ temp_delay ] [ sb ] [ 0 ] = inputLeft [ 0 ] ; this . delay_SubQmf [ temp_delay ] [ sb ] [ 1 ] = inputLeft [ 1 ] ; Phi_Fract [ 0 ] = Phi_Fract_SubQmf [ sb ] [ 0 ] ; Phi_Fract [ 1 ] = Phi_Fract_SubQmf [ sb ] [ 1 ] ; } else { /* select data from the QMF subbands */ tmp0 [ 0 ] = this . delay_Qmf [ temp_delay ] [ sb ] [ 0 ] ; tmp0 [ 1 ] = this . delay_Qmf [ temp_delay ] [ sb ] [ 1 ] ; this . delay_Qmf [ temp_delay ] [ sb ] [ 0 ] = inputLeft [ 0 ] ; this . delay_Qmf [ temp_delay ] [ sb ] [ 1 ] = inputLeft [ 1 ] ; Phi_Fract [ 0 ] = Phi_Fract_Qmf [ sb ] [ 0 ] ; Phi_Fract [ 1 ] = Phi_Fract_Qmf [ sb ] [ 1 ] ; } /* z^(-2) * Phi_Fract[k] */ tmp [ 0 ] = ( tmp [ 0 ] * Phi_Fract [ 0 ] ) + ( tmp0 [ 1 ] * Phi_Fract [ 1 ] ) ; tmp [ 1 ] = ( tmp0 [ 1 ] * Phi_Fract [ 0 ] ) - ( tmp0 [ 0 ] * Phi_Fract [ 1 ] ) ; R0 [ 0 ] = tmp [ 0 ] ; R0 [ 1 ] = tmp [ 1 ] ; for ( m = 0 ; m < NO_ALLPASS_LINKS ; m ++ ) { float [ ] Q_Fract_allpass = new float [ 2 ] , tmp2 = new float [ 2 ] ; /* fetch parameters */ if ( gr < this . num_hybrid_groups ) { /* select data from the hybrid subbands */ tmp0 [ 0 ] = this . delay_SubQmf_ser [ m ] [ temp_delay_ser [ m ] ] [ sb ] [ 0 ] ; tmp0 [ 1 ] = this . delay_SubQmf_ser [ m ] [ temp_delay_ser [ m ] ] [ sb ] [ 1 ] ; if ( this . use34hybrid_bands ) { Q_Fract_allpass [ 0 ] = Q_Fract_allpass_SubQmf34 [ sb ] [ m ] [ 0 ] ; Q_Fract_allpass [ 1 ] = Q_Fract_allpass_SubQmf34 [ sb ] [ m ] [ 1 ] ; } else { Q_Fract_allpass [ 0 ] = Q_Fract_allpass_SubQmf20 [ sb ] [ m ] [ 0 ] ; Q_Fract_allpass [ 1 ] = Q_Fract_allpass_SubQmf20 [ sb ] [ m ] [ 1 ] ; } } else { /* select data from the QMF subbands */ tmp0 [ 0 ] = this . delay_Qmf_ser [ m ] [ temp_delay_ser [ m ] ] [ sb ] [ 0 ] ; tmp0 [ 1 ] = this . delay_Qmf_ser [ m ] [ temp_delay_ser [ m ] ] [ sb ] [ 1 ] ; Q_Fract_allpass [ 0 ] = Q_Fract_allpass_Qmf [ sb ] [ m ] [ 0 ] ; Q_Fract_allpass [ 1 ] = Q_Fract_allpass_Qmf [ sb ] [ m ] [ 1 ] ; } /* delay by a fraction */ /* z^(-d(m)) * Q_Fract_allpass[k,m] */ tmp [ 0 ] = ( tmp0 [ 0 ] * Q_Fract_allpass [ 0 ] ) + ( tmp0 [ 1 ] * Q_Fract_allpass [ 1 ] ) ; tmp [ 1 ] = ( tmp0 [ 1 ] * Q_Fract_allpass [ 0 ] ) - ( tmp0 [ 0 ] * Q_Fract_allpass [ 1 ] ) ; /* -a(m) * g_DecaySlope[k] */ tmp [ 0 ] += - ( g_DecaySlope_filt [ m ] * R0 [ 0 ] ) ; tmp [ 1 ] += - ( g_DecaySlope_filt [ m ] * R0 [ 1 ] ) ; /* -a(m) * g_DecaySlope[k] * Q_Fract_allpass[k,m] * z^(-d(m)) */ tmp2 [ 0 ] = R0 [ 0 ] + ( g_DecaySlope_filt [ m ] * tmp [ 0 ] ) ; tmp2 [ 1 ] = R0 [ 1 ] + ( g_DecaySlope_filt [ m ] * tmp [ 1 ] ) ; /* store sample */ if ( gr < this . num_hybrid_groups ) { this . delay_SubQmf_ser [ m ] [ temp_delay_ser [ m ] ] [ sb ] [ 0 ] = tmp2 [ 0 ] ; this . delay_SubQmf_ser [ m ] [ temp_delay_ser [ m ] ] [ sb ] [ 1 ] = tmp2 [ 1 ] ; } else { this . delay_Qmf_ser [ m ] [ temp_delay_ser [ m ] ] [ sb ] [ 0 ] = tmp2 [ 0 ] ; this . delay_Qmf_ser [ m ] [ temp_delay_ser [ m ] ] [ sb ] [ 1 ] = tmp2 [ 1 ] ; } /* store for next iteration (or as output value if last iteration) */ R0 [ 0 ] = tmp [ 0 ] ; R0 [ 1 ] = tmp [ 1 ] ; } } /* select b(k) for reading the transient ratio */ bk = ( ~ NEGATE_IPD_MASK ) & this . map_group2bk [ gr ] ; /* duck if a past transient is found */ R0 [ 0 ] = ( G_TransientRatio [ n ] [ bk ] * R0 [ 0 ] ) ; R0 [ 1 ] = ( G_TransientRatio [ n ] [ bk ] * R0 [ 1 ] ) ; if ( gr < this . num_hybrid_groups ) { /* hybrid */ X_hybrid_right [ n ] [ sb ] [ 0 ] = R0 [ 0 ] ; X_hybrid_right [ n ] [ sb ] [ 1 ] = R0 [ 1 ] ; } else { /* QMF */ X_right [ n ] [ sb ] [ 0 ] = R0 [ 0 ] ; X_right [ n ] [ sb ] [ 1 ] = R0 [ 1 ] ; } /* Update delay buffer index */ if ( ++ temp_delay >= 2 ) { temp_delay = 0 ; } /* update delay indices */ if ( sb > this . nr_allpass_bands && gr >= this . num_hybrid_groups ) { /* delay_D depends on the samplerate, it can hold the values 14 and 1 */ if ( ++ this . delay_buf_index_delay [ sb ] >= this . delay_D [ sb ] ) { this . delay_buf_index_delay [ sb ] = 0 ; } } for ( m = 0 ; m < NO_ALLPASS_LINKS ; m ++ ) { if ( ++ temp_delay_ser [ m ] >= this . num_sample_delay_ser [ m ] ) { temp_delay_ser [ m ] = 0 ; } } } } } /* update delay indices */ this . saved_delay = temp_delay ; for ( m = 0 ; m < NO_ALLPASS_LINKS ; m ++ ) { this . delay_buf_index_ser [ m ] = temp_delay_ser [ m ] ; } }


Input:
/ * main Parametric Stereo decoding function [CODESPLIT] public int process ( float [ ] [ ] [ ] X_left , float [ ] [ ] [ ] X_right ) { float [ ] [ ] [ ] X_hybrid_left = new float [ 32 ] [ 32 ] [ 2 ] ; float [ ] [ ] [ ] X_hybrid_right = new float [ 32 ] [ 32 ] [ 2 ] ; /* delta decoding of the bitstream data */ ps_data_decode ( ) ; /* set up some parameters depending on filterbank type */ if ( this . use34hybrid_bands ) { this . group_border = group_border34 ; this . map_group2bk = map_group2bk34 ; this . num_groups = 32 + 18 ; this . num_hybrid_groups = 32 ; this . nr_par_bands = 34 ; this . decay_cutoff = 5 ; } else { this . group_border = group_border20 ; this . map_group2bk = map_group2bk20 ; this . num_groups = 10 + 12 ; this . num_hybrid_groups = 10 ; this . nr_par_bands = 20 ; this . decay_cutoff = 3 ; } /* Perform further analysis on the lowest subbands to get a higher
		 * frequency resolution
		 */ hyb . hybrid_analysis ( X_left , X_hybrid_left , this . use34hybrid_bands , this . numTimeSlotsRate ) ; /* decorrelate mono signal */ ps_decorrelate ( X_left , X_right , X_hybrid_left , X_hybrid_right ) ; /* apply mixing and phase parameters */ ps_mix_phase ( X_left , X_right , X_hybrid_left , X_hybrid_right ) ; /* hybrid synthesis, to rebuild the SBR QMF matrices */ hyb . hybrid_synthesis ( X_left , X_hybrid_left , this . use34hybrid_bands , this . numTimeSlotsRate ) ; hyb . hybrid_synthesis ( X_right , X_hybrid_right , this . use34hybrid_bands , this . numTimeSlotsRate ) ; return 0 ; }


Input: Returns a sample frequency instance for the given index . If the index is not between 0 and 11 inclusive SAMPLE_FREQUENCY_NONE is returned . [CODESPLIT] public static SampleFrequency forInt ( int i ) { final SampleFrequency freq ; if ( i >= 0 && i < 12 ) freq = values ( ) [ i ] ; else freq = SAMPLE_FREQUENCY_NONE ; return freq ; }


Input: this may be a result of color greening out in long GOPs . [CODESPLIT] @ Override public void predictPlane ( byte [ ] ref , int refX , int refY , int refW , int refH , int refVertStep , int refVertOff , int [ ] tgt , int tgtY , int tgtW , int tgtH , int tgtVertStep ) { super . predictPlane ( ref , refX << 1 , refY << 1 , refW , refH , refVertStep , refVertOff , tgt , tgtY , tgtW << 2 , tgtH << 2 , tgtVertStep ) ; }


Input: Creates a cropped clone of this picture . [CODESPLIT] public Picture cloneCropped ( ) { if ( cropNeeded ( ) ) { return cropped ( ) ; } else { Picture clone = createCompatible ( ) ; clone . copyFrom ( this ) ; return clone ; } }


Input:
sectionDataResilience = hDecoder - > aacSectionDataResilienceFlag [CODESPLIT] public static void decodeReorderedSpectralData ( ICStream ics , IBitStream _in , short [ ] spectralData , boolean sectionDataResilience ) throws AACException { final ICSInfo info = ics . getInfo ( ) ; final int windowGroupCount = info . getWindowGroupCount ( ) ; final int maxSFB = info . getMaxSFB ( ) ; final int [ ] swbOffsets = info . getSWBOffsets ( ) ; final int swbOffsetMax = info . getSWBOffsetMax ( ) ; //TODO: //final SectionData sectData = ics.getSectionData(); final int [ ] [ ] sectStart = new int [ 0 ] [ 0 ] ; //sectData.getSectStart(); final int [ ] [ ] sectEnd = new int [ 0 ] [ 0 ] ; //sectData.getSectEnd(); final int [ ] numSec = new int [ 0 ] ; //sectData.getNumSec(); final int [ ] [ ] sectCB = new int [ 0 ] [ 0 ] ; //sectData.getSectCB(); final int [ ] [ ] sectSFBOffsets = new int [ 0 ] [ 0 ] ; //info.getSectSFBOffsets(); //check parameter final int spDataLen = ics . getReorderedSpectralDataLength ( ) ; if ( spDataLen == 0 ) return ; final int longestLen = ics . getLongestCodewordLength ( ) ; if ( longestLen == 0 || longestLen >= spDataLen ) throw new AACException ( "length of longest HCR codeword out of range" ) ; //create spOffsets final int [ ] spOffsets = new int [ 8 ] ; final int shortFrameLen = spectralData . length / 8 ; spOffsets [ 0 ] = 0 ; int g ; for ( g = 1 ; g < windowGroupCount ; g ++ ) { spOffsets [ g ] = spOffsets [ g - 1 ] + shortFrameLen * info . getWindowGroupLength ( g - 1 ) ; } final Codeword [ ] codeword = new Codeword [ 512 ] ; final BitsBuffer [ ] segment = new BitsBuffer [ 512 ] ; int lastCB ; int [ ] preSortCB ; if ( sectionDataResilience ) { preSortCB = PRE_SORT_CB_ER ; lastCB = NUM_CB_ER ; } else { preSortCB = PRE_SORT_CB_STD ; lastCB = NUM_CB ; } int PCWs_done = 0 ; int segmentsCount = 0 ; int numberOfCodewords = 0 ; int bitsread = 0 ; int sfb , w_idx , i , thisCB , thisSectCB , cws ; //step 1: decode PCW's (set 0), and stuff data in easier-to-use format for ( int sortloop = 0 ; sortloop < lastCB ; sortloop ++ ) { //select codebook to process this pass thisCB = preSortCB [ sortloop ] ; for ( sfb = 0 ; sfb < maxSFB ; sfb ++ ) { for ( w_idx = 0 ; 4 * w_idx < ( Math . min ( swbOffsets [ sfb + 1 ] , swbOffsetMax ) - swbOffsets [ sfb ] ) ; w_idx ++ ) { for ( g = 0 ; g < windowGroupCount ; g ++ ) { for ( i = 0 ; i < numSec [ g ] ; i ++ ) { if ( ( sectStart [ g ] [ i ] <= sfb ) && ( sectEnd [ g ] [ i ] > sfb ) ) { /* check whether codebook used here is the one we want to process */ thisSectCB = sectCB [ g ] [ i ] ; if ( isGoodCB ( thisCB , thisSectCB ) ) { //precalculation int sect_sfb_size = sectSFBOffsets [ g ] [ sfb + 1 ] - sectSFBOffsets [ g ] [ sfb ] ; int inc = ( thisSectCB < HCB . FIRST_PAIR_HCB ) ? 4 : 2 ; int group_cws_count = ( 4 * info . getWindowGroupLength ( g ) ) / inc ; int segwidth = Math . min ( MAX_CW_LEN [ thisSectCB ] , longestLen ) ; //read codewords until end of sfb or end of window group for ( cws = 0 ; ( cws < group_cws_count ) && ( ( cws + w_idx * group_cws_count ) < sect_sfb_size ) ; cws ++ ) { int sp = spOffsets [ g ] + sectSFBOffsets [ g ] [ sfb ] + inc * ( cws + w_idx * group_cws_count ) ; //read and decode PCW if ( PCWs_done == 0 ) { //read in normal segments if ( bitsread + segwidth <= spDataLen ) { segment [ segmentsCount ] . readSegment ( segwidth , _in ) ; bitsread += segwidth ; //Huffman.decodeSpectralDataER(segment[segmentsCount], thisSectCB, spectralData, sp); //keep leftover bits segment [ segmentsCount ] . rewindReverse ( ) ; segmentsCount ++ ; } else { //remaining after last segment if ( bitsread < spDataLen ) { int additional_bits = spDataLen - bitsread ; segment [ segmentsCount ] . readSegment ( additional_bits , _in ) ; segment [ segmentsCount ] . len += segment [ segmentsCount - 1 ] . len ; segment [ segmentsCount ] . rewindReverse ( ) ; if ( segment [ segmentsCount - 1 ] . len > 32 ) { segment [ segmentsCount - 1 ] . bufb = segment [ segmentsCount ] . bufb + segment [ segmentsCount - 1 ] . showBits ( segment [ segmentsCount - 1 ] . len - 32 ) ; segment [ segmentsCount - 1 ] . bufa = segment [ segmentsCount ] . bufa + segment [ segmentsCount - 1 ] . showBits ( 32 ) ; } else { segment [ segmentsCount - 1 ] . bufa = segment [ segmentsCount ] . bufa + segment [ segmentsCount - 1 ] . showBits ( segment [ segmentsCount - 1 ] . len ) ; segment [ segmentsCount - 1 ] . bufb = segment [ segmentsCount ] . bufb ; } segment [ segmentsCount - 1 ] . len += additional_bits ; } bitsread = spDataLen ; PCWs_done = 1 ; codeword [ 0 ] . fill ( sp , thisSectCB ) ; } } else { codeword [ numberOfCodewords - segmentsCount ] . fill ( sp , thisSectCB ) ; } numberOfCodewords ++ ; } } } } } } } } if ( segmentsCount == 0 ) throw new AACException ( "no segments _in HCR" ) ; final int numberOfSets = numberOfCodewords / segmentsCount ; //step 2: decode nonPCWs int trial , codewordBase , segmentID , codewordID ; for ( int set = 1 ; set <= numberOfSets ; set ++ ) { for ( trial = 0 ; trial < segmentsCount ; trial ++ ) { for ( codewordBase = 0 ; codewordBase < segmentsCount ; codewordBase ++ ) { segmentID = ( trial + codewordBase ) % segmentsCount ; codewordID = codewordBase + set * segmentsCount - segmentsCount ; //data up if ( codewordID >= numberOfCodewords - segmentsCount ) break ; if ( ( codeword [ codewordID ] . decoded == 0 ) && ( segment [ segmentID ] . len > 0 ) ) { if ( codeword [ codewordID ] . bits . len != 0 ) segment [ segmentID ] . concatBits ( codeword [ codewordID ] . bits ) ; int tmplen = segment [ segmentID ] . len ; /*int ret = Huffman.decodeSpectralDataER(segment[segmentID], codeword[codewordID].cb,
								spectralData, codeword[codewordID].sp_offset);

						if(ret>=0) codeword[codewordID].decoded = 1;
						else {
							codeword[codewordID].bits = segment[segmentID];
							codeword[codewordID].bits.len = tmplen;
						}*/ } } } for ( i = 0 ; i < segmentsCount ; i ++ ) { segment [ i ] . rewindReverse ( ) ; } } }


Input: Starts DCT reconstruction [CODESPLIT] public static final void start ( int [ ] block , int dc ) { dc <<= DC_SHIFT ; for ( int i = 0 ; i < 64 ; i += 4 ) { block [ i + 0 ] = dc ; block [ i + 1 ] = dc ; block [ i + 2 ] = dc ; block [ i + 3 ] = dc ; } }


Input: Recalculates image based on new DCT coefficient [CODESPLIT] public static final void coeff ( int [ ] block , int ind , int level ) { for ( int i = 0 ; i < 64 ; i += 4 ) { block [ i ] += COEFF [ ind ] [ i ] * level ; block [ i + 1 ] += COEFF [ ind ] [ i + 1 ] * level ; block [ i + 2 ] += COEFF [ ind ] [ i + 2 ] * level ; block [ i + 3 ] += COEFF [ ind ] [ i + 3 ] * level ; } }


Input: Finalizes DCT calculation [CODESPLIT] public static final void finish ( int block [ ] ) { for ( int i = 0 ; i < 64 ; i += 4 ) { block [ i ] = div ( block [ i ] ) ; block [ i + 1 ] = div ( block [ i + 1 ] ) ; block [ i + 2 ] = div ( block [ i + 2 ] ) ; block [ i + 3 ] = div ( block [ i + 3 ] ) ; } }


Input: Constructs this decoder from a portion of a stream that contains AnnexB delimited ( 00 00 00 01 ) SPS / PPS NAL units . SPS / PPS NAL units are 0x67 and 0x68 respectfully . [CODESPLIT] public static H264Decoder createH264DecoderFromCodecPrivate ( ByteBuffer codecPrivate ) { H264Decoder d = new H264Decoder ( ) ; for ( ByteBuffer bb : H264Utils . splitFrame ( codecPrivate . duplicate ( ) ) ) { NALUnit nu = NALUnit . read ( bb ) ; if ( nu . type == NALUnitType . SPS ) { d . reader . addSps ( bb ) ; } else if ( nu . type == NALUnitType . PPS ) { d . reader . addPps ( bb ) ; } } return d ; }


Input: TODO : this may be optimized of - course if it turns out to be a frequently called method [CODESPLIT] public static MKVType getParent ( MKVType t ) { for ( Entry < MKVType , Set < MKVType > > ent : children . entrySet ( ) ) { if ( ent . getValue ( ) . contains ( t ) ) return ent . getKey ( ) ; } return null ; }


Input: merge bits of a to b [CODESPLIT] public void concatBits ( BitsBuffer a ) { if ( a . len == 0 ) return ; int al = a . bufa ; int ah = a . bufb ; int bl , bh ; if ( len > 32 ) { //mask off superfluous high b bits bl = bufa ; bh = bufb & ( ( 1 << ( len - 32 ) ) - 1 ) ; //left shift a len bits ah = al << ( len - 32 ) ; al = 0 ; } else { bl = bufa & ( ( 1 << ( len ) ) - 1 ) ; bh = 0 ; ah = ( ah << ( len ) ) | ( al >> ( 32 - len ) ) ; al = al << len ; } //merge bufa = bl | al ; bufb = bh | ah ; len += a . len ; }


Input: 32 bit rewind and reverse [CODESPLIT] static int rewindReverse32 ( int v , int len ) { v = ( ( v >> S [ 0 ] ) & B [ 0 ] ) | ( ( v << S [ 0 ] ) & ~ B [ 0 ] ) ; v = ( ( v >> S [ 1 ] ) & B [ 1 ] ) | ( ( v << S [ 1 ] ) & ~ B [ 1 ] ) ; v = ( ( v >> S [ 2 ] ) & B [ 2 ] ) | ( ( v << S [ 2 ] ) & ~ B [ 2 ] ) ; v = ( ( v >> S [ 3 ] ) & B [ 3 ] ) | ( ( v << S [ 3 ] ) & ~ B [ 3 ] ) ; v = ( ( v >> S [ 4 ] ) & B [ 4 ] ) | ( ( v << S [ 4 ] ) & ~ B [ 4 ] ) ; //shift off low bits v >>= ( 32 - len ) ; return v ; }


Input: 64 bit rewind and reverse [CODESPLIT] static int [ ] rewindReverse64 ( int hi , int lo , int len ) { int [ ] i = new int [ 2 ] ; if ( len <= 32 ) { i [ 0 ] = 0 ; i [ 1 ] = rewindReverse32 ( lo , len ) ; } else { lo = ( ( lo >> S [ 0 ] ) & B [ 0 ] ) | ( ( lo << S [ 0 ] ) & ~ B [ 0 ] ) ; hi = ( ( hi >> S [ 0 ] ) & B [ 0 ] ) | ( ( hi << S [ 0 ] ) & ~ B [ 0 ] ) ; lo = ( ( lo >> S [ 1 ] ) & B [ 1 ] ) | ( ( lo << S [ 1 ] ) & ~ B [ 1 ] ) ; hi = ( ( hi >> S [ 1 ] ) & B [ 1 ] ) | ( ( hi << S [ 1 ] ) & ~ B [ 1 ] ) ; lo = ( ( lo >> S [ 2 ] ) & B [ 2 ] ) | ( ( lo << S [ 2 ] ) & ~ B [ 2 ] ) ; hi = ( ( hi >> S [ 2 ] ) & B [ 2 ] ) | ( ( hi << S [ 2 ] ) & ~ B [ 2 ] ) ; lo = ( ( lo >> S [ 3 ] ) & B [ 3 ] ) | ( ( lo << S [ 3 ] ) & ~ B [ 3 ] ) ; hi = ( ( hi >> S [ 3 ] ) & B [ 3 ] ) | ( ( hi << S [ 3 ] ) & ~ B [ 3 ] ) ; lo = ( ( lo >> S [ 4 ] ) & B [ 4 ] ) | ( ( lo << S [ 4 ] ) & ~ B [ 4 ] ) ; hi = ( ( hi >> S [ 4 ] ) & B [ 4 ] ) | ( ( hi << S [ 4 ] ) & ~ B [ 4 ] ) ; //shift off low bits i [ 1 ] = ( hi >> ( 64 - len ) ) | ( lo << ( len - 32 ) ) ; i [ 1 ] = lo >> ( 64 - len ) ; } return i ; }


Input: / * ========= decoding ========== [CODESPLIT] public void decode ( IBitStream _in , boolean commonWindow , AACDecoderConfig conf ) throws AACException { if ( conf . isScalefactorResilienceUsed ( ) && rvlc == null ) rvlc = new RVLC ( ) ; final boolean er = conf . getProfile ( ) . isErrorResilientProfile ( ) ; globalGain = _in . readBits ( 8 ) ; if ( ! commonWindow ) info . decode ( _in , conf , commonWindow ) ; decodeSectionData ( _in , conf . isSectionDataResilienceUsed ( ) ) ; //if(conf.isScalefactorResilienceUsed()) rvlc.decode(_in, this, scaleFactors); /*else*/ decodeScaleFactors ( _in ) ; pulseDataPresent = _in . readBool ( ) ; if ( pulseDataPresent ) { if ( info . isEightShortFrame ( ) ) throw new AACException ( "pulse data not allowed for short frames" ) ; Logger . debug ( "PULSE" ) ; decodePulseData ( _in ) ; } tnsDataPresent = _in . readBool ( ) ; if ( tnsDataPresent && ! er ) { if ( tns == null ) tns = new TNS ( ) ; tns . decode ( _in , info ) ; } gainControlPresent = _in . readBool ( ) ; if ( gainControlPresent ) { if ( gainControl == null ) gainControl = new GainControl ( frameLength ) ; Logger . debug ( "GAIN" ) ; gainControl . decode ( _in , info . getWindowSequence ( ) ) ; } //RVLC spectral data //if(conf.isScalefactorResilienceUsed()) rvlc.decodeScalefactors(this, _in, scaleFactors); if ( conf . isSpectralDataResilienceUsed ( ) ) { int max = ( conf . getChannelConfiguration ( ) == ChannelConfiguration . CHANNEL_CONFIG_STEREO ) ? 6144 : 12288 ; reorderedSpectralDataLen = Math . max ( _in . readBits ( 14 ) , max ) ; longestCodewordLen = Math . max ( _in . readBits ( 6 ) , 49 ) ; //HCR.decodeReorderedSpectralData(this, _in, data, conf.isSectionDataResilienceUsed()); } else decodeSpectralData ( _in ) ; }


Input: } [CODESPLIT] private void scheduleClose ( ) { if ( task != null ) task . cancel ( ) ; task = new TimerTask ( ) { public void run ( ) { state = State . HIDING ; } } ; timer . schedule ( task , 1000 ) ; }


Input: Get frame at a specified second as AWT image [CODESPLIT] public static Bitmap getFrame ( File file , double second ) throws IOException , JCodecException { FileChannelWrapper ch = null ; try { ch = NIOUtils . readableChannel ( file ) ; return ( ( AndroidFrameGrab ) createAndroidFrameGrab ( ch ) . seekToSecondPrecise ( second ) ) . getFrame ( ) ; } finally { NIOUtils . closeQuietly ( ch ) ; } }


Input: Get frame at a specified second as AWT image [CODESPLIT] public static Bitmap getFrame ( SeekableByteChannel file , double second ) throws JCodecException , IOException { return ( ( AndroidFrameGrab ) createAndroidFrameGrab ( file ) . seekToSecondPrecise ( second ) ) . getFrame ( ) ; }


Input: Get frame at current position in AWT image [CODESPLIT] public BitmapWithMetadata getFrameWithMetadata ( ) throws IOException { PictureWithMetadata pictureWithMeta = getNativeFrameWithMetadata ( ) ; if ( pictureWithMeta == null ) return null ; Bitmap bitmap = AndroidUtil . toBitmap ( pictureWithMeta . getPicture ( ) ) ; return new BitmapWithMetadata ( bitmap , pictureWithMeta . getTimestamp ( ) , pictureWithMeta . getDuration ( ) ) ; }


Input: Get frame at current position in AWT image [CODESPLIT] public void getFrame ( Bitmap bmp ) throws IOException { Picture picture = getNativeFrame ( ) ; AndroidUtil . toBitmap ( picture , bmp ) ; }


Input: Get frame at current position in AWT image [CODESPLIT] public BitmapWithMetadata getFrameWithMetadata ( Bitmap bmp ) throws IOException { PictureWithMetadata pictureWithMetadata = getNativeFrameWithMetadata ( ) ; if ( pictureWithMetadata == null ) return null ; AndroidUtil . toBitmap ( pictureWithMetadata . getPicture ( ) , bmp ) ; return new BitmapWithMetadata ( bmp , pictureWithMetadata . getTimestamp ( ) , pictureWithMetadata . getDuration ( ) ) ; }


Input: Get frame at a specified frame number as AWT image [CODESPLIT] public static Bitmap getFrame ( File file , int frameNumber ) throws IOException , JCodecException { FileChannelWrapper ch = null ; try { ch = NIOUtils . readableChannel ( file ) ; return ( ( AndroidFrameGrab ) createAndroidFrameGrab ( ch ) . seekToFramePrecise ( frameNumber ) ) . getFrame ( ) ; } finally { NIOUtils . closeQuietly ( ch ) ; } }


Input: Get frame at a specified frame number as AWT image [CODESPLIT] public static Bitmap getFrame ( SeekableByteChannel file , int frameNumber ) throws JCodecException , IOException { return ( ( AndroidFrameGrab ) createAndroidFrameGrab ( file ) . seekToFramePrecise ( frameNumber ) ) . getFrame ( ) ; }


Input: Get a specified frame by number from an already open demuxer track [CODESPLIT] public static Bitmap getFrame ( SeekableDemuxerTrack vt , ContainerAdaptor decoder , int frameNumber ) throws IOException , JCodecException { return ( ( AndroidFrameGrab ) new AndroidFrameGrab ( vt , decoder ) . seekToFramePrecise ( frameNumber ) ) . getFrame ( ) ; }


Input: Get a specified frame by second from an already open demuxer track [CODESPLIT] public static Bitmap getFrame ( SeekableDemuxerTrack vt , ContainerAdaptor decoder , double second ) throws IOException , JCodecException { return ( ( AndroidFrameGrab ) new AndroidFrameGrab ( vt , decoder ) . seekToSecondPrecise ( second ) ) . getFrame ( ) ; }


Input: Get a specified frame by number from an already open demuxer track ( sloppy mode i . e . nearest keyframe ) [CODESPLIT] public static Bitmap getFrameSloppy ( SeekableDemuxerTrack vt , ContainerAdaptor decoder , int frameNumber ) throws IOException , JCodecException { return ( ( AndroidFrameGrab ) new AndroidFrameGrab ( vt , decoder ) . seekToFrameSloppy ( frameNumber ) ) . getFrame ( ) ; }


Input: Get a specified frame by second from an already open demuxer track ( sloppy mode i . e . nearest keyframe ) [CODESPLIT] public static Bitmap getFrameSloppy ( SeekableDemuxerTrack vt , ContainerAdaptor decoder , double second ) throws IOException , JCodecException { return ( ( AndroidFrameGrab ) new AndroidFrameGrab ( vt , decoder ) . seekToSecondSloppy ( second ) ) . getFrame ( ) ; }


Input: Seeks to a previous key frame prior or on the given frame if the track is not seekable returns 0 . [CODESPLIT] protected int seekToKeyFrame ( int frame ) throws IOException { if ( videoInputTrack instanceof SeekableDemuxerTrack ) { SeekableDemuxerTrack seekable = ( SeekableDemuxerTrack ) videoInputTrack ; seekable . gotoSyncFrame ( frame ) ; return ( int ) seekable . getCurFrame ( ) ; } else { Logger . warn ( "Can not seek in " + videoInputTrack + " container." ) ; return - 1 ; } }


Input: Returns a pixel buffer of a suitable size to hold the given video frame . The video size is taken either from the video metadata or by analyzing the incoming video packet . [CODESPLIT] protected LoanerPicture getPixelBuffer ( ByteBuffer firstFrame ) { VideoCodecMeta videoMeta = getVideoCodecMeta ( ) ; Size size = videoMeta . getSize ( ) ; return pixelStore . getPicture ( ( size . getWidth ( ) + 15 ) & ~ 0xf , ( size . getHeight ( ) + 15 ) & ~ 0xf , videoMeta . getColor ( ) ) ; }


Input: Wrong usage of Javascript keyword : in [CODESPLIT] private void dctOnePlane ( int blocksPerSlice , byte [ ] src , byte [ ] hibd , int [ ] dst ) { for ( int i = 0 ; i < src . length ; i ++ ) { dst [ i ] = ( ( src [ i ] + 128 ) << 2 ) ; } if ( hibd != null ) { for ( int i = 0 ; i < src . length ; i ++ ) { dst [ i ] += hibd [ i ] ; } } for ( int i = 0 ; i < blocksPerSlice ; i ++ ) { fdctProres10 ( dst , i << 6 ) ; } }


Input: Wrong usage of Javascript keyword : in [CODESPLIT] private void split ( Picture src , Picture dst , int mbX , int mbY , int sliceMbCount , int vStep , int vOffset ) { byte [ ] [ ] inData = src . getData ( ) ; byte [ ] [ ] inhbdData = src . getLowBits ( ) ; byte [ ] [ ] outData = dst . getData ( ) ; byte [ ] [ ] outhbdData = dst . getLowBits ( ) ; doSplit ( inData [ 0 ] , outData [ 0 ] , src . getPlaneWidth ( 0 ) , mbX , mbY , sliceMbCount , 0 , vStep , vOffset ) ; doSplit ( inData [ 1 ] , outData [ 1 ] , src . getPlaneWidth ( 1 ) , mbX , mbY , sliceMbCount , 1 , vStep , vOffset ) ; doSplit ( inData [ 2 ] , outData [ 2 ] , src . getPlaneWidth ( 2 ) , mbX , mbY , sliceMbCount , 1 , vStep , vOffset ) ; if ( src . getLowBits ( ) != null ) { doSplit ( inhbdData [ 0 ] , outhbdData [ 0 ] , src . getPlaneWidth ( 0 ) , mbX , mbY , sliceMbCount , 0 , vStep , vOffset ) ; doSplit ( inhbdData [ 1 ] , outhbdData [ 1 ] , src . getPlaneWidth ( 1 ) , mbX , mbY , sliceMbCount , 1 , vStep , vOffset ) ; doSplit ( inhbdData [ 2 ] , outhbdData [ 2 ] , src . getPlaneWidth ( 2 ) , mbX , mbY , sliceMbCount , 1 , vStep , vOffset ) ; } }


Input: gain compensation and overlap - add : - the gain control function is calculated - the gain control function applies to IMDCT output samples as a another IMDCT window - the reconstructed time domain signal produces by overlap - add [CODESPLIT] private void compensate ( float [ ] _in , float [ ] [ ] out , WindowSequence winSeq , int band ) { int j ; if ( winSeq . equals ( WindowSequence . EIGHT_SHORT_SEQUENCE ) ) { int a , b ; for ( int k = 0 ; k < 8 ; k ++ ) { //calculation calculateFunctionData ( lbShort * 2 , band , winSeq , k ) ; //applying for ( j = 0 ; j < lbShort * 2 ; j ++ ) { a = band * lbLong * 2 + k * lbShort * 2 + j ; _in [ a ] *= _function [ j ] ; } //overlapping for ( j = 0 ; j < lbShort ; j ++ ) { a = j + lbLong * 7 / 16 + lbShort * k ; b = band * lbLong * 2 + k * lbShort * 2 + j ; overlap [ band ] [ a ] += _in [ b ] ; } //store for next frame for ( j = 0 ; j < lbShort ; j ++ ) { a = j + lbLong * 7 / 16 + lbShort * ( k + 1 ) ; b = band * lbLong * 2 + k * lbShort * 2 + lbShort + j ; overlap [ band ] [ a ] = _in [ b ] ; } locationPrev [ band ] [ 0 ] = Platform . copyOfInt ( location [ band ] [ k ] , location [ band ] [ k ] . length ) ; levelPrev [ band ] [ 0 ] = Platform . copyOfInt ( level [ band ] [ k ] , level [ band ] [ k ] . length ) ; } arraycopy ( overlap [ band ] , 0 , out [ band ] , 0 , lbLong ) ; arraycopy ( overlap [ band ] , lbLong , overlap [ band ] , 0 , lbLong ) ; } else { //calculation calculateFunctionData ( lbLong * 2 , band , winSeq , 0 ) ; //applying for ( j = 0 ; j < lbLong * 2 ; j ++ ) { _in [ band * lbLong * 2 + j ] *= _function [ j ] ; } //overlapping for ( j = 0 ; j < lbLong ; j ++ ) { out [ band ] [ j ] = overlap [ band ] [ j ] + _in [ band * lbLong * 2 + j ] ; } //store for next frame for ( j = 0 ; j < lbLong ; j ++ ) { overlap [ band ] [ j ] = _in [ band * lbLong * 2 + lbLong + j ] ; } final int lastBlock = winSeq . equals ( WindowSequence . ONLY_LONG_SEQUENCE ) ? 1 : 0 ; locationPrev [ band ] [ 0 ] = Platform . copyOfInt ( location [ band ] [ lastBlock ] , location [ band ] [ lastBlock ] . length ) ; levelPrev [ band ] [ 0 ] = Platform . copyOfInt ( level [ band ] [ lastBlock ] , level [ band ] [ lastBlock ] . length ) ; } }


Input: produces gain control function data stores it in function array [CODESPLIT] private void calculateFunctionData ( int samples , int band , WindowSequence winSeq , int blockID ) { final int [ ] locA = new int [ 10 ] ; final float [ ] levA = new float [ 10 ] ; final float [ ] modFunc = new float [ samples ] ; final float [ ] buf1 = new float [ samples / 2 ] ; final float [ ] buf2 = new float [ samples / 2 ] ; final float [ ] buf3 = new float [ samples / 2 ] ; int maxLocGain0 = 0 , maxLocGain1 = 0 , maxLocGain2 = 0 ; switch ( winSeq ) { case ONLY_LONG_SEQUENCE : case EIGHT_SHORT_SEQUENCE : maxLocGain0 = maxLocGain1 = samples / 2 ; maxLocGain2 = 0 ; break ; case LONG_START_SEQUENCE : maxLocGain0 = samples / 2 ; maxLocGain1 = samples * 7 / 32 ; maxLocGain2 = samples / 16 ; break ; case LONG_STOP_SEQUENCE : maxLocGain0 = samples / 16 ; maxLocGain1 = samples * 7 / 32 ; maxLocGain2 = samples / 2 ; break ; } //calculate the fragment modification functions //for the first half region calculateFMD ( band , 0 , true , maxLocGain0 , samples , locA , levA , buf1 ) ; //for the latter half region int block = ( winSeq . equals ( WindowSequence . EIGHT_SHORT_SEQUENCE ) ) ? blockID : 0 ; float secLevel = calculateFMD ( band , block , false , maxLocGain1 , samples , locA , levA , buf2 ) ; //for the non-overlapped region if ( winSeq . equals ( WindowSequence . LONG_START_SEQUENCE ) || winSeq . equals ( WindowSequence . LONG_STOP_SEQUENCE ) ) { calculateFMD ( band , 1 , false , maxLocGain2 , samples , locA , levA , buf3 ) ; } //calculate a gain modification function int i ; int flatLen = 0 ; if ( winSeq . equals ( WindowSequence . LONG_STOP_SEQUENCE ) ) { flatLen = samples / 2 - maxLocGain0 - maxLocGain1 ; for ( i = 0 ; i < flatLen ; i ++ ) { modFunc [ i ] = 1.0f ; } } if ( winSeq . equals ( WindowSequence . ONLY_LONG_SEQUENCE ) || winSeq . equals ( WindowSequence . EIGHT_SHORT_SEQUENCE ) ) levA [ 0 ] = 1.0f ; for ( i = 0 ; i < maxLocGain0 ; i ++ ) { modFunc [ i + flatLen ] = levA [ 0 ] * secLevel * buf1 [ i ] ; } for ( i = 0 ; i < maxLocGain1 ; i ++ ) { modFunc [ i + flatLen + maxLocGain0 ] = levA [ 0 ] * buf2 [ i ] ; } if ( winSeq . equals ( WindowSequence . LONG_START_SEQUENCE ) ) { for ( i = 0 ; i < maxLocGain2 ; i ++ ) { modFunc [ i + maxLocGain0 + maxLocGain1 ] = buf3 [ i ] ; } flatLen = samples / 2 - maxLocGain1 - maxLocGain2 ; for ( i = 0 ; i < flatLen ; i ++ ) { modFunc [ i + maxLocGain0 + maxLocGain1 + maxLocGain2 ] = 1.0f ; } } else if ( winSeq . equals ( WindowSequence . LONG_STOP_SEQUENCE ) ) { for ( i = 0 ; i < maxLocGain2 ; i ++ ) { modFunc [ i + flatLen + maxLocGain0 + maxLocGain1 ] = buf3 [ i ] ; } } //calculate a gain control function for ( i = 0 ; i < samples ; i ++ ) { _function [ i ] = 1.0f / modFunc [ i ] ; } }


Input: / * calculates a fragment modification function by interpolating the gain values of the gain change positions [CODESPLIT] private float calculateFMD ( int bd , int wd , boolean prev , int maxLocGain , int samples , int [ ] loc , float [ ] lev , float [ ] fmd ) { final int [ ] m = new int [ samples / 2 ] ; final int [ ] lct = prev ? locationPrev [ bd ] [ wd ] : location [ bd ] [ wd ] ; final int [ ] lvl = prev ? levelPrev [ bd ] [ wd ] : level [ bd ] [ wd ] ; final int length = lct . length ; int lngain ; int i ; for ( i = 0 ; i < length ; i ++ ) { loc [ i + 1 ] = 8 * lct [ i ] ; //gainc lngain = getGainChangePointID ( lvl [ i ] ) ; //gainc if ( lngain < 0 ) lev [ i + 1 ] = 1.0f / ( float ) Math . pow ( 2 , - lngain ) ; else lev [ i + 1 ] = ( float ) Math . pow ( 2 , lngain ) ; } //set start point values loc [ 0 ] = 0 ; if ( length == 0 ) lev [ 0 ] = 1.0f ; else lev [ 0 ] = lev [ 1 ] ; float secLevel = lev [ 0 ] ; //set end point values loc [ length + 1 ] = maxLocGain ; lev [ length + 1 ] = 1.0f ; int j ; for ( i = 0 ; i < maxLocGain ; i ++ ) { m [ i ] = 0 ; for ( j = 0 ; j <= length + 1 ; j ++ ) { if ( loc [ j ] <= i ) m [ i ] = j ; } } for ( i = 0 ; i < maxLocGain ; i ++ ) { if ( ( i >= loc [ m [ i ] ] ) && ( i <= loc [ m [ i ] ] + 7 ) ) fmd [ i ] = interpolateGain ( lev [ m [ i ] ] , lev [ m [ i ] + 1 ] , i - loc [ m [ i ] ] ) ; else fmd [ i ] = lev [ m [ i ] + 1 ] ; } return secLevel ; }


Input: transformes the exponent value of the gain to the id of the gain change point [CODESPLIT] private int getGainChangePointID ( int lngain ) { for ( int i = 0 ; i < ID_GAIN ; i ++ ) { if ( lngain == LN_GAIN [ i ] ) return i ; } return 0 ; //shouldn't happen }


Input: calculates a fragment modification function the interpolated gain value between the gain values of two gain change positions is calculated by the formula : f ( a b j ) = 2^ ((( 8 - j ) log2 ( a ) + j * log2 ( b )) / 8 ) [CODESPLIT] private float interpolateGain ( float alev0 , float alev1 , int iloc ) { final float a0 = ( float ) ( Math . log ( alev0 ) / Math . log ( 2 ) ) ; final float a1 = ( float ) ( Math . log ( alev1 ) / Math . log ( 2 ) ) ; return ( float ) Math . pow ( 2.0f , ( ( ( 8 - iloc ) * a0 + iloc * a1 ) / 8 ) ) ; }


Input: Generic byte - array to integer - array conversion [CODESPLIT] public static int [ ] fromByte ( byte [ ] b , int depth , boolean isBe ) { if ( depth == 24 ) if ( isBe ) return from24BE ( b ) ; else return from24LE ( b ) ; else if ( depth == 16 ) if ( isBe ) return from16BE ( b ) ; else return from16LE ( b ) ; throw new NotSupportedException ( "Conversion from " + depth + "bit " + ( isBe ? "big endian" : "little endian" ) + " is not supported." ) ; }


Input: Generic integer - array to byte - array conversion [CODESPLIT] public static byte [ ] toByte ( int [ ] ia , int depth , boolean isBe ) { if ( depth == 24 ) if ( isBe ) return to24BE ( ia ) ; else return to24LE ( ia ) ; else if ( depth == 16 ) if ( isBe ) return to16BE ( ia ) ; else return to16LE ( ia ) ; throw new NotSupportedException ( "Conversion to " + depth + "bit " + ( isBe ? "big endian" : "little endian" ) + " is not supported." ) ; }


Input: Converts PCM samples stored in buf and described with format to float array representation [CODESPLIT] public static void toFloat ( AudioFormat format , ByteBuffer buf , FloatBuffer floatBuf ) { if ( ! format . isSigned ( ) ) throw new NotSupportedException ( "Unsigned PCM is not supported ( yet? )." ) ; if ( format . getSampleSizeInBits ( ) != 16 && format . getSampleSizeInBits ( ) != 24 ) throw new NotSupportedException ( format . getSampleSizeInBits ( ) + " bit PCM is not supported ( yet? )." ) ; if ( format . isBigEndian ( ) ) { if ( format . getSampleSizeInBits ( ) == 16 ) { toFloat16BE ( buf , floatBuf ) ; } else { toFloat24BE ( buf , floatBuf ) ; } } else { if ( format . getSampleSizeInBits ( ) == 16 ) { toFloat16LE ( buf , floatBuf ) ; } else { toFloat24LE ( buf , floatBuf ) ; } } }


Input: Converts float PCM samples stored in floatBuf to integer representation according to format and stores them in buf [CODESPLIT] public static void fromFloat ( FloatBuffer floatBuf , AudioFormat format , ByteBuffer buf ) { if ( ! format . isSigned ( ) ) throw new NotSupportedException ( "Unsigned PCM is not supported ( yet? )." ) ; if ( format . getSampleSizeInBits ( ) != 16 && format . getSampleSizeInBits ( ) != 24 ) throw new NotSupportedException ( format . getSampleSizeInBits ( ) + " bit PCM is not supported ( yet? )." ) ; if ( format . isBigEndian ( ) ) { if ( format . getSampleSizeInBits ( ) == 16 ) { fromFloat16BE ( buf , floatBuf ) ; } else { fromFloat24BE ( buf , floatBuf ) ; } } else { if ( format . getSampleSizeInBits ( ) == 16 ) { fromFloat16LE ( buf , floatBuf ) ; } else { fromFloat24LE ( buf , floatBuf ) ; } } }


Input: Interleaves audio samples in ins into outb using sample size from the format [CODESPLIT] public static void interleave ( AudioFormat format , ByteBuffer [ ] ins , ByteBuffer outb ) { int bytesPerSample = format . getSampleSizeInBits ( ) >> 3 ; int bytesPerFrame = bytesPerSample * ins . length ; int max = 0 ; for ( int i = 0 ; i < ins . length ; i ++ ) if ( ins [ i ] . remaining ( ) > max ) max = ins [ i ] . remaining ( ) ; for ( int frames = 0 ; frames < max && outb . remaining ( ) >= bytesPerFrame ; frames ++ ) { for ( int j = 0 ; j < ins . length ; j ++ ) { if ( ins [ j ] . remaining ( ) < bytesPerSample ) { for ( int i = 0 ; i < bytesPerSample ; i ++ ) outb . put ( ( byte ) 0 ) ; } else { for ( int i = 0 ; i < bytesPerSample ; i ++ ) { outb . put ( ins [ j ] . get ( ) ) ; } } } } }


Input: Deinterleaves audio samples from inb into outs using sample size from format [CODESPLIT] public static void deinterleave ( AudioFormat format , ByteBuffer inb , ByteBuffer [ ] outs ) { int bytesPerSample = format . getSampleSizeInBits ( ) >> 3 ; int bytesPerFrame = bytesPerSample * outs . length ; while ( inb . remaining ( ) >= bytesPerFrame ) { for ( int j = 0 ; j < outs . length ; j ++ ) { for ( int i = 0 ; i < bytesPerSample ; i ++ ) { outs [ j ] . put ( inb . get ( ) ) ; } } } }


Input: Retrieves coded size of this video track . [CODESPLIT] public Size getCodedSize ( ) { SampleEntry se = getSampleEntries ( ) [ 0 ] ; if ( ! ( se instanceof VideoSampleEntry ) ) throw new IllegalArgumentException ( "Not a video track" ) ; VideoSampleEntry vse = ( VideoSampleEntry ) se ; return new Size ( vse . getWidth ( ) , vse . getHeight ( ) ) ; }


Input: A dispersed map . Every odd line starts from the ( N / 2 ) th group [CODESPLIT] public static int [ ] buildDispersedMap ( int picWidthInMbs , int picHeightInMbs , int numSliceGroups ) { int picSizeInMbs = picWidthInMbs * picHeightInMbs ; int [ ] groups = new int [ picSizeInMbs ] ; for ( int i = 0 ; i < picSizeInMbs ; i ++ ) { int group = ( ( i % picWidthInMbs ) + ( ( ( i / picWidthInMbs ) * numSliceGroups ) / 2 ) ) % numSliceGroups ; groups [ i ] = group ; } return groups ; }


Input: A boxout macroblock to slice group mapping . Only applicable when there s exactly 2 slice groups . Slice group 1 is a background while slice group 0 is a box in the middle of the frame . [CODESPLIT] public static int [ ] buildBoxOutMap ( int picWidthInMbs , int picHeightInMbs , boolean changeDirection , int numberOfMbsInBox ) { int picSizeInMbs = picWidthInMbs * picHeightInMbs ; int [ ] groups = new int [ picSizeInMbs ] ; int changeDirectionInt = changeDirection ? 1 : 0 ; for ( int i = 0 ; i < picSizeInMbs ; i ++ ) groups [ i ] = 1 ; int x = ( picWidthInMbs - changeDirectionInt ) / 2 ; int y = ( picHeightInMbs - changeDirectionInt ) / 2 ; int leftBound = x ; int topBound = y ; int rightBound = x ; int bottomBound = y ; int xDir = changeDirectionInt - 1 ; int yDir = changeDirectionInt ; boolean mapUnitVacant = false ; for ( int k = 0 ; k < numberOfMbsInBox ; k += ( mapUnitVacant ? 1 : 0 ) ) { int mbAddr = y * picWidthInMbs + x ; mapUnitVacant = ( groups [ mbAddr ] == 1 ) ; if ( mapUnitVacant ) { groups [ mbAddr ] = 0 ; } if ( xDir == - 1 && x == leftBound ) { leftBound = Max ( leftBound - 1 , 0 ) ; x = leftBound ; xDir = 0 ; yDir = 2 * changeDirectionInt - 1 ; } else if ( xDir == 1 && x == rightBound ) { rightBound = Min ( rightBound + 1 , picWidthInMbs - 1 ) ; x = rightBound ; xDir = 0 ; yDir = 1 - 2 * changeDirectionInt ; } else if ( yDir == - 1 && y == topBound ) { topBound = Max ( topBound - 1 , 0 ) ; y = topBound ; xDir = 1 - 2 * changeDirectionInt ; yDir = 0 ; } else if ( yDir == 1 && y == bottomBound ) { bottomBound = Min ( bottomBound + 1 , picHeightInMbs - 1 ) ; y = bottomBound ; xDir = 2 * changeDirectionInt - 1 ; yDir = 0 ; } else { x += xDir ; y += yDir ; } } return groups ; }


Input: A macroblock to slice group map that fills frame column by column [CODESPLIT] public static int [ ] buildWipeMap ( int picWidthInMbs , int picHeightInMbs , int sizeOfUpperLeftGroup , boolean changeDirection ) { int picSizeInMbs = picWidthInMbs * picHeightInMbs ; int [ ] groups = new int [ picSizeInMbs ] ; int changeDirectionInt = changeDirection ? 1 : 0 ; int k = 0 ; for ( int j = 0 ; j < picWidthInMbs ; j ++ ) { for ( int i = 0 ; i < picHeightInMbs ; i ++ ) { int mbAddr = i * picWidthInMbs + j ; if ( k ++ < sizeOfUpperLeftGroup ) { groups [ mbAddr ] = changeDirectionInt ; } else { groups [ mbAddr ] = 1 - changeDirectionInt ; } } } return groups ; }


Input: Utility method to read a batch of ULS [CODESPLIT] protected static UL [ ] readULBatch ( ByteBuffer _bb ) { int count = _bb . getInt ( ) ; _bb . getInt ( ) ; UL [ ] result = new UL [ count ] ; for ( int i = 0 ; i < count ; i ++ ) { result [ i ] = UL . read ( _bb ) ; } return result ; }


Input: Utility method to read a batch of int32 [CODESPLIT] protected static int [ ] readInt32Batch ( ByteBuffer _bb ) { int count = _bb . getInt ( ) ; _bb . getInt ( ) ; int [ ] result = new int [ count ] ; for ( int i = 0 ; i < count ; i ++ ) { result [ i ] = _bb . getInt ( ) ; } return result ; }