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


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


Input: Get frame at current position in AWT image [CODESPLIT] public BufferedImage getFrame ( ) throws IOException { Picture nativeFrame = getNativeFrame ( ) ; return nativeFrame == null ? null : AWTUtil . toBufferedImage ( nativeFrame ) ; }


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


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


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


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


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


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


Input: Used to auto - detect MPEG Audio ( MP3 ) files [CODESPLIT] @ UsedViaReflection public static int probe ( final ByteBuffer b ) { ByteBuffer fork = b . duplicate ( ) ; int valid = 0 , total = 0 ; int header = fork . getInt ( ) ; do { if ( ! validHeader ( header ) ) header = skipJunkBB ( header , fork ) ; int size = calcFrameSize ( header ) ; if ( fork . remaining ( ) < size ) break ; ++ total ; if ( size > 0 ) NIOUtils . skip ( fork , size - 4 ) ; else header = skipJunkBB ( header , fork ) ; if ( fork . remaining ( ) >= 4 ) { header = fork . getInt ( ) ; if ( size >= MIN_FRAME_SIZE && size <= MAX_FRAME_SIZE && validHeader ( header ) ) valid ++ ; } } while ( fork . remaining ( ) >= 4 ) ; return ( 100 * valid ) / total ; }


Input: Calculates median prediction [CODESPLIT] public static int calcMVPredictionMedian ( int a , int b , int c , int d , boolean aAvb , boolean bAvb , boolean cAvb , boolean dAvb , int ref , int comp ) { if ( ! cAvb ) { c = d ; cAvb = dAvb ; } if ( aAvb && ! bAvb && ! cAvb ) { b = c = a ; bAvb = cAvb = aAvb ; } a = aAvb ? a : NULL_VECTOR ; b = bAvb ? b : NULL_VECTOR ; c = cAvb ? c : NULL_VECTOR ; if ( mvRef ( a ) == ref && mvRef ( b ) != ref && mvRef ( c ) != ref ) return mvC ( a , comp ) ; else if ( mvRef ( b ) == ref && mvRef ( a ) != ref && mvRef ( c ) != ref ) return mvC ( b , comp ) ; else if ( mvRef ( c ) == ref && mvRef ( a ) != ref && mvRef ( b ) != ref ) return mvC ( c , comp ) ; return mvC ( a , comp ) + mvC ( b , comp ) + mvC ( c , comp ) - min ( mvC ( a , comp ) , mvC ( b , comp ) , mvC ( c , comp ) ) - max ( mvC ( a , comp ) , mvC ( b , comp ) , mvC ( c , comp ) ) ; }


Input: Encodes DCT / WHT coefficients into the provided instance of a boolean encoder [CODESPLIT] public void encodeCoeffs ( VPXBooleanEncoder bc , int [ ] coeffs , int firstCoeff , int nCoeff , int blkType , int ctx ) { boolean prevZero = false ; int i ; for ( i = firstCoeff ; i < nCoeff ; i ++ ) { int [ ] probs = tokenBinProbs [ blkType ] [ coeffBandMapping [ i ] ] [ ctx ] ; int coeffAbs = MathUtil . abs ( coeffs [ i ] ) ; if ( ! prevZero ) bc . writeBit ( probs [ 0 ] , 1 ) ; if ( coeffAbs == 0 ) { bc . writeBit ( probs [ 1 ] , 0 ) ; ctx = 0 ; } else { bc . writeBit ( probs [ 1 ] , 1 ) ; if ( coeffAbs == 1 ) { bc . writeBit ( probs [ 2 ] , 0 ) ; ctx = 1 ; } else { ctx = 2 ; bc . writeBit ( probs [ 2 ] , 1 ) ; if ( coeffAbs <= 4 ) { bc . writeBit ( probs [ 3 ] , 0 ) ; if ( coeffAbs == 2 ) bc . writeBit ( probs [ 4 ] , 0 ) ; else { bc . writeBit ( probs [ 4 ] , 1 ) ; bc . writeBit ( probs [ 5 ] , coeffAbs - 3 ) ; } } else { bc . writeBit ( probs [ 3 ] , 1 ) ; if ( coeffAbs <= 10 ) { bc . writeBit ( probs [ 6 ] , 0 ) ; if ( coeffAbs <= 6 ) { bc . writeBit ( probs [ 7 ] , 0 ) ; bc . writeBit ( 159 , coeffAbs - 5 ) ; } else { bc . writeBit ( probs [ 7 ] , 1 ) ; int d = coeffAbs - 7 ; bc . writeBit ( 165 , d >> 1 ) ; bc . writeBit ( 145 , d & 1 ) ; } } else { bc . writeBit ( probs [ 6 ] , 1 ) ; if ( coeffAbs <= 34 ) { bc . writeBit ( probs [ 8 ] , 0 ) ; if ( coeffAbs <= 18 ) { bc . writeBit ( probs [ 9 ] , 0 ) ; writeCat3Ext ( bc , coeffAbs ) ; } else { bc . writeBit ( probs [ 9 ] , 1 ) ; writeCat4Ext ( bc , coeffAbs ) ; } } else { bc . writeBit ( probs [ 8 ] , 1 ) ; if ( coeffAbs <= 66 ) { bc . writeBit ( probs [ 10 ] , 0 ) ; writeCatExt ( bc , coeffAbs , 35 , VPXConst . probCoeffExtCat5 ) ; } else { bc . writeBit ( probs [ 10 ] , 1 ) ; writeCatExt ( bc , coeffAbs , 67 , VPXConst . probCoeffExtCat6 ) ; } } } } } bc . writeBit ( 128 , MathUtil . sign ( coeffs [ i ] ) ) ; } prevZero = coeffAbs == 0 ; } if ( nCoeff < 16 ) { int [ ] probs = tokenBinProbs [ blkType ] [ coeffBandMapping [ i ] ] [ ctx ] ; bc . writeBit ( probs [ 0 ] , 0 ) ; } }


Input: Wrong usage of Javascript keyword : in [CODESPLIT] public static int [ ] readScalingList ( BitReader src , int sizeOfScalingList ) { int [ ] scalingList = new int [ sizeOfScalingList ] ; int lastScale = 8 ; int nextScale = 8 ; for ( int j = 0 ; j < sizeOfScalingList ; j ++ ) { if ( nextScale != 0 ) { int deltaScale = readSE ( src , "deltaScale" ) ; nextScale = ( lastScale + deltaScale + 256 ) % 256 ; if ( j == 0 && nextScale == 0 ) return null ; } scalingList [ j ] = nextScale == 0 ? lastScale : nextScale ; lastScale = scalingList [ j ] ; } return scalingList ; }


Input: Wrong usage of Javascript keyword : in [CODESPLIT] private static void readScalingListMatrix ( BitReader src , SeqParameterSet sps ) { sps . scalingMatrix = new int [ 8 ] [  ] ; for ( int i = 0 ; i < 8 ; i ++ ) { boolean seqScalingListPresentFlag = readBool ( src , "SPS: seqScalingListPresentFlag" ) ; if ( seqScalingListPresentFlag ) { int scalingListSize = i < 6 ? 16 : 64 ; sps . scalingMatrix [ i ] = readScalingList ( src , scalingListSize ) ; } } }


Input: Encode this picture into h . 264 frame . Frame type will be selected by encoder . [CODESPLIT] public EncodedFrame encodeFrame ( Picture pic , ByteBuffer _out ) { if ( pic . getColor ( ) != ColorSpace . YUV420J ) throw new IllegalArgumentException ( "Input picture color is not supported: " + pic . getColor ( ) ) ; if ( frameNumber >= keyInterval ) { frameNumber = 0 ; } SliceType sliceType = frameNumber == 0 ? SliceType . I : SliceType . P ; boolean idr = frameNumber == 0 ; ByteBuffer data = doEncodeFrame ( pic , _out , idr , frameNumber ++ , sliceType ) ; return new EncodedFrame ( data , idr ) ; }


Input: Encode this picture as an IDR frame . IDR frame starts a new independently decodeable video sequence [CODESPLIT] public ByteBuffer encodeIDRFrame ( Picture pic , ByteBuffer _out ) { frameNumber = 0 ; return doEncodeFrame ( pic , _out , true , frameNumber , SliceType . I ) ; }


Input: Encode this picture as a P - frame . P - frame is an frame predicted from one or more of the previosly decoded frame and is usually 10x less in size then the IDR frame . [CODESPLIT] public ByteBuffer encodePFrame ( Picture pic , ByteBuffer _out ) { frameNumber ++ ; return doEncodeFrame ( pic , _out , true , frameNumber , SliceType . P ) ; }


Input:
Returns the name of the numbered property .

 [CODESPLIT] public Property getPropertyMetaData ( int propertyNo ) { long cPtr = VideoJNI . Configurable_getPropertyMetaData__SWIG_0 ( swigCPtr , this , propertyNo ) ; return ( cPtr == 0 ) ? null : new Property ( cPtr , false ) ; }


Input:
Returns the name of the named property .

 [CODESPLIT] public Property getPropertyMetaData ( String name ) { long cPtr = VideoJNI . Configurable_getPropertyMetaData__SWIG_1 ( swigCPtr , this , name ) ; return ( cPtr == 0 ) ? null : new Property ( cPtr , false ) ; }


Input:
Sets a property on this Object .

 All AVOptions supported by the underlying AVClass are supported .

 [CODESPLIT] public void setProperty ( String name , String value ) { VideoJNI . Configurable_setProperty__SWIG_0 ( swigCPtr , this , name , value ) ; }


Input:
Looks up the property name and sets the
 value of the property to value .

 [CODESPLIT] public void setProperty ( String name , Rational value ) { VideoJNI . Configurable_setProperty__SWIG_4 ( swigCPtr , this , name , Rational . getCPtr ( value ) , value ) ; }


