Input: Remove user - defined word List from the dictionary for the specified KoreanPos . [CODESPLIT] public static void removeWordFromDictionary ( KoreanPosJava pos , List < String > words ) { OpenKoreanTextProcessor . removeWordsFromDictionary ( KoreanPos . withName ( pos . toString ( ) ) , JavaConverters . asScalaBufferConverter ( words ) . asScala ( ) ) ; }


Input: Transforms the tokenization output to List<KoreanTokenJava > [CODESPLIT] public static List < KoreanTokenJava > tokensToJavaKoreanTokenList ( Seq < KoreanToken > tokens , boolean keepSpace ) { Iterator < KoreanToken > tokenized = tokens . iterator ( ) ; List < KoreanTokenJava > output = new LinkedList <> ( ) ; while ( tokenized . hasNext ( ) ) { KoreanToken token = tokenized . next ( ) ; String stem = "" ; if ( token . stem ( ) . nonEmpty ( ) ) { stem += token . stem ( ) . get ( ) ; } if ( keepSpace || token . pos ( ) != KoreanPos . Space ( ) ) { output . add ( new KoreanTokenJava ( token . text ( ) , KoreanPosJava . valueOf ( token . pos ( ) . toString ( ) ) , token . offset ( ) , token . length ( ) , token . unknown ( ) , stem ) ) ; } } return output ; }


Input: Tokenize with the builder options into a String Iterable . [CODESPLIT] public static List < String > tokensToJavaStringList ( Seq < KoreanToken > tokens , boolean keepSpace ) { Iterator < KoreanToken > tokenized = tokens . iterator ( ) ; List < String > output = new LinkedList <> ( ) ; while ( tokenized . hasNext ( ) ) { final KoreanToken token = tokenized . next ( ) ; if ( keepSpace || token . pos ( ) != KoreanPos . Space ( ) ) { output . add ( token . text ( ) ) ; } } return output ; }


Input: Extract phrases from Korean input text [CODESPLIT] public static List < KoreanPhraseExtractor . KoreanPhrase > extractPhrases ( Seq < KoreanToken > tokens , boolean filterSpam , boolean includeHashtags ) { Seq < KoreanPhraseExtractor . KoreanPhrase > seq = OpenKoreanTextProcessor . extractPhrases ( tokens , filterSpam , includeHashtags ) ; return toJavaList ( seq ) ; }


Input: Detokenize the input list of words . [CODESPLIT] public static String detokenize ( List < String > tokens ) { return OpenKoreanTextProcessor . detokenize ( JavaConverters . asScalaBufferConverter ( tokens ) . asScala ( ) ) ; }


Input: Returns an unmodifiable { @link CharArraySet } . This allows to provide unmodifiable views of internal sets for read - only use . [CODESPLIT] public static CharArraySet unmodifiableSet ( CharArraySet set ) { if ( set == null ) throw new NullPointerException ( "Given set is null" ) ; if ( set == EMPTY_SET ) return EMPTY_SET ; if ( set . map instanceof CharArrayMap . UnmodifiableCharArrayMap ) return set ; return new CharArraySet ( CharArrayMap . unmodifiableMap ( set . map ) ) ; }


Input: Reads size amount of bytes from ch into a new ByteBuffer allocated from a buffer buf [CODESPLIT] public static ByteBuffer fetchFrom ( ByteBuffer buf , ReadableByteChannel ch , int size ) throws IOException { ByteBuffer result = buf . duplicate ( ) ; result . limit ( size ) ; NIOUtils . readFromChannel ( ch , result ) ; result . flip ( ) ; return result ; }


Input: / * [ 0 .. 1 ] [CODESPLIT] public static float calc_Q_div ( SBR sbr , int ch , int m , int l ) { if ( sbr . bs_coupling ) { /* left channel */ if ( ( sbr . Q [ 0 ] [ m ] [ l ] < 0 || sbr . Q [ 0 ] [ m ] [ l ] > 30 ) || ( sbr . Q [ 1 ] [ m ] [ l ] < 0 || sbr . Q [ 1 ] [ m ] [ l ] > 24 /* 2*panOffset(1) */ ) ) { return 0 ; } else { /* the pan parameter is always even */ if ( ch == 0 ) { return Q_div_tab_left [ sbr . Q [ 0 ] [ m ] [ l ] ] [ sbr . Q [ 1 ] [ m ] [ l ] >> 1 ] ; } else { return Q_div_tab_right [ sbr . Q [ 0 ] [ m ] [ l ] ] [ sbr . Q [ 1 ] [ m ] [ l ] >> 1 ] ; } } } else { /* no coupling */ if ( sbr . Q [ ch ] [ m ] [ l ] < 0 || sbr . Q [ ch ] [ m ] [ l ] > 30 ) { return 0 ; } else { return Q_div_tab [ sbr . Q [ ch ] [ m ] [ l ] ] ; } } }


Input: / * [ 0 .. 1 ] [CODESPLIT] public static float calc_Q_div2 ( SBR sbr , int ch , int m , int l ) { if ( sbr . bs_coupling ) { if ( ( sbr . Q [ 0 ] [ m ] [ l ] < 0 || sbr . Q [ 0 ] [ m ] [ l ] > 30 ) || ( sbr . Q [ 1 ] [ m ] [ l ] < 0 || sbr . Q [ 1 ] [ m ] [ l ] > 24 /* 2*panOffset(1) */ ) ) { return 0 ; } else { /* the pan parameter is always even */ if ( ch == 0 ) { return Q_div2_tab_left [ sbr . Q [ 0 ] [ m ] [ l ] ] [ sbr . Q [ 1 ] [ m ] [ l ] >> 1 ] ; } else { return Q_div2_tab_right [ sbr . Q [ 0 ] [ m ] [ l ] ] [ sbr . Q [ 1 ] [ m ] [ l ] >> 1 ] ; } } } else { /* no coupling */ if ( sbr . Q [ ch ] [ m ] [ l ] < 0 || sbr . Q [ ch ] [ m ] [ l ] > 30 ) { return 0 ; } else { return Q_div2_tab [ sbr . Q [ ch ] [ m ] [ l ] ] ; } } }


Input: Finds next Nth H . 264 bitstream NAL unit ( 0x00000001 ) and returns the data that preceeds it as a ByteBuffer slice [CODESPLIT] public static final ByteBuffer gotoNALUnit ( ByteBuffer buf ) { 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 <<= 8 ; val |= ( buf . get ( ) & 0xff ) ; if ( ( val & 0xffffff ) == 1 ) { buf . position ( buf . position ( ) - ( val == 1 ? 4 : 3 ) ) ; result . limit ( buf . position ( ) - from ) ; break ; } } return result ; }


Input: Finds next Nth H . 264 bitstream NAL unit ( 0x00000001 ) and returns the data that preceeds it as a ByteBuffer slice [CODESPLIT] public static final ByteBuffer gotoNALUnitWithArray ( ByteBuffer buf ) { if ( ! buf . hasRemaining ( ) ) return null ; int from = buf . position ( ) ; ByteBuffer result = buf . slice ( ) ; result . order ( ByteOrder . BIG_ENDIAN ) ; byte [ ] arr = buf . array ( ) ; int pos = from + buf . arrayOffset ( ) ; int posFrom = pos ; int lim = buf . limit ( ) + buf . arrayOffset ( ) ; while ( pos < lim ) { byte b = arr [ pos ] ; if ( ( b & 254 ) == 0 ) { while ( b == 0 && ++ pos < lim ) b = arr [ pos ] ; if ( b == 1 ) { if ( pos - posFrom >= 2 && arr [ pos - 1 ] == 0 && arr [ pos - 2 ] == 0 ) { int lenSize = ( pos - posFrom >= 3 && arr [ pos - 3 ] == 0 ) ? 4 : 3 ; buf . position ( pos + 1 - buf . arrayOffset ( ) - lenSize ) ; result . limit ( buf . position ( ) - from ) ; return result ; } } } pos += 3 ; } buf . position ( buf . limit ( ) ) ; return result ; }


Input: Encodes AVC frame in ISO BMF format . Takes Annex B format . [CODESPLIT] public static void encodeMOVPacketInplace ( ByteBuffer avcFrame ) { ByteBuffer dup = avcFrame . duplicate ( ) ; ByteBuffer d1 = avcFrame . duplicate ( ) ; for ( int tot = d1 . position ( ) ; ; ) { ByteBuffer buf = H264Utils . nextNALUnit ( dup ) ; if ( buf == null ) break ; d1 . position ( tot ) ; d1 . putInt ( buf . remaining ( ) ) ; tot += buf . remaining ( ) + 4 ; } }


Input: Encodes AVC frame in ISO BMF format . Takes Annex B format . [CODESPLIT] public static ByteBuffer encodeMOVPacket ( ByteBuffer avcFrame ) { ByteBuffer dup = avcFrame . duplicate ( ) ; List < ByteBuffer > list = new ArrayList < ByteBuffer > ( ) ; ByteBuffer buf ; int totalLen = 0 ; while ( ( buf = H264Utils . nextNALUnit ( dup ) ) != null ) { list . add ( buf ) ; totalLen += buf . remaining ( ) ; } ByteBuffer result = ByteBuffer . allocate ( list . size ( ) * 4 + totalLen ) ; for ( ByteBuffer byteBuffer : list ) { result . putInt ( byteBuffer . remaining ( ) ) ; result . put ( byteBuffer ) ; } result . flip ( ) ; return result ; }


Input: Decodes AVC packet in ISO BMF format into Annex B format . [CODESPLIT] public static ByteBuffer decodeMOVPacket ( ByteBuffer result , AvcCBox avcC ) { if ( avcC . getNalLengthSize ( ) == 4 ) { decodeMOVPacketInplace ( result , avcC ) ; return result ; } return joinNALUnits ( splitMOVPacket ( result , avcC ) ) ; }


Input: Decodes AVC packet in ISO BMF format into Annex B format . [CODESPLIT] public static void decodeMOVPacketInplace ( ByteBuffer result , AvcCBox avcC ) { if ( avcC . getNalLengthSize ( ) != 4 ) throw new IllegalArgumentException ( "Can only inplace decode AVC MOV packet with nal_length_size = 4." ) ; ByteBuffer dup = result . duplicate ( ) ; while ( dup . remaining ( ) >= 4 ) { int size = dup . getInt ( ) ; dup . position ( dup . position ( ) - 4 ) ; dup . putInt ( 1 ) ; dup . position ( dup . position ( ) + size ) ; } }


Input: Wipes AVC parameter sets ( SPS / PPS ) from the packet [CODESPLIT] public static void wipePS ( ByteBuffer _in , ByteBuffer out , List < ByteBuffer > spsList , List < ByteBuffer > ppsList ) { ByteBuffer dup = _in . duplicate ( ) ; while ( dup . hasRemaining ( ) ) { ByteBuffer buf = H264Utils . nextNALUnit ( dup ) ; if ( buf == null ) break ; NALUnit nu = NALUnit . read ( buf . duplicate ( ) ) ; if ( nu . type == NALUnitType . PPS ) { if ( ppsList != null ) ppsList . add ( NIOUtils . duplicate ( buf ) ) ; } else if ( nu . type == NALUnitType . SPS ) { if ( spsList != null ) spsList . add ( NIOUtils . duplicate ( buf ) ) ; } else if ( out != null ) { out . putInt ( 1 ) ; out . put ( buf ) ; } } if ( out != null ) out . flip ( ) ; }


Input: Wipes AVC parameter sets ( SPS / PPS ) from the packet ( inplace operation ) [CODESPLIT] public static void wipePSinplace ( ByteBuffer _in , Collection < ByteBuffer > spsList , Collection < ByteBuffer > ppsList ) { ByteBuffer dup = _in . duplicate ( ) ; while ( dup . hasRemaining ( ) ) { ByteBuffer buf = H264Utils . nextNALUnit ( dup ) ; if ( buf == null ) break ; NALUnit nu = NALUnit . read ( buf ) ; if ( nu . type == NALUnitType . PPS ) { if ( ppsList != null ) ppsList . add ( NIOUtils . duplicate ( buf ) ) ; _in . position ( dup . position ( ) ) ; } else if ( nu . type == NALUnitType . SPS ) { if ( spsList != null ) spsList . add ( NIOUtils . duplicate ( buf ) ) ; _in . position ( dup . position ( ) ) ; } else if ( nu . type == NALUnitType . IDR_SLICE || nu . type == NALUnitType . NON_IDR_SLICE ) break ; } }


Input: Creates a MP4 sample entry given AVC / H . 264 codec private . [CODESPLIT] public static SampleEntry createMOVSampleEntryFromBytes ( ByteBuffer codecPrivate ) { List < ByteBuffer > rawSPS = getRawSPS ( codecPrivate . duplicate ( ) ) ; List < ByteBuffer > rawPPS = getRawPPS ( codecPrivate . duplicate ( ) ) ; return createMOVSampleEntryFromSpsPpsList ( rawSPS , rawPPS , 4 ) ; }


Input: Creates a MP4 sample entry given AVC / H . 264 codec private . [CODESPLIT] public static AvcCBox createAvcCFromBytes ( ByteBuffer codecPrivate ) { List < ByteBuffer > rawSPS = getRawSPS ( codecPrivate . duplicate ( ) ) ; List < ByteBuffer > rawPPS = getRawPPS ( codecPrivate . duplicate ( ) ) ; return createAvcCFromPS ( rawSPS , rawPPS , 4 ) ; }


Input: Joins buffers containing individual NAL units into a single AnnexB delimited buffer . Each NAL unit will be separated with 00 00 00 01 markers . Allocates a new byte buffer and writes data into it . [CODESPLIT] public static ByteBuffer joinNALUnits ( List < ByteBuffer > nalUnits ) { int size = 0 ; for ( ByteBuffer nal : nalUnits ) { size += 4 + nal . remaining ( ) ; } ByteBuffer allocate = ByteBuffer . allocate ( size ) ; joinNALUnitsToBuffer ( nalUnits , allocate ) ; return allocate ; }


Input: Joins buffers containing individual NAL units into a single AnnexB delimited buffer . Each NAL unit will be separated with 00 00 00 01 markers . [CODESPLIT] public static void joinNALUnitsToBuffer ( List < ByteBuffer > nalUnits , ByteBuffer out ) { for ( ByteBuffer nal : nalUnits ) { out . putInt ( 1 ) ; out . put ( nal . duplicate ( ) ) ; } }


Input: Get block of ( possibly interpolated ) luma pixels [CODESPLIT] public void getBlockLuma ( Picture pic , Picture out , int off , int x , int y , int w , int h ) { int xInd = x & 0x3 ; int yInd = y & 0x3 ; int xFp = x >> 2 ; int yFp = y >> 2 ; if ( xFp < 2 || yFp < 2 || xFp > pic . getWidth ( ) - w - 5 || yFp > pic . getHeight ( ) - h - 5 ) { unsafe [ ( yInd << 2 ) + xInd ] . getLuma ( pic . getData ( ) [ 0 ] , pic . getWidth ( ) , pic . getHeight ( ) , out . getPlaneData ( 0 ) , off , out . getPlaneWidth ( 0 ) , xFp , yFp , w , h ) ; } else { safe [ ( yInd << 2 ) + xInd ] . getLuma ( pic . getData ( ) [ 0 ] , pic . getWidth ( ) , pic . getHeight ( ) , out . getPlaneData ( 0 ) , off , out . getPlaneWidth ( 0 ) , xFp , yFp , w , h ) ; } }


Input: Fullpel ( 0 0 ) unsafe [CODESPLIT] static void getLuma00Unsafe ( byte [ ] pic , int picW , int picH , byte [ ] blk , int blkOff , int blkStride , int x , int y , int blkW , int blkH ) { int maxH = picH - 1 ; int maxW = picW - 1 ; for ( int j = 0 ; j < blkH ; j ++ ) { int lineStart = clip ( j + y , 0 , maxH ) * picW ; for ( int i = 0 ; i < blkW ; i ++ ) { blk [ blkOff + i ] = pic [ lineStart + clip ( x + i , 0 , maxW ) ] ; } blkOff += blkStride ; } }


