src/main/java/org/jcodec/containers/imgseq/ImageSequenceDemuxer.java
public int getMaxAvailableFrame() {
        if (maxAvailableFrame == -1) {

            int firstPoint = 0;
            for (int i = MAX_MAX; i > 0; i /= 2) {
                if (new File(String.format(namePattern, i)).exists()) {
                    firstPoint = i;
                    break;
                }
            }
            int pos = firstPoint;
            for (int interv = firstPoint / 2; interv > 1; interv /= 2) {
                if (new File(String.format(namePattern, pos + interv)).exists()) {
                    pos += interv;
                }
            }
            maxAvailableFrame = pos;
            Logger.info("Max frame found: " + maxAvailableFrame);
        }
        return Math.min(maxAvailableFrame, maxFrames);
    }
public int getMaxAvailableFrame() {
        if (maxAvailableFrame == -1) {

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

Performs at max at max 48 Stat calls ( 2*log2(MAX_MAX) ).

@return
Finds maximum frame of a sequence by bisecting the range .