Bistream class is responsible for parsing an MPEG audio bitstream.
REVIEW: much of the parsing currently occurs in the various decoders. This should be moved into this class and
associated inner classes.
| Modifier and Type | Field and Description |
|---|---|
| private int | bitindex
Number (0-31, from MSB to LSB) of next bit for get_bits() |
| private final int[] | |
| public static final int | BITSTREAM_ERROR
The first bitstream error code. |
| public static final int | |
| private static final int | BUFFER_INT_SIZE
Maximum size of the frame buffer. |
| private Crc16[] | |
| private boolean | |
| private byte[] | frame_bytes
The bytes read from the stream. |
| private final int[] | framebuffer
The frame buffer that holds the data for the current frame. |
| private int | framesize
Number of valid bytes in the frame buffer. |
| private final Header | |
| private int | header_pos
Audio header position in stream. |
| pack-priv static byte | INITIAL_SYNC
Synchronization control constant for the initial synchronization to the start of a frame. |
| public static final int | INVALIDFRAME
Frame data are missing. |
| private byte[] | |
| private Float | |
| private boolean | |
| private final PushbackInputStream | |
| public static final int | STREAM_EOF
The end of the stream was reached. |
| public static final int | STREAM_ERROR
A problem occurred reading from the stream. |
| pack-priv static byte | STRICT_SYNC
Synchronization control constant for non-initial frame synchronizations. |
| private final byte[] | |
| private int | syncword
The current specified syncword |
| public static final int | UNEXPECTED_EOF
The end of the stream was reached prematurely. |
| public static final int | UNKNOWN_ERROR
An undeterminable error occurred. |
| public static final int | UNKNOWN_SAMPLE_RATE
The header describes an unknown sample rate. |
| private int | wordpointer
Index into |
| Access | Constructor and Description |
|---|---|
| public | Bitstream(InputStream
The InputStream to read from. in)Construct a IBitstream that reads data from a given InputStream. |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public int | |
| public InputStream | Returns: ID3v2 InputStream or null if ID3v2 frames are not available.Return raw ID3v2 frames + header. |
| public Float | |
| public int | |
| public boolean | isSyncCurrentPosition(int syncmode)
Determines if the next 4 bytes of the stream represent a frame header. |
| public boolean | |
| private void | |
| protected BitstreamException | |
| protected BitstreamException | |
| private void | |
| pack-priv void | |
| private void | |
| private String | |
| pack-priv int | |
| public int | |
| private int | readBytes(byte[] b, int offs, int len)
Simlar to readFully, but doesn't throw exception when EOF is reached. |
| public int | |
| public Header | Returns: the Header describing details of the frame read, or null if the end of the stream has been reached.Reads and parses the next frame from the input source. |
| private int | readFully(byte[]
The byte array to read the specified number of bytes into. b, int The index in the array where the first byte read should be stored. offs, int the number of bytes to read. len)Reads the exact number of bytes from the source input stream into a byte array. |
| private int | Returns: size of ID3v2 frames + headerMP3 InputStream in)Parse ID3v2 tag header to find out size of ID3v2 frames. |
| private Header | |
| pack-priv void | |
| pack-priv int | |
| public void |
| bitindex | back to summary |
|---|---|
| private int bitindex Number (0-31, from MSB to LSB) of next bit for get_bits() | |
| bitmask | back to summary |
|---|---|
| private final int[] bitmask | |
| BITSTREAM_ERROR | back to summary |
|---|---|
| public static final int BITSTREAM_ERROR The first bitstream error code. See the | |
| BITSTREAM_LAST | back to summary |
|---|---|
| public static final int BITSTREAM_LAST | |
| BUFFER_INT_SIZE | back to summary |
|---|---|
| private static final int BUFFER_INT_SIZE Maximum size of the frame buffer. | |
| crc | back to summary |
|---|---|
| private Crc16[] crc | |
| firstframe | back to summary |
|---|---|
| private boolean firstframe | |
| frame_bytes | back to summary |
|---|---|
| private byte[] frame_bytes The bytes read from the stream. | |
| framebuffer | back to summary |
|---|---|
| private final int[] framebuffer The frame buffer that holds the data for the current frame. | |
| framesize | back to summary |
|---|---|
| private int framesize Number of valid bytes in the frame buffer. | |
| header | back to summary |
|---|---|
| private final Header header | |
| header_pos | back to summary |
|---|---|
| private int header_pos Audio header position in stream. | |
| INITIAL_SYNC | back to summary |
|---|---|
| pack-priv static byte INITIAL_SYNC Synchronization control constant for the initial synchronization to the start of a frame. | |
| INVALIDFRAME | back to summary |
|---|---|
| public static final int INVALIDFRAME Frame data are missing. | |
| rawid3v2 | back to summary |
|---|---|
| private byte[] rawid3v2 | |
| replayGainScale | back to summary |
|---|---|
| private Float replayGainScale | |
| single_ch_mode | back to summary |
|---|---|
| private boolean single_ch_mode | |
| source | back to summary |
|---|---|
| private final PushbackInputStream source | |
| STREAM_EOF | back to summary |
|---|---|
| public static final int STREAM_EOF The end of the stream was reached. | |
| STREAM_ERROR | back to summary |
|---|---|
| public static final int STREAM_ERROR A problem occurred reading from the stream. | |
| STRICT_SYNC | back to summary |
|---|---|
| pack-priv static byte STRICT_SYNC Synchronization control constant for non-initial frame synchronizations. | |
| syncbuf | back to summary |
|---|---|
| private final byte[] syncbuf | |
| syncword | back to summary |
|---|---|
| private int syncword The current specified syncword | |
| UNEXPECTED_EOF | back to summary |
|---|---|
| public static final int UNEXPECTED_EOF The end of the stream was reached prematurely. | |
| UNKNOWN_ERROR | back to summary |
|---|---|
| public static final int UNKNOWN_ERROR An undeterminable error occurred. | |
| UNKNOWN_SAMPLE_RATE | back to summary |
|---|---|
| public static final int UNKNOWN_SAMPLE_RATE The header describes an unknown sample rate. | |
| wordpointer | back to summary |
|---|---|
| private int wordpointer Index into | |
| Bitstream | back to summary |
|---|---|
| public Bitstream(InputStream in) Construct a IBitstream that reads data from a given InputStream.
| |
| close | back to summary |
|---|---|
| public void close() throws BitstreamException Close the Bitstream. | |
| closeFrame | back to summary |
|---|---|
| public void closeFrame() Close MP3 frame. | |
| get_bits | back to summary |
|---|---|
| public int get_bits(int number_of_bits) Read bits from buffer into the lower bits of an unsigned int. The LSB contains the latest read bit of the stream. (1 <= number_of_bits <= 16) | |
| getRawID3v2 | back to summary |
|---|---|
| public InputStream getRawID3v2() Return raw ID3v2 frames + header.
| |
| getReplayGainScale | back to summary |
|---|---|
| public Float getReplayGainScale() | |
| header_pos | back to summary |
|---|---|
| public int header_pos() Return position of the first audio header.
| |
| isSyncCurrentPosition | back to summary |
|---|---|
| public boolean isSyncCurrentPosition(int syncmode) throws BitstreamException Determines if the next 4 bytes of the stream represent a frame header. | |
| isSyncMark | back to summary |
|---|---|
| public boolean isSyncMark(int headerstring, int syncmode, int word) | |
| loadID3v2 | back to summary |
|---|---|
| private void loadID3v2(InputStream in) Load ID3v2 frames.
| |
| newBitstreamException | back to summary |
|---|---|
| protected BitstreamException newBitstreamException(int errorcode) | |
| newBitstreamException | back to summary |
|---|---|
| protected BitstreamException newBitstreamException(int errorcode, Throwable throwable) | |
| nextFrame | back to summary |
|---|---|
| private void nextFrame() throws BitstreamException Read next MP3 frame. | |
| parse_frame | back to summary |
|---|---|
| pack-priv void parse_frame() throws BitstreamException Parses the data previously read with read_frame_data(). | |
| parseID3v2Frames | back to summary |
|---|---|
| private void parseID3v2Frames(byte[] bframes) | |
| parseText | back to summary |
|---|---|
| private String parseText(byte[] bframes, int offset, int size, int skip) | |
| read_frame_data | back to summary |
|---|---|
| pack-priv int read_frame_data(int bytesize) throws BitstreamException Reads the data for the next frame. The frame is not parsed until parse frame is called. | |
| readBits | back to summary |
|---|---|
| public int readBits(int n) | |
| readBytes | back to summary |
|---|---|
| private int readBytes(byte[] b, int offs, int len) throws BitstreamException Simlar to readFully, but doesn't throw exception when EOF is reached. | |
| readCheckedBits | back to summary |
|---|---|
| public int readCheckedBits(int n) | |
| readFrame | back to summary |
|---|---|
| public Header readFrame() throws BitstreamException Reads and parses the next frame from the input source.
| |
| readFully | back to summary |
|---|---|
| private int readFully(byte[] b, int offs, int len) throws BitstreamException Reads the exact number of bytes from the source input stream into a byte array.
| |
| readID3v2Header | back to summary |
|---|---|
| private int readID3v2Header(InputStream in) throws IOException Parse ID3v2 tag header to find out size of ID3v2 frames.
| |
| readNextFrame | back to summary |
|---|---|
| private Header readNextFrame() throws BitstreamException Read next MP3 frame.
| |
| set_syncword | back to summary |
|---|---|
| pack-priv void set_syncword(int syncword0) Set the word we want to sync the header to. In Big-Endian byte order | |
| syncHeader | back to summary |
|---|---|
| pack-priv int syncHeader(byte syncmode) throws BitstreamException Get next 32 bits from bitstream. They are stored in the headerstring. syncmod allows Synchro flag ID The returned value is False at the end of stream. | |
| unreadFrame | back to summary |
|---|---|
| public void unreadFrame() throws BitstreamException Unreads the bytes read from the frame. | |