Input: Halfpel ( 2 0 ) horizontal int argument version [CODESPLIT] static void getLuma20NoRoundInt ( int [ ] pic , int picW , int [ ] blk , int blkOff , int blkStride , int x , int y , int blkW , int blkH ) { int off = y * picW + x ; for ( int j = 0 ; j < blkH ; j ++ ) { int off1 = - 2 ; for ( int i = 0 ; i < blkW ; i ++ ) { int a = pic [ off + off1 ] + pic [ off + off1 + 5 ] ; int b = pic [ off + off1 + 1 ] + pic [ off + off1 + 4 ] ; int c = pic [ off + off1 + 2 ] + pic [ off + off1 + 3 ] ; blk [ blkOff + i ] = a + 5 * ( ( c << 2 ) - b ) ; ++ off1 ; } off += picW ; blkOff += blkStride ; } }


Input: Halfpel ( 2 0 ) horizontal unsafe [CODESPLIT] static void getLuma20UnsafeNoRound ( byte [ ] pic , int picW , int picH , int [ ] blk , int blkOff , int blkStride , int x , int y , int blkW , int blkH ) { int maxW = picW - 1 ; int maxH = picH - 1 ; for ( int i = 0 ; i < blkW ; i ++ ) { int ipos_m2 = clip ( x + i - 2 , 0 , maxW ) ; int ipos_m1 = clip ( x + i - 1 , 0 , maxW ) ; int ipos = clip ( x + i , 0 , maxW ) ; int ipos_p1 = clip ( x + i + 1 , 0 , maxW ) ; int ipos_p2 = clip ( x + i + 2 , 0 , maxW ) ; int ipos_p3 = clip ( x + i + 3 , 0 , maxW ) ; int boff = blkOff ; for ( int j = 0 ; j < blkH ; j ++ ) { int lineStart = clip ( j + y , 0 , maxH ) * picW ; int a = pic [ lineStart + ipos_m2 ] + pic [ lineStart + ipos_p3 ] ; int b = pic [ lineStart + ipos_m1 ] + pic [ lineStart + ipos_p2 ] ; int c = pic [ lineStart + ipos ] + pic [ lineStart + ipos_p1 ] ; blk [ boff + i ] = a + 5 * ( ( c << 2 ) - b ) ; boff += blkStride ; } } }


Input: Hpel ( 0 2 ) vertical unsafe [CODESPLIT] static void getLuma02UnsafeNoRound ( byte [ ] pic , int picW , int picH , int [ ] blk , int blkOff , int blkStride , int x , int y , int blkW , int blkH ) { int maxH = picH - 1 ; int maxW = picW - 1 ; for ( int j = 0 ; j < blkH ; j ++ ) { int offP0 = clip ( y + j - 2 , 0 , maxH ) * picW ; int offP1 = clip ( y + j - 1 , 0 , maxH ) * picW ; int offP2 = clip ( y + j , 0 , maxH ) * picW ; int offP3 = clip ( y + j + 1 , 0 , maxH ) * picW ; int offP4 = clip ( y + j + 2 , 0 , maxH ) * picW ; int offP5 = clip ( y + j + 3 , 0 , maxH ) * picW ; for ( int i = 0 ; i < blkW ; i ++ ) { int pres_x = clip ( x + i , 0 , maxW ) ; int a = pic [ pres_x + offP0 ] + pic [ pres_x + offP5 ] ; int b = pic [ pres_x + offP1 ] + pic [ pres_x + offP4 ] ; int c = pic [ pres_x + offP2 ] + pic [ pres_x + offP3 ] ; blk [ blkOff + i ] = a + 5 * ( ( c << 2 ) - b ) ; } blkOff += blkStride ; } }


Input: Qpel : ( 1 0 ) horizontal [CODESPLIT] static void getLuma10 ( byte [ ] pic , int picW , byte [ ] blk , int blkOff , int blkStride , int x , int y , int blkW , int blkH ) { getLuma20 ( pic , picW , blk , blkOff , blkStride , x , y , blkW , blkH ) ; int off = y * picW + x ; for ( int j = 0 ; j < blkH ; j ++ ) { for ( int i = 0 ; i < blkW ; i ++ ) { blk [ blkOff + i ] = ( byte ) ( ( blk [ blkOff + i ] + pic [ off + i ] + 1 ) >> 1 ) ; } off += picW ; blkOff += blkStride ; } }


Input: Qpel vertical ( 0 3 ) [CODESPLIT] static void getLuma03 ( byte [ ] pic , int picW , byte [ ] blk , int blkOff , int blkStride , int x , int y , int blkW , int blkH ) { getLuma02 ( pic , picW , blk , blkOff , blkStride , x , y , blkW , blkH ) ; int off = y * picW + x ; for ( int j = 0 ; j < blkH ; j ++ ) { for ( int i = 0 ; i < blkW ; i ++ ) { blk [ blkOff + i ] = ( byte ) ( ( blk [ blkOff + i ] + pic [ off + i + picW ] + 1 ) >> 1 ) ; } off += picW ; blkOff += blkStride ; } }


Input: Hpel horizontal Qpel vertical ( 2 1 ) [CODESPLIT] void getLuma21 ( byte [ ] pic , int picW , byte [ ] blk , int blkOff , int blkStride , int x , int y , int blkW , int blkH ) { getLuma20NoRound ( pic , picW , tmp1 , 0 , blkW , x , y - 2 , blkW , blkH + 7 ) ; getLuma02NoRoundInt ( tmp1 , blkW , tmp2 , blkOff , blkStride , 0 , 2 , blkW , blkH ) ; int off = blkW << 1 ; for ( int j = 0 ; j < blkH ; j ++ ) { for ( int i = 0 ; i < blkW ; i ++ ) { int rounded = clip ( ( tmp2 [ blkOff + i ] + 512 ) >> 10 , - 128 , 127 ) ; int rounded2 = clip ( ( tmp1 [ off + i ] + 16 ) >> 5 , - 128 , 127 ) ; blk [ blkOff + i ] = ( byte ) ( ( rounded + rounded2 + 1 ) >> 1 ) ; } blkOff += blkStride ; off += blkW ; } }


Input: Hpel horizontal Hpel vertical ( 2 2 ) [CODESPLIT] void getLuma22 ( byte [ ] pic , int picW , byte [ ] blk , int blkOff , int blkStride , int x , int y , int blkW , int blkH ) { getLuma20NoRound ( pic , picW , tmp1 , 0 , blkW , x , y - 2 , blkW , blkH + 7 ) ; getLuma02NoRoundInt ( tmp1 , blkW , tmp2 , blkOff , blkStride , 0 , 2 , blkW , blkH ) ; for ( int j = 0 ; j < blkH ; j ++ ) { for ( int i = 0 ; i < blkW ; i ++ ) { blk [ blkOff + i ] = ( byte ) ( clip ( ( tmp2 [ blkOff + i ] + 512 ) >> 10 , - 128 , 127 ) ) ; } blkOff += blkStride ; } }


Input: Hpel ( 2 2 ) unsafe [CODESPLIT] void getLuma22Unsafe ( byte [ ] pic , int picW , int imgH , byte [ ] blk , int blkOff , int blkStride , int x , int y , int blkW , int blkH ) { getLuma20UnsafeNoRound ( pic , picW , imgH , tmp1 , 0 , blkW , x , y - 2 , blkW , blkH + 7 ) ; getLuma02NoRoundInt ( tmp1 , blkW , tmp2 , blkOff , blkStride , 0 , 2 , blkW , blkH ) ; for ( int j = 0 ; j < blkH ; j ++ ) { for ( int i = 0 ; i < blkW ; i ++ ) { blk [ blkOff + i ] = ( byte ) clip ( ( tmp2 [ blkOff + i ] + 512 ) >> 10 , - 128 , 127 ) ; } blkOff += blkStride ; } }


Input: Qpel ( 2 3 ) unsafe [CODESPLIT] void getLuma23Unsafe ( byte [ ] pic , int picW , int imgH , byte [ ] blk , int blkOff , int blkStride , int x , int y , int blkW , int blkH ) { getLuma20UnsafeNoRound ( pic , picW , imgH , tmp1 , 0 , blkW , x , y - 2 , blkW , blkH + 7 ) ; getLuma02NoRoundInt ( tmp1 , blkW , tmp2 , blkOff , blkStride , 0 , 2 , blkW , blkH ) ; int off = blkW << 1 ; for ( int j = 0 ; j < blkH ; j ++ ) { for ( int i = 0 ; i < blkW ; i ++ ) { int rounded = clip ( ( tmp2 [ blkOff + i ] + 512 ) >> 10 , - 128 , 127 ) ; int rounded2 = clip ( ( tmp1 [ off + i + blkW ] + 16 ) >> 5 , - 128 , 127 ) ; blk [ blkOff + i ] = ( byte ) ( ( rounded + rounded2 + 1 ) >> 1 ) ; } blkOff += blkStride ; off += blkW ; } }


Input: Qpel horizontal Hpel vertical ( 1 2 ) [CODESPLIT] void getLuma12 ( byte [ ] pic , int picW , byte [ ] blk , int blkOff , int blkStride , int x , int y , int blkW , int blkH ) { int tmpW = blkW + 7 ; getLuma02NoRound ( pic , picW , tmp1 , 0 , tmpW , x - 2 , y , tmpW , blkH ) ; getLuma20NoRoundInt ( tmp1 , tmpW , tmp2 , blkOff , blkStride , 2 , 0 , blkW , blkH ) ; int off = 2 ; for ( int j = 0 ; j < blkH ; j ++ ) { for ( int i = 0 ; i < blkW ; i ++ ) { int rounded = clip ( ( tmp2 [ blkOff + i ] + 512 ) >> 10 , - 128 , 127 ) ; int rounded2 = clip ( ( tmp1 [ off + i ] + 16 ) >> 5 , - 128 , 127 ) ; blk [ blkOff + i ] = ( byte ) ( ( rounded + rounded2 + 1 ) >> 1 ) ; } blkOff += blkStride ; off += tmpW ; } }


Input: Qpel ( 1 2 ) unsafe [CODESPLIT] void getLuma12Unsafe ( byte [ ] pic , int picW , int imgH , byte [ ] blk , int blkOff , int blkStride , int x , int y , int blkW , int blkH ) { int tmpW = blkW + 7 ; getLuma02UnsafeNoRound ( pic , picW , imgH , tmp1 , 0 , tmpW , x - 2 , y , tmpW , blkH ) ; getLuma20NoRoundInt ( tmp1 , tmpW , tmp2 , blkOff , blkStride , 2 , 0 , blkW , blkH ) ; int off = 2 ; for ( int j = 0 ; j < blkH ; j ++ ) { for ( int i = 0 ; i < blkW ; i ++ ) { int rounded = clip ( ( tmp2 [ blkOff + i ] + 512 ) >> 10 , - 128 , 127 ) ; int rounded2 = clip ( ( tmp1 [ off + i ] + 16 ) >> 5 , - 128 , 127 ) ; blk [ blkOff + i ] = ( byte ) ( ( rounded + rounded2 + 1 ) >> 1 ) ; } blkOff += blkStride ; off += tmpW ; } }


Input: Qpel ( 1 1 ) unsafe [CODESPLIT] void getLuma11Unsafe ( byte [ ] pic , int picW , int imgH , byte [ ] blk , int blkOff , int blkStride , int x , int y , int blkW , int blkH ) { getLuma20Unsafe ( pic , picW , imgH , blk , blkOff , blkStride , x , y , blkW , blkH ) ; getLuma02Unsafe ( pic , picW , imgH , tmp3 , 0 , blkW , x , y , blkW , blkH ) ; merge ( blk , tmp3 , blkOff , blkStride , blkW , blkH ) ; }


Input: Qpel horizontal Qpel vertical ( 1 3 ) [CODESPLIT] void getLuma13 ( byte [ ] pic , int picW , byte [ ] blk , int blkOff , int blkStride , int x , int y , int blkW , int blkH ) { getLuma20 ( pic , picW , blk , blkOff , blkStride , x , y + 1 , blkW , blkH ) ; getLuma02 ( pic , picW , tmp3 , 0 , blkW , x , y , blkW , blkH ) ; merge ( blk , tmp3 , blkOff , blkStride , blkW , blkH ) ; }


Input: Qpel horizontal Qpel vertical ( 3 1 ) [CODESPLIT] void getLuma31 ( byte [ ] pels , int picW , byte [ ] blk , int blkOff , int blkStride , int x , int y , int blkW , int blkH ) { getLuma20 ( pels , picW , blk , blkOff , blkStride , x , y , blkW , blkH ) ; getLuma02 ( pels , picW , tmp3 , 0 , blkW , x + 1 , y , blkW , blkH ) ; merge ( blk , tmp3 , blkOff , blkStride , blkW , blkH ) ; }


Input: Qpel ( 3 1 ) unsafe [CODESPLIT] void getLuma31Unsafe ( byte [ ] pels , int picW , int imgH , byte [ ] blk , int blkOff , int blkStride , int x , int y , int blkW , int blkH ) { getLuma20Unsafe ( pels , picW , imgH , blk , blkOff , blkStride , x , y , blkW , blkH ) ; getLuma02Unsafe ( pels , picW , imgH , tmp3 , 0 , blkW , x + 1 , y , blkW , blkH ) ; merge ( blk , tmp3 , blkOff , blkStride , blkW , blkH ) ; }


Input: Chroma ( 0 0 ) [CODESPLIT] private static void getChroma00 ( byte [ ] pic , int picW , int picH , byte [ ] blk , int blkOff , int blkStride , int x , int y , int blkW , int blkH ) { int off = y * picW + x ; for ( int j = 0 ; j < blkH ; j ++ ) { arraycopy ( pic , off , blk , blkOff , blkW ) ; off += picW ; blkOff += blkStride ; } }


Input: Chroma ( X 0 ) [CODESPLIT] private static void getChroma0X ( byte [ ] pels , int picW , int picH , byte [ ] blk , int blkOff , int blkStride , int fullX , int fullY , int fracY , int blkW , int blkH ) { int w00 = fullY * picW + fullX ; int w01 = w00 + ( fullY < picH - 1 ? picW : 0 ) ; int eMy = 8 - fracY ; for ( int j = 0 ; j < blkH ; j ++ ) { for ( int i = 0 ; i < blkW ; i ++ ) { blk [ blkOff + i ] = ( byte ) ( ( eMy * pels [ w00 + i ] + fracY * pels [ w01 + i ] + 4 ) >> 3 ) ; } w00 += picW ; w01 += picW ; blkOff += blkStride ; } }


Input: Chroma ( X 0 ) [CODESPLIT] private static void getChromaX0 ( byte [ ] pels , int picW , int imgH , byte [ ] blk , int blkOff , int blkStride , int fullX , int fullY , int fracX , int blkW , int blkH ) { int w00 = fullY * picW + fullX ; int w10 = w00 + ( fullX < picW - 1 ? 1 : 0 ) ; int eMx = 8 - fracX ; for ( int j = 0 ; j < blkH ; j ++ ) { for ( int i = 0 ; i < blkW ; i ++ ) { blk [ blkOff + i ] = ( byte ) ( ( eMx * pels [ w00 + i ] + fracX * pels [ w10 + i ] + 4 ) >> 3 ) ; } w00 += picW ; w10 += picW ; blkOff += blkStride ; } }


Input: Chroma ( X X ) [CODESPLIT] private static void getChromaXX ( byte [ ] pels , int picW , int picH , byte [ ] blk , int blkOff , int blkStride , int fullX , int fullY , int fracX , int fracY , int blkW , int blkH ) { int w00 = fullY * picW + fullX ; int w01 = w00 + ( fullY < picH - 1 ? picW : 0 ) ; int w10 = w00 + ( fullX < picW - 1 ? 1 : 0 ) ; int w11 = w10 + w01 - w00 ; int eMx = 8 - fracX ; int eMy = 8 - fracY ; for ( int j = 0 ; j < blkH ; j ++ ) { for ( int i = 0 ; i < blkW ; i ++ ) { blk [ blkOff + i ] = ( byte ) ( ( eMx * eMy * pels [ w00 + i ] + fracX * eMy * pels [ w10 + i ] + eMx * fracY * pels [ w01 + i ] + fracX * fracY * pels [ w11 + i ] + 32 ) >> 6 ) ; } blkOff += blkStride ; w00 += picW ; w01 += picW ; w10 += picW ; w11 += picW ; } }


