Java Code Examples for com.google.android.exoplayer2.util.ParsableBitArray#reset()
The following examples show how to use
com.google.android.exoplayer2.util.ParsableBitArray#reset() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Id3Decoder.java From MediaSDK with Apache License 2.0 | 5 votes |
private static MlltFrame decodeMlltFrame(ParsableByteArray id3Data, int frameSize) { // See ID3v2.4.0 native frames subsection 4.6. int mpegFramesBetweenReference = id3Data.readUnsignedShort(); int bytesBetweenReference = id3Data.readUnsignedInt24(); int millisecondsBetweenReference = id3Data.readUnsignedInt24(); int bitsForBytesDeviation = id3Data.readUnsignedByte(); int bitsForMillisecondsDeviation = id3Data.readUnsignedByte(); ParsableBitArray references = new ParsableBitArray(); references.reset(id3Data); int referencesBits = 8 * (frameSize - 10); int bitsPerReference = bitsForBytesDeviation + bitsForMillisecondsDeviation; int referencesCount = referencesBits / bitsPerReference; int[] bytesDeviations = new int[referencesCount]; int[] millisecondsDeviations = new int[referencesCount]; for (int i = 0; i < referencesCount; i++) { int bytesDeviation = references.readBits(bitsForBytesDeviation); int millisecondsDeviation = references.readBits(bitsForMillisecondsDeviation); bytesDeviations[i] = bytesDeviation; millisecondsDeviations[i] = millisecondsDeviation; } return new MlltFrame( mpegFramesBetweenReference, bytesBetweenReference, millisecondsBetweenReference, bytesDeviations, millisecondsDeviations); }
Example 2
Source File: DtsUtil.java From MediaSDK with Apache License 2.0 | 5 votes |
private static ParsableBitArray getNormalizedFrameHeader(byte[] frameHeader) { if (frameHeader[0] == FIRST_BYTE_BE) { // The frame is already 16-bit mode, big endian. return new ParsableBitArray(frameHeader); } // Data is not normalized, but we don't want to modify frameHeader. frameHeader = Arrays.copyOf(frameHeader, frameHeader.length); if (isLittleEndianFrameHeader(frameHeader)) { // Change endianness. for (int i = 0; i < frameHeader.length - 1; i += 2) { byte temp = frameHeader[i]; frameHeader[i] = frameHeader[i + 1]; frameHeader[i + 1] = temp; } } ParsableBitArray frameBits = new ParsableBitArray(frameHeader); if (frameHeader[0] == (byte) (SYNC_VALUE_14B_BE >> 24)) { // Discard the 2 most significant bits of each 16 bit word. ParsableBitArray scratchBits = new ParsableBitArray(frameHeader); while (scratchBits.bitsLeft() >= 16) { scratchBits.skipBits(2); frameBits.putInt(scratchBits.readBits(14), 14); } } frameBits.reset(frameHeader); return frameBits; }
Example 3
Source File: DtsUtil.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private static ParsableBitArray getNormalizedFrameHeader(byte[] frameHeader) { if (frameHeader[0] == FIRST_BYTE_BE) { // The frame is already 16-bit mode, big endian. return new ParsableBitArray(frameHeader); } // Data is not normalized, but we don't want to modify frameHeader. frameHeader = Arrays.copyOf(frameHeader, frameHeader.length); if (isLittleEndianFrameHeader(frameHeader)) { // Change endianness. for (int i = 0; i < frameHeader.length - 1; i += 2) { byte temp = frameHeader[i]; frameHeader[i] = frameHeader[i + 1]; frameHeader[i + 1] = temp; } } ParsableBitArray frameBits = new ParsableBitArray(frameHeader); if (frameHeader[0] == (byte) (SYNC_VALUE_14B_BE >> 24)) { // Discard the 2 most significant bits of each 16 bit word. ParsableBitArray scratchBits = new ParsableBitArray(frameHeader); while (scratchBits.bitsLeft() >= 16) { scratchBits.skipBits(2); frameBits.putInt(scratchBits.readBits(14), 14); } } frameBits.reset(frameHeader); return frameBits; }
Example 4
Source File: DtsUtil.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private static ParsableBitArray getNormalizedFrameHeader(byte[] frameHeader) { if (frameHeader[0] == FIRST_BYTE_BE) { // The frame is already 16-bit mode, big endian. return new ParsableBitArray(frameHeader); } // Data is not normalized, but we don't want to modify frameHeader. frameHeader = Arrays.copyOf(frameHeader, frameHeader.length); if (isLittleEndianFrameHeader(frameHeader)) { // Change endianness. for (int i = 0; i < frameHeader.length - 1; i += 2) { byte temp = frameHeader[i]; frameHeader[i] = frameHeader[i + 1]; frameHeader[i + 1] = temp; } } ParsableBitArray frameBits = new ParsableBitArray(frameHeader); if (frameHeader[0] == (byte) (SYNC_VALUE_14B_BE >> 24)) { // Discard the 2 most significant bits of each 16 bit word. ParsableBitArray scratchBits = new ParsableBitArray(frameHeader); while (scratchBits.bitsLeft() >= 16) { scratchBits.skipBits(2); frameBits.putInt(scratchBits.readBits(14), 14); } } frameBits.reset(frameHeader); return frameBits; }
Example 5
Source File: Id3Decoder.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private static MlltFrame decodeMlltFrame(ParsableByteArray id3Data, int frameSize) { // See ID3v2.4.0 native frames subsection 4.6. int mpegFramesBetweenReference = id3Data.readUnsignedShort(); int bytesBetweenReference = id3Data.readUnsignedInt24(); int millisecondsBetweenReference = id3Data.readUnsignedInt24(); int bitsForBytesDeviation = id3Data.readUnsignedByte(); int bitsForMillisecondsDeviation = id3Data.readUnsignedByte(); ParsableBitArray references = new ParsableBitArray(); references.reset(id3Data); int referencesBits = 8 * (frameSize - 10); int bitsPerReference = bitsForBytesDeviation + bitsForMillisecondsDeviation; int referencesCount = referencesBits / bitsPerReference; int[] bytesDeviations = new int[referencesCount]; int[] millisecondsDeviations = new int[referencesCount]; for (int i = 0; i < referencesCount; i++) { int bytesDeviation = references.readBits(bitsForBytesDeviation); int millisecondsDeviation = references.readBits(bitsForMillisecondsDeviation); bytesDeviations[i] = bytesDeviation; millisecondsDeviations[i] = millisecondsDeviation; } return new MlltFrame( mpegFramesBetweenReference, bytesBetweenReference, millisecondsBetweenReference, bytesDeviations, millisecondsDeviations); }
Example 6
Source File: DtsUtil.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private static ParsableBitArray getNormalizedFrameHeader(byte[] frameHeader) { if (frameHeader[0] == FIRST_BYTE_BE) { // The frame is already 16-bit mode, big endian. return new ParsableBitArray(frameHeader); } // Data is not normalized, but we don't want to modify frameHeader. frameHeader = Arrays.copyOf(frameHeader, frameHeader.length); if (isLittleEndianFrameHeader(frameHeader)) { // Change endianness. for (int i = 0; i < frameHeader.length - 1; i += 2) { byte temp = frameHeader[i]; frameHeader[i] = frameHeader[i + 1]; frameHeader[i + 1] = temp; } } ParsableBitArray frameBits = new ParsableBitArray(frameHeader); if (frameHeader[0] == (byte) (SYNC_VALUE_14B_BE >> 24)) { // Discard the 2 most significant bits of each 16 bit word. ParsableBitArray scratchBits = new ParsableBitArray(frameHeader); while (scratchBits.bitsLeft() >= 16) { scratchBits.skipBits(2); frameBits.putInt(scratchBits.readBits(14), 14); } } frameBits.reset(frameHeader); return frameBits; }
Example 7
Source File: Id3Decoder.java From Telegram with GNU General Public License v2.0 | 5 votes |
private static MlltFrame decodeMlltFrame(ParsableByteArray id3Data, int frameSize) { // See ID3v2.4.0 native frames subsection 4.6. int mpegFramesBetweenReference = id3Data.readUnsignedShort(); int bytesBetweenReference = id3Data.readUnsignedInt24(); int millisecondsBetweenReference = id3Data.readUnsignedInt24(); int bitsForBytesDeviation = id3Data.readUnsignedByte(); int bitsForMillisecondsDeviation = id3Data.readUnsignedByte(); ParsableBitArray references = new ParsableBitArray(); references.reset(id3Data); int referencesBits = 8 * (frameSize - 10); int bitsPerReference = bitsForBytesDeviation + bitsForMillisecondsDeviation; int referencesCount = referencesBits / bitsPerReference; int[] bytesDeviations = new int[referencesCount]; int[] millisecondsDeviations = new int[referencesCount]; for (int i = 0; i < referencesCount; i++) { int bytesDeviation = references.readBits(bitsForBytesDeviation); int millisecondsDeviation = references.readBits(bitsForMillisecondsDeviation); bytesDeviations[i] = bytesDeviation; millisecondsDeviations[i] = millisecondsDeviation; } return new MlltFrame( mpegFramesBetweenReference, bytesBetweenReference, millisecondsBetweenReference, bytesDeviations, millisecondsDeviations); }
Example 8
Source File: DtsUtil.java From Telegram with GNU General Public License v2.0 | 5 votes |
private static ParsableBitArray getNormalizedFrameHeader(byte[] frameHeader) { if (frameHeader[0] == FIRST_BYTE_BE) { // The frame is already 16-bit mode, big endian. return new ParsableBitArray(frameHeader); } // Data is not normalized, but we don't want to modify frameHeader. frameHeader = Arrays.copyOf(frameHeader, frameHeader.length); if (isLittleEndianFrameHeader(frameHeader)) { // Change endianness. for (int i = 0; i < frameHeader.length - 1; i += 2) { byte temp = frameHeader[i]; frameHeader[i] = frameHeader[i + 1]; frameHeader[i + 1] = temp; } } ParsableBitArray frameBits = new ParsableBitArray(frameHeader); if (frameHeader[0] == (byte) (SYNC_VALUE_14B_BE >> 24)) { // Discard the 2 most significant bits of each 16 bit word. ParsableBitArray scratchBits = new ParsableBitArray(frameHeader); while (scratchBits.bitsLeft() >= 16) { scratchBits.skipBits(2); frameBits.putInt(scratchBits.readBits(14), 14); } } frameBits.reset(frameHeader); return frameBits; }