src/main/java/org/jcodec/containers/mp3/MPEGAudioDemuxer.java
@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;
    }
@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;
    }
Used to auto-detect MPEG Audio (MP3) files

@param b
Buffer containing a snippet of data
@return Score from 0 to 100