Input: Decode an array of 4 bit element IDs optionally interleaved with a stereo / mono switching bit . [CODESPLIT] private void decodeChannelMap ( ChannelMapping layout_map [ ] , int offset , ChannelPosition type , BitReader _in , int n ) { while ( n -- > 0 ) { RawDataBlockType syn_ele = null ; switch ( type ) { case AAC_CHANNEL_FRONT : case AAC_CHANNEL_BACK : case AAC_CHANNEL_SIDE : syn_ele = RawDataBlockType . values ( ) [ _in . read1Bit ( ) ] ; break ; case AAC_CHANNEL_CC : _in . read1Bit ( ) ; syn_ele = RawDataBlockType . TYPE_CCE ; break ; case AAC_CHANNEL_LFE : syn_ele = RawDataBlockType . TYPE_LFE ; break ; } layout_map [ offset ] . syn_ele = syn_ele ; layout_map [ offset ] . someInt = ( int ) _in . readNBit ( 4 ) ; layout_map [ offset ] . position = type ; offset ++ ; } }


Input: Returns a profile instance for the given index . If the index is not between 1 and 23 inclusive UNKNOWN is returned . [CODESPLIT] public static Profile forInt ( int i ) { Profile p ; if ( i <= 0 || i > ALL . length ) p = UNKNOWN ; else p = ALL [ i - 1 ] ; return p ; }


Input: Converts floating point taps to fixed precision taps . [CODESPLIT] public static void normalizeAndGenerateFixedPrecision ( double [ ] taps , int precBits , short [ ] out ) { double sum = 0 ; for ( int i = 0 ; i < taps . length ; i ++ ) { sum += taps [ i ] ; } int sumFix = 0 ; int precNum = 1 << precBits ; for ( int i = 0 ; i < taps . length ; i ++ ) { double d = ( taps [ i ] * precNum ) / sum + precNum ; int s = ( int ) d ; taps [ i ] = d - s ; out [ i ] = ( short ) ( s - precNum ) ; sumFix += out [ i ] ; } long tapsTaken = 0 ; while ( sumFix < precNum ) { int maxI = - 1 ; for ( int i = 0 ; i < taps . length ; i ++ ) { if ( ( tapsTaken & ( 1 << i ) ) == 0 && ( maxI == - 1 || taps [ i ] > taps [ maxI ] ) ) maxI = i ; } out [ maxI ] ++ ; sumFix ++ ; tapsTaken |= ( 1 << maxI ) ; } for ( int i = 0 ; i < taps . length ; i ++ ) { taps [ i ] += out [ i ] ; if ( ( tapsTaken & ( 1 << i ) ) != 0 ) taps [ i ] -= 1 ; } }