Input:
Gets the value of this property and returns as an Rational ;

 [CODESPLIT] public Rational getPropertyAsRational ( String name ) { long cPtr = VideoJNI . Configurable_getPropertyAsRational ( swigCPtr , this , name ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ; }


Input:
Sets all properties in valuesToSet on this Configurable object .

 [CODESPLIT] public void setProperty ( KeyValueBag valuesToSet , KeyValueBag valuesNotFound ) { VideoJNI . Configurable_setProperty__SWIG_5 ( swigCPtr , this , KeyValueBag . getCPtr ( valuesToSet ) , valuesToSet , KeyValueBag . getCPtr ( valuesNotFound ) , valuesNotFound ) ; }


Input: Returns a list of all codecs supported for this Object . [CODESPLIT] public java . util . Collection < Codec . ID > getSupportedCodecs ( ) { final java . util . List < Codec . ID > retval = new java . util . LinkedList < Codec . ID > ( ) ; final java . util . Set < Codec . ID > uniqueSet = new java . util . HashSet < Codec . ID > ( ) ; int numCodecs = getNumSupportedCodecs ( ) ; for ( int i = 0 ; i < numCodecs ; i ++ ) { Codec . ID id = getSupportedCodecId ( i ) ; // remove duplicate IDs if ( id != Codec . ID . CODEC_ID_NONE && ! uniqueSet . contains ( id ) ) retval . add ( id ) ; uniqueSet . add ( id ) ; } return retval ; }


Input: Returns a list of all codec tags supported for this container . [CODESPLIT] public java . util . Collection < Long > getSupportedTags ( ) { final java . util . List < Long > retval = new java . util . LinkedList < Long > ( ) ; final java . util . Set < Long > uniqueSet = new java . util . HashSet < Long > ( ) ; int numCodecs = getNumSupportedCodecs ( ) ; for ( int i = 0 ; i < numCodecs ; i ++ ) { long tag = getSupportedCodecTag ( i ) ; Codec . ID id = getSupportedCodecId ( i ) ; // remove duplicate tags if ( id != Codec . ID . CODEC_ID_NONE && ! uniqueSet . contains ( tag ) ) retval . add ( tag ) ; uniqueSet . add ( tag ) ; } return retval ; }


Input:
Get the Codec . ID for the n th codec supported by this container .

 [CODESPLIT] protected Codec . ID getSupportedCodecId ( int n ) { return Codec . ID . swigToEnum ( VideoJNI . ContainerFormat_getSupportedCodecId ( swigCPtr , this , n ) ) ; }


Input: Get the number of Ferry objects we believe are still in use . <p > This may be different than what you think because the Java garbage collector may not have collected all objects yet . < / p > <p > Also this method needs to walk the entire ferry reference heap so it can be expensive and not accurate ( as the value may change even before this method returns ) . Use only for debugging . < / p > [CODESPLIT] public long getNumPinnedObjects ( ) { long numPinnedObjects = 0 ; blockingLock ( ) ; try { int numItems = mNextAvailableReferenceSlot ; for ( int i = 0 ; i < numItems ; i ++ ) { JNIReference ref = mValidReferences [ i ] ; if ( ref != null && ! ref . isDeleted ( ) ) ++ numPinnedObjects ; } } finally { blockingUnlock ( ) ; } return numPinnedObjects ; }


Input: Dump the contents of our memory cache to the log . <p > This method requires a global lock in order to run so only use for debugging . < / p > [CODESPLIT] public void dumpMemoryLog ( ) { blockingLock ( ) ; try { int numItems = mNextAvailableReferenceSlot ; log . debug ( "Memory slots in use: {}" , numItems ) ; for ( int i = 0 ; i < numItems ; i ++ ) { JNIReference ref = mValidReferences [ i ] ; if ( ref != null ) log . debug ( "Slot: {}; Ref: {}" , i , ref ) ; } } finally { blockingUnlock ( ) ; } return ; }


Input:
Add a reference to the set of references we ll collect . [CODESPLIT] final boolean addReference ( final JNIReference ref ) { /* Implementation note: This method is extremely
     * hot, and so I've unrolled the lock and unlock
     * methods from above.  Take care if you change
     * them to change the unrolled versions here.
     *
     */ // First try to grab the non blocking lock boolean gotNonblockingLock = false ; gotNonblockingLock = mSpinLock . compareAndSet ( false , true ) ; if ( gotNonblockingLock ) { final int slot = mNextAvailableReferenceSlot ++ ; if ( slot < mMaxValidReference ) { mValidReferences [ slot ] = ref ; // unlock the non-blocking lock, and progress to a full lock. final boolean result = mSpinLock . compareAndSet ( true , false ) ; assert result : "Should never be unlocked here" ; return true ; } // try the big lock without blocking if ( ! mLock . tryLock ( ) ) { // we couldn't get the big lock, so release the spin lock // and try getting the bit lock while blocking gotNonblockingLock = false ; mSpinLock . compareAndSet ( true , false ) ; } } // The above code needs to make sure that we never // have gotNonblockingLock set, unless we have both // the spin lock and the big lock. if ( ! gotNonblockingLock ) { mLock . lock ( ) ; while ( ! mSpinLock . compareAndSet ( false , true ) ) ; // grab the spin lock } try { int slot = mNextAvailableReferenceSlot ++ ; if ( slot >= mMaxValidReference ) { sweepAndCollect ( ) ; slot = mNextAvailableReferenceSlot ++ ; } mValidReferences [ slot ] = ref ; } finally { final boolean result = mSpinLock . compareAndSet ( true , false ) ; assert result : "Should never ever be unlocked here" ; mLock . unlock ( ) ; } return true ; }


Input: The actual GC ; [CODESPLIT] void gcInternal ( ) { JNIReference ref = null ; while ( ( ref = ( JNIReference ) mRefQueue . poll ( ) ) != null ) { ref . delete ( ) ; } }


Input: Starts a new Ferry collection thread that will wake up whenever a memory reference needs clean - up from native code . <p > This thread is not started by default as Ferry calls { [CODESPLIT] public void startCollectionThread ( ) { synchronized ( this ) { if ( mCollectionThread != null ) throw new RuntimeException ( "Thread already running" ) ; mCollectionThread = new Thread ( new Runnable ( ) { public void run ( ) { JNIReference ref = null ; try { while ( true ) { ref = ( JNIReference ) mRefQueue . remove ( ) ; if ( ref != null ) ref . delete ( ) ; } } catch ( InterruptedException ex ) { synchronized ( JNIMemoryManager . this ) { mCollectionThread = null ; // reset the interruption Thread . currentThread ( ) . interrupt ( ) ; } return ; } } } , "Humble Ferry Collection Thread" ) ; mCollectionThread . setDaemon ( true ) ; mCollectionThread . start ( ) ; } }


Input: Internal Only . [CODESPLIT] final public void flush ( ) { blockingLock ( ) ; try { int numSurvivors = sweepAndCollect ( ) ; for ( int i = 0 ; i < numSurvivors ; i ++ ) { final JNIReference ref = mValidReferences [ i ] ; if ( ref != null ) ref . delete ( ) ; } sweepAndCollect ( ) ; // finally, reset the valid references to the minimum mValidReferences = new JNIReference [ mMinimumReferencesToCache ] ; mNextAvailableReferenceSlot = 0 ; mMaxValidReference = mMinimumReferencesToCache ; } finally { blockingUnlock ( ) ; } }


Input: Internal Only . Allocate a new block of bytes . Called from native code . <p > Will retry many times if it can t get memory backing off in timeouts to get there . < / p > <p > Callers must eventually call { [CODESPLIT] public byte [ ] malloc ( int size ) { byte [ ] retval = null ; // first check the parachute JNIMemoryParachute . getParachute ( ) . packChute ( ) ; try { if ( SHOULD_RETRY_FAILED_ALLOCS ) { int allocationAttempts = 0 ; int backoffTimeout = 10 ; // start at 10 milliseconds while ( true ) { try { // log.debug("attempting malloc of size: {}", size); retval = new byte [ size ] ; // log.debug("malloced block of size: {}", size); // we succeed, so break out break ; } catch ( final OutOfMemoryError e ) { // try clearing our queue now and do it again. Why? // because the first failure may have allowed us to // catch a RefCounted no longer in use, and the second // attempt may have freed that memory. // do a JNI collect before the alloc ++ allocationAttempts ; if ( allocationAttempts >= MAX_ALLOCATION_ATTEMPTS ) { // try pulling our rip cord JNIMemoryParachute . getParachute ( ) . pullCord ( ) ; // do one last "hope gc" to free our own memory JNIReference . getMgr ( ) . gcInternal ( ) ; // and throw the error back to the native code throw e ; } log . debug ( "retrying ({}) allocation of {} bytes" , allocationAttempts , size ) ; try { // give the finalizer a chance if ( allocationAttempts <= 1 ) { // first just yield Thread . yield ( ) ; } else { Thread . sleep ( backoffTimeout ) ; // and slowly get longer... backoffTimeout = ( int ) ( backoffTimeout * FALLBACK_TIME_DECAY ) ; } } catch ( InterruptedException e1 ) { // reset the interruption so underlying // code can also interrupt Thread . currentThread ( ) . interrupt ( ) ; // and throw the error condition throw e ; } // do a JNI collect before the alloc JNIReference . getMgr ( ) . gcInternal ( ) ; } } } else { retval = new byte [ size ] ; } addToBuffer ( retval ) ; retval [ retval . length - 1 ] = 0 ; //      log.debug("malloc: {}({}:{})", new Object[] //      { //          retval.hashCode(), retval.length, size //      }); } catch ( Throwable t ) { // do not let an exception leak out since we go back to native code. retval = null ; } return retval ; }


Input:
Adds a picture to this source . NOTE : If you add a picture to a FilterSource
 be careful with re - using or rewriting the underlying data . Filters will
 try hard to avoid copying data so if you change the data out from under
 them unexpected results can occur .
 [CODESPLIT] public void addPicture ( MediaPicture picture ) { VideoJNI . FilterPictureSource_addPicture ( swigCPtr , this , MediaPicture . getCPtr ( picture ) , picture ) ; }


Input: Load the given library into the given application . [CODESPLIT] @ SuppressWarnings ( "deprecation" ) public static void load ( String appname , JNILibrary library ) { // we force ALL work on all libraries to be synchronized synchronized ( mLock ) { deleteTemporaryFiles ( ) ; try { library . load ( appname ) ; } catch ( UnsatisfiedLinkError e ) { // failed; faill back to old way JNILibraryLoader . loadLibrary ( library . getName ( ) , library . getVersion ( ) ) ; } } }


Input: Looks for a URL in a classpath and if found unpacks it [CODESPLIT] private boolean unpackLibrary ( String path ) { boolean retval = false ; try { final Enumeration < URL > c = JNILibrary . class . getClassLoader ( ) . getResources ( path ) ; while ( c . hasMoreElements ( ) ) { final URL url = c . nextElement ( ) ; log . trace ( "path: {}; url: {}" , path , url ) ; if ( url == null ) return false ; boolean unpacked = false ; File lib ; if ( url . getProtocol ( ) . toLowerCase ( ) . equals ( "file" ) ) { // it SHOULD already exist on the disk. let's look for it. try { lib = new File ( new URI ( url . toString ( ) ) ) ; } catch ( URISyntaxException e ) { lib = new File ( url . getPath ( ) ) ; } if ( ! lib . exists ( ) ) { log . error ( "Unpacked library not unpacked correctedly;  url: {}" , url ) ; continue ; } } else if ( url . getProtocol ( ) . toLowerCase ( ) . equals ( "jar" ) ) { // sucktastic -- we cannot in a JVM load a shared library // directly from a JAR, so we need to unpack to a temp // directory and load from there. InputStream stream = url . openStream ( ) ; if ( stream == null ) { log . error ( "could not get stream for resource: {}" , url . getPath ( ) ) ; continue ; } FileOutputStream out = null ; try { File dir = getTmpDir ( ) ; // did you know windows REQUIRES .dll. Sigh. lib = File . createTempFile ( "humble" , JNIEnv . getEnv ( ) . getOSFamily ( ) == JNIEnv . OSFamily . WINDOWS ? ".dll" : null , dir ) ; lib . deleteOnExit ( ) ; out = new FileOutputStream ( lib ) ; int bytesRead = 0 ; final byte [ ] buffer = new byte [ 2048 ] ; while ( ( bytesRead = stream . read ( buffer , 0 , buffer . length ) ) > 0 ) { out . write ( buffer , 0 , bytesRead ) ; } unpacked = true ; } catch ( IOException e ) { log . error ( "could not create temp file: {}" , e ) ; continue ; } finally { try { stream . close ( ) ; } catch ( IOException e ) { } if ( out != null ) try { out . close ( ) ; } catch ( IOException e ) { } } try { doJNILoad ( lib . getAbsolutePath ( ) ) ; retval = true ; break ; } catch ( UnsatisfiedLinkError e ) { // expected in some cases, try the next case. } finally { if ( unpacked ) { // Well let's try to clean up after ourselves since // we had ot unpack. deleteUnpackedFile ( lib . getAbsolutePath ( ) ) ; } } } } } catch ( IOException e1 ) { retval = false ; } return retval ; }


Input: Finds all . humble temp files in the temp directory and nukes them . [CODESPLIT] private static void deleteTemporaryFiles ( ) { final File dir = getTmpDir ( ) ; final FilenameFilter filter = new FilenameFilter ( ) { public boolean accept ( File dir , String name ) { return name . endsWith ( HUMBLE_TEMP_EXTENSION ) ; } } ; final File markers [ ] = dir . listFiles ( filter ) ; for ( File marker : markers ) { final String markerName = marker . getName ( ) ; final String libName = markerName . substring ( 0 , markerName . length ( ) - HUMBLE_TEMP_EXTENSION . length ( ) ) ; final File lib = new File ( marker . getParentFile ( ) , libName ) ; if ( ! lib . exists ( ) || lib . delete ( ) ) marker . delete ( ) ; } }


Input: Return default channel layout for a given number of channels . [CODESPLIT] public static AudioChannel . Layout getDefaultLayout ( int numChannels ) { return AudioChannel . Layout . swigToEnum ( VideoJNI . AudioChannel_getDefaultLayout ( numChannels ) ) ; }


Input:
Get the index of a channel in channel_layout .

 Use this method to find out which index into channel data corresponds
 to the channel you care about . The way you use this differs depending
 on whether your audio is packed or planar . To illustrate let s assume
 you have CH_LAYOUT_STEREO audio and you ask for the index of CH_FRONT_LEFT
 and we return 1 ( indexes are zero based ) .

 If packed then audio is laid out in one big buffer as RLRLRLRLRLRLRLRL audio
 and every 2nd ( 1 + 1 ) sample is the left channel

 If planar then audio is out in two buffer as RRRRRRRR and LLLLLLLL and the
 second plan ( 1 + 1 ) is the left channel .

 [CODESPLIT] public static int getIndexOfChannelInLayout ( AudioChannel . Layout layout , AudioChannel . Type channel ) { return VideoJNI . AudioChannel_getIndexOfChannelInLayout ( layout . swigValue ( ) , channel . swigValue ( ) ) ; }


Input: Get the channel with the given index in channel_layout . [CODESPLIT] public static AudioChannel . Type getChannelFromLayoutAtIndex ( AudioChannel . Layout layout , int index ) { return AudioChannel . Type . swigToEnum ( VideoJNI . AudioChannel_getChannelFromLayoutAtIndex ( layout . swigValue ( ) , index ) ) ; }


Input:
Return the pixel format corresponding to name .

 If there is no pixel format with name name then looks for a
 pixel format with the name corresponding to the native endian
 format of name .
 For example in a little - endian system first looks for gray16
 then for gray16le .

 Finally if no pixel format has been found returns AV_PIX_FMT_NONE . [CODESPLIT] public static PixelFormat . Type getFormat ( String name ) { return PixelFormat . Type . swigToEnum ( VideoJNI . PixelFormat_getFormat ( name ) ) ; }


Input:
Returns the i th pixel format descriptor that is known to humble video

 [CODESPLIT] public static PixelFormatDescriptor getInstalledFormatDescriptor ( int i ) { long cPtr = VideoJNI . PixelFormat_getInstalledFormatDescriptor ( i ) ; return ( cPtr == 0 ) ? null : new PixelFormatDescriptor ( cPtr , false ) ; }


Input:
Utility function to swap the endianness of a pixel format .

 pix_fmt the pixel format

 [CODESPLIT] public static PixelFormat . Type swapEndianness ( PixelFormat . Type pix_fmt ) { return PixelFormat . Type . swigToEnum ( VideoJNI . PixelFormat_swapEndianness ( pix_fmt . swigValue ( ) ) ) ; }


Input: Find the buffer size that would be necessary to store an image<br > with the given qualities . [CODESPLIT] public static int getBufferSizeNeeded ( int width , int height , PixelFormat . Type pix_fmt ) { return VideoJNI . PixelFormat_getBufferSizeNeeded ( width , height , pix_fmt . swigValue ( ) ) ; }


Input: Create a new Packet [CODESPLIT] public static MediaPacket make ( ) { long cPtr = VideoJNI . MediaPacket_make__SWIG_0 ( ) ; return ( cPtr == 0 ) ? null : new MediaPacket ( cPtr , false ) ; }


Input:
Allocate a new packet that wraps an existing Buffer .

 NOTE : At least 16 bytes of the passed in buffer will be used
 for header information so the resulting Packet . getSize ()
 will be smaller than Buffer . getBufferSize () .

 [CODESPLIT] public static MediaPacket make ( Buffer buffer ) { long cPtr = VideoJNI . MediaPacket_make__SWIG_1 ( Buffer . getCPtr ( buffer ) , buffer ) ; return ( cPtr == 0 ) ? null : new MediaPacket ( cPtr , false ) ; }


Input:
Allocate a new packet wrapping the existing contents of
 a passed in packet . Callers can then modify
 #getPts ()
 #getDts () and other get / set methods without
 modifying the original packet .

 [CODESPLIT] public static MediaPacket make ( MediaPacket packet , boolean copyData ) { long cPtr = VideoJNI . MediaPacket_make__SWIG_2 ( MediaPacket . getCPtr ( packet ) , packet , copyData ) ; return ( cPtr == 0 ) ? null : new MediaPacket ( cPtr , false ) ; }


Input:
Allocate a new packet .

 Note that any buffers this packet needs will be
 lazily allocated ( i . e . we won t actually grab all
 the memory until we need it ) .

 [CODESPLIT] public static MediaPacket make ( int size ) { long cPtr = VideoJNI . MediaPacket_make__SWIG_3 ( size ) ; return ( cPtr == 0 ) ? null : new MediaPacket ( cPtr , false ) ; }


Input:
Get any underlying raw data available for this packet .

 [CODESPLIT] public Buffer getData ( ) { long cPtr = VideoJNI . MediaPacket_getData ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new Buffer ( cPtr , false ) ; }


Input:
Get the n th item of SideData .

 WARNING : Callers must ensure that the the packet object
 this is called form is NOT reset or destroyed while using this buffer
 as unfortunately we cannot ensure this buffer survives the
 underlying packet data .

 [CODESPLIT] public Buffer getSideData ( int n ) { long cPtr = VideoJNI . MediaPacket_getSideData ( swigCPtr , this , n ) ; return ( cPtr == 0 ) ? null : new Buffer ( cPtr , false ) ; }


Input:
Get the n th item of SideData .

 [CODESPLIT] public MediaPacket . SideDataType getSideDataType ( int n ) { return MediaPacket . SideDataType . swigToEnum ( VideoJNI . MediaPacket_getSideDataType ( swigCPtr , this , n ) ) ; }


Input:
Find a given filter by name .

 [CODESPLIT] public static FilterType findFilterType ( String name ) { long cPtr = VideoJNI . FilterType_findFilterType ( name ) ; return ( cPtr == 0 ) ? null : new FilterType ( cPtr , false ) ; }


Input: { [CODESPLIT] public int open ( String url , int flags ) { if ( mOpenStream != null ) { log . debug ( "attempting to open already open handler: {}" , mOpenStream ) ; return - 1 ; } switch ( flags ) { case URL_RDWR : if ( mDataInput != null && mDataOutput != null && mDataInput == mDataOutput && mDataInput instanceof RandomAccessFile ) { mOpenStream = mDataInput ; } else { log . debug ( "do not support read/write mode for Java IO Handlers" ) ; return - 1 ; } break ; case URL_WRONLY_MODE : mOpenStream = mDataOutput ; if ( mOpenStream == null ) { log . error ( "No OutputStream specified for writing: {}" , url ) ; return - 1 ; } break ; case URL_RDONLY_MODE : mOpenStream = mDataInput ; if ( mOpenStream == null ) { log . error ( "No InputStream specified for reading: {}" , url ) ; return - 1 ; } break ; default : log . error ( "Invalid flag passed to open: {}" , url ) ; return - 1 ; } return 0 ; }


Input: { [CODESPLIT] public int read ( byte [ ] buf , int size ) { int ret = - 1 ; if ( mOpenStream == null || ! ( mOpenStream instanceof DataInput ) ) return - 1 ; try { if ( mOpenStream instanceof RandomAccessFile ) { RandomAccessFile file = ( RandomAccessFile ) mOpenStream ; return file . read ( buf , 0 , size ) ; } else if ( mOpenStream instanceof DataInputStream ) { DataInputStream stream = ( DataInputStream ) mOpenStream ; return stream . read ( buf , 0 , size ) ; } else { DataInput input = ( DataInput ) mOpenStream ; try { input . readFully ( buf , 0 , size ) ; ret = size ; } catch ( EOFException e ) { // man; we have no idea how many bytes were actually // read now... so we truncate the data // what a sucky interface! ret = - 1 ; } return ret ; } } catch ( IOException e ) { log . error ( "Got IO exception reading from channel: {}; {}" , mOpenStream , e ) ; return - 1 ; } }


Input: { @inheritDoc } [CODESPLIT] public long seek ( long offset , int whence ) { if ( mOpenStream == null ) return - 1 ; if ( ! ( mOpenStream instanceof RandomAccessFile ) ) return - 1 ; final RandomAccessFile file = ( RandomAccessFile ) mOpenStream ; try { final long seek ; if ( whence == SEEK_SET ) seek = offset ; else if ( whence == SEEK_CUR ) seek = file . getFilePointer ( ) + offset ; else if ( whence == SEEK_END ) seek = file . length ( ) + offset ; else if ( whence == SEEK_SIZE ) // odd feature of the protocol handler; this request // just returns the file size without actually seeking return ( int ) file . length ( ) ; else { log . error ( "invalid seek value \"{}\" for file: {}" , whence , file ) ; return - 1 ; } file . seek ( seek ) ; return seek ; } catch ( IOException e ) { log . debug ( "got io exception \"{}\" while seeking in: {}" , e . getMessage ( ) , file ) ; return - 1 ; } }


Input: { [CODESPLIT] public int write ( byte [ ] buf , int size ) { if ( mOpenStream == null || ! ( mOpenStream instanceof DataOutput ) ) return - 1 ; try { DataOutput output = ( DataOutput ) mOpenStream ; output . write ( buf , 0 , size ) ; return size ; } catch ( IOException e ) { log . error ( "Got error writing to file: {}; {}" , mOpenStream , e ) ; return - 1 ; } }


Input: { [CODESPLIT] public boolean isStreamed ( String url , int flags ) { if ( mDataInput != null && mDataInput instanceof RandomAccessFile ) return false ; if ( mDataOutput != null && mDataOutput instanceof RandomAccessFile ) return false ; return true ; }


Input:
Parameters that describe how pixels are packed .
 If the format has 2 or 4 components then alpha is last .
 If the format has 1 or 2 components then luma is 0 .
 If the format has 3 or 4 components
 if the RGB flag is set then 0 is red 1 is green and 2 is blue ;
 otherwise 0 is luma 1 is chroma - U and 2 is chroma - V . [CODESPLIT] public PixelComponentDescriptor getComponentDescriptor ( int component ) { long cPtr = VideoJNI . PixelFormatDescriptor_getComponentDescriptor ( swigCPtr , this , component ) ; return ( cPtr == 0 ) ? null : new PixelComponentDescriptor ( cPtr , false ) ; }


Input: Prints the version of this library to System . out along with some information on what this jar is . [CODESPLIT] public static String getVersionInfo ( ) { final Class < ? > c = Version . class ; final StringBuilder b = new StringBuilder ( ) ; final Package p = c . getPackage ( ) ; b . append ( "Class: " + c . getCanonicalName ( ) + "; " ) ; b . append ( "Specification Vendor: " + p . getSpecificationVendor ( ) + "; " ) ; b . append ( "Specification Title: " + p . getSpecificationTitle ( ) + "; " ) ; b . append ( "Specification Version: " + p . getSpecificationVersion ( ) + "; " ) ; b . append ( "Implementation Vendor: " + p . getImplementationVendor ( ) + "; " ) ; b . append ( "Implementation Title: " + p . getImplementationTitle ( ) + "; " ) ; b . append ( "Implementation Version: " + p . getImplementationVersion ( ) + ";" ) ; return b . toString ( ) ; }


Input: The default timebase used by media if not otherwise specified . [CODESPLIT] public static Rational getDefaultTimeBase ( ) { long cPtr = VideoJNI . Global_getDefaultTimeBase ( ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ; }


Input:
If this IProperty is of the type Type#PROPERTY_FLAGS this method will
 give you another IProperty representing a constant setting for that flag .

 [CODESPLIT] public Property getFlagConstant ( int position ) { long cPtr = VideoJNI . Property_getFlagConstant__SWIG_0 ( swigCPtr , this , position ) ; return ( cPtr == 0 ) ? null : new Property ( cPtr , false ) ; }


Input:
If this IProperty is of the type Type#PROPERTY_FLAGS this method will
 give you another IProperty representing a constant setting for that flag .

 [CODESPLIT] public Property getFlagConstant ( String name ) { long cPtr = VideoJNI . Property_getFlagConstant__SWIG_1 ( swigCPtr , this , name ) ; return ( cPtr == 0 ) ? null : new Property ( cPtr , false ) ; }


Input: Create a new Demuxer [CODESPLIT] public static Demuxer make ( ) { long cPtr = VideoJNI . Demuxer_make ( ) ; return ( cPtr == 0 ) ? null : new Demuxer ( cPtr , false ) ; }


Input: Get the DemuxerFormat associated with this Demuxer<br > or null if unknown . [CODESPLIT] public DemuxerFormat getFormat ( ) { long cPtr = VideoJNI . Demuxer_getFormat ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new DemuxerFormat ( cPtr , false ) ; }


Input:
Open this container and make it ready for reading optionally
 reading as far into the container as necessary to find all streams .

 The caller must call #close () when done but if not the
 Demuxer will eventually close
 them later but warn to the logging system .

 [CODESPLIT] public void open ( String url , DemuxerFormat format , boolean streamsCanBeAddedDynamically , boolean queryStreamMetaData , KeyValueBag options , KeyValueBag optionsNotSet ) throws java . lang . InterruptedException , java . io . IOException { VideoJNI . Demuxer_open ( swigCPtr , this , url , DemuxerFormat . getCPtr ( format ) , format , streamsCanBeAddedDynamically , queryStreamMetaData , KeyValueBag . getCPtr ( options ) , options , KeyValueBag . getCPtr ( optionsNotSet ) , optionsNotSet ) ; }


Input:
Close the container . open () must have been called first or
 else an error is returned .

 If this method exits because of an interruption
 all resources will be closed anyway .

 [CODESPLIT] public void close ( ) throws java . lang . InterruptedException , java . io . IOException { VideoJNI . Demuxer_close ( swigCPtr , this ) ; }


Input:
Get the stream at the given position .

 [CODESPLIT] public DemuxerStream getStream ( int streamIndex ) throws java . lang . InterruptedException , java . io . IOException { long cPtr = VideoJNI . Demuxer_getStream ( swigCPtr , this , streamIndex ) ; return ( cPtr == 0 ) ? null : new DemuxerStream ( cPtr , false ) ; }


Input:
Reads the next packet in the Demuxer into the Packet . This method will
 release any buffers currently held by this packet and allocate
 new ones .

 For non - blocking IO data sources it is possible for this method
 to return as successful but with no complete packet . In that case
 the caller should retry again later ( think EAGAIN ) semantics .

 [CODESPLIT] public int read ( MediaPacket packet ) throws java . lang . InterruptedException , java . io . IOException { return VideoJNI . Demuxer_read ( swigCPtr , this , MediaPacket . getCPtr ( packet ) , packet ) ; }


Input:
Attempts to read all the meta data in this stream potentially by reading ahead
 and decoding packets .

 Any packets this method reads ahead will be cached and correctly returned when you
 read packets but this method can be non - blocking potentially until end of container
 to get all meta data . Take care when you call it .

 After this method is called other meta data methods like #getDuration () should
 work .
 [CODESPLIT] public void queryStreamMetaData ( ) throws java . lang . InterruptedException , java . io . IOException { VideoJNI . Demuxer_queryStreamMetaData ( swigCPtr , this ) ; }


Input:
Set the flag .

 [CODESPLIT] public void setFlag ( Container . Flag flag , boolean value ) { VideoJNI . Demuxer_setFlag ( swigCPtr , this , flag . swigValue ( ) , value ) ; }


Input:
Get the KeyValueBag of media MetaData for this object
 or null if none .

 If the Demuxer or IStream object
 that this KeyValueBag came from was opened
 for reading then changes via KeyValueBag#setValue ( String String )
 will have no effect on the underlying media .

 If the Demuxer or IStream object
 that this KeyValueBag came from was opened
 for writing then changes via KeyValueBag#setValue ( String String )
 will have no effect after Demuxer#writeHeader ()
 is called .

 [CODESPLIT] public KeyValueBag getMetaData ( ) { long cPtr = VideoJNI . Demuxer_getMetaData ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new KeyValueBag ( cPtr , false ) ; }


Input:
Seek to timestamp ts .

 Seeking will be done so that the point from which all active streams
 can be presented successfully will be closest to ts and within min / max_ts .
 Active streams are all streams that have Stream . getDiscardSetting &lt ;
 Codec . DISCARD_ALL .

 If flags contain SeekFlags . SEEK_BYTE then all timestamps are in bytes and
 are the file position ( this may not be supported by all demuxers ) .
 If flags contain SeekFlags . SEEK_FRAME then all timestamps are in frames
 in the stream with stream_index ( this may not be supported by all demuxers ) .
 Otherwise all timestamps are in units of the stream selected by stream_index
 or if stream_index is - 1 in ( 1 / Global . DEFAULT_PTS_MICROSECONDS } units .
 If flags contain SeekFlags . SEEK_ANY then non - keyframes are treated as
 keyframes ( this may not be supported by all demuxers ) .

 [CODESPLIT] public int seek ( int stream_index , long min_ts , long ts , long max_ts , int flags ) throws java . lang . InterruptedException , java . io . IOException { return VideoJNI . Demuxer_seek ( swigCPtr , this , stream_index , min_ts , ts , max_ts , flags ) ; }


Input: Start playing a network source . Call #pause () to pause . [CODESPLIT] public void play ( ) throws java . lang . InterruptedException , java . io . IOException { VideoJNI . Demuxer_play ( swigCPtr , this ) ; }


Input:
Pause a playing network source . Call #play () to unpause .

 [CODESPLIT] public void pause ( ) throws java . lang . InterruptedException , java . io . IOException { VideoJNI . Demuxer_pause ( swigCPtr , this ) ; }


Input:
Creates a new IRational object by copying ( by value ) this object .

 [CODESPLIT] public Rational copy ( ) { long cPtr = VideoJNI . Rational_copy ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ; }


Input: Compare a rational to this rational<br > [CODESPLIT] public int compareTo ( Rational other ) { return VideoJNI . Rational_compareTo ( swigCPtr , this , Rational . getCPtr ( other ) , other ) ; }


Input: Compare two rationals<br > [CODESPLIT] public static int sCompareTo ( Rational a , Rational b ) { return VideoJNI . Rational_sCompareTo ( Rational . getCPtr ( a ) , a , Rational . getCPtr ( b ) , b ) ; }


Input:
Reduce a fraction to it s lowest common denominators .
 This is useful for framerate calculations .
 [CODESPLIT] public int reduce ( long num , long den , long max ) { return VideoJNI . Rational_reduce ( swigCPtr , this , num , den , max ) ; }


Input:
Reduce a fraction to it s lowest common denominators .
 This is useful for framerate calculations .
 [CODESPLIT] public static int sReduce ( Rational dst , long num , long den , long max ) { return VideoJNI . Rational_sReduce ( Rational . getCPtr ( dst ) , dst , num , den , max ) ; }


Input: Multiplies this number by arg<br > [CODESPLIT] public Rational multiply ( Rational arg ) { long cPtr = VideoJNI . Rational_multiply ( swigCPtr , this , Rational . getCPtr ( arg ) , arg ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ; }


Input: Multiples a by b . <br > [CODESPLIT] public static Rational sMultiply ( Rational a , Rational b ) { long cPtr = VideoJNI . Rational_sMultiply ( Rational . getCPtr ( a ) , a , Rational . getCPtr ( b ) , b ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ; }


Input: Divides this rational by arg . <br > [CODESPLIT] public Rational divide ( Rational arg ) { long cPtr = VideoJNI . Rational_divide ( swigCPtr , this , Rational . getCPtr ( arg ) , arg ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ; }


Input: Divides a by b . <br > [CODESPLIT] public static Rational sDivide ( Rational a , Rational b ) { long cPtr = VideoJNI . Rational_sDivide ( Rational . getCPtr ( a ) , a , Rational . getCPtr ( b ) , b ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ; }


Input: Subtracts arg from this rational<br > [CODESPLIT] public Rational subtract ( Rational arg ) { long cPtr = VideoJNI . Rational_subtract ( swigCPtr , this , Rational . getCPtr ( arg ) , arg ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ; }


Input: Subtracts a from b . <br > [CODESPLIT] public static Rational sSubtract ( Rational a , Rational b ) { long cPtr = VideoJNI . Rational_sSubtract ( Rational . getCPtr ( a ) , a , Rational . getCPtr ( b ) , b ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ; }


Input: Adds arg to this rational<br > [CODESPLIT] public Rational add ( Rational arg ) { long cPtr = VideoJNI . Rational_add ( swigCPtr , this , Rational . getCPtr ( arg ) , arg ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ; }


Input: Adds a to b . <br > [CODESPLIT] public static Rational sAdd ( Rational a , Rational b ) { long cPtr = VideoJNI . Rational_sAdd ( Rational . getCPtr ( a ) , a , Rational . getCPtr ( b ) , b ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ; }


Input:
Takes a value scaled in increments of origBase and gives the
 equivalent value scaled in terms of this Rational .

 [CODESPLIT] public long rescale ( long origValue , Rational origBase ) { return VideoJNI . Rational_rescale__SWIG_0 ( swigCPtr , this , origValue , Rational . getCPtr ( origBase ) , origBase ) ; }


Input:
Takes a value scaled in increments of origBase and gives the
 equivalent value scaled in terms of this Rational .

 [CODESPLIT] public static long sRescale ( long origValue , Rational origBase , Rational newBase ) { return VideoJNI . Rational_sRescale__SWIG_0 ( origValue , Rational . getCPtr ( origBase ) , origBase , Rational . getCPtr ( newBase ) , newBase ) ; }


Input:
Get a new rational that will be set to 0 / 1 .
 The rational will not have #init () called
 and hence will be modifiable by #setValue ( double )
 until #init () is called .
 [CODESPLIT] public static Rational make ( ) { long cPtr = VideoJNI . Rational_make__SWIG_0 ( ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ; }


Input: Converts a double precision floating point number to a rational . <br > [CODESPLIT] public static Rational make ( double d ) { long cPtr = VideoJNI . Rational_make__SWIG_1 ( d ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ; }


Input:
Creates deep copy of a Rational from another Rational .

 [CODESPLIT] public static Rational make ( Rational src ) { long cPtr = VideoJNI . Rational_make__SWIG_2 ( Rational . getCPtr ( src ) , src ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ; }


Input:
Create a rational from a numerator and denominator .

 We will always reduce this to the lowest num / den pair
 we can but never having den exceed what was passed in .

 [CODESPLIT] public static Rational make ( int num , int den ) { long cPtr = VideoJNI . Rational_make__SWIG_3 ( num , den ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ; }


Input:
Takes a value scaled in increments of origBase and gives the
 equivalent value scaled in terms of this Rational .

 [CODESPLIT] public long rescale ( long origValue , Rational origBase , Rational . Rounding rounding ) { return VideoJNI . Rational_rescale__SWIG_1 ( swigCPtr , this , origValue , Rational . getCPtr ( origBase ) , origBase , rounding . swigValue ( ) ) ; }


Input:
Takes a value scaled in increments of origBase and gives the
 equivalent value scaled in terms of this Rational .

 [CODESPLIT] public static long sRescale ( long origValue , Rational origBase , Rational newBase , Rational . Rounding rounding ) { return VideoJNI . Rational_sRescale__SWIG_1 ( origValue , Rational . getCPtr ( origBase ) , origBase , Rational . getCPtr ( newBase ) , newBase , rounding . swigValue ( ) ) ; }


Input:
Rescales a long value to another long value .

 This method doesn t use IRational values but
 instead uses numerators and denominators
 passed in by the caller . It will not result
 in any memory allocations .

 [CODESPLIT] public static long rescale ( long srcValue , int dstNumerator , int dstDenominator , int srcNumerator , int srcDenominator , Rational . Rounding rounding ) { return VideoJNI . Rational_rescale__SWIG_2 ( srcValue , dstNumerator , dstDenominator , srcNumerator , srcDenominator , rounding . swigValue ( ) ) ; }


Input:
Opens a file and plays the video from it on a screen at the right rate . [CODESPLIT] private static void playVideo ( String filename ) throws InterruptedException , IOException { /*
     * Start by creating a container object, in this case a demuxer since
     * we are reading, to get video data from.
     */ Demuxer demuxer = Demuxer . make ( ) ; /*
     * Open the demuxer with the filename passed on.
     */ demuxer . open ( filename , null , false , true , null , null ) ; /*
     * Query how many streams the call to open found
     */ int numStreams = demuxer . getNumStreams ( ) ; /*
     * Iterate through the streams to find the first video stream
     */ int videoStreamId = - 1 ; long streamStartTime = Global . NO_PTS ; Decoder videoDecoder = null ; for ( int i = 0 ; i < numStreams ; i ++ ) { final DemuxerStream stream = demuxer . getStream ( i ) ; streamStartTime = stream . getStartTime ( ) ; final Decoder decoder = stream . getDecoder ( ) ; if ( decoder != null && decoder . getCodecType ( ) == MediaDescriptor . Type . MEDIA_VIDEO ) { videoStreamId = i ; videoDecoder = decoder ; // stop at the first one. break ; } } if ( videoStreamId == - 1 ) throw new RuntimeException ( "could not find video stream in container: " + filename ) ; /*
     * Now we have found the audio stream in this file.  Let's open up our decoder so it can
     * do work.
     */ videoDecoder . open ( null , null ) ; final MediaPicture picture = MediaPicture . make ( videoDecoder . getWidth ( ) , videoDecoder . getHeight ( ) , videoDecoder . getPixelFormat ( ) ) ; /** A converter object we'll use to convert the picture in the video to a BGR_24 format that Java Swing
     * can work with. You can still access the data directly in the MediaPicture if you prefer, but this
     * abstracts away from this demo most of that byte-conversion work. Go read the source code for the
     * converters if you're a glutton for punishment.
     */ final MediaPictureConverter converter = MediaPictureConverterFactory . createConverter ( MediaPictureConverterFactory . HUMBLE_BGR_24 , picture ) ; BufferedImage image = null ; /**
     * This is the Window we will display in. See the code for this if you're curious, but to keep this demo clean
     * we're 'simplifying' Java AWT UI updating code. This method just creates a single window on the UI thread, and blocks
     * until it is displayed.
     */ final ImageFrame window = ImageFrame . make ( ) ; if ( window == null ) { throw new RuntimeException ( "Attempting this demo on a headless machine, and that will not work. Sad day for you." ) ; } /**
     * Media playback, like comedy, is all about timing. Here we're going to introduce very very basic
     * timing. This code is deliberately kept simple (i.e. doesn't worry about A/V drift, garbage collection pause time, etc.)
     * because that will quickly make things more complicated.
     *
     * But the basic idea is there are two clocks:
     *

     *
Player Clock: The time that the player sees (relative to the system clock).

     *
Stream Clock: Each stream has its own clock, and the ticks are measured in units of time-bases

     *

     *
     * And we need to convert between the two units of time. Each MediaPicture and MediaAudio object have associated
     * time stamps, and much of the complexity in video players goes into making sure the right picture (or sound) is
     * seen (or heard) at the right time. This is actually very tricky and many folks get it wrong -- watch enough
     * Netflix and you'll see what I mean -- audio and video slightly out of sync. But for this demo, we're erring for
     * 'simplicity' of code, not correctness. It is beyond the scope of this demo to make a full fledged video player.
     */ // Calculate the time BEFORE we start playing. long systemStartTime = System . nanoTime ( ) ; // Set units for the system time, which because we used System.nanoTime will be in nanoseconds. final Rational systemTimeBase = Rational . make ( 1 , 1000000000 ) ; // All the MediaPicture objects decoded from the videoDecoder will share this timebase. final Rational streamTimebase = videoDecoder . getTimeBase ( ) ; /**
     * Now, we start walking through the container looking at each packet. This
     * is a decoding loop, and as you work with Humble you'll write a lot
     * of these.
     *
     * Notice how in this loop we reuse all of our objects to avoid
     * reallocating them. Each call to Humble resets objects to avoid
     * unnecessary reallocation.
     */ final MediaPacket packet = MediaPacket . make ( ) ; while ( demuxer . read ( packet ) >= 0 ) { /**
       * Now we have a packet, let's see if it belongs to our video stream
       */ if ( packet . getStreamIndex ( ) == videoStreamId ) { /**
         * A packet can actually contain multiple sets of samples (or frames of samples
         * in decoding speak).  So, we may need to call decode  multiple
         * times at different offsets in the packet's data.  We capture that here.
         */ int offset = 0 ; int bytesRead = 0 ; do { bytesRead += videoDecoder . decode ( picture , packet , offset ) ; if ( picture . isComplete ( ) ) { image = displayVideoAtCorrectTime ( streamStartTime , picture , converter , image , window , systemStartTime , systemTimeBase , streamTimebase ) ; } offset += bytesRead ; } while ( offset < packet . getSize ( ) ) ; } } // Some video decoders (especially advanced ones) will cache // video data before they begin decoding, so when you are done you need // to flush them. The convention to flush Encoders or Decoders in Humble Video // is to keep passing in null until incomplete samples or packets are returned. do { videoDecoder . decode ( picture , null , 0 ) ; if ( picture . isComplete ( ) ) { image = displayVideoAtCorrectTime ( streamStartTime , picture , converter , image , window , systemStartTime , systemTimeBase , streamTimebase ) ; } } while ( picture . isComplete ( ) ) ; // It is good practice to close demuxers when you're done to free // up file handles. Humble will EVENTUALLY detect if nothing else // references this demuxer and close it then, but get in the habit // of cleaning up after yourself, and your future girlfriend/boyfriend // will appreciate it. demuxer . close ( ) ; // similar with the demuxer, for the windowing system, clean up after yourself. window . dispose ( ) ; }


Input: Takes the video picture and displays it at the right time . [CODESPLIT] private static BufferedImage displayVideoAtCorrectTime ( long streamStartTime , final MediaPicture picture , final MediaPictureConverter converter , BufferedImage image , final ImageFrame window , long systemStartTime , final Rational systemTimeBase , final Rational streamTimebase ) throws InterruptedException { long streamTimestamp = picture . getTimeStamp ( ) ; // convert streamTimestamp into system units (i.e. nano-seconds) streamTimestamp = systemTimeBase . rescale ( streamTimestamp - streamStartTime , streamTimebase ) ; // get the current clock time, with our most accurate clock long systemTimestamp = System . nanoTime ( ) ; // loop in a sleeping loop until we're within 1 ms of the time for that video frame. // a real video player needs to be much more sophisticated than this. while ( streamTimestamp > ( systemTimestamp - systemStartTime + 1000000 ) ) { Thread . sleep ( 1 ) ; systemTimestamp = System . nanoTime ( ) ; } // finally, convert the image from Humble format into Java images. image = converter . toImage ( image , picture ) ; // And ask the UI thread to repaint with the new image. window . setImage ( image ) ; return image ; }


Input: Gets a collection of ALL codecs installed on this system . [CODESPLIT] public static java . util . Collection < BitStreamFilterType > getInstalledBitStreamFilterTypes ( ) { java . util . Collection < BitStreamFilterType > retval = new java . util . HashSet < BitStreamFilterType > ( ) ; int count = getNumBitStreamFilterTypes ( ) ; for ( int i = 0 ; i < count ; i ++ ) { BitStreamFilterType t = getBitStreamFilterType ( i ) ; if ( t != null ) retval . add ( t ) ; } return retval ; }


Input: Create a converter . [CODESPLIT] public static MediaAudioConverter createConverter ( String description , MediaAudio protoAudio ) { return createConverter ( description , protoAudio . getSampleRate ( ) , protoAudio . getChannelLayout ( ) , protoAudio . getFormat ( ) ) ; }


Input: Create a converter . [CODESPLIT] public static MediaAudioConverter createConverter ( String description , int sampleRate , Layout layout , Type format ) { if ( description != DEFAULT_JAVA_AUDIO ) throw new RuntimeException ( "Unsupported converter type" ) ; return new StereoS16AudioConverter ( sampleRate , layout , format ) ; }


Input:
Create a Encoder that will use the given Codec .

 [CODESPLIT] public static Encoder make ( Codec codec ) { long cPtr = VideoJNI . Encoder_make__SWIG_0 ( Codec . getCPtr ( codec ) , codec ) ; return ( cPtr == 0 ) ? null : new Encoder ( cPtr , false ) ; }


Input: Creates a Encoder from a given Encoder<br > [CODESPLIT] public static Encoder make ( Coder src ) { long cPtr = VideoJNI . Encoder_make__SWIG_1 ( Coder . getCPtr ( src ) , src ) ; return ( cPtr == 0 ) ? null : new Encoder ( cPtr , false ) ; }


Input:
Open this Coder using the given bag of Codec - specific options .

 [CODESPLIT] public void open ( KeyValueBag inputOptions , KeyValueBag unsetOptions ) { VideoJNI . Encoder_open ( swigCPtr , this , KeyValueBag . getCPtr ( inputOptions ) , inputOptions , KeyValueBag . getCPtr ( unsetOptions ) , unsetOptions ) ; }


Input:
Encode the given MediaPicture using this encoder .

 The MediaPicture will allocate a buffer to use internally for this and
 will free it when the frame destroys itself .

 Also when done in order to flush the encoder caller should call
 this method passing in 0 ( null ) for frame to tell the encoder
 to flush any data it was keeping a hold of .

 [CODESPLIT] public void encodeVideo ( MediaPacket output , MediaPicture picture ) { VideoJNI . Encoder_encodeVideo ( swigCPtr , this , MediaPacket . getCPtr ( output ) , output , MediaPicture . getCPtr ( picture ) , picture ) ; }


Input:
Encode the given MediaAudio using this encoder .

 Callers should call this repeatedly on a set of samples until
 we consume all the samples .

 Also when done in order to flush the encoder caller should call
 this method passing in 0 ( null ) for samples to tell the encoder
 to flush any data it was keeping a hold of .

 [CODESPLIT] public void encodeAudio ( MediaPacket output , MediaAudio samples ) { VideoJNI . Encoder_encodeAudio ( swigCPtr , this , MediaPacket . getCPtr ( output ) , output , MediaAudio . getCPtr ( samples ) , samples ) ; }


Input:
Encode the given Media using this encoder .

 Callers should call this repeatedly on a media object ntil
 we consume all the media .

 Also when done in order to flush the encoder caller should call
 this method passing in 0 ( null ) for media to tell the encoder
 to flush any data it was keeping a hold of .

 [CODESPLIT] public void encode ( MediaPacket output , MediaSampled media ) { VideoJNI . Encoder_encode ( swigCPtr , this , MediaPacket . getCPtr ( output ) , output , MediaSampled . getCPtr ( media ) , media ) ; }


Input: { [CODESPLIT] @ Override public MediaPicture toPicture ( MediaPicture output , final BufferedImage input , long timestamp ) { // validate the image validateImage ( input ) ; if ( output == null ) { output = MediaPicture . make ( mPictureWidth , mPictureHeight , getPictureType ( ) ) ; } // get the image byte buffer buffer DataBuffer imageBuffer = input . getRaster ( ) . getDataBuffer ( ) ; byte [ ] imageBytes = null ; int [ ] imageInts = null ; // handle byte buffer case if ( imageBuffer instanceof DataBufferByte ) { imageBytes = ( ( DataBufferByte ) imageBuffer ) . getData ( ) ; } // handle integer buffer case else if ( imageBuffer instanceof DataBufferInt ) { imageInts = ( ( DataBufferInt ) imageBuffer ) . getData ( ) ; } // if it's some other type, throw else { throw new IllegalArgumentException ( "Unsupported BufferedImage data buffer type: " + imageBuffer . getDataType ( ) ) ; } // create the video picture and get it's underlying buffer final AtomicReference < JNIReference > ref = new AtomicReference < JNIReference > ( null ) ; final MediaPicture picture = willResample ( ) ? mResampleMediaPicture : output ; try { Buffer buffer = picture . getData ( 0 ) ; int size = picture . getDataPlaneSize ( 0 ) ; ByteBuffer pictureByteBuffer = buffer . getByteBuffer ( 0 , size , ref ) ; buffer . delete ( ) ; buffer = null ; if ( imageInts != null ) { pictureByteBuffer . order ( ByteOrder . BIG_ENDIAN ) ; IntBuffer pictureIntBuffer = pictureByteBuffer . asIntBuffer ( ) ; pictureIntBuffer . put ( imageInts ) ; } else { pictureByteBuffer . put ( imageBytes ) ; } pictureByteBuffer = null ; picture . setTimeStamp ( timestamp ) ; picture . setComplete ( true ) ; // resample as needed if ( willResample ( ) ) { resample ( output , picture , mToPictureResampler ) ; } return output ; } finally { if ( ref . get ( ) != null ) ref . get ( ) . delete ( ) ; } }


Input: { [CODESPLIT] @ Override public BufferedImage toImage ( BufferedImage output , final MediaPicture input ) { validatePicture ( input ) ; // test that the picture is valid if ( output == null ) { final byte [ ] bytes = new byte [ willResample ( ) ? mResampleMediaPicture . getDataPlaneSize ( 0 ) : input . getDataPlaneSize ( 0 ) ] ; // create the data buffer from the bytes final DataBufferByte db = new DataBufferByte ( bytes , bytes . length ) ; // create an a sample model which matches the byte layout of the // image data and raster which contains the data which now can be // properly interpreted int w = mImageWidth ; int h = mImageHeight ; final SampleModel sm = new PixelInterleavedSampleModel ( db . getDataType ( ) , w , h , 3 , 3 * w , mBandOffsets ) ; final WritableRaster wr = Raster . createWritableRaster ( sm , db , null ) ; // create a color model final ColorModel colorModel = new ComponentColorModel ( mColorSpace , false , false , ColorModel . OPAQUE , db . getDataType ( ) ) ; // return a new image created from the color model and raster output = new BufferedImage ( colorModel , wr , false , null ) ; } MediaPicture picture ; // resample as needed AtomicReference < JNIReference > ref = new AtomicReference < JNIReference > ( null ) ; try { if ( willResample ( ) ) { picture = resample ( mResampleMediaPicture , input , mToImageResampler ) ; } else { picture = input ; } final Buffer buffer = picture . getData ( 0 ) ; final int size = picture . getDataPlaneSize ( 0 ) ; final ByteBuffer byteBuf = buffer . getByteBuffer ( 0 , size , ref ) ; buffer . delete ( ) ; // get the bytes out of the image final DataBufferByte db = ( DataBufferByte ) output . getRaster ( ) . getDataBuffer ( ) ; final byte [ ] bytes = db . getData ( ) ; // and copy them in. byteBuf . get ( bytes , 0 , size ) ; // return a new image created from the color model and raster return output ; } finally { if ( ref . get ( ) != null ) ref . get ( ) . delete ( ) ; } }


Input: Get the descriptor for the given id . [CODESPLIT] public static CodecDescriptor make ( Codec . ID id ) { long cPtr = VideoJNI . CodecDescriptor_make ( id . swigValue ( ) ) ; return ( cPtr == 0 ) ? null : new CodecDescriptor ( cPtr , false ) ; }


Input: Print out all configurable options on the { @link Configurable } object . [CODESPLIT] public static void printConfigurable ( java . io . PrintStream stream , Configurable configObj ) { stream . println ( "=======================================" ) ; stream . println ( "  " + configObj . getClass ( ) . getName ( ) + " Properties" ) ; stream . println ( "=======================================" ) ; int numOptions = configObj . getNumProperties ( ) ; for ( int i = 0 ; i < numOptions ; i ++ ) { Property prop = configObj . getPropertyMetaData ( i ) ; printOption ( stream , configObj , prop ) ; } }


Input: Print information about the property on the configurable object . [CODESPLIT] public static void printOption ( java . io . PrintStream stream , Configurable configObj , Property prop ) { if ( prop . getType ( ) != Property . Type . PROPERTY_FLAGS ) { stream . printf ( "  %s; default= %s; type=%s;\n" , prop . getName ( ) , configObj . getPropertyAsString ( prop . getName ( ) ) , prop . getType ( ) ) ; } else { // it's a flag stream . printf ( "  %s; default= %d; valid values=(" , prop . getName ( ) , configObj . getPropertyAsLong ( prop . getName ( ) ) ) ; int numSettings = prop . getNumFlagSettings ( ) ; long value = configObj . getPropertyAsLong ( prop . getName ( ) ) ; for ( int i = 0 ; i < numSettings ; i ++ ) { Property fprop = prop . getFlagConstant ( i ) ; long flagMask = fprop . getDefault ( ) ; boolean isSet = ( value & flagMask ) > 0 ; stream . printf ( "%s%s; " , isSet ? "+" : "-" , fprop . getName ( ) ) ; } stream . printf ( "); type=%s;\n" , prop . getType ( ) ) ; } stream . printf ( "    help for %s: %s\n" , prop . getName ( ) , prop . getHelp ( ) == null ? "no help available" : prop . getHelp ( ) ) ; }


Input: Configures an { [CODESPLIT] @ SuppressWarnings ( "unchecked" ) public static void configure ( final Properties properties , final Configurable config ) { for ( final Enumeration < String > names = ( Enumeration < String > ) properties . propertyNames ( ) ; names . hasMoreElements ( ) ; ) { final String name = names . nextElement ( ) ; final String value = properties . getProperty ( name ) ; if ( value != null ) { try { config . setProperty ( name , value ) ; } catch ( PropertyNotFoundException e ) { log . warn ( "Could not find property on object {}; name=\"{}\"; value=\"{}\"" , new Object [ ] { config , name , value } ) ; } } } }


Input: Configures an { [CODESPLIT] @ SuppressWarnings ( "unchecked" ) public static void configure ( final String file , final Configurable config ) throws FileNotFoundException , IOException { Properties props = new Properties ( ) ; props . load ( new FileInputStream ( file ) ) ; Configuration . configure ( props , config ) ; }


Input:
Set the time base that time stamps of this object are represented in .

 [CODESPLIT] public void setTimeBase ( Rational aBase ) { VideoJNI . MediaEncoded_setTimeBase ( swigCPtr , this , Rational . getCPtr ( aBase ) , aBase ) ; }


Input: Find a descriptor given a { @link BufferedImage } . [CODESPLIT] public static String findDescriptor ( BufferedImage image ) { for ( Type converterType : getRegisteredConverters ( ) ) if ( converterType . getImageType ( ) == image . getType ( ) ) return converterType . getDescriptor ( ) ; return null ; }


Input: Create a converter which translates betewen { @link BufferedImage } and { @link MediaPicture } types . The { @link io . humble . video . PixelFormat . Type } and size are extracted from the passed in picture . This factory will attempt to create a converter which can perform the translation . If no converter can be created a descriptive { @link UnsupportedOperationException } is thrown . [CODESPLIT] public static MediaPictureConverter createConverter ( String converterDescriptor , MediaPicture picture ) { if ( picture == null ) throw new IllegalArgumentException ( "The picture is NULL." ) ; return createConverter ( converterDescriptor , picture . getFormat ( ) , picture . getWidth ( ) , picture . getHeight ( ) ) ; }


Input: Create a converter which translates between { @link BufferedImage } and { @link MediaPicture } . This factory will attempt to create a converter which can perform the translation . If no converter can be created a descriptive { @link UnsupportedOperationException } is thrown . [CODESPLIT] public static MediaPictureConverter createConverter ( BufferedImage image , MediaPicture picture ) { if ( image == null ) throw new IllegalArgumentException ( "cannot pass null image" ) ; if ( picture == null ) throw new IllegalArgumentException ( "cannot pass null picture" ) ; return createConverter ( image , picture . getFormat ( ) ) ; }


Input: Create a converter which translates between { @link BufferedImage } and { @link MediaPicture } types . The { @link BufferedImage } type and size are extracted from the passed in image . This factory will attempt to create a converter which can perform the translation . If no converter can be created a descriptive { @link UnsupportedOperationException } is thrown . [CODESPLIT] public static MediaPictureConverter createConverter ( BufferedImage image , PixelFormat . Type pictureType ) { if ( image == null ) throw new IllegalArgumentException ( "The image is NULL." ) ; // find the converter type based in image type String converterDescriptor = findDescriptor ( image ) ; if ( converterDescriptor == null ) throw new UnsupportedOperationException ( "No converter found for BufferedImage type #" + image . getType ( ) ) ; // create and return the converter return createConverter ( converterDescriptor , pictureType , image . getWidth ( ) , image . getHeight ( ) ) ; }


Input: Create a converter which translates between { @link BufferedImage } and { @link MediaPicture } types . This factory will attempt to create a converter which can perform the translation . If no converter can be created a descriptive { @link UnsupportedOperationException } is thrown . [CODESPLIT] public static MediaPictureConverter createConverter ( String converterDescriptor , PixelFormat . Type pictureType , int width , int height ) { return createConverter ( converterDescriptor , pictureType , width , height , width , height ) ; }


Input: Create a converter which translates betewen { @link BufferedImage } and { @link MediaPicture } types . This factory will attempt to create a converter which can perform the translation . If different image and pictures sizes are passed the converter will resize during translation . If no converter can be created a descriptive { @link UnsupportedOperationException } is thrown . [CODESPLIT] public static MediaPictureConverter createConverter ( String converterDescriptor , PixelFormat . Type pictureType , int pictureWidth , int pictureHeight , int imageWidth , int imageHeight ) { MediaPictureConverter converter = null ; // establish the converter type Type converterType = findRegisteredConverter ( converterDescriptor ) ; if ( null == converterType ) throw new UnsupportedOperationException ( "No converter \"" + converterDescriptor + "\" found." ) ; // create the converter try { // establish the constructor  Constructor < ? extends MediaPictureConverter > converterConstructor = converterType . getConverterClass ( ) . getConstructor ( PixelFormat . Type . class , int . class , int . class , int . class , int . class ) ; // create the converter converter = converterConstructor . newInstance ( pictureType , pictureWidth , pictureHeight , imageWidth , imageHeight ) ; } catch ( NoSuchMethodException e ) { throw new UnsupportedOperationException ( "Converter " + converterType . getConverterClass ( ) + " requries a constructor of the form " + "(PixelFormat.Type, int, int, int, int)" ) ; } catch ( InvocationTargetException e ) { Throwable cause = e . getCause ( ) ; if ( cause != null && cause instanceof OutOfMemoryError ) { throw ( OutOfMemoryError ) cause ; } else { throw new UnsupportedOperationException ( "Converter " + converterType . getConverterClass ( ) + " constructor failed with: " + e . getCause ( ) ) ; } } catch ( IllegalAccessException e ) { Throwable cause = e . getCause ( ) ; if ( cause != null && cause instanceof OutOfMemoryError ) { throw ( OutOfMemoryError ) cause ; } else { throw new UnsupportedOperationException ( "Converter " + converterType . getConverterClass ( ) + " constructor failed with: " + e . getCause ( ) ) ; } } catch ( InstantiationException e ) { Throwable cause = e . getCause ( ) ; if ( cause != null && cause instanceof OutOfMemoryError ) { throw ( OutOfMemoryError ) cause ; } else { throw new UnsupportedOperationException ( "Converter " + converterType . getConverterClass ( ) + " constructor failed with: " + e . getCause ( ) ) ; } } // return the newly created converter return converter ; }


Input: Convert a { @link BufferedImage } of any type to { @link BufferedImage } of a specified type . If the source image is the same type as the target type then original image is returned otherwise new image of the correct type is created and the content of the source image is copied into the new image . [CODESPLIT] public static BufferedImage convertToType ( BufferedImage sourceImage , int targetType ) { BufferedImage image ; // if the source image is already the target type, return the source image if ( sourceImage . getType ( ) == targetType ) image = sourceImage ; // otherwise create a new image of the target type and draw the new // image  else { image = new BufferedImage ( sourceImage . getWidth ( ) , sourceImage . getHeight ( ) , targetType ) ; image . getGraphics ( ) . drawImage ( sourceImage , 0 , 0 , null ) ; } return image ; }


Input: Checks the current parachute and recreates ( reloads ) our payload if needed . [CODESPLIT] boolean packChute ( ) throws OutOfMemoryError { if ( mPayload != null ) return true ; // otherwise the payload is null synchronized ( this ) { if ( mPayload != null ) return true ; try { //System.out.println("Packing the parachute! this=" + this); mPayload = new byte [ PAYLOAD_BYTES ] ; mPayload [ 0 ] = ' ' ; mPayload [ 1 ] = ' ' ; mPayload [ 2 ] = ' ' ; mPayload [ 3 ] = ' ' ; mPayload [ 4 ] = ' ' ; mPayload [ 5 ] = ' ' ; mPayload [ 6 ] = ' ' ; mPayload [ 7 ] = ' ' ; mPayload [ 8 ] = ' ' ; mPayload [ 9 ] = ' ' ; return true ; } catch ( OutOfMemoryError e ) { // we failed to create the parachute.  Also known as bad. // forward it on. throw e ; } } }


Input: { [CODESPLIT] public int close ( ) { int retval = 0 ; try { if ( mOpenStream != null && mCloseStreamOnClose ) { mOpenStream . close ( ) ; } } catch ( IOException e ) { log . error ( "could not close stream {}: {}" , mOpenStream , e ) ; retval = - 1 ; } mOpenStream = null ; return retval ; }


Input: { [CODESPLIT] public int open ( String url , int flags ) { if ( mOpenStream != null ) { log . debug ( "attempting to open already open handler: {}" , mOpenStream ) ; return - 1 ; } switch ( flags ) { case URL_RDWR : log . debug ( "do not support read/write mode for Java IO Handlers" ) ; return - 1 ; case URL_WRONLY_MODE : mOpenStream = mWriteChannel ; if ( mOpenStream == null ) { log . error ( "No OutputStream specified for writing: {}" , url ) ; return - 1 ; } break ; case URL_RDONLY_MODE : mOpenStream = mReadChannel ; if ( mOpenStream == null ) { log . error ( "No InputStream specified for reading: {}" , url ) ; return - 1 ; } break ; default : log . error ( "Invalid flag passed to open: {}" , url ) ; return - 1 ; } return 0 ; }


Input: { [CODESPLIT] public int read ( byte [ ] buf , int size ) { int ret = - 1 ; if ( mOpenStream == null || ! ( mOpenStream instanceof ReadableByteChannel ) ) return - 1 ; try { ReadableByteChannel channel = ( ReadableByteChannel ) mOpenStream ; ByteBuffer buffer = ByteBuffer . allocate ( size ) ; ret = channel . read ( buffer ) ; if ( ret > 0 ) { buffer . flip ( ) ; buffer . get ( buf , 0 , ret ) ; } return ret ; } catch ( IOException e ) { log . error ( "Got IO exception reading from channel: {}; {}" , mOpenStream , e ) ; return - 1 ; } }


Input: { [CODESPLIT] public int write ( byte [ ] buf , int size ) { if ( mOpenStream == null || ! ( mOpenStream instanceof WritableByteChannel ) ) return - 1 ; try { WritableByteChannel channel = ( WritableByteChannel ) mOpenStream ; ByteBuffer buffer = ByteBuffer . allocate ( size ) ; buffer . put ( buf , 0 , size ) ; buffer . flip ( ) ; return channel . write ( buffer ) ; } catch ( IOException e ) { log . error ( "Got error writing to file: {}; {}" , mOpenStream , e ) ; return - 1 ; } }


Input: Register a new protocol name for this factory that Humble . IO will use for the given protocol . [CODESPLIT] static HumbleIO registerFactory ( String protocolPrefix ) { URLProtocolManager manager = URLProtocolManager . getManager ( ) ; manager . registerFactory ( protocolPrefix , mFactory ) ; return mFactory ; }


Input: Generates a unique name suitable for using in the map methods for the URL parameter . [CODESPLIT] static public String generateUniqueName ( Object src , String extension ) { StringBuilder builder = new StringBuilder ( ) ; builder . append ( UUID . randomUUID ( ) . toString ( ) ) ; if ( src != null ) { builder . append ( "-" ) ; builder . append ( src . getClass ( ) . getName ( ) ) ; builder . append ( "-" ) ; builder . append ( Integer . toHexString ( src . hashCode ( ) ) ) ; } if ( extension != null ) { builder . append ( extension ) ; } return builder . toString ( ) ; }


Input: Maps a { @link IURLProtocolHandler } to a url that Humble can open . [CODESPLIT] public static String map ( String url , IURLProtocolHandler handler ) { return map ( url , handler , DEFAULT_UNMAP_URL_ON_OPEN ) ; }


Input: Maps a { @link DataInput } object to a URL for use by Humble . [CODESPLIT] public static String map ( DataInput input ) { return map ( generateUniqueName ( input ) , input , null , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ; }


Input: Maps a { @link DataInput } object to a URL for use by Humble . [CODESPLIT] public static String map ( String url , DataInput input ) { return map ( url , input , null , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ; }


Input: Maps a { @link DataOutput } object to a URL for use by Humble . [CODESPLIT] public static String map ( DataOutput output ) { return map ( generateUniqueName ( output ) , null , output , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ; }


Input: Maps a { @link DataOutput } object to a URL for use by Humble . [CODESPLIT] public static String map ( String url , DataOutput output ) { return map ( url , null , output , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ; }


Input: Maps a { @link RandomAccessFile } object to a URL for use by Humble . [CODESPLIT] public static String map ( RandomAccessFile file ) { return map ( generateUniqueName ( file ) , file , file , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ; }


Input: Maps a { @link RandomAccessFile } object to a URL for use by Humble . [CODESPLIT] public static String map ( String url , RandomAccessFile file ) { return map ( url , file , file , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ; }


Input: Maps a { @link ReadableByteChannel } to a URL for use by Humble . [CODESPLIT] public static String map ( ReadableByteChannel channel ) { return map ( generateUniqueName ( channel ) , channel , null , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ; }


Input: Maps a { @link ReadableByteChannel } to a URL for use by Humble . [CODESPLIT] public static String map ( String url , ReadableByteChannel channel ) { return map ( url , channel , null , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ; }


Input: Maps a { @link WritableByteChannel } to a URL for use by Humble . [CODESPLIT] public static String map ( WritableByteChannel channel ) { return map ( generateUniqueName ( channel ) , null , channel , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ; }


Input: Maps a { @link WritableByteChannel } to a URL for use by Humble . [CODESPLIT] public static String map ( String url , WritableByteChannel channel ) { return map ( url , null , channel , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ; }


Input: Maps a { @link ByteChannel } to a URL for use by Humble . [CODESPLIT] public static String map ( ByteChannel channel ) { return map ( generateUniqueName ( channel ) , channel , channel , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ; }


Input: Maps a { @link ByteChannel } to a URL for use by Humble . [CODESPLIT] public static String map ( String url , ByteChannel channel ) { return map ( url , channel , channel , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ; }


Input: Maps an { @link InputStream } to a URL for use by Humble . [CODESPLIT] public static String map ( InputStream in ) { return map ( generateUniqueName ( in ) , in , null , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ; }


Input: Maps an { @link InputStream } to a URL for use by Humble . [CODESPLIT] public static String map ( String url , InputStream in ) { return map ( url , in , null , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ; }


Input: Maps an { @link OutputStream } to a URL for use by Humble . [CODESPLIT] public static String map ( OutputStream out ) { return map ( generateUniqueName ( out ) , null , out , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ; }


Input: Maps an { @link OutputStream } to a URL for use by Humble . [CODESPLIT] public static String map ( String url , OutputStream out ) { return map ( url , null , out , DEFAULT_UNMAP_URL_ON_OPEN , DEFAULT_CLOSE_STREAM_ON_CLOSE ) ; }


Input: Maps a { @link DataInput } or { @link DataOutput } object to a URL for use by Humble . [CODESPLIT] public static String map ( String url , DataInput in , DataOutput out , boolean unmapOnOpen , boolean closeOnClose ) { return map ( url , new DataInputOutputHandler ( in , out , closeOnClose ) ) ; }


Input: Maps an { @link ReadableByteChannel } or { @link WritableByteChannel } to a URL for use by Humble . [CODESPLIT] public static String map ( String url , ReadableByteChannel in , WritableByteChannel out , boolean unmapOnOpen , boolean closeOnClose ) { return map ( url , new ReadableWritableChannelHandler ( in , out , closeOnClose ) ) ; }


Input: Maps an { @link InputStream } or { @link OutputStream } to a URL for use by Humble . [CODESPLIT] public static String map ( String url , InputStream in , OutputStream out , boolean unmapOnOpen , boolean closeOnClose ) { return map ( url , new InputOutputStreamHandler ( in , out , closeOnClose ) ) ; }


Input: Maps a { @link IURLProtocolHandler } to a url that Humble can open . [CODESPLIT] public static String map ( String url , IURLProtocolHandler handler , boolean unmapUrlOnOpen ) { if ( mFactory . mapIO ( url , handler , unmapUrlOnOpen ) != null ) throw new RuntimeException ( "url is already mapped: " + url ) ; return DEFAULT_PROTOCOL + ":" + URLProtocolManager . getResourceFromURL ( url ) ; }


Input: Maps the given url or file name to the given { @link IURLProtocolHandler } or so that Humble calls to open the URL it will call back to the handler . [CODESPLIT] public IURLProtocolHandler mapIO ( String url , IURLProtocolHandler handler , boolean unmapUrlOnOpen ) { { if ( url == null || url . length ( ) <= 0 ) throw new IllegalArgumentException ( "must pass in non-zero url" ) ; if ( handler == null ) { throw new IllegalArgumentException ( "must pass in a non null handler" ) ; } String streamName = URLProtocolManager . getResourceFromURL ( url ) ; RegistrationInformation tuple = new RegistrationInformation ( streamName , handler , unmapUrlOnOpen ) ; RegistrationInformation oldTuple = mURLs . putIfAbsent ( streamName , tuple ) ; return oldTuple == null ? null : oldTuple . getHandler ( ) ; } }


Input: Unmaps a registration between a URL and the underlying i / o objects . <p > If URL contains a protocol it is ignored when trying to find the matching IO stream . < / p > [CODESPLIT] public IURLProtocolHandler unmapIO ( String url ) { if ( url == null || url . length ( ) <= 0 ) throw new IllegalArgumentException ( "must pass in non-zero url" ) ; String streamName = URLProtocolManager . getResourceFromURL ( url ) ; RegistrationInformation oldTuple = mURLs . remove ( streamName ) ; return oldTuple == null ? null : oldTuple . getHandler ( ) ; }


Input: { [CODESPLIT] public IURLProtocolHandler getHandler ( String protocol , String url , int flags ) { // Note: We need to remove any protocol markers from the url String streamName = URLProtocolManager . getResourceFromURL ( url ) ; RegistrationInformation tuple = mURLs . get ( streamName ) ; if ( tuple != null ) { IURLProtocolHandler handler = tuple . getHandler ( ) ; if ( tuple . isUnmappingOnOpen ( ) ) { IURLProtocolHandler oldHandler = unmapIO ( tuple . getName ( ) ) ; // the unmapIO is an atomic operation if ( handler != null && ! handler . equals ( oldHandler ) ) { // someone already unmapped this stream log . error ( "stream {} already unmapped; it was likely already opened" , tuple . getName ( ) ) ; return null ; } } return handler ; } return null ; }


Input:
Returns a new Logger object for this loggerName .

 [CODESPLIT] public static Logger getLogger ( String aLoggerName ) { long cPtr = FerryJNI . Logger_getLogger ( aLoggerName ) ; return ( cPtr == 0 ) ? null : new Logger ( cPtr , false ) ; }


Input:
Get a Logger object but ask the Logger code to
 free it up once the JavaVM shuts down . Use at your
 own risk .

 [CODESPLIT] public static Logger getStaticLogger ( String aLoggerName ) { long cPtr = FerryJNI . Logger_getStaticLogger ( aLoggerName ) ; return ( cPtr == 0 ) ? null : new Logger ( cPtr , false ) ; }


Input:
Log the message to the logger using sprintf () format
 strings .

 [CODESPLIT] public boolean log ( String filename , int lineNo , Logger . Level level , String format ) { return FerryJNI . Logger_log ( swigCPtr , this , filename , lineNo , level . swigValue ( ) , format ) ; }


Input: Create a new MediaAudioResampler . [CODESPLIT] public static MediaAudioResampler make ( AudioChannel . Layout outLayout , int outSampleRate , AudioFormat . Type outFormat , AudioChannel . Layout inLayout , int inSampleRate , AudioFormat . Type inFormat ) { long cPtr = VideoJNI . MediaAudioResampler_make ( outLayout . swigValue ( ) , outSampleRate , outFormat . swigValue ( ) , inLayout . swigValue ( ) , inSampleRate , inFormat . swigValue ( ) ) ; return ( cPtr == 0 ) ? null : new MediaAudioResampler ( cPtr , false ) ; }


Input:
Convert audio .

 in can be set to null to flush the last few samples out at the
 end .

 If more input is provided than output space then the input will be buffered .
 You can avoid this buffering by providing more output space than input .
 Conversion will run directly without copying whenever possible .

 [CODESPLIT] public int resample ( MediaSampled out , MediaSampled in ) { return VideoJNI . MediaAudioResampler_resample ( swigCPtr , this , MediaSampled . getCPtr ( out ) , out , MediaSampled . getCPtr ( in ) , in ) ; }


Input:
Get the timebase used when outputting time stamps for audio .

 Defaults to 1 / ( the lowest common multiple of getInputSampleRate ()
 and getOutputSampleRate () ) in order to ensure that no rounding
 of time stamps occur .

 For example if the input sample rate is 22050 and the output sample
 rate is 44100 then the output time base will be ( 1 / 44100 ) . But if the
 input sample rate is 48000 and the output sample rate is 22050 then
 the output time base will be ( 1 / lcm ( 48000 22050 )) which will be 1 / 7056000
 ( trust me ) . This is done so that timestamp values do not get rounded ( and
 therefore introduce drift ) . [CODESPLIT] public Rational getTimeBase ( ) { long cPtr = VideoJNI . MediaAudioResampler_getTimeBase ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ; }


Input:
Set the timebase to use for timestamps on output audio .

 [CODESPLIT] public void setTimeBase ( Rational rational ) { VideoJNI . MediaAudioResampler_setTimeBase ( swigCPtr , this , Rational . getCPtr ( rational ) , rational ) ; }


Input: Get an ordered sequence of index entries in this { @link Stream } . [CODESPLIT] public java . util . List < IndexEntry > getIndexEntries ( ) { final int numEntries = getNumIndexEntries ( ) ; java . util . List < IndexEntry > retval = new java . util . ArrayList < IndexEntry > ( Math . max ( numEntries , 10 ) ) ; for ( int i = 0 ; i < numEntries ; i ++ ) { final IndexEntry entry = getIndexEntry ( i ) ; if ( entry != null ) { retval . add ( entry ) ; } } return retval ; }


Input:
Get the ( sometimes estimated ) average frame rate of this container .
 For variable frame - rate containers ( they do exist ) this is just
 an approximation . Better to use getTimeBase () .

 For contant frame - rate containers this will be 1 / ( getTimeBase () )

 [CODESPLIT] public Rational getFrameRate ( ) { long cPtr = VideoJNI . ContainerStream_getFrameRate ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ; }


Input:
The time base in which all timestamps ( e . g . Presentation Time Stamp ( PTS )
 and Decompression Time Stamp ( DTS )) are represented . For example
 if the time base is 1 / 1000 then the difference between a PTS of 1 and
 a PTS of 2 is 1 millisecond . If the timebase is 1 / 1 then the difference
 between a PTS of 1 and a PTS of 2 is 1 second .

 [CODESPLIT] public Rational getTimeBase ( ) { long cPtr = VideoJNI . ContainerStream_getTimeBase ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ; }


Input:
Gets the sample aspect ratio .

 [CODESPLIT] public Rational getSampleAspectRatio ( ) { long cPtr = VideoJNI . ContainerStream_getSampleAspectRatio ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ; }


Input:
Get the underlying container for this stream or null if Humble Video
 doesn t know .

 [CODESPLIT] public Container getContainer ( ) { long cPtr = VideoJNI . ContainerStream_getContainer ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new Container ( cPtr , false ) ; }


Input:
Get the KeyValueBag for this object
 or null if none .

 If the Container or Stream object
 that this KeyValueBag came from was opened
 for reading then changes via KeyValueBag#setValue ( String String )
 will have no effect on the underlying media .

 If the Container or Stream object
 that this KeyValueBag came from was opened
 for writing then changes via KeyValueBag#setValue ( String String )
 will have no effect after Container#writeHeader ()
 is called .

 [CODESPLIT] public KeyValueBag getMetaData ( ) { long cPtr = VideoJNI . ContainerStream_getMetaData ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new KeyValueBag ( cPtr , false ) ; }


Input:
Search for the given time stamp in the key - frame index for this Stream .

 Not all ContainerFormat implementations
 maintain key frame indexes but if they have one
 then this method searches in the Stream index
 to quickly find the byte - offset of the nearest key - frame to
 the given time stamp .

 [CODESPLIT] public IndexEntry findTimeStampEntryInIndex ( long wantedTimeStamp , int flags ) { long cPtr = VideoJNI . ContainerStream_findTimeStampEntryInIndex ( swigCPtr , this , wantedTimeStamp , flags ) ; return ( cPtr == 0 ) ? null : new IndexEntry ( cPtr , false ) ; }


Input:
Get the IndexEntry at the given position in this
 Stream object s index .

 Not all ContainerFormat types maintain
 Stream indexes but if they do
 this method can return those entries .

 Do not modify the Container this stream
 is from between calls to this method and
 #getNumIndexEntries () as indexes may
 be compacted while processing .

 [CODESPLIT] public IndexEntry getIndexEntry ( int position ) { long cPtr = VideoJNI . ContainerStream_getIndexEntry ( swigCPtr , this , position ) ; return ( cPtr == 0 ) ? null : new IndexEntry ( cPtr , false ) ; }


Input:
For containers with Stream . Disposition . DISPOSITION_ATTACHED_PIC
 this returns a read - only copy of the packet containing the
 picture ( needs to be decoded separately ) . [CODESPLIT] public MediaPacket getAttachedPic ( ) { long cPtr = VideoJNI . ContainerStream_getAttachedPic ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new MediaPacket ( cPtr , false ) ; }


Input: Gets a collection of ALL codecs installed on this system . [CODESPLIT] public static java . util . Collection < Codec > getInstalledCodecs ( ) { java . util . Collection < Codec > retval = new java . util . HashSet < Codec > ( ) ; int count = getNumInstalledCodecs ( ) ; for ( int i = 0 ; i < count ; i ++ ) { Codec codec = getInstalledCodec ( i ) ; if ( codec != null ) retval . add ( codec ) ; } return retval ; }


Input: Returns a list of supported frame - rates this codec can encode video to . [CODESPLIT] public java . util . Collection < Rational > getSupportedVideoFrameRates ( ) { java . util . List < Rational > retval = new java . util . LinkedList < Rational > ( ) ; int count = getNumSupportedVideoFrameRates ( ) ; for ( int i = 0 ; i < count ; i ++ ) { Rational rate = getSupportedVideoFrameRate ( i ) ; if ( rate != null ) retval . add ( rate ) ; } return retval ; }


Input: Returns a list of supported pixel formats this codec can encode video in . [CODESPLIT] public java . util . Collection < PixelFormat . Type > getSupportedVideoPixelFormats ( ) { java . util . List < PixelFormat . Type > retval = new java . util . LinkedList < PixelFormat . Type > ( ) ; int count = getNumSupportedVideoPixelFormats ( ) ; for ( int i = 0 ; i < count ; i ++ ) { PixelFormat . Type type = getSupportedVideoPixelFormat ( i ) ; if ( type != null && type != PixelFormat . Type . PIX_FMT_NONE ) retval . add ( type ) ; } return retval ; }


Input: Returns a list of supported audio sample rates this codec can encode audio in . [CODESPLIT] public java . util . Collection < Integer > getSupportedAudioSampleRates ( ) { java . util . List < Integer > retval = new java . util . LinkedList < Integer > ( ) ; int count = getNumSupportedAudioSampleRates ( ) ; for ( int i = 0 ; i < count ; i ++ ) { int rate = getSupportedAudioSampleRate ( i ) ; if ( rate != 0 ) retval . add ( rate ) ; } return retval ; }


Input: Returns a list of supported audio sample formats this codec can encode audio in . [CODESPLIT] public java . util . Collection < AudioFormat . Type > getSupportedAudioFormats ( ) { java . util . List < AudioFormat . Type > retval = new java . util . LinkedList < AudioFormat . Type > ( ) ; int count = getNumSupportedAudioFormats ( ) ; for ( int i = 0 ; i < count ; i ++ ) { AudioFormat . Type fmt = getSupportedAudioFormat ( i ) ; if ( fmt != null && fmt != AudioFormat . Type . SAMPLE_FMT_NONE ) retval . add ( fmt ) ; } return retval ; }


Input: Returns a list of supported audio channel layouts this codec can encode audio in . [CODESPLIT] public java . util . Collection < AudioChannel . Layout > getSupportedAudioChannelLayouts ( ) { java . util . List < AudioChannel . Layout > retval = new java . util . LinkedList < AudioChannel . Layout > ( ) ; int count = getNumSupportedAudioChannelLayouts ( ) ; for ( int i = 0 ; i < count ; i ++ ) { AudioChannel . Layout layout = getSupportedAudioChannelLayout ( i ) ; if ( layout != AudioChannel . Layout . CH_LAYOUT_UNKNOWN ) retval . add ( layout ) ; } return retval ; }


Input: Find a codec that can be used for encoding . <br > [CODESPLIT] public static Codec findEncodingCodec ( Codec . ID id ) { long cPtr = VideoJNI . Codec_findEncodingCodec ( id . swigValue ( ) ) ; return ( cPtr == 0 ) ? null : new Codec ( cPtr , false ) ; }


Input: Find a codec that can be used for encoding . <br > [CODESPLIT] public static Codec findEncodingCodecByIntID ( int id ) { long cPtr = VideoJNI . Codec_findEncodingCodecByIntID ( id ) ; return ( cPtr == 0 ) ? null : new Codec ( cPtr , false ) ; }


Input: Find a codec that can be used for encoding . <br > [CODESPLIT] public static Codec findEncodingCodecByName ( String id ) { long cPtr = VideoJNI . Codec_findEncodingCodecByName ( id ) ; return ( cPtr == 0 ) ? null : new Codec ( cPtr , false ) ; }


Input: Find a codec that can be used for decoding . <br > [CODESPLIT] public static Codec findDecodingCodec ( Codec . ID id ) { long cPtr = VideoJNI . Codec_findDecodingCodec ( id . swigValue ( ) ) ; return ( cPtr == 0 ) ? null : new Codec ( cPtr , false ) ; }


Input: Find a codec that can be used for decoding . <br > [CODESPLIT] public static Codec findDecodingCodecByIntID ( int id ) { long cPtr = VideoJNI . Codec_findDecodingCodecByIntID ( id ) ; return ( cPtr == 0 ) ? null : new Codec ( cPtr , false ) ; }


Input: Find a codec that can be used for decoding . <br > [CODESPLIT] public static Codec findDecodingCodecByName ( String id ) { long cPtr = VideoJNI . Codec_findDecodingCodecByName ( id ) ; return ( cPtr == 0 ) ? null : new Codec ( cPtr , false ) ; }


Input:
Ask us to guess an encoding codec based on the inputs
 passed in .

 You must pass in at least one non null fmt shortName
 url or mime_type .

 [CODESPLIT] public static Codec guessEncodingCodec ( MuxerFormat fmt , String shortName , String url , String mimeType , MediaDescriptor . Type type ) { long cPtr = VideoJNI . Codec_guessEncodingCodec ( MuxerFormat . getCPtr ( fmt ) , fmt , shortName , url , mimeType , type . swigValue ( ) ) ; return ( cPtr == 0 ) ? null : new Codec ( cPtr , false ) ; }


Input:
Get the ICodec at the given index .

 [CODESPLIT] public static Codec getInstalledCodec ( int index ) { long cPtr = VideoJNI . Codec_getInstalledCodec ( index ) ; return ( cPtr == 0 ) ? null : new Codec ( cPtr , false ) ; }


Input:
Return the supported frame rate at the given index .

 [CODESPLIT] public Rational getSupportedVideoFrameRate ( int index ) { long cPtr = VideoJNI . Codec_getSupportedVideoFrameRate ( swigCPtr , this , index ) ; return ( cPtr == 0 ) ? null : new Rational ( cPtr , false ) ; }


Input:
Return the supported video pixel format at the given index .

 [CODESPLIT] public PixelFormat . Type getSupportedVideoPixelFormat ( int index ) { return PixelFormat . Type . swigToEnum ( VideoJNI . Codec_getSupportedVideoPixelFormat ( swigCPtr , this , index ) ) ; }


Input:
Get the supported sample format at this index .

 [CODESPLIT] public AudioFormat . Type getSupportedAudioFormat ( int index ) { return AudioFormat . Type . swigToEnum ( VideoJNI . Codec_getSupportedAudioFormat ( swigCPtr , this , index ) ) ; }


Input:
Get the supported audio channel layout at this index .

 The value returned is a bit flag representing the different
 types of audio layout this codec can support . Test the values
 by bit - comparing them to the AudioChannel . Layout
 enum types .

 [CODESPLIT] public AudioChannel . Layout getSupportedAudioChannelLayout ( int index ) { return AudioChannel . Layout . swigToEnum ( VideoJNI . Codec_getSupportedAudioChannelLayout ( swigCPtr , this , index ) ) ; }


Input:
Get the supported CodecProfile at this index .

 [CODESPLIT] public CodecProfile getSupportedProfile ( int index ) { long cPtr = VideoJNI . Codec_getSupportedProfile ( swigCPtr , this , index ) ; return ( cPtr == 0 ) ? null : new CodecProfile ( cPtr , false ) ; }


Input:
Resample in to out based on the resampler parameters .

 Resamples the in picture based on the parameters set when
 this resampler was constructed .

 [CODESPLIT] public int resample ( MediaSampled out , MediaSampled in ) { return VideoJNI . MediaPictureResampler_resample ( swigCPtr , this , MediaSampled . getCPtr ( out ) , out , MediaSampled . getCPtr ( in ) , in ) ; }


Input: A more precisely typed way to call #resample [CODESPLIT] public int resamplePicture ( MediaPicture out , MediaPicture in ) { return VideoJNI . MediaPictureResampler_resamplePicture ( swigCPtr , this , MediaPicture . getCPtr ( out ) , out , MediaPicture . getCPtr ( in ) , in ) ; }


Input:
Get a new picture resampler .

 [CODESPLIT] public static MediaPictureResampler make ( int outputWidth , int outputHeight , PixelFormat . Type outputFmt , int inputWidth , int inputHeight , PixelFormat . Type inputFmt , int flags ) { long cPtr = VideoJNI . MediaPictureResampler_make ( outputWidth , outputHeight , outputFmt . swigValue ( ) , inputWidth , inputHeight , inputFmt . swigValue ( ) , flags ) ; return ( cPtr == 0 ) ? null : new MediaPictureResampler ( cPtr , false ) ; }


Input: { [CODESPLIT] public int open ( String url , int flags ) { if ( mOpenStream != null ) { log . debug ( "attempting to open already open handler: {}" , mOpenStream ) ; return - 1 ; } switch ( flags ) { case URL_RDWR : log . debug ( "do not support read/write mode for Java IO Handlers" ) ; return - 1 ; case URL_WRONLY_MODE : mOpenStream = mOutputStream ; if ( mOpenStream == null ) { log . error ( "No OutputStream specified for writing: {}" , url ) ; return - 1 ; } break ; case URL_RDONLY_MODE : mOpenStream = mInputStream ; if ( mOpenStream == null ) { log . error ( "No InputStream specified for reading: {}" , url ) ; return - 1 ; } break ; default : log . error ( "Invalid flag passed to open: {}" , url ) ; return - 1 ; } return 0 ; }


Input: { [CODESPLIT] public int read ( byte [ ] buf , int size ) { int ret = - 1 ; if ( mOpenStream == null || ! ( mOpenStream instanceof InputStream ) ) return - 1 ; try { InputStream stream = ( InputStream ) mOpenStream ; ret = stream . read ( buf , 0 , size ) ; return ret ; } catch ( IOException e ) { log . error ( "Got IO exception reading from stream: {}; {}" , mOpenStream , e ) ; return - 1 ; } }