question: public static int decode_residual ( H264Context h , GetBitContext gb , short [ ] block_base , int block_offset , int n , int [ ] scantable_base , int scantable_offset , long [ ] qmul_base , int qmul_offset , int max_coeff ) { final int [ ] coeff_token_table_index = { 0 , 0 , 1 , 1 , 2 , 2 , 2 , 2 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 } ; int [ ] level = new int [ 16 ] ; int zeros_left , coeff_token , total_coeff , i , trailing_ones , run_before ; if ( n >= H264Context . CHROMA_DC_BLOCK_INDEX ) { coeff_token = gb . get_vlc2 ( chroma_dc_coeff_token_vlc . table_base , chroma_dc_coeff_token_vlc . table_offset , H264Context . CHROMA_DC_COEFF_TOKEN_VLC_BITS , 1 , "coeff_token_CROMA_DC" ) ; total_coeff = coeff_token > > 2 ; } else { if ( n == H264Context . LUMA_DC_BLOCK_INDEX ) { total_coeff = pred_non_zero_count ( h , 0 ) ; coeff_token = gb . get_vlc2 ( coeff_token_vlc [ coeff_token_table_index [ total_coeff ] ] . table_base , coeff_token_vlc [ coeff_token_table_index [ total_coeff ] ] . table_offset , H264Context . COEFF_TOKEN_VLC_BITS , 2 , "coeff_token_LUMA_DC" ) ; total_coeff = coeff_token > > 2 ; } else { total_coeff = pred_non_zero_count ( h , n ) ; coeff_token = gb . get_vlc2 ( coeff_token_vlc [ coeff_token_table_index [ total_coeff ] ] . table_base , coeff_token_vlc [ coeff_token_table_index [ total_coeff ] ] . table_offset , H264Context . COEFF_TOKEN_VLC_BITS , 2 , "coeff_token_LUMA(2)_DC" ) ; total_coeff = coeff_token > > 2 ; } } h . non_zero_count_cache [ H264Context . scan8 [ n ] ] = total_coeff ; if ( total_coeff == 0 ) return 0 ; if ( total_coeff > max_coeff ) { return - 1 ; } trailing_ones = coeff_token & 3 ; i = ( int ) gb . show_bits ( 3 ) ; gb . skip_bits ( trailing_ones ) ; level [ 0 ] = 1 - ( ( i & 4 ) > > 1 ) ; level [ 1 ] = 1 - ( ( i & 2 ) ) ; level [ 2 ] = 1 - ( ( i & 1 ) << 1 ) ; if ( trailing_ones < total_coeff ) { int mask , prefix ; int suffix_length = ( ( total_coeff > 10 ) ? 1 : 0 ) & ( ( trailing_ones < 3 ) ? 1 : 0 ) ; int bitsi = ( int ) gb . show_bits ( LEVEL_TAB_BITS ) ; int level_code = cavlc_level_tab [ suffix_length ] [ bitsi ] [ 0 ] ; gb . skip_bits ( cavlc_level_tab [ suffix_length ] [ bitsi ] [ 1 ] ) ; if ( level_code >= 100 ) { prefix = level_code - 100 ; if ( prefix == LEVEL_TAB_BITS ) prefix += get_level_prefix ( gb ) ; if ( prefix < 14 ) { if ( suffix_length != 0 ) level_code = ( int ) ( ( prefix << 1 ) + gb . get_bits1 ( "level_code" ) ) ; else level_code = prefix ; } else if ( prefix == 14 ) { if ( suffix_length != 0 ) level_code = ( int ) ( ( prefix << 1 ) + gb . get_bits1 ( "level_code" ) ) ; else level_code = ( int ) ( prefix + gb . get_bits ( 4 , "level_code" ) ) ; } else { level_code = 30 + ( int ) ( gb . get_bits ( prefix - 3 , "level_code" ) ) ; if ( prefix >= 16 ) { if ( prefix > 25 + 3 ) { return - 1 ; } level_code += ( 1 << ( prefix - 3 ) ) - 4096 ; } } if ( trailing_ones < 3 ) level_code += 2 ; suffix_length = 2 ; mask = - ( level_code & 1 ) ; level [ trailing_ones ] = ( ( ( 2 + level_code ) > > 1 ) ^ mask ) - mask ; } else { level_code += ( ( level_code > > 31 ) | 1 ) & - ( ( trailing_ones < 3 ) ? 1 : 0 ) ; suffix_length = 1 + ( ( ( 0xffffffffL & ( level_code + 3 ) ) > 6 ) ? 1 : 0 ) ; level [ trailing_ones ] = level_code ; } for ( i = trailing_ones + 1 ; i < total_coeff ; i ++ ) { final int [ ] suffix_limit = { 0 , 3 , 6 , 12 , 24 , 48 , Integer . MAX_VALUE } ; bitsi = ( int ) gb . show_bits ( LEVEL_TAB_BITS ) ; level_code = cavlc_level_tab [ suffix_length ] [ bitsi ] [ 0 ] ; gb . skip_bits ( cavlc_level_tab [ suffix_length ] [ bitsi ] [ 1 ] ) ; if ( level_code >= 100 ) { prefix = level_code - 100 ; if ( prefix == LEVEL_TAB_BITS ) { prefix += get_level_prefix ( gb ) ; } if ( prefix < 15 ) { level_code = ( int ) ( ( prefix << suffix_length ) + gb . get_bits ( suffix_length , "level_code" ) ) ; } else { level_code = ( int ) ( ( 15 << suffix_length ) + gb . get_bits ( prefix - 3 , "level_code" ) ) ; if ( prefix >= 16 ) level_code += ( 1 << ( prefix - 3 ) ) - 4096 ; } mask = - ( level_code & 1 ) ; level_code = ( ( ( 2 + level_code ) > > 1 ) ^ mask ) - mask ; } level [ i ] = level_code ; suffix_length += ( ( ( 0xffffffffL & ( suffix_limit [ suffix_length ] + level_code ) ) > ( 2L * suffix_limit [ suffix_length ] ) ) ? 1 : 0 ) ; } } if ( total_coeff == max_coeff ) zeros_left = 0 ; else { if ( n >= H264Context . CHROMA_DC_BLOCK_INDEX ) { zeros_left = gb . get_vlc2 ( chroma_dc_total_zeros_vlc [ total_coeff - 1 ] . table_base , chroma_dc_total_zeros_vlc [ total_coeff - 1 ] . table_offset , H264Context . CHROMA_DC_TOTAL_ZEROS_VLC_BITS , 1 , "coeff_token_CROMA_DC_TOTAL_ZERO" ) ; } else { zeros_left = gb . get_vlc2 ( total_zeros_vlc [ total_coeff - 1 ] . table_base , total_zeros_vlc [ total_coeff - 1 ] . table_offset , H264Context . TOTAL_ZEROS_VLC_BITS , 1 , "coeff_token_TOTAL_ZEROS" ) ; } } scantable_offset += zeros_left + total_coeff - 1 ; if ( scantable_offset < 0 ) { int [ ] new_scantable_base = new int [ scantable_base . length + ( - scantable_offset ) ] ; System . arraycopy ( scantable_base , 0 , new_scantable_base , - scantable_offset , scantable_base . length ) ; scantable_base = new_scantable_base ; scantable_offset = 0 ; } if ( n >= H264Context . LUMA_DC_BLOCK_INDEX ) { block_base [ block_offset + scantable_base [ scantable_offset ] ] = ( short ) level [ 0 ] ; for ( i = 1 ; i < total_coeff && zeros_left > 0 ; i ++ ) { if ( zeros_left < 7 ) { run_before = gb . get_vlc2 ( run_vlc [ zeros_left - 1 ] . table_base , run_vlc [ zeros_left - 1 ] . table_offset , H264Context . RUN_VLC_BITS , 1 , "RUN_VLC" ) ; } else { run_before = gb . get_vlc2 ( run7_vlc . table_base , run7_vlc . table_offset , H264Context . RUN7_VLC_BITS , 2 , "RUN7_VLC" ) ; } zeros_left -= run_before ; scantable_offset -= 1 + run_before ; block_base [ block_offset + scantable_base [ scantable_offset ] ] = ( short ) level [ i ] ; } for ( ; i < total_coeff ; i ++ ) { scantable_offset -- ; block_base [ block_offset + scantable_base [ scantable_offset ] ] = ( short ) level [ i ] ; } } else { block_base [ block_offset + scantable_base [ scantable_offset ] ] = ( short ) ( ( level [ 0 ] * qmul_base [ qmul_offset + scantable_base [ scantable_offset ] ] + 32 ) > > 6 ) ; for ( i = 1 ; i < total_coeff && zeros_left > 0 ; i ++ ) { if ( zeros_left < 7 ) { run_before = gb . get_vlc2 ( run_vlc [ zeros_left - 1 ] . table_base , run_vlc [ zeros_left - 1 ] . table_offset , H264Context . RUN_VLC_BITS , 1 , "RUN_VLC" ) ; } else { run_before = gb . get_vlc2 ( run7_vlc . table_base , run7_vlc . table_offset , H264Context . RUN7_VLC_BITS , 2 , "RUN7_VLC" ) ; } zeros_left -= run_before ; scantable_offset -= ( 1 + run_before ) ; block_base [ block_offset + scantable_base [ scantable_offset ] ] = ( short ) ( ( level [ i ] * qmul_base [ qmul_offset + scantable_base [ scantable_offset ] ] + 32 ) > > 6 ) ; } for ( ; i < total_coeff ; i ++ ) { scantable_offset -- ; block_base [ block_offset + scantable_base [ scantable_offset ] ] = ( short ) ( ( level [ i ] * qmul_base [ qmul_offset + scantable_base [ scantable_offset ] ] + 32 ) > > 6 ) ; } } if ( zeros_left < 0 ) { return - 1 ; } return 0 ; }
target:  decodes a residual block.