Input: Wrong usage of Javascript keyword : in [CODESPLIT] public void resample ( Picture src , Picture dst ) { int [ ] temp = tempBuffers . get ( ) ; int taps = nTaps ( ) ; if ( temp == null ) { temp = new int [ toSize . getWidth ( ) * ( fromSize . getHeight ( ) + taps ) ] ; tempBuffers . set ( temp ) ; } for ( int p = 0 ; p < src . getColor ( ) . nComp ; p ++ ) { // Horizontal pass for ( int y = 0 ; y < src . getPlaneHeight ( p ) + taps ; y ++ ) { for ( int x = 0 ; x < dst . getPlaneWidth ( p ) ; x ++ ) { short [ ] tapsXs = getTapsX ( x ) ; int srcX = ( int ) ( scaleFactorX * x ) - taps / 2 + 1 ; int sum = 0 ; for ( int i = 0 ; i < taps ; i ++ ) { sum += ( getPel ( src , p , srcX + i , y - taps / 2 + 1 ) + 128 ) * tapsXs [ i ] ; } temp [ y * toSize . getWidth ( ) + x ] = sum ; } } // Vertical pass for ( int y = 0 ; y < dst . getPlaneHeight ( p ) ; y ++ ) { for ( int x = 0 ; x < dst . getPlaneWidth ( p ) ; x ++ ) { short [ ] tapsYs = getTapsY ( y ) ; int srcY = ( int ) ( scaleFactorY * y ) ; int sum = 0 ; for ( int i = 0 ; i < taps ; i ++ ) { sum += temp [ x + ( srcY + i ) * toSize . getWidth ( ) ] * tapsYs [ i ] ; } dst . getPlaneData ( p ) [ y * dst . getPlaneWidth ( p ) + x ] = ( byte ) ( MathUtil . clip ( ( sum + 8192 ) >> 14 , 0 , 255 ) - 128 ) ; } } } }


Input: / * parameter is also called k0 [CODESPLIT] public static int qmf_start_channel ( int bs_start_freq , int bs_samplerate_mode , SampleFrequency sample_rate ) { int startMin = startMinTable [ sample_rate . getIndex ( ) ] ; int offsetIndex = offsetIndexTable [ sample_rate . getIndex ( ) ] ; if ( bs_samplerate_mode != 0 ) { return startMin + OFFSET [ offsetIndex ] [ bs_start_freq ] ; } else { return startMin + OFFSET [ 6 ] [ bs_start_freq ] ; } }


Input: / * parameter is also called k2 [CODESPLIT] public static int qmf_stop_channel ( int bs_stop_freq , SampleFrequency sample_rate , int k0 ) { if ( bs_stop_freq == 15 ) { return Math . min ( 64 , k0 * 3 ) ; } else if ( bs_stop_freq == 14 ) { return Math . min ( 64 , k0 * 2 ) ; } else { int stopMin = stopMinTable [ sample_rate . getIndex ( ) ] ; /* bs_stop_freq <= 13 */ return Math . min ( 64 , stopMin + STOP_OFFSET_TABLE [ sample_rate . getIndex ( ) ] [ Math . min ( bs_stop_freq , 13 ) ] ) ; } }


Input: / * calculate the master frequency table from k0 k2 bs_freq_scale and bs_alter_scale [CODESPLIT] public static int master_frequency_table_fs0 ( SBR sbr , int k0 , int k2 , boolean bs_alter_scale ) { int incr ; int k ; int dk ; int nrBands , k2Achieved ; int k2Diff ; int [ ] vDk = new int [ 64 ] ; /* mft only defined for k2 > k0 */ if ( k2 <= k0 ) { sbr . N_master = 0 ; return 1 ; } dk = bs_alter_scale ? 2 : 1 ; if ( bs_alter_scale ) { nrBands = ( ( ( k2 - k0 + 2 ) >> 2 ) << 1 ) ; } else { nrBands = ( ( ( k2 - k0 ) >> 1 ) << 1 ) ; } nrBands = Math . min ( nrBands , 63 ) ; if ( nrBands <= 0 ) return 1 ; k2Achieved = k0 + nrBands * dk ; k2Diff = k2 - k2Achieved ; for ( k = 0 ; k < nrBands ; k ++ ) { vDk [ k ] = dk ; } if ( k2Diff != 0 ) { incr = ( k2Diff > 0 ) ? - 1 : 1 ; k = ( ( k2Diff > 0 ) ? ( nrBands - 1 ) : 0 ) ; while ( k2Diff != 0 ) { vDk [ k ] -= incr ; k += incr ; k2Diff += incr ; } } sbr . f_master [ 0 ] = k0 ; for ( k = 1 ; k <= nrBands ; k ++ ) { sbr . f_master [ k ] = ( sbr . f_master [ k - 1 ] + vDk [ k - 1 ] ) ; } sbr . N_master = nrBands ; sbr . N_master = Math . min ( sbr . N_master , 64 ) ; return 0 ; }


Input: / * This function finds the number of bands using this formula : bands * log ( a1 / a0 ) / log ( 2 . 0 ) + 0 . 5 [CODESPLIT] public static int find_bands ( int warp , int bands , int a0 , int a1 ) { float div = ( float ) Math . log ( 2.0 ) ; if ( warp != 0 ) div *= 1.3f ; return ( int ) ( bands * Math . log ( ( float ) a1 / ( float ) a0 ) / div + 0.5 ) ; }


Input: / * version for bs_freq_scale > 0 [CODESPLIT] public static int master_frequency_table ( SBR sbr , int k0 , int k2 , int bs_freq_scale , boolean bs_alter_scale ) { int k , bands ; boolean twoRegions ; int k1 ; int nrBand0 , nrBand1 ; int [ ] vDk0 = new int [ 64 ] , vDk1 = new int [ 64 ] ; int [ ] vk0 = new int [ 64 ] , vk1 = new int [ 64 ] ; int [ ] temp1 = { 6 , 5 , 4 } ; float q , qk ; int A_1 ; /* mft only defined for k2 > k0 */ if ( k2 <= k0 ) { sbr . N_master = 0 ; return 1 ; } bands = temp1 [ bs_freq_scale - 1 ] ; if ( ( float ) k2 / ( float ) k0 > 2.2449 ) { twoRegions = true ; k1 = k0 << 1 ; } else { twoRegions = false ; k1 = k2 ; } nrBand0 = ( 2 * find_bands ( 0 , bands , k0 , k1 ) ) ; nrBand0 = Math . min ( nrBand0 , 63 ) ; if ( nrBand0 <= 0 ) return 1 ; q = find_initial_power ( nrBand0 , k0 , k1 ) ; qk = k0 ; A_1 = ( int ) ( qk + 0.5f ) ; for ( k = 0 ; k <= nrBand0 ; k ++ ) { int A_0 = A_1 ; qk *= q ; A_1 = ( int ) ( qk + 0.5f ) ; vDk0 [ k ] = A_1 - A_0 ; } /* needed? */ //qsort(vDk0, nrBand0, sizeof(vDk0[0]), longcmp); Arrays . sort ( vDk0 , 0 , nrBand0 ) ; vk0 [ 0 ] = k0 ; for ( k = 1 ; k <= nrBand0 ; k ++ ) { vk0 [ k ] = vk0 [ k - 1 ] + vDk0 [ k - 1 ] ; if ( vDk0 [ k - 1 ] == 0 ) return 1 ; } if ( ! twoRegions ) { for ( k = 0 ; k <= nrBand0 ; k ++ ) { sbr . f_master [ k ] = vk0 [ k ] ; } sbr . N_master = nrBand0 ; sbr . N_master = Math . min ( sbr . N_master , 64 ) ; return 0 ; } nrBand1 = ( 2 * find_bands ( 1 /* warped */ , bands , k1 , k2 ) ) ; nrBand1 = Math . min ( nrBand1 , 63 ) ; q = find_initial_power ( nrBand1 , k1 , k2 ) ; qk = k1 ; A_1 = ( int ) ( qk + 0.5f ) ; for ( k = 0 ; k <= nrBand1 - 1 ; k ++ ) { int A_0 = A_1 ; qk *= q ; A_1 = ( int ) ( qk + 0.5f ) ; vDk1 [ k ] = A_1 - A_0 ; } if ( vDk1 [ 0 ] < vDk0 [ nrBand0 - 1 ] ) { int change ; /* needed? */ //qsort(vDk1, nrBand1+1, sizeof(vDk1[0]), longcmp); Arrays . sort ( vDk1 , 0 , nrBand1 + 1 ) ; change = vDk0 [ nrBand0 - 1 ] - vDk1 [ 0 ] ; vDk1 [ 0 ] = vDk0 [ nrBand0 - 1 ] ; vDk1 [ nrBand1 - 1 ] = vDk1 [ nrBand1 - 1 ] - change ; } /* needed? */ //qsort(vDk1, nrBand1, sizeof(vDk1[0]), longcmp); Arrays . sort ( vDk1 , 0 , nrBand1 ) ; vk1 [ 0 ] = k1 ; for ( k = 1 ; k <= nrBand1 ; k ++ ) { vk1 [ k ] = vk1 [ k - 1 ] + vDk1 [ k - 1 ] ; if ( vDk1 [ k - 1 ] == 0 ) return 1 ; } sbr . N_master = nrBand0 + nrBand1 ; sbr . N_master = Math . min ( sbr . N_master , 64 ) ; for ( k = 0 ; k <= nrBand0 ; k ++ ) { sbr . f_master [ k ] = vk0 [ k ] ; } for ( k = nrBand0 + 1 ; k <= sbr . N_master ; k ++ ) { sbr . f_master [ k ] = vk1 [ k - nrBand0 ] ; } return 0 ; }


Input: / * calculate the derived frequency border tables from f_master [CODESPLIT] public static int derived_frequency_table ( SBR sbr , int bs_xover_band , int k2 ) { int k , i = 0 ; int minus ; /* The following relation shall be satisfied: bs_xover_band < N_Master */ if ( sbr . N_master <= bs_xover_band ) return 1 ; sbr . N_high = sbr . N_master - bs_xover_band ; sbr . N_low = ( sbr . N_high >> 1 ) + ( sbr . N_high - ( ( sbr . N_high >> 1 ) << 1 ) ) ; sbr . n [ 0 ] = sbr . N_low ; sbr . n [ 1 ] = sbr . N_high ; for ( k = 0 ; k <= sbr . N_high ; k ++ ) { sbr . f_table_res [ HI_RES ] [ k ] = sbr . f_master [ k + bs_xover_band ] ; } sbr . M = sbr . f_table_res [ HI_RES ] [ sbr . N_high ] - sbr . f_table_res [ HI_RES ] [ 0 ] ; sbr . kx = sbr . f_table_res [ HI_RES ] [ 0 ] ; if ( sbr . kx > 32 ) return 1 ; if ( sbr . kx + sbr . M > 64 ) return 1 ; minus = ( ( sbr . N_high & 1 ) != 0 ) ? 1 : 0 ; for ( k = 0 ; k <= sbr . N_low ; k ++ ) { if ( k == 0 ) i = 0 ; else i = ( 2 * k - minus ) ; sbr . f_table_res [ LO_RES ] [ k ] = sbr . f_table_res [ HI_RES ] [ i ] ; } sbr . N_Q = 0 ; if ( sbr . bs_noise_bands == 0 ) { sbr . N_Q = 1 ; } else { sbr . N_Q = ( Math . max ( 1 , find_bands ( 0 , sbr . bs_noise_bands , sbr . kx , k2 ) ) ) ; sbr . N_Q = Math . min ( 5 , sbr . N_Q ) ; } for ( k = 0 ; k <= sbr . N_Q ; k ++ ) { if ( k == 0 ) { i = 0 ; } else { /* i = i + (int32_t)((sbr.N_low - i)/(sbr.N_Q + 1 - k)); */ i += ( sbr . N_low - i ) / ( sbr . N_Q + 1 - k ) ; } sbr . f_table_noise [ k ] = sbr . f_table_res [ LO_RES ] [ i ] ; } /* build table for mapping k to g in hf patching */ for ( k = 0 ; k < 64 ; k ++ ) { int g ; for ( g = 0 ; g < sbr . N_Q ; g ++ ) { if ( ( sbr . f_table_noise [ g ] <= k ) && ( k < sbr . f_table_noise [ g + 1 ] ) ) { sbr . table_map_k_to_g [ k ] = g ; break ; } } } return 0 ; }


Input: Reads one full segment till the next marker . Will read as much data as the provided buffer fits if the provided buffer doesn t fit all data will return MORE_DATA . [CODESPLIT] public final State readToNextMarkerPartial ( ByteBuffer out ) throws IOException { if ( done ) return State . STOP ; int skipOneMarker = curMarker >= 0x100 && curMarker <= 0x1ff ? 1 : 0 ; int written = out . position ( ) ; do { while ( buf . hasRemaining ( ) ) { if ( curMarker >= 0x100 && curMarker <= 0x1ff ) { if ( skipOneMarker == 0 ) { return State . DONE ; } -- skipOneMarker ; } if ( ! out . hasRemaining ( ) ) return State . MORE_DATA ; out . put ( ( byte ) ( curMarker >>> 24 ) ) ; curMarker = ( curMarker << 8 ) | ( buf . get ( ) & 0xff ) ; } buf = NIOUtils . fetchFromChannel ( channel , fetchSize ) ; pos += buf . remaining ( ) ; } while ( buf . hasRemaining ( ) ) ; written = out . position ( ) - written ; if ( written > 0 && curMarker >= 0x100 && curMarker <= 0x1ff ) return State . DONE ; for ( ; bytesInMarker > 0 && out . hasRemaining ( ) ; ) { out . put ( ( byte ) ( curMarker >>> 24 ) ) ; curMarker = ( curMarker << 8 ) ; -- bytesInMarker ; if ( curMarker >= 0x100 && curMarker <= 0x1ff ) return State . DONE ; } if ( bytesInMarker == 0 ) { done = true ; return State . STOP ; } else { return State . MORE_DATA ; } }


Input: Reads one full segment till the next marker . Will allocate the necessary buffer to hold the full segment . Internally uses a growing collection of smaller buffers since the segment size is intitially unkwnown . [CODESPLIT] public ByteBuffer readToNextMarkerNewBuffer ( ) throws IOException { if ( done ) return null ; List < ByteBuffer > buffers = new ArrayList < ByteBuffer > ( ) ; readToNextMarkerBuffers ( buffers ) ; return NIOUtils . combineBuffers ( buffers ) ; }


Input: There is a method in the class ( or one of its parents ) having the same name with the method named [ readTree ] but is less generic [CODESPLIT] public int readTree3 ( int [ ] tree , int prob0 , int prob1 ) { int i = 0 ; if ( ( i = tree [ i + readBit ( prob0 ) ] ) > 0 ) { while ( ( i = tree [ i + readBit ( prob1 ) ] ) > 0 ) ; } return - i ; /* negate the return value */ }


Input: Finds maximum frame of a sequence by bisecting the range . [CODESPLIT] public int getMaxAvailableFrame ( ) { if ( maxAvailableFrame == - 1 ) { int firstPoint = 0 ; for ( int i = MAX_MAX ; i > 0 ; i /= 2 ) { if ( new File ( String . format ( namePattern , i ) ) . exists ( ) ) { firstPoint = i ; break ; } } int pos = firstPoint ; for ( int interv = firstPoint / 2 ; interv > 1 ; interv /= 2 ) { if ( new File ( String . format ( namePattern , pos + interv ) ) . exists ( ) ) { pos += interv ; } } maxAvailableFrame = pos ; Logger . info ( "Max frame found: " + maxAvailableFrame ) ; } return Math . min ( maxAvailableFrame , maxFrames ) ; }


Input:
Pass 2 : process rows from work array store into output array . [CODESPLIT] private static void pass2 ( IntBuffer outptr , IntBuffer wsptr ) { for ( int ctr = 0 ; ctr < DCTSIZE ; ctr ++ ) { /* Even part: reverse the even part of the forward DCT. */ /* The rotator is sqrt(2)c(-6). */ int z2 = wsptr . get ( 2 ) ; int z3 = wsptr . get ( 6 ) ; int z1 = MULTIPLY ( z2 + z3 , FIX_0_541196100 ) ; int tmp2 = z1 + MULTIPLY ( z3 , - FIX_1_847759065 ) ; int tmp3 = z1 + MULTIPLY ( z2 , FIX_0_765366865 ) ; int tmp0 = ( ( int ) wsptr . get ( 0 ) + ( int ) wsptr . get ( 4 ) ) << CONST_BITS ; int tmp1 = ( ( int ) wsptr . get ( 0 ) - ( int ) wsptr . get ( 4 ) ) << CONST_BITS ; int tmp10 = tmp0 + tmp3 ; int tmp13 = tmp0 - tmp3 ; int tmp11 = tmp1 + tmp2 ; int tmp12 = tmp1 - tmp2 ; /*
             * Odd part per figure 8; the matrix is unitary and hence its
             * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
             */ tmp0 = ( int ) wsptr . get ( 7 ) ; tmp1 = ( int ) wsptr . get ( 5 ) ; tmp2 = ( int ) wsptr . get ( 3 ) ; tmp3 = ( int ) wsptr . get ( 1 ) ; z1 = tmp0 + tmp3 ; z2 = tmp1 + tmp2 ; z3 = tmp0 + tmp2 ; int z4 = tmp1 + tmp3 ; int z5 = MULTIPLY ( z3 + z4 , FIX_1_175875602 ) ; /* sqrt(2) c3 */ tmp0 = MULTIPLY ( tmp0 , FIX_0_298631336 ) ; /* sqrt(2) (-c1+c3+c5-c7) */ tmp1 = MULTIPLY ( tmp1 , FIX_2_053119869 ) ; /* sqrt(2) ( c1+c3-c5+c7) */ tmp2 = MULTIPLY ( tmp2 , FIX_3_072711026 ) ; /* sqrt(2) ( c1+c3+c5-c7) */ tmp3 = MULTIPLY ( tmp3 , FIX_1_501321110 ) ; /* sqrt(2) ( c1+c3-c5-c7) */ z1 = MULTIPLY ( z1 , - FIX_0_899976223 ) ; /* sqrt(2) (c7-c3) */ z2 = MULTIPLY ( z2 , - FIX_2_562915447 ) ; /* sqrt(2) (-c1-c3) */ z3 = MULTIPLY ( z3 , - FIX_1_961570560 ) ; /* sqrt(2) (-c3-c5) */ z4 = MULTIPLY ( z4 , - FIX_0_390180644 ) ; /* sqrt(2) (c5-c3) */ z3 += z5 ; z4 += z5 ; tmp0 += z1 + z3 ; tmp1 += z2 + z4 ; tmp2 += z2 + z3 ; tmp3 += z1 + z4 ; /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ int D = CONST_BITS + PASS1_BITS + 3 ; outptr . put ( range_limit ( DESCALE ( tmp10 + tmp3 , D ) & RANGE_MASK ) ) ; outptr . put ( range_limit ( DESCALE ( tmp11 + tmp2 , D ) & RANGE_MASK ) ) ; outptr . put ( range_limit ( DESCALE ( tmp12 + tmp1 , D ) & RANGE_MASK ) ) ; outptr . put ( range_limit ( DESCALE ( tmp13 + tmp0 , D ) & RANGE_MASK ) ) ; outptr . put ( range_limit ( DESCALE ( tmp13 - tmp0 , D ) & RANGE_MASK ) ) ; outptr . put ( range_limit ( DESCALE ( tmp12 - tmp1 , D ) & RANGE_MASK ) ) ; outptr . put ( range_limit ( DESCALE ( tmp11 - tmp2 , D ) & RANGE_MASK ) ) ; outptr . put ( range_limit ( DESCALE ( tmp10 - tmp3 , D ) & RANGE_MASK ) ) ; wsptr = doAdvance ( wsptr , DCTSIZE ) ; /* advance pointer to next row */ } }


Input: / * Allocate and fill in the sample_range_limit table [CODESPLIT] private static void prepare_range_limit_table ( ) { sample_range_limit . position ( 256 ) ; for ( int i = 0 ; i < 128 ; i ++ ) { sample_range_limit . put ( i ) ; } for ( int i = - 128 ; i < 0 ; i ++ ) { sample_range_limit . put ( i ) ; } for ( int i = 0 ; i < 256 + 128 ; i ++ ) { sample_range_limit . put ( - 1 ) ; } for ( int i = 0 ; i < 256 + 128 ; i ++ ) { sample_range_limit . put ( 0 ) ; } for ( int i = 0 ; i < 128 ; i ++ ) { sample_range_limit . put ( i ) ; } for ( int i = 0 ; i < idct_sample_range_limit . capacity ( ) ; i ++ ) { idct_sample_range_limit . put ( sample_range_limit . get ( i + 128 ) & 0xff ) ; } }


Input: Tries to modify movie header in place according to what s implemented in the edit the file gets pysically modified if the operation is successful . No temporary file is created . [CODESPLIT] public boolean modify ( File file , MP4Edit edit ) throws IOException { SeekableByteChannel fi = null ; try { fi = NIOUtils . rwChannel ( file ) ; List < Tuple . _2 < Atom , ByteBuffer > > fragments = doTheFix ( fi , edit ) ; if ( fragments == null ) return false ; // If everything is clean, only then actually writing stuff to the // file for ( Tuple . _2 < Atom , ByteBuffer > fragment : fragments ) { replaceBox ( fi , fragment . v0 , fragment . v1 ) ; } return true ; } finally { NIOUtils . closeQuietly ( fi ) ; } }


Input: Tries to modify movie header in place according to what s implemented in the edit . Copies modified contents to a new file . [CODESPLIT] public boolean copy ( File src , File dst , MP4Edit edit ) throws IOException { SeekableByteChannel fi = null ; SeekableByteChannel fo = null ; try { fi = NIOUtils . readableChannel ( src ) ; fo = NIOUtils . writableChannel ( dst ) ; List < Tuple . _2 < Atom , ByteBuffer > > fragments = doTheFix ( fi , edit ) ; if ( fragments == null ) return false ; List < _2 < Long , ByteBuffer > > fragOffsets = Tuple . _2map0 ( fragments , new Tuple . Mapper < Atom , Long > ( ) { public Long map ( Atom t ) { return t . getOffset ( ) ; } } ) ; // If everything is clean, only then actually start writing file Map < Long , ByteBuffer > rewrite = Tuple . asMap ( fragOffsets ) ; for ( Atom atom : MP4Util . getRootAtoms ( fi ) ) { ByteBuffer byteBuffer = rewrite . get ( atom . getOffset ( ) ) ; if ( byteBuffer != null ) fo . write ( byteBuffer ) ; else atom . copy ( fi , fo ) ; } return true ; } finally { NIOUtils . closeQuietly ( fi ) ; NIOUtils . closeQuietly ( fo ) ; } }


Input: / * calculate linear prediction coefficients using the covariance method [CODESPLIT] private static void calc_prediction_coef ( SBR sbr , float [ ] [ ] [ ] Xlow , float [ ] [ ] alpha_0 , float [ ] [ ] alpha_1 , int k ) { float tmp ; acorr_coef ac = new acorr_coef ( ) ; auto_correlation ( sbr , ac , Xlow , k , sbr . numTimeSlotsRate + 6 ) ; if ( ac . det == 0 ) { alpha_1 [ k ] [ 0 ] = 0 ; alpha_1 [ k ] [ 1 ] = 0 ; } else { tmp = 1.0f / ac . det ; alpha_1 [ k ] [ 0 ] = ( ( ac . r01 [ 0 ] * ac . r12 [ 0 ] ) - ( ac . r01 [ 1 ] * ac . r12 [ 1 ] ) - ( ac . r02 [ 0 ] * ac . r11 [ 0 ] ) ) * tmp ; alpha_1 [ k ] [ 1 ] = ( ( ac . r01 [ 1 ] * ac . r12 [ 0 ] ) + ( ac . r01 [ 0 ] * ac . r12 [ 1 ] ) - ( ac . r02 [ 1 ] * ac . r11 [ 0 ] ) ) * tmp ; } if ( ac . r11 [ 0 ] == 0 ) { alpha_0 [ k ] [ 0 ] = 0 ; alpha_0 [ k ] [ 1 ] = 0 ; } else { tmp = 1.0f / ac . r11 [ 0 ] ; alpha_0 [ k ] [ 0 ] = - ( ac . r01 [ 0 ] + ( alpha_1 [ k ] [ 0 ] * ac . r12 [ 0 ] ) + ( alpha_1 [ k ] [ 1 ] * ac . r12 [ 1 ] ) ) * tmp ; alpha_0 [ k ] [ 1 ] = - ( ac . r01 [ 1 ] + ( alpha_1 [ k ] [ 1 ] * ac . r12 [ 0 ] ) - ( alpha_1 [ k ] [ 0 ] * ac . r12 [ 1 ] ) ) * tmp ; } if ( ( ( alpha_0 [ k ] [ 0 ] * alpha_0 [ k ] [ 0 ] ) + ( alpha_0 [ k ] [ 1 ] * alpha_0 [ k ] [ 1 ] ) >= 16.0f ) || ( ( alpha_1 [ k ] [ 0 ] * alpha_1 [ k ] [ 0 ] ) + ( alpha_1 [ k ] [ 1 ] * alpha_1 [ k ] [ 1 ] ) >= 16.0f ) ) { alpha_0 [ k ] [ 0 ] = 0 ; alpha_0 [ k ] [ 1 ] = 0 ; alpha_1 [ k ] [ 0 ] = 0 ; alpha_1 [ k ] [ 1 ] = 0 ; } }


Input: / * FIXED POINT : bwArray = COEF [CODESPLIT] private static void calc_chirp_factors ( SBR sbr , int ch ) { int i ; for ( i = 0 ; i < sbr . N_Q ; i ++ ) { sbr . bwArray [ ch ] [ i ] = mapNewBw ( sbr . bs_invf_mode [ ch ] [ i ] , sbr . bs_invf_mode_prev [ ch ] [ i ] ) ; if ( sbr . bwArray [ ch ] [ i ] < sbr . bwArray_prev [ ch ] [ i ] ) sbr . bwArray [ ch ] [ i ] = ( sbr . bwArray [ ch ] [ i ] * 0.75f ) + ( sbr . bwArray_prev [ ch ] [ i ] * 0.25f ) ; else sbr . bwArray [ ch ] [ i ] = ( sbr . bwArray [ ch ] [ i ] * 0.90625f ) + ( sbr . bwArray_prev [ ch ] [ i ] * 0.09375f ) ; if ( sbr . bwArray [ ch ] [ i ] < 0.015625f ) sbr . bwArray [ ch ] [ i ] = 0.0f ; if ( sbr . bwArray [ ch ] [ i ] >= 0.99609375f ) sbr . bwArray [ ch ] [ i ] = 0.99609375f ; sbr . bwArray_prev [ ch ] [ i ] = sbr . bwArray [ ch ] [ i ] ; sbr . bs_invf_mode_prev [ ch ] [ i ] = sbr . bs_invf_mode [ ch ] [ i ] ; } }


Input: / * ========== decoding ========== [CODESPLIT] public void decode ( IBitStream _in , AACDecoderConfig conf , boolean commonWindow ) throws AACException { final SampleFrequency sf = conf . getSampleFrequency ( ) ; if ( sf . equals ( SampleFrequency . SAMPLE_FREQUENCY_NONE ) ) throw new AACException ( "invalid sample frequency" ) ; _in . skipBit ( ) ; //reserved windowSequence = windowSequenceFromInt ( _in . readBits ( 2 ) ) ; windowShape [ PREVIOUS ] = windowShape [ CURRENT ] ; windowShape [ CURRENT ] = _in . readBit ( ) ; windowGroupCount = 1 ; windowGroupLength [ 0 ] = 1 ; if ( windowSequence . equals ( WindowSequence . EIGHT_SHORT_SEQUENCE ) ) { maxSFB = _in . readBits ( 4 ) ; int i ; for ( i = 0 ; i < 7 ; i ++ ) { if ( _in . readBool ( ) ) windowGroupLength [ windowGroupCount - 1 ] ++ ; else { windowGroupCount ++ ; windowGroupLength [ windowGroupCount - 1 ] = 1 ; } } windowCount = 8 ; swbOffsets = SWB_OFFSET_SHORT_WINDOW [ sf . getIndex ( ) ] ; swbCount = SWB_SHORT_WINDOW_COUNT [ sf . getIndex ( ) ] ; predictionDataPresent = false ; } else { maxSFB = _in . readBits ( 6 ) ; windowCount = 1 ; swbOffsets = SWB_OFFSET_LONG_WINDOW [ sf . getIndex ( ) ] ; swbCount = SWB_LONG_WINDOW_COUNT [ sf . getIndex ( ) ] ; predictionDataPresent = _in . readBool ( ) ; if ( predictionDataPresent ) readPredictionData ( _in , conf . getProfile ( ) , sf , commonWindow ) ; } }


Input: Calculates track duration considering edits [CODESPLIT] public static long getEditedDuration ( TrakBox track ) { List < Edit > edits = track . getEdits ( ) ; if ( edits == null ) return track . getDuration ( ) ; long duration = 0 ; for ( Edit edit : edits ) { duration += edit . getDuration ( ) ; } return duration ; }


Input: Finds timevalue of a frame number [CODESPLIT] public static long frameToTimevalue ( TrakBox trak , int frameNumber ) { TimeToSampleBox stts = NodeBox . findFirstPath ( trak , TimeToSampleBox . class , Box . path ( "mdia.minf.stbl.stts" ) ) ; TimeToSampleEntry [ ] timeToSamples = stts . getEntries ( ) ; long pts = 0 ; int sttsInd = 0 , sttsSubInd = frameNumber ; while ( sttsSubInd >= timeToSamples [ sttsInd ] . getSampleCount ( ) ) { sttsSubInd -= timeToSamples [ sttsInd ] . getSampleCount ( ) ; pts += timeToSamples [ sttsInd ] . getSampleCount ( ) * timeToSamples [ sttsInd ] . getSampleDuration ( ) ; sttsInd ++ ; } return pts + timeToSamples [ sttsInd ] . getSampleDuration ( ) * sttsSubInd ; }


Input: Finds frame by timevalue [CODESPLIT] public static int timevalueToFrame ( TrakBox trak , long tv ) { TimeToSampleEntry [ ] tts = NodeBox . findFirstPath ( trak , TimeToSampleBox . class , Box . path ( "mdia.minf.stbl.stts" ) ) . getEntries ( ) ; int frame = 0 ; for ( int i = 0 ; tv > 0 && i < tts . length ; i ++ ) { long rem = tv / tts [ i ] . getSampleDuration ( ) ; tv -= tts [ i ] . getSampleCount ( ) * tts [ i ] . getSampleDuration ( ) ; frame += tv > 0 ? tts [ i ] . getSampleCount ( ) : rem ; } return frame ; }


Input: Converts media timevalue to edited timevalue [CODESPLIT] public static long mediaToEdited ( TrakBox trak , long mediaTv , int movieTimescale ) { if ( trak . getEdits ( ) == null ) return mediaTv ; long accum = 0 ; for ( Edit edit : trak . getEdits ( ) ) { if ( mediaTv < edit . getMediaTime ( ) ) return accum ; long duration = trak . rescale ( edit . getDuration ( ) , movieTimescale ) ; if ( edit . getMediaTime ( ) != - 1 && ( mediaTv >= edit . getMediaTime ( ) && mediaTv < edit . getMediaTime ( ) + duration ) ) { accum += mediaTv - edit . getMediaTime ( ) ; break ; } accum += duration ; } return accum ; }


Input: Converts edited timevalue to media timevalue [CODESPLIT] public static long editedToMedia ( TrakBox trak , long editedTv , int movieTimescale ) { if ( trak . getEdits ( ) == null ) return editedTv ; long accum = 0 ; for ( Edit edit : trak . getEdits ( ) ) { long duration = trak . rescale ( edit . getDuration ( ) , movieTimescale ) ; if ( accum + duration > editedTv ) { return edit . getMediaTime ( ) + editedTv - accum ; } accum += duration ; } return accum ; }


Input: Calculates frame number as it shows in quicktime player [CODESPLIT] public static int qtPlayerFrameNo ( MovieBox movie , int mediaFrameNo ) { TrakBox videoTrack = movie . getVideoTrack ( ) ; long editedTv = mediaToEdited ( videoTrack , frameToTimevalue ( videoTrack , mediaFrameNo ) , movie . getTimescale ( ) ) ; return tv2QTFrameNo ( movie , editedTv ) ; }


Input: Calculates and formats standard time as in Quicktime player [CODESPLIT] public static String qtPlayerTime ( MovieBox movie , int mediaFrameNo ) { TrakBox videoTrack = movie . getVideoTrack ( ) ; long editedTv = mediaToEdited ( videoTrack , frameToTimevalue ( videoTrack , mediaFrameNo ) , movie . getTimescale ( ) ) ; int sec = ( int ) ( editedTv / videoTrack . getTimescale ( ) ) ; return String . format ( "%02d" , sec / 3600 ) + "_" + String . format ( "%02d" , ( sec % 3600 ) / 60 ) + "_" + String . format ( "%02d" , sec % 60 ) ; }


Input: Calculates and formats tape timecode as in Quicktime player [CODESPLIT] public static String qtPlayerTimecodeFromMovie ( MovieBox movie , TimecodeMP4DemuxerTrack timecodeTrack , int mediaFrameNo ) throws IOException { TrakBox videoTrack = movie . getVideoTrack ( ) ; long editedTv = mediaToEdited ( videoTrack , frameToTimevalue ( videoTrack , mediaFrameNo ) , movie . getTimescale ( ) ) ; TrakBox tt = timecodeTrack . getBox ( ) ; int ttTimescale = tt . getTimescale ( ) ; long ttTv = editedToMedia ( tt , editedTv * ttTimescale / videoTrack . getTimescale ( ) , movie . getTimescale ( ) ) ; return formatTimecode ( timecodeTrack . getBox ( ) , timecodeTrack . getStartTimecode ( ) + timevalueToTimecodeFrame ( timecodeTrack . getBox ( ) , new RationalLarge ( ttTv , ttTimescale ) , movie . getTimescale ( ) ) ) ; }


Input: Calculates and formats tape timecode as in Quicktime player [CODESPLIT] public static String qtPlayerTimecode ( TimecodeMP4DemuxerTrack timecodeTrack , RationalLarge tv , int movieTimescale ) throws IOException { TrakBox tt = timecodeTrack . getBox ( ) ; int ttTimescale = tt . getTimescale ( ) ; long ttTv = editedToMedia ( tt , tv . multiplyS ( ttTimescale ) , movieTimescale ) ; return formatTimecode ( timecodeTrack . getBox ( ) , timecodeTrack . getStartTimecode ( ) + timevalueToTimecodeFrame ( timecodeTrack . getBox ( ) , new RationalLarge ( ttTv , ttTimescale ) , movieTimescale ) ) ; }


Input: Converts timevalue to frame number based on timecode track [CODESPLIT] public static int timevalueToTimecodeFrame ( TrakBox timecodeTrack , RationalLarge tv , int movieTimescale ) { TimecodeSampleEntry se = ( TimecodeSampleEntry ) timecodeTrack . getSampleEntries ( ) [ 0 ] ; return ( int ) ( ( 2 * tv . multiplyS ( se . getTimescale ( ) ) / se . getFrameDuration ( ) ) + 1 ) / 2 ; }


Input: Formats tape timecode based on frame counter [CODESPLIT] public static String formatTimecode ( TrakBox timecodeTrack , int counter ) { TimecodeSampleEntry tmcd = NodeBox . findFirstPath ( timecodeTrack , TimecodeSampleEntry . class , Box . path ( "mdia.minf.stbl.stsd.tmcd" ) ) ; byte nf = tmcd . getNumFrames ( ) ; String tc = String . format ( "%02d" , counter % nf ) ; counter /= nf ; tc = String . format ( "%02d" , counter % 60 ) + ":" + tc ; counter /= 60 ; tc = String . format ( "%02d" , counter % 60 ) + ":" + tc ; counter /= 60 ; tc = String . format ( "%02d" , counter ) + ":" + tc ; return tc ; }


Input: Creates packed 4bit list with 7 values in it [CODESPLIT] public static int _7 ( int val0 , int val1 , int val2 , int val3 , int val4 , int val5 , int val6 ) { return ( 7 << 28 ) | ( ( val0 & 0xf ) << 24 ) | ( ( val1 & 0xf ) << 20 ) | ( ( val2 & 0xf ) << 16 ) | ( ( val3 & 0xf ) << 12 ) | ( ( val4 & 0xf ) << 8 ) | ( ( val5 & 0xf ) << 4 ) | ( ( val6 & 0xf ) ) ; }


Input: Sets a 4 bit value into the list [CODESPLIT] public static int set ( int list , int val , int n ) { int cnt = ( list >> 28 ) & 0xf ; int newc = n + 1 ; cnt = newc > cnt ? newc : cnt ; return ( list & CLEAR_MASK [ n ] ) | ( ( val & 0xff ) << ( n << 2 ) ) | ( cnt << 28 ) ; }


Input: Determines if two colors match . Aside from simply comparing the objects this function also takes into account lables ANY ANY_INTERLEAVED ANY PLANAR . [CODESPLIT] public boolean matches ( ColorSpace inputColor ) { if ( inputColor == this ) return true ; if ( inputColor == ANY || this == ANY ) return true ; if ( ( inputColor == ANY_INTERLEAVED || this == ANY_INTERLEAVED || inputColor == ANY_PLANAR || this == ANY_PLANAR ) && inputColor . planar == this . planar ) return true ; return false ; }


Input: Calculates the component size based on the fullt size and color subsampling of the given component index . [CODESPLIT] public Size compSize ( Size size , int comp ) { if ( compWidth [ comp ] == 0 && compHeight [ comp ] == 0 ) return size ; return new Size ( size . getWidth ( ) >> compWidth [ comp ] , size . getHeight ( ) >> compHeight [ comp ] ) ; }


Input: Get frame at current position in JCodec native image [CODESPLIT] public PictureWithMetadata getNativeFrameWithMetadata ( ) throws IOException { Packet frame = videoTrack . nextFrame ( ) ; if ( frame == null ) return null ; Picture picture = decoder . decodeFrame ( frame , getBuffer ( ) ) ; return new PictureWithMetadata ( picture , frame . getPtsD ( ) , frame . getDurationD ( ) , videoTrack . getMeta ( ) . getOrientation ( ) ) ; }


Input: Get frame at current position in JCodec native image [CODESPLIT] public Picture getNativeFrame ( ) throws IOException { Packet frame = videoTrack . nextFrame ( ) ; if ( frame == null ) return null ; return decoder . decodeFrame ( frame , getBuffer ( ) ) ; }


Input: Get frame at a specified second as JCodec image [CODESPLIT] public static Picture getFrameAtSec ( File file , double second ) throws IOException , JCodecException { FileChannelWrapper ch = null ; try { ch = NIOUtils . readableChannel ( file ) ; return createFrameGrab ( ch ) . seekToSecondPrecise ( second ) . getNativeFrame ( ) ; } finally { NIOUtils . closeQuietly ( ch ) ; } }


Input: Get frame at a specified second as JCodec image [CODESPLIT] public static Picture getFrameFromChannelAtSec ( SeekableByteChannel file , double second ) throws JCodecException , IOException { return createFrameGrab ( file ) . seekToSecondPrecise ( second ) . getNativeFrame ( ) ; }


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


Input: Get frame at a specified frame number as JCodec image [CODESPLIT] public static Picture getFrameFromChannel ( SeekableByteChannel file , int frameNumber ) throws JCodecException , IOException { return createFrameGrab ( file ) . seekToFramePrecise ( frameNumber ) . getNativeFrame ( ) ; }


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


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


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


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


Input: does not modify packets [CODESPLIT] public static MP4Demuxer createRawMP4Demuxer ( SeekableByteChannel input ) throws IOException { return new MP4Demuxer ( input ) { @ Override protected AbstractMP4DemuxerTrack newTrack ( TrakBox trak ) { return new MP4DemuxerTrack ( movie , trak , this . input ) ; } } ; }


Input: only for LTP : no overlapping no short blocks [CODESPLIT] public void processLTP ( WindowSequence windowSequence , int windowShape , int windowShapePrev , float [ ] _in , float [ ] out ) { int i ; switch ( windowSequence ) { case ONLY_LONG_SEQUENCE : for ( i = length - 1 ; i >= 0 ; i -- ) { buf [ i ] = _in [ i ] * LONG_WINDOWS [ windowShapePrev ] [ i ] ; buf [ i + length ] = _in [ i + length ] * LONG_WINDOWS [ windowShape ] [ length - 1 - i ] ; } break ; case LONG_START_SEQUENCE : for ( i = 0 ; i < length ; i ++ ) { buf [ i ] = _in [ i ] * LONG_WINDOWS [ windowShapePrev ] [ i ] ; } for ( i = 0 ; i < mid ; i ++ ) { buf [ i + length ] = _in [ i + length ] ; } for ( i = 0 ; i < shortLen ; i ++ ) { buf [ i + length + mid ] = _in [ i + length + mid ] * SHORT_WINDOWS [ windowShape ] [ shortLen - 1 - i ] ; } for ( i = 0 ; i < mid ; i ++ ) { buf [ i + length + mid + shortLen ] = 0 ; } break ; case LONG_STOP_SEQUENCE : for ( i = 0 ; i < mid ; i ++ ) { buf [ i ] = 0 ; } for ( i = 0 ; i < shortLen ; i ++ ) { buf [ i + mid ] = _in [ i + mid ] * SHORT_WINDOWS [ windowShapePrev ] [ i ] ; } for ( i = 0 ; i < mid ; i ++ ) { buf [ i + mid + shortLen ] = _in [ i + mid + shortLen ] ; } for ( i = 0 ; i < length ; i ++ ) { buf [ i + length ] = _in [ i + length ] * LONG_WINDOWS [ windowShape ] [ length - 1 - i ] ; } break ; } mdctLong . processForward ( buf , out ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public final void setData ( byte [ ] data ) { //make the buffer size an integer number of words final int size = WORD_BYTES * ( ( data . length + WORD_BYTES - 1 ) / WORD_BYTES ) ; //only reallocate if needed if ( buffer == null || buffer . length != size ) buffer = new byte [ size ] ; arraycopy ( data , 0 , buffer , 0 , data . length ) ; reset ( ) ; }


Input: Reads the next four bytes . [CODESPLIT] protected int readCache ( boolean peek ) throws AACException { int i ; if ( pos > buffer . length - WORD_BYTES ) throw AACException . endOfStream ( ) ; else i = ( ( buffer [ pos ] & BYTE_MASK ) << 24 ) | ( ( buffer [ pos + 1 ] & BYTE_MASK ) << 16 ) | ( ( buffer [ pos + 2 ] & BYTE_MASK ) << 8 ) | ( buffer [ pos + 3 ] & BYTE_MASK ) ; if ( ! peek ) pos += WORD_BYTES ; return i ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public int readBits ( int n ) throws AACException { int result ; if ( bitsCached >= n ) { bitsCached -= n ; result = ( cache >> bitsCached ) & maskBits ( n ) ; position += n ; } else { position += n ; final int c = cache & maskBits ( bitsCached ) ; final int left = n - bitsCached ; cache = readCache ( false ) ; bitsCached = WORD_BITS - left ; result = ( ( cache >> bitsCached ) & maskBits ( left ) ) | ( c << left ) ; } return result ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public int readBit ( ) throws AACException { int i ; if ( bitsCached > 0 ) { bitsCached -- ; i = ( cache >> ( bitsCached ) ) & 1 ; position ++ ; } else { cache = readCache ( false ) ; bitsCached = WORD_BITS - 1 ; position ++ ; i = ( cache >> bitsCached ) & 1 ; } return i ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public int peekBits ( int n ) throws AACException { int ret ; if ( bitsCached >= n ) { ret = ( cache >> ( bitsCached - n ) ) & maskBits ( n ) ; } else { //old cache final int c = cache & maskBits ( bitsCached ) ; n -= bitsCached ; //read next & combine ret = ( ( readCache ( true ) >> WORD_BITS - n ) & maskBits ( n ) ) | ( c << n ) ; } return ret ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public int peekBit ( ) throws AACException { int ret ; if ( bitsCached > 0 ) { ret = ( cache >> ( bitsCached - 1 ) ) & 1 ; } else { final int word = readCache ( true ) ; ret = ( word >> WORD_BITS - 1 ) & 1 ; } return ret ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public void skipBits ( int n ) throws AACException { position += n ; if ( n <= bitsCached ) { bitsCached -= n ; } else { n -= bitsCached ; while ( n >= WORD_BITS ) { n -= WORD_BITS ; readCache ( false ) ; } if ( n > 0 ) { cache = readCache ( false ) ; bitsCached = WORD_BITS - n ; } else { cache = 0 ; bitsCached = 0 ; } } }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public void skipBit ( ) throws AACException { position ++ ; if ( bitsCached > 0 ) { bitsCached -- ; } else { cache = readCache ( false ) ; bitsCached = WORD_BITS - 1 ; } }


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


Input: 6 * 16 * 2 + 10 * 8 + 4 * 16 * 2 = 192 + 80 + 128 = 400 additions [CODESPLIT] private static void fft_dif ( float [ ] Real , float [ ] Imag ) { float w_real , w_imag ; // For faster access float point1_real , point1_imag , point2_real , point2_imag ; // For faster access int j , i , i2 , w_index ; // Counters // First 2 stages of 32 point FFT decimation in frequency // 4*16*2=64*2=128 multiplications // 6*16*2=96*2=192 additions // Stage 1 of 32 point FFT decimation in frequency for ( i = 0 ; i < 16 ; i ++ ) { point1_real = Real [ i ] ; point1_imag = Imag [ i ] ; i2 = i + 16 ; point2_real = Real [ i2 ] ; point2_imag = Imag [ i2 ] ; w_real = w_array_real [ i ] ; w_imag = w_array_imag [ i ] ; // temp1 = x[i] - x[i2] point1_real -= point2_real ; point1_imag -= point2_imag ; // x[i1] = x[i] + x[i2] Real [ i ] += point2_real ; Imag [ i ] += point2_imag ; // x[i2] = (x[i] - x[i2]) * w Real [ i2 ] = ( ( point1_real * w_real ) - ( point1_imag * w_imag ) ) ; Imag [ i2 ] = ( ( point1_real * w_imag ) + ( point1_imag * w_real ) ) ; } // Stage 2 of 32 point FFT decimation in frequency for ( j = 0 , w_index = 0 ; j < 8 ; j ++ , w_index += 2 ) { w_real = w_array_real [ w_index ] ; w_imag = w_array_imag [ w_index ] ; i = j ; point1_real = Real [ i ] ; point1_imag = Imag [ i ] ; i2 = i + 8 ; point2_real = Real [ i2 ] ; point2_imag = Imag [ i2 ] ; // temp1 = x[i] - x[i2] point1_real -= point2_real ; point1_imag -= point2_imag ; // x[i1] = x[i] + x[i2] Real [ i ] += point2_real ; Imag [ i ] += point2_imag ; // x[i2] = (x[i] - x[i2]) * w Real [ i2 ] = ( ( point1_real * w_real ) - ( point1_imag * w_imag ) ) ; Imag [ i2 ] = ( ( point1_real * w_imag ) + ( point1_imag * w_real ) ) ; i = j + 16 ; point1_real = Real [ i ] ; point1_imag = Imag [ i ] ; i2 = i + 8 ; point2_real = Real [ i2 ] ; point2_imag = Imag [ i2 ] ; // temp1 = x[i] - x[i2] point1_real -= point2_real ; point1_imag -= point2_imag ; // x[i1] = x[i] + x[i2] Real [ i ] += point2_real ; Imag [ i ] += point2_imag ; // x[i2] = (x[i] - x[i2]) * w Real [ i2 ] = ( ( point1_real * w_real ) - ( point1_imag * w_imag ) ) ; Imag [ i2 ] = ( ( point1_real * w_imag ) + ( point1_imag * w_real ) ) ; } // Stage 3 of 32 point FFT decimation in frequency // 2*4*2=16 multiplications // 4*4*2+6*4*2=10*8=80 additions for ( i = 0 ; i < n ; i += 8 ) { i2 = i + 4 ; point1_real = Real [ i ] ; point1_imag = Imag [ i ] ; point2_real = Real [ i2 ] ; point2_imag = Imag [ i2 ] ; // out[i1] = point1 + point2 Real [ i ] += point2_real ; Imag [ i ] += point2_imag ; // out[i2] = point1 - point2 Real [ i2 ] = point1_real - point2_real ; Imag [ i2 ] = point1_imag - point2_imag ; } w_real = w_array_real [ 4 ] ; // = sqrt(2)/2 // w_imag = -w_real; // = w_array_imag[4]; // = -sqrt(2)/2 for ( i = 1 ; i < n ; i += 8 ) { i2 = i + 4 ; point1_real = Real [ i ] ; point1_imag = Imag [ i ] ; point2_real = Real [ i2 ] ; point2_imag = Imag [ i2 ] ; // temp1 = x[i] - x[i2] point1_real -= point2_real ; point1_imag -= point2_imag ; // x[i1] = x[i] + x[i2] Real [ i ] += point2_real ; Imag [ i ] += point2_imag ; // x[i2] = (x[i] - x[i2]) * w Real [ i2 ] = ( point1_real + point1_imag ) * w_real ; Imag [ i2 ] = ( point1_imag - point1_real ) * w_real ; } for ( i = 2 ; i < n ; i += 8 ) { i2 = i + 4 ; point1_real = Real [ i ] ; point1_imag = Imag [ i ] ; point2_real = Real [ i2 ] ; point2_imag = Imag [ i2 ] ; // x[i] = x[i] + x[i2] Real [ i ] += point2_real ; Imag [ i ] += point2_imag ; // x[i2] = (x[i] - x[i2]) * (-i) Real [ i2 ] = point1_imag - point2_imag ; Imag [ i2 ] = point2_real - point1_real ; } w_real = w_array_real [ 12 ] ; // = -sqrt(2)/2 // w_imag = w_real; // = w_array_imag[12]; // = -sqrt(2)/2 for ( i = 3 ; i < n ; i += 8 ) { i2 = i + 4 ; point1_real = Real [ i ] ; point1_imag = Imag [ i ] ; point2_real = Real [ i2 ] ; point2_imag = Imag [ i2 ] ; // temp1 = x[i] - x[i2] point1_real -= point2_real ; point1_imag -= point2_imag ; // x[i1] = x[i] + x[i2] Real [ i ] += point2_real ; Imag [ i ] += point2_imag ; // x[i2] = (x[i] - x[i2]) * w Real [ i2 ] = ( point1_real - point1_imag ) * w_real ; Imag [ i2 ] = ( point1_real + point1_imag ) * w_real ; } // Stage 4 of 32 point FFT decimation in frequency (no multiplications) // 16*4=64 additions for ( i = 0 ; i < n ; i += 4 ) { i2 = i + 2 ; point1_real = Real [ i ] ; point1_imag = Imag [ i ] ; point2_real = Real [ i2 ] ; point2_imag = Imag [ i2 ] ; // x[i1] = x[i] + x[i2] Real [ i ] += point2_real ; Imag [ i ] += point2_imag ; // x[i2] = x[i] - x[i2] Real [ i2 ] = point1_real - point2_real ; Imag [ i2 ] = point1_imag - point2_imag ; } for ( i = 1 ; i < n ; i += 4 ) { i2 = i + 2 ; point1_real = Real [ i ] ; point1_imag = Imag [ i ] ; point2_real = Real [ i2 ] ; point2_imag = Imag [ i2 ] ; // x[i] = x[i] + x[i2] Real [ i ] += point2_real ; Imag [ i ] += point2_imag ; // x[i2] = (x[i] - x[i2]) * (-i) Real [ i2 ] = point1_imag - point2_imag ; Imag [ i2 ] = point2_real - point1_real ; } // Stage 5 of 32 point FFT decimation in frequency (no multiplications) // 16*4=64 additions for ( i = 0 ; i < n ; i += 2 ) { i2 = i + 1 ; point1_real = Real [ i ] ; point1_imag = Imag [ i ] ; point2_real = Real [ i2 ] ; point2_imag = Imag [ i2 ] ; // out[i1] = point1 + point2 Real [ i ] += point2_real ; Imag [ i ] += point2_imag ; // out[i2] = point1 - point2 Real [ i2 ] = point1_real - point2_real ; Imag [ i2 ] = point1_imag - point2_imag ; } //FFTReorder(Real, Imag); }


Input: / * size 64 only! [CODESPLIT] public static void dct4_kernel ( float [ ] in_real , float [ ] in_imag , float [ ] out_real , float [ ] out_imag ) { // Tables with bit reverse values for 5 bits, bit reverse of i at i-th position int i , i_rev ; /* Step 2: modulate */ // 3*32=96 multiplications // 3*32=96 additions for ( i = 0 ; i < 32 ; i ++ ) { float x_re , x_im , tmp ; x_re = in_real [ i ] ; x_im = in_imag [ i ] ; tmp = ( x_re + x_im ) * dct4_64_tab [ i ] ; in_real [ i ] = ( x_im * dct4_64_tab [ i + 64 ] ) + tmp ; in_imag [ i ] = ( x_re * dct4_64_tab [ i + 32 ] ) + tmp ; } /* Step 3: FFT, but with output in bit reverse order */ fft_dif ( in_real , in_imag ) ; /* Step 4: modulate + bitreverse reordering */ // 3*31+2=95 multiplications // 3*31+2=95 additions for ( i = 0 ; i < 16 ; i ++ ) { float x_re , x_im , tmp ; i_rev = bit_rev_tab [ i ] ; x_re = in_real [ i_rev ] ; x_im = in_imag [ i_rev ] ; tmp = ( x_re + x_im ) * dct4_64_tab [ i + 3 * 32 ] ; out_real [ i ] = ( x_im * dct4_64_tab [ i + 5 * 32 ] ) + tmp ; out_imag [ i ] = ( x_re * dct4_64_tab [ i + 4 * 32 ] ) + tmp ; } // i = 16, i_rev = 1 = rev(16); out_imag [ 16 ] = ( in_imag [ 1 ] - in_real [ 1 ] ) * dct4_64_tab [ 16 + 3 * 32 ] ; out_real [ 16 ] = ( in_real [ 1 ] + in_imag [ 1 ] ) * dct4_64_tab [ 16 + 3 * 32 ] ; for ( i = 17 ; i < 32 ; i ++ ) { float x_re , x_im , tmp ; i_rev = bit_rev_tab [ i ] ; x_re = in_real [ i_rev ] ; x_im = in_imag [ i_rev ] ; tmp = ( x_re + x_im ) * dct4_64_tab [ i + 3 * 32 ] ; out_real [ i ] = ( x_im * dct4_64_tab [ i + 5 * 32 ] ) + tmp ; out_imag [ i ] = ( x_re * dct4_64_tab [ i + 4 * 32 ] ) + tmp ; } }


Input: Creates wav header for the specified audio format [CODESPLIT] public static WavHeader createWavHeader ( AudioFormat format , int samples ) { WavHeader w = new WavHeader ( "RIFF" , 40 , "WAVE" , new FmtChunk ( ( short ) 1 , ( short ) format . getChannels ( ) , format . getSampleRate ( ) , format . getSampleRate ( ) * format . getChannels ( ) * ( format . getSampleSizeInBits ( ) >> 3 ) , ( short ) ( format . getChannels ( ) * ( format . getSampleSizeInBits ( ) >> 3 ) ) , ( short ) format . getSampleSizeInBits ( ) ) , 44 , calcDataSize ( format . getChannels ( ) , format . getSampleSizeInBits ( ) >> 3 , samples ) ) ; return w ; }


Input: Takes single channel wavs as input produces multi channel wav [CODESPLIT] public static WavHeader multiChannelWav ( WavHeader [ ] headers ) { WavHeader w = emptyWavHeader ( ) ; int totalSize = 0 ; for ( int i = 0 ; i < headers . length ; i ++ ) { WavHeader wavHeader = headers [ i ] ; totalSize += wavHeader . dataSize ; } w . dataSize = totalSize ; FmtChunk fmt = headers [ 0 ] . fmt ; int bitsPerSample = fmt . bitsPerSample ; int bytesPerSample = bitsPerSample / 8 ; int sampleRate = ( int ) fmt . sampleRate ; w . fmt . bitsPerSample = ( short ) bitsPerSample ; w . fmt . blockAlign = ( short ) ( headers . length * bytesPerSample ) ; w . fmt . byteRate = headers . length * bytesPerSample * sampleRate ; w . fmt . numChannels = ( short ) headers . length ; w . fmt . sampleRate = sampleRate ; return w ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public int readNBit ( int n ) throws IOException { if ( n > 32 ) throw new IllegalArgumentException ( "Can not read more then 32 bit" ) ; int val = 0 ; for ( int i = 0 ; i < n ; i ++ ) { val <<= 1 ; val |= read1BitInt ( ) ; } return val ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public boolean moreRBSPData ( ) throws IOException { if ( nBit == 8 ) { advance ( ) ; } int tail = 1 << ( 8 - nBit - 1 ) ; int mask = ( ( tail << 1 ) - 1 ) ; boolean hasTail = ( curByte & mask ) == tail ; return ! ( curByte == - 1 || ( nextByte == - 1 && hasTail ) ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public int peakNextBits ( int n ) throws IOException { if ( n > 8 ) throw new IllegalArgumentException ( "N should be less then 8" ) ; if ( nBit == 8 ) { advance ( ) ; if ( curByte == - 1 ) { return - 1 ; } } int [ ] bits = new int [ 16 - nBit ] ; int cnt = 0 ; for ( int i = nBit ; i < 8 ; i ++ ) { bits [ cnt ++ ] = ( curByte >> ( 7 - i ) ) & 0x1 ; } for ( int i = 0 ; i < 8 ; i ++ ) { bits [ cnt ++ ] = ( nextByte >> ( 7 - i ) ) & 0x1 ; } int result = 0 ; for ( int i = 0 ; i < n ; i ++ ) { result <<= 1 ; result |= bits [ i ] ; } return result ; }


Input: Wrong usage of Javascript keyword : in [CODESPLIT] static MP3SideInfo readSideInfo ( MpaHeader header , ByteBuffer src , int channels ) { MP3SideInfo si = new MP3SideInfo ( ) ; BitReader stream = BitReader . createBitReader ( src ) ; if ( header . version == MPEG1 ) { si . mainDataBegin = stream . readNBit ( 9 ) ; if ( channels == 1 ) si . privateBits = stream . readNBit ( 5 ) ; else si . privateBits = stream . readNBit ( 3 ) ; for ( int ch = 0 ; ch < channels ; ch ++ ) { si . scfsi [ ch ] [ 0 ] = stream . read1Bit ( ) == 0 ; si . scfsi [ ch ] [ 1 ] = stream . read1Bit ( ) == 0 ; si . scfsi [ ch ] [ 2 ] = stream . read1Bit ( ) == 0 ; si . scfsi [ ch ] [ 3 ] = stream . read1Bit ( ) == 0 ; } for ( int gr = 0 ; gr < 2 ; gr ++ ) { for ( int ch = 0 ; ch < channels ; ch ++ ) { Granule granule = si . granule [ ch ] [ gr ] ; granule . part23Length = stream . readNBit ( 12 ) ; granule . bigValues = stream . readNBit ( 9 ) ; granule . globalGain = stream . readNBit ( 8 ) ; granule . scalefacCompress = stream . readNBit ( 4 ) ; granule . windowSwitchingFlag = stream . readNBit ( 1 ) != 0 ; if ( granule . windowSwitchingFlag ) { granule . blockType = stream . readNBit ( 2 ) ; granule . mixedBlockFlag = stream . readNBit ( 1 ) != 0 ; granule . tableSelect [ 0 ] = stream . readNBit ( 5 ) ; granule . tableSelect [ 1 ] = stream . readNBit ( 5 ) ; granule . subblockGain [ 0 ] = stream . readNBit ( 3 ) ; granule . subblockGain [ 1 ] = stream . readNBit ( 3 ) ; granule . subblockGain [ 2 ] = stream . readNBit ( 3 ) ; if ( granule . blockType == 0 ) { return null ; } else if ( granule . blockType == 2 && ! granule . mixedBlockFlag ) { granule . region0Count = 8 ; } else { granule . region0Count = 7 ; } granule . region1Count = 20 - granule . region0Count ; } else { granule . tableSelect [ 0 ] = stream . readNBit ( 5 ) ; granule . tableSelect [ 1 ] = stream . readNBit ( 5 ) ; granule . tableSelect [ 2 ] = stream . readNBit ( 5 ) ; granule . region0Count = stream . readNBit ( 4 ) ; granule . region1Count = stream . readNBit ( 3 ) ; granule . blockType = 0 ; } granule . preflag = stream . readNBit ( 1 ) != 0 ; granule . scalefacScale = stream . readNBit ( 1 ) ; granule . count1tableSelect = stream . readNBit ( 1 ) ; } } } else { si . mainDataBegin = stream . readNBit ( 8 ) ; if ( channels == 1 ) si . privateBits = stream . readNBit ( 1 ) ; else si . privateBits = stream . readNBit ( 2 ) ; for ( int ch = 0 ; ch < channels ; ch ++ ) { Granule granule = si . granule [ ch ] [ 0 ] ; granule . part23Length = stream . readNBit ( 12 ) ; granule . bigValues = stream . readNBit ( 9 ) ; granule . globalGain = stream . readNBit ( 8 ) ; granule . scalefacCompress = stream . readNBit ( 9 ) ; granule . windowSwitchingFlag = stream . readNBit ( 1 ) != 0 ; if ( granule . windowSwitchingFlag ) { granule . blockType = stream . readNBit ( 2 ) ; granule . mixedBlockFlag = stream . readNBit ( 1 ) != 0 ; granule . tableSelect [ 0 ] = stream . readNBit ( 5 ) ; granule . tableSelect [ 1 ] = stream . readNBit ( 5 ) ; granule . subblockGain [ 0 ] = stream . readNBit ( 3 ) ; granule . subblockGain [ 1 ] = stream . readNBit ( 3 ) ; granule . subblockGain [ 2 ] = stream . readNBit ( 3 ) ; if ( granule . blockType == 0 ) { return null ; } else if ( granule . blockType == 2 && ! granule . mixedBlockFlag ) { granule . region0Count = 8 ; } else { granule . region0Count = 7 ; granule . region1Count = 20 - granule . region0Count ; } } else { granule . tableSelect [ 0 ] = stream . readNBit ( 5 ) ; granule . tableSelect [ 1 ] = stream . readNBit ( 5 ) ; granule . tableSelect [ 2 ] = stream . readNBit ( 5 ) ; granule . region0Count = stream . readNBit ( 4 ) ; granule . region1Count = stream . readNBit ( 3 ) ; granule . blockType = 0 ; } granule . scalefacScale = stream . readNBit ( 1 ) ; granule . count1tableSelect = stream . readNBit ( 1 ) ; } } stream . terminate ( ) ; return si ; }


Input: Reads one MPEG1 / 2 video frame from MPEG1 / 2 elementary stream into a provided buffer . [CODESPLIT] public MPEGPacket frame ( ByteBuffer buffer ) throws IOException { ByteBuffer dup = buffer . duplicate ( ) ; while ( curMarker != 0x100 && curMarker != 0x1b3 && skipToMarker ( ) ) ; while ( curMarker != 0x100 && readToNextMarker ( dup ) ) ; readToNextMarker ( dup ) ; while ( curMarker != 0x100 && curMarker != 0x1b3 && readToNextMarker ( dup ) ) ; dup . flip ( ) ; PictureHeader ph = MPEGDecoder . getPictureHeader ( dup . duplicate ( ) ) ; return dup . hasRemaining ( ) ? new MPEGPacket ( dup , 0 , 90000 , 0 , frameNo ++ , ph . picture_coding_type <= MPEGConst . IntraCoded ? FrameType . KEY : FrameType . INTER , null ) : null ; }


Input: Reads one MPEG1 / 2 video frame from MPEG1 / 2 elementary stream . [CODESPLIT] public MPEGPacket getFrame ( ) throws IOException { while ( curMarker != 0x100 && curMarker != 0x1b3 && skipToMarker ( ) ) ; List < ByteBuffer > buffers = new ArrayList < ByteBuffer > ( ) ; // Reading to the frame header, sequence header, sequence header // extensions and group header go in here while ( curMarker != 0x100 && ! done ) readToNextMarkerBuffers ( buffers ) ; // Reading the frame header readToNextMarkerBuffers ( buffers ) ; // Reading the slices, will stop on encounter of a frame header of the // next frame or a sequence header while ( curMarker != 0x100 && curMarker != 0x1b3 && ! done ) readToNextMarkerBuffers ( buffers ) ; ByteBuffer dup = NIOUtils . combineBuffers ( buffers ) ; PictureHeader ph = MPEGDecoder . getPictureHeader ( dup . duplicate ( ) ) ; return dup . hasRemaining ( ) ? new MPEGPacket ( dup , 0 , 90000 , 0 , frameNo ++ , ph . picture_coding_type <= MPEGConst . IntraCoded ? FrameType . KEY : FrameType . INTER , null ) : null ; }


Input: Parses the input arrays as a DecoderSpecificInfo as used in MP4 containers . [CODESPLIT] public static AACDecoderConfig parseMP4DecoderSpecificInfo ( byte [ ] data ) throws AACException { final IBitStream _in = BitStream . createBitStream ( data ) ; final AACDecoderConfig config = new AACDecoderConfig ( ) ; try { config . profile = readProfile ( _in ) ; int sf = _in . readBits ( 4 ) ; if ( sf == 0xF ) config . sampleFrequency = SampleFrequency . forFrequency ( _in . readBits ( 24 ) ) ; else config . sampleFrequency = SampleFrequency . forInt ( sf ) ; config . channelConfiguration = ChannelConfiguration . forInt ( _in . readBits ( 4 ) ) ; Profile cp = config . profile ; if ( AAC_SBR == cp ) { config . extProfile = cp ; config . sbrPresent = true ; sf = _in . readBits ( 4 ) ; //TODO: 24 bits already read; read again? //if(sf==0xF) config.sampleFrequency = SampleFrequency.forFrequency(_in.readBits(24)); //if sample frequencies are the same: downsample SBR config . downSampledSBR = config . sampleFrequency . getIndex ( ) == sf ; config . sampleFrequency = SampleFrequency . forInt ( sf ) ; config . profile = readProfile ( _in ) ; } else if ( AAC_MAIN == cp || AAC_LC == cp || AAC_SSR == cp || AAC_LTP == cp || ER_AAC_LC == cp || ER_AAC_LTP == cp || ER_AAC_LD == cp ) { //ga-specific info: config . frameLengthFlag = _in . readBool ( ) ; if ( config . frameLengthFlag ) throw new AACException ( "config uses 960-sample frames, not yet supported" ) ; //TODO: are 960-frames working yet? config . dependsOnCoreCoder = _in . readBool ( ) ; if ( config . dependsOnCoreCoder ) config . coreCoderDelay = _in . readBits ( 14 ) ; else config . coreCoderDelay = 0 ; config . extensionFlag = _in . readBool ( ) ; if ( config . extensionFlag ) { if ( cp . isErrorResilientProfile ( ) ) { config . sectionDataResilience = _in . readBool ( ) ; config . scalefactorResilience = _in . readBool ( ) ; config . spectralDataResilience = _in . readBool ( ) ; } //extensionFlag3 _in . skipBit ( ) ; } if ( config . channelConfiguration == ChannelConfiguration . CHANNEL_CONFIG_NONE ) { //TODO: is this working correct? -> ISO 14496-3 part 1: 1.A.4.3 _in . skipBits ( 3 ) ; //PCE PCE pce = new PCE ( ) ; pce . decode ( _in ) ; config . profile = pce . getProfile ( ) ; config . sampleFrequency = pce . getSampleFrequency ( ) ; config . channelConfiguration = ChannelConfiguration . forInt ( pce . getChannelCount ( ) ) ; } if ( _in . getBitsLeft ( ) > 10 ) readSyncExtension ( _in , config ) ; } else { throw new AACException ( "profile not supported: " + cp . getIndex ( ) ) ; } return config ; } finally { _in . destroy ( ) ; } }


Input: Encodes one symbol either 0 or 1 [CODESPLIT] public void encode ( int symbol , Context cm ) throws IOException { int rangeLps = MQConst . pLps [ cm . getState ( ) ] ; if ( symbol == cm . getMps ( ) ) { range -= rangeLps ; offset += rangeLps ; if ( range < 0x8000 ) { while ( range < 0x8000 ) renormalize ( ) ; cm . setState ( MQConst . transitMPS [ cm . getState ( ) ] ) ; } } else { range = rangeLps ; while ( range < 0x8000 ) renormalize ( ) ; if ( MQConst . mpsSwitch [ cm . getState ( ) ] != 0 ) cm . setMps ( 1 - cm . getMps ( ) ) ; cm . setState ( MQConst . transitLPS [ cm . getState ( ) ] ) ; } }


Input: static int i = 0 ; [CODESPLIT] private static void readDecoderPicMarking ( NALUnit nalUnit , SliceHeader sh , BitReader _in ) { if ( nalUnit . type == NALUnitType . IDR_SLICE ) { boolean noOutputOfPriorPicsFlag = readBool ( _in , "SH: no_output_of_prior_pics_flag" ) ; boolean longTermReferenceFlag = readBool ( _in , "SH: long_term_reference_flag" ) ; sh . refPicMarkingIDR = new RefPicMarkingIDR ( noOutputOfPriorPicsFlag , longTermReferenceFlag ) ; } else { boolean adaptiveRefPicMarkingModeFlag = readBool ( _in , "SH: adaptive_ref_pic_marking_mode_flag" ) ; if ( adaptiveRefPicMarkingModeFlag ) { ArrayList < Instruction > mmops = new ArrayList < Instruction > ( ) ; int memoryManagementControlOperation ; do { memoryManagementControlOperation = readUEtrace ( _in , "SH: memory_management_control_operation" ) ; Instruction instr = null ; switch ( memoryManagementControlOperation ) { case 1 : instr = new RefPicMarking . Instruction ( InstrType . REMOVE_SHORT , readUEtrace ( _in , "SH: difference_of_pic_nums_minus1" ) + 1 , 0 ) ; break ; case 2 : instr = new RefPicMarking . Instruction ( InstrType . REMOVE_LONG , readUEtrace ( _in , "SH: long_term_pic_num" ) , 0 ) ; break ; case 3 : instr = new RefPicMarking . Instruction ( InstrType . CONVERT_INTO_LONG , readUEtrace ( _in , "SH: difference_of_pic_nums_minus1" ) + 1 , readUEtrace ( _in , "SH: long_term_frame_idx" ) ) ; break ; case 4 : instr = new RefPicMarking . Instruction ( InstrType . TRUNK_LONG , readUEtrace ( _in , "SH: max_long_term_frame_idx_plus1" ) - 1 , 0 ) ; break ; case 5 : instr = new RefPicMarking . Instruction ( InstrType . CLEAR , 0 , 0 ) ; break ; case 6 : instr = new RefPicMarking . Instruction ( InstrType . MARK_LONG , readUEtrace ( _in , "SH: long_term_frame_idx" ) , 0 ) ; break ; } if ( instr != null ) mmops . add ( instr ) ; } while ( memoryManagementControlOperation != 0 ) ; sh . refPicMarkingNonIDR = new RefPicMarking ( mmops . toArray ( new Instruction [ ] { } ) ) ; } } }


Input: } [CODESPLIT] private void show ( Frame frame ) { pts = frame . getPts ( ) ; fireTimeEvent ( frame ) ; Picture src = frame . getPic ( ) ; if ( src . getColor ( ) != vo . getColorSpace ( ) ) { if ( dst == null || dst . getWidth ( ) != src . getWidth ( ) || dst . getHeight ( ) != src . getHeight ( ) ) dst = Picture . create ( src . getWidth ( ) , src . getHeight ( ) , vo . getColorSpace ( ) ) ; ColorUtil . getTransform ( src . getColor ( ) , vo . getColorSpace ( ) ) . transform ( src , dst ) ; vo . show ( dst , frame . getPixelAspect ( ) ) ; } else { vo . show ( src , frame . getPixelAspect ( ) ) ; } }


Input: Splits track on the timevalue specified [CODESPLIT] public static Pair < List < Edit > > split ( MovieBox movie , TrakBox track , long tvMv ) { return splitEdits ( track . getEdits ( ) , new Rational ( track . getTimescale ( ) , movie . getTimescale ( ) ) , tvMv ) ; }


Input: Decodes one frame of AAC data in frame mode and returns the raw PCM data . [CODESPLIT] public void decodeFrame ( byte [ ] frame , SampleBuffer buffer ) throws AACException { if ( frame != null ) _in . setData ( frame ) ; Logger . debug ( "bits left " + _in . getBitsLeft ( ) ) ; try { decode ( buffer ) ; } catch ( AACException e ) { if ( ! e . isEndOfStream ( ) ) throw e ; else Logger . warn ( "unexpected end of frame" ) ; } }


Input: Sets the endianness for the data . [CODESPLIT] public void setBigEndian ( boolean bigEndian ) { if ( bigEndian != this . bigEndian ) { byte tmp ; for ( int i = 0 ; i < data . length ; i += 2 ) { tmp = data [ i ] ; data [ i ] = data [ i + 1 ] ; data [ i + 1 ] = tmp ; } this . bigEndian = bigEndian ; } }


Input: Deblocks bottom edge of topOutMB right edge of leftOutMB and left / top and inner block edges of outMB [CODESPLIT] public void deblockMBGeneric ( EncodedMB curMB , EncodedMB leftMB , EncodedMB topMB , int [ ] [ ] vertStrength , int horizStrength [ ] [ ] ) { Picture curPix = curMB . getPixels ( ) ; if ( leftMB != null ) { Picture leftPix = leftMB . getPixels ( ) ; int avgQp = MathUtil . clip ( ( leftMB . getQp ( ) + curMB . getQp ( ) + 1 ) >> 1 , 0 , 51 ) ; deblockBorder ( vertStrength [ 0 ] , avgQp , leftPix . getPlaneData ( 0 ) , 3 , curPix . getPlaneData ( 0 ) , 0 , P_POS_V , Q_POS_V , false ) ; deblockBorderChroma ( vertStrength [ 0 ] , avgQp , leftPix . getPlaneData ( 1 ) , 3 , curPix . getPlaneData ( 1 ) , 0 , P_POS_V_CHR , Q_POS_V_CHR , false ) ; deblockBorderChroma ( vertStrength [ 0 ] , avgQp , leftPix . getPlaneData ( 2 ) , 3 , curPix . getPlaneData ( 2 ) , 0 , P_POS_V_CHR , Q_POS_V_CHR , false ) ; } for ( int i = 0 ; i < 3 ; i ++ ) { deblockBorder ( vertStrength [ i + 1 ] , curMB . getQp ( ) , curPix . getPlaneData ( 0 ) , i , curPix . getPlaneData ( 0 ) , i + 1 , P_POS_V , Q_POS_V , false ) ; deblockBorderChroma ( vertStrength [ i + 1 ] , curMB . getQp ( ) , curPix . getPlaneData ( 1 ) , i , curPix . getPlaneData ( 1 ) , i + 1 , P_POS_V_CHR , Q_POS_V_CHR , false ) ; deblockBorderChroma ( vertStrength [ i + 1 ] , curMB . getQp ( ) , curPix . getPlaneData ( 2 ) , i , curPix . getPlaneData ( 2 ) , i + 1 , P_POS_V_CHR , Q_POS_V_CHR , false ) ; } if ( topMB != null ) { Picture topPix = topMB . getPixels ( ) ; int avgQp = MathUtil . clip ( ( topMB . getQp ( ) + curMB . getQp ( ) + 1 ) >> 1 , 0 , 51 ) ; deblockBorder ( horizStrength [ 0 ] , avgQp , topPix . getPlaneData ( 0 ) , 3 , curPix . getPlaneData ( 0 ) , 0 , P_POS_H , Q_POS_H , true ) ; deblockBorderChroma ( horizStrength [ 0 ] , avgQp , topPix . getPlaneData ( 1 ) , 3 , curPix . getPlaneData ( 1 ) , 0 , P_POS_H_CHR , Q_POS_H_CHR , true ) ; deblockBorderChroma ( horizStrength [ 0 ] , avgQp , topPix . getPlaneData ( 2 ) , 3 , curPix . getPlaneData ( 2 ) , 0 , P_POS_H_CHR , Q_POS_H_CHR , true ) ; } for ( int i = 0 ; i < 3 ; i ++ ) { deblockBorder ( horizStrength [ i + 1 ] , curMB . getQp ( ) , curPix . getPlaneData ( 0 ) , i , curPix . getPlaneData ( 0 ) , i + 1 , P_POS_H , Q_POS_H , true ) ; deblockBorderChroma ( horizStrength [ i + 1 ] , curMB . getQp ( ) , curPix . getPlaneData ( 1 ) , i , curPix . getPlaneData ( 1 ) , i + 1 , P_POS_H_CHR , Q_POS_H_CHR , true ) ; deblockBorderChroma ( horizStrength [ i + 1 ] , curMB . getQp ( ) , curPix . getPlaneData ( 2 ) , i , curPix . getPlaneData ( 2 ) , i + 1 , P_POS_H_CHR , Q_POS_H_CHR , true ) ; } }


Input: Deblocks P - macroblock [CODESPLIT] public void deblockMBP ( EncodedMB cur , EncodedMB left , EncodedMB top ) { int [ ] [ ] vertStrength = new int [ 4 ] [ 4 ] ; int [ ] [ ] horizStrength = new int [ 4 ] [ 4 ] ; calcStrengthForBlocks ( cur , left , vertStrength , LOOKUP_IDX_P_V , LOOKUP_IDX_Q_V ) ; calcStrengthForBlocks ( cur , top , horizStrength , LOOKUP_IDX_P_H , LOOKUP_IDX_Q_H ) ; deblockMBGeneric ( cur , left , top , vertStrength , horizStrength ) ; }


Input: Encodes a frame into a movie . [CODESPLIT] public void encodeNativeFrame ( Picture pic ) throws IOException { if ( pic . getColor ( ) != ColorSpace . RGB ) throw new IllegalArgumentException ( "The input images is expected in RGB color." ) ; ColorSpace sinkColor = sink . getInputColor ( ) ; LoanerPicture toEncode ; if ( sinkColor != null ) { toEncode = pixelStore . getPicture ( pic . getWidth ( ) , pic . getHeight ( ) , sinkColor ) ; transform . transform ( pic , toEncode . getPicture ( ) ) ; } else { toEncode = new LoanerPicture ( pic , 0 ) ; } Packet pkt = Packet . createPacket ( null , timestamp , fps . getNum ( ) , fps . getDen ( ) , frameNo , FrameType . KEY , null ) ; sink . outputVideoFrame ( new VideoFrameWithPacket ( pkt , toEncode ) ) ; if ( sinkColor != null ) pixelStore . putBack ( toEncode ) ; timestamp += fps . getDen ( ) ; frameNo ++ ; }


Input: Encodes unsigned integer with given length [CODESPLIT] public static byte [ ] ebmlEncodeLen ( long value , int length ) { byte [ ] b = new byte [ length ] ; for ( int idx = 0 ; idx < length ; idx ++ ) { // Rightmost bytes should go to end of array to preserve big-endian notation b [ length - idx - 1 ] = ( byte ) ( ( value >>> ( 8 * idx ) ) & 0xFF L ) ; } b [ 0 ] |= 0x80 >>> ( length - 1 ) ; return b ; }


Input: This method is used mostly during reading EBML bitstream . It asnwers the question What is the length of an integer ( signed / unsigned ) encountered in the bitstream [CODESPLIT] static public int computeLength ( byte b ) { if ( b == 0x00 ) throw new RuntimeException ( "Invalid head element for ebml sequence" ) ; int i = 1 ; while ( ( b & lengthOptions [ i ] ) == 0 ) i ++ ; return i ; }


Input: This method is used mostly during writing EBML bitstream . It answers the following question How many bytes should be used to encode unsigned integer value [CODESPLIT] public static int ebmlLength ( long v ) { if ( v == 0 ) return 1 ; int length = 8 ; while ( length > 0 && ( v & ebmlLengthMasks [ length ] ) == 0 ) length -- ; return length ; }


Input: Wrong usage of Javascript keyword : in [CODESPLIT] static void oneLong ( float [ ] src , float [ ] dst ) { for ( int i = 17 ; i > 0 ; i -- ) src [ i ] += src [ i - 1 ] ; for ( int i = 17 ; i > 2 ; i -= 2 ) src [ i ] += src [ i - 2 ] ; for ( int i = 0 , k = 0 ; i < 2 ; i ++ , k += 8 ) { float tmp0 = src [ i ] + src [ i ] ; float tmp1 = tmp0 + src [ 12 + i ] ; float tmp2 = src [ 6 + i ] * factor36pt3 ; tmp [ k + 0 ] = tmp1 + src [ 4 + i ] * factor36pt2 + src [ 8 + i ] * factor36pt1 + src [ 16 + i ] * factor36pt0 ; tmp [ k + 1 ] = tmp0 + src [ 4 + i ] - src [ 8 + i ] - src [ 12 + i ] - src [ 12 + i ] - src [ 16 + i ] ; tmp [ k + 2 ] = tmp1 - src [ 4 + i ] * factor36pt0 - src [ 8 + i ] * factor36pt2 + src [ 16 + i ] * factor36pt1 ; tmp [ k + 3 ] = tmp1 - src [ 4 + i ] * factor36pt1 + src [ 8 + i ] * factor36pt0 - src [ 16 + i ] * factor36pt2 ; tmp [ k + 4 ] = src [ 2 + i ] * factor36pt4 + tmp2 + src [ 10 + i ] * factor36pt5 + src [ 14 + i ] * factor36pt6 ; tmp [ k + 5 ] = ( src [ 2 + i ] - src [ 10 + i ] - src [ 14 + i ] ) * factor36pt3 ; tmp [ k + 6 ] = src [ 2 + i ] * factor36pt5 - tmp2 - src [ 10 + i ] * factor36pt6 + src [ 14 + i ] * factor36pt4 ; tmp [ k + 7 ] = src [ 2 + i ] * factor36pt6 - tmp2 + src [ 10 + i ] * factor36pt4 - src [ 14 + i ] * factor36pt5 ; } for ( int i = 0 , j = 4 , k = 8 , l = 12 ; i < 4 ; i ++ , j ++ , k ++ , l ++ ) { float q1 = tmp [ i ] ; float q2 = tmp [ k ] ; tmp [ i ] += tmp [ j ] ; tmp [ j ] = q1 - tmp [ j ] ; tmp [ k ] = ( tmp [ k ] + tmp [ l ] ) * factor36 [ i ] ; tmp [ l ] = ( q2 - tmp [ l ] ) * factor36 [ 7 - i ] ; } for ( int i = 0 ; i < 4 ; i ++ ) { dst [ 26 - i ] = tmp [ i ] + tmp [ 8 + i ] ; dst [ 8 - i ] = tmp [ 8 + i ] - tmp [ i ] ; dst [ 27 + i ] = dst [ 26 - i ] ; dst [ 9 + i ] = - dst [ 8 - i ] ; } for ( int i = 0 ; i < 4 ; i ++ ) { dst [ 21 - i ] = tmp [ 7 - i ] + tmp [ 15 - i ] ; dst [ 3 - i ] = tmp [ 15 - i ] - tmp [ 7 - i ] ; dst [ 32 + i ] = dst [ 21 - i ] ; dst [ 14 + i ] = - dst [ 3 - i ] ; } float tmp0 = src [ 0 ] - src [ 4 ] + src [ 8 ] - src [ 12 ] + src [ 16 ] ; float tmp1 = ( src [ 1 ] - src [ 5 ] + src [ 9 ] - src [ 13 ] + src [ 17 ] ) * cos450 ; dst [ 4 ] = tmp1 - tmp0 ; dst [ 13 ] = - dst [ 4 ] ; dst [ 31 ] = dst [ 22 ] = tmp0 + tmp1 ; }


Input: Wrong usage of Javascript keyword : in [CODESPLIT] static void threeShort ( float [ ] src , float [ ] dst ) { Arrays . fill ( dst , 0.0f ) ; for ( int i = 0 , outOff = 0 ; i < 3 ; i ++ , outOff += 6 ) { imdct12 ( src , dst , outOff , i ) ; } }


Input: Wrong usage of Javascript keyword : in [CODESPLIT] private static void imdct12 ( float [ ] src , float [ ] dst , int outOff , int wndIdx ) { for ( int j = 15 + wndIdx , k = 12 + wndIdx ; j >= 3 + wndIdx ; j -= 3 , k -= 3 ) src [ j ] += src [ k ] ; src [ 15 + wndIdx ] += src [ 9 + wndIdx ] ; src [ 9 + wndIdx ] += src [ 3 + wndIdx ] ; float pp2 = src [ 12 + wndIdx ] * cos600 ; float pp1 = src [ 6 + wndIdx ] * cos300 ; float sum = src [ 0 + wndIdx ] + pp2 ; tmp [ 1 ] = src [ wndIdx ] - src [ 12 + wndIdx ] ; tmp [ 0 ] = sum + pp1 ; tmp [ 2 ] = sum - pp1 ; pp2 = src [ 15 + wndIdx ] * cos600 ; pp1 = src [ 9 + wndIdx ] * cos300 ; sum = src [ 3 + wndIdx ] + pp2 ; tmp [ 4 ] = src [ 3 + wndIdx ] - src [ 15 + wndIdx ] ; tmp [ 5 ] = sum + pp1 ; tmp [ 3 ] = sum - pp1 ; tmp [ 3 ] *= factor12pt0 ; tmp [ 4 ] *= cos450 ; tmp [ 5 ] *= factor12pt1 ; float t = tmp [ 0 ] ; tmp [ 0 ] += tmp [ 5 ] ; tmp [ 5 ] = t - tmp [ 5 ] ; t = tmp [ 1 ] ; tmp [ 1 ] += tmp [ 4 ] ; tmp [ 4 ] = t - tmp [ 4 ] ; t = tmp [ 2 ] ; tmp [ 2 ] += tmp [ 3 ] ; tmp [ 3 ] = t - tmp [ 3 ] ; for ( int j = 0 ; j < 6 ; j ++ ) tmp [ j ] *= factor12 [ j ] ; tmp [ 8 ] = - tmp [ 0 ] * cos375 ; tmp [ 9 ] = - tmp [ 0 ] * cos525 ; tmp [ 7 ] = - tmp [ 1 ] * cos225 ; tmp [ 10 ] = - tmp [ 1 ] * cos675 ; tmp [ 6 ] = - tmp [ 2 ] * cos075 ; tmp [ 11 ] = - tmp [ 2 ] * cos825 ; tmp [ 0 ] = tmp [ 3 ] ; tmp [ 1 ] = tmp [ 4 ] * cos675 ; tmp [ 2 ] = tmp [ 5 ] * cos525 ; tmp [ 3 ] = - tmp [ 5 ] * cos375 ; tmp [ 4 ] = - tmp [ 4 ] * cos225 ; tmp [ 5 ] = - tmp [ 0 ] * cos075 ; tmp [ 0 ] *= cos825 ; for ( int i = 0 , j = outOff + 6 ; i < 12 ; i ++ , j ++ ) { dst [ j ] += tmp [ i ] ; } }


Input:
/ * table 2 [CODESPLIT] public int decode ( IBitStream ld , int cnt ) throws AACException { int result = 0 ; int num_align_bits = 0 ; long num_sbr_bits1 = ld . getPosition ( ) ; int num_sbr_bits2 ; int saved_start_freq , saved_samplerate_mode ; int saved_stop_freq , saved_freq_scale ; int saved_xover_band ; boolean saved_alter_scale ; int bs_extension_type = ld . readBits ( 4 ) ; if ( bs_extension_type == EXT_SBR_DATA_CRC ) { this . bs_sbr_crc_bits = ld . readBits ( 10 ) ; } /* save old header values, in case the new ones are corrupted */ saved_start_freq = this . bs_start_freq ; saved_samplerate_mode = this . bs_samplerate_mode ; saved_stop_freq = this . bs_stop_freq ; saved_freq_scale = this . bs_freq_scale ; saved_alter_scale = this . bs_alter_scale ; saved_xover_band = this . bs_xover_band ; this . bs_header_flag = ld . readBool ( ) ; if ( this . bs_header_flag ) sbr_header ( ld ) ; /* Reset? */ sbr_reset ( ) ; /* first frame should have a header */ //if (!(sbr.frame == 0 && sbr.bs_header_flag == 0)) if ( this . header_count != 0 ) { if ( this . Reset || ( this . bs_header_flag && this . just_seeked ) ) { int rt = calc_sbr_tables ( this . bs_start_freq , this . bs_stop_freq , this . bs_samplerate_mode , this . bs_freq_scale , this . bs_alter_scale , this . bs_xover_band ) ; /* if an error occured with the new header values revert to the old ones */ if ( rt > 0 ) { calc_sbr_tables ( saved_start_freq , saved_stop_freq , saved_samplerate_mode , saved_freq_scale , saved_alter_scale , saved_xover_band ) ; } } if ( result == 0 ) { result = sbr_data ( ld ) ; /* sbr_data() returning an error means that there was an error in
				 envelope_time_border_vector().
				 In this case the old time border vector is saved and all the previous
				 data normally read after sbr_grid() is saved.
				 */ /* to be on the safe side, calculate old sbr tables in case of error */ if ( ( result > 0 ) && ( this . Reset || ( this . bs_header_flag && this . just_seeked ) ) ) { calc_sbr_tables ( saved_start_freq , saved_stop_freq , saved_samplerate_mode , saved_freq_scale , saved_alter_scale , saved_xover_band ) ; } /* we should be able to safely set result to 0 now, */ /* but practise indicates this doesn't work well */ } } else { result = 1 ; } num_sbr_bits2 = ( int ) ( ld . getPosition ( ) - num_sbr_bits1 ) ; /* check if we read more bits then were available for sbr */ if ( 8 * cnt < num_sbr_bits2 ) { throw new AACException ( "frame overread" ) ; //faad_resetbits(ld, num_sbr_bits1+8*cnt); //num_sbr_bits2 = 8*cnt; /* turn off PS for the unfortunate case that we randomly read some
			 * PS data that looks correct */ //this.ps_used = 0; /* Make sure it doesn't decode SBR in this frame, or we'll get glitches */ //return 1; } { /* -4 does not apply, bs_extension_type is re-read in this function */ num_align_bits = 8 * cnt /*- 4*/ - num_sbr_bits2 ; while ( num_align_bits > 7 ) { ld . readBits ( 8 ) ; num_align_bits -= 8 ; } ld . readBits ( num_align_bits ) ; } return result ; }


Input:
/ * table 3 [CODESPLIT] private void sbr_header ( IBitStream ld ) throws AACException { boolean bs_header_extra_1 , bs_header_extra_2 ; this . header_count ++ ; this . bs_amp_res = ld . readBool ( ) ; /* bs_start_freq and bs_stop_freq must define a fequency band that does
		 not exceed 48 channels */ this . bs_start_freq = ld . readBits ( 4 ) ; this . bs_stop_freq = ld . readBits ( 4 ) ; this . bs_xover_band = ld . readBits ( 3 ) ; ld . readBits ( 2 ) ; //reserved bs_header_extra_1 = ld . readBool ( ) ; bs_header_extra_2 = ld . readBool ( ) ; if ( bs_header_extra_1 ) { this . bs_freq_scale = ld . readBits ( 2 ) ; this . bs_alter_scale = ld . readBool ( ) ; this . bs_noise_bands = ld . readBits ( 2 ) ; } else { /* Default values */ this . bs_freq_scale = 2 ; this . bs_alter_scale = true ; this . bs_noise_bands = 2 ; } if ( bs_header_extra_2 ) { this . bs_limiter_bands = ld . readBits ( 2 ) ; this . bs_limiter_gains = ld . readBits ( 2 ) ; this . bs_interpol_freq = ld . readBool ( ) ; this . bs_smoothing_mode = ld . readBool ( ) ; } else { /* Default values */ this . bs_limiter_bands = 2 ; this . bs_limiter_gains = 2 ; this . bs_interpol_freq = true ; this . bs_smoothing_mode = true ; } }


Input: / * table 4 [CODESPLIT] private int sbr_data ( IBitStream ld ) throws AACException { int result ; this . rate = ( this . bs_samplerate_mode != 0 ) ? 2 : 1 ; if ( stereo ) { if ( ( result = sbr_channel_pair_element ( ld ) ) > 0 ) return result ; } else { if ( ( result = sbr_single_channel_element ( ld ) ) > 0 ) return result ; } return 0 ; }


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