com.google.android.exoplayer2.audio.Ac3Util Java Examples
The following examples show how to use
com.google.android.exoplayer2.audio.Ac3Util.
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: Ac3Reader.java From MediaSDK with Apache License 2.0 | 6 votes |
/** * Parses the sample header. */ @SuppressWarnings("ReferenceEquality") private void parseHeader() { headerScratchBits.setPosition(0); SyncFrameInfo frameInfo = Ac3Util.parseAc3SyncframeInfo(headerScratchBits); if (format == null || frameInfo.channelCount != format.channelCount || frameInfo.sampleRate != format.sampleRate || frameInfo.mimeType != format.sampleMimeType) { format = Format.createAudioSampleFormat(trackFormatId, frameInfo.mimeType, null, Format.NO_VALUE, Format.NO_VALUE, frameInfo.channelCount, frameInfo.sampleRate, null, null, 0, language); output.format(format); } sampleSize = frameInfo.frameSize; // In this class a sample is an access unit (syncframe in AC-3), but Format#sampleRate // specifies the number of PCM audio samples per second. sampleDurationUs = C.MICROS_PER_SECOND * frameInfo.sampleCount / format.sampleRate; }
Example #2
Source File: MatroskaExtractor.java From Telegram with GNU General Public License v2.0 | 6 votes |
public void startSample(ExtractorInput input, @C.BufferFlags int blockFlags, int size) throws IOException, InterruptedException { if (!foundSyncframe) { input.peekFully(syncframePrefix, 0, Ac3Util.TRUEHD_SYNCFRAME_PREFIX_LENGTH); input.resetPeekPosition(); if (Ac3Util.parseTrueHdSyncframeAudioSampleCount(syncframePrefix) == 0) { return; } foundSyncframe = true; sampleCount = 0; } if (sampleCount == 0) { // This is the first sample in the chunk, so reset the block flags and chunk size. this.blockFlags = blockFlags; chunkSize = 0; } chunkSize += size; }
Example #3
Source File: Ac3Reader.java From Telegram with GNU General Public License v2.0 | 6 votes |
/** * Parses the sample header. */ @SuppressWarnings("ReferenceEquality") private void parseHeader() { headerScratchBits.setPosition(0); SyncFrameInfo frameInfo = Ac3Util.parseAc3SyncframeInfo(headerScratchBits); if (format == null || frameInfo.channelCount != format.channelCount || frameInfo.sampleRate != format.sampleRate || frameInfo.mimeType != format.sampleMimeType) { format = Format.createAudioSampleFormat(trackFormatId, frameInfo.mimeType, null, Format.NO_VALUE, Format.NO_VALUE, frameInfo.channelCount, frameInfo.sampleRate, null, null, 0, language); output.format(format); } sampleSize = frameInfo.frameSize; // In this class a sample is an access unit (syncframe in AC-3), but Format#sampleRate // specifies the number of PCM audio samples per second. sampleDurationUs = C.MICROS_PER_SECOND * frameInfo.sampleCount / format.sampleRate; }
Example #4
Source File: MatroskaExtractor.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public void startSample(ExtractorInput input, @C.BufferFlags int blockFlags, int size) throws IOException, InterruptedException { if (!foundSyncframe) { input.peekFully(syncframePrefix, 0, Ac3Util.TRUEHD_SYNCFRAME_PREFIX_LENGTH); input.resetPeekPosition(); if (Ac3Util.parseTrueHdSyncframeAudioSampleCount(syncframePrefix) == 0) { return; } foundSyncframe = true; sampleCount = 0; } if (sampleCount == 0) { // This is the first sample in the chunk, so reset the block flags and chunk size. this.blockFlags = blockFlags; chunkSize = 0; } chunkSize += size; }
Example #5
Source File: Ac3Reader.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
/** * Parses the sample header. */ @SuppressWarnings("ReferenceEquality") private void parseHeader() { headerScratchBits.setPosition(0); SyncFrameInfo frameInfo = Ac3Util.parseAc3SyncframeInfo(headerScratchBits); if (format == null || frameInfo.channelCount != format.channelCount || frameInfo.sampleRate != format.sampleRate || frameInfo.mimeType != format.sampleMimeType) { format = Format.createAudioSampleFormat(trackFormatId, frameInfo.mimeType, null, Format.NO_VALUE, Format.NO_VALUE, frameInfo.channelCount, frameInfo.sampleRate, null, null, 0, language); output.format(format); } sampleSize = frameInfo.frameSize; // In this class a sample is an access unit (syncframe in AC-3), but Format#sampleRate // specifies the number of PCM audio samples per second. sampleDurationUs = C.MICROS_PER_SECOND * frameInfo.sampleCount / format.sampleRate; }
Example #6
Source File: Ac3Reader.java From K-Sonic with MIT License | 6 votes |
/** * Parses the sample header. */ private void parseHeader() { if (format == null) { // We read ahead to distinguish between AC-3 and E-AC-3. headerScratchBits.skipBits(40); isEac3 = headerScratchBits.readBits(5) == 16; headerScratchBits.setPosition(headerScratchBits.getPosition() - 45); format = isEac3 ? Ac3Util.parseEac3SyncframeFormat(headerScratchBits, trackFormatId, language , null) : Ac3Util.parseAc3SyncframeFormat(headerScratchBits, trackFormatId, language, null); output.format(format); } sampleSize = isEac3 ? Ac3Util.parseEAc3SyncframeSize(headerScratchBits.data) : Ac3Util.parseAc3SyncframeSize(headerScratchBits.data); int audioSamplesPerSyncframe = isEac3 ? Ac3Util.parseEAc3SyncframeAudioSampleCount(headerScratchBits.data) : Ac3Util.getAc3SyncframeAudioSampleCount(); // In this class a sample is an access unit (syncframe in AC-3), but the MediaFormat sample rate // specifies the number of PCM audio samples per second. sampleDurationUs = (int) (C.MICROS_PER_SECOND * audioSamplesPerSyncframe / format.sampleRate); }
Example #7
Source File: MatroskaExtractor.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public void startSample(ExtractorInput input, @C.BufferFlags int blockFlags, int size) throws IOException, InterruptedException { if (!foundSyncframe) { input.peekFully(syncframePrefix, 0, Ac3Util.TRUEHD_SYNCFRAME_PREFIX_LENGTH); input.resetPeekPosition(); if ((Ac3Util.parseTrueHdSyncframeAudioSampleCount(syncframePrefix) == C.INDEX_UNSET)) { return; } foundSyncframe = true; sampleCount = 0; } if (sampleCount == 0) { // This is the first sample in the chunk, so reset the block flags and chunk size. this.blockFlags = blockFlags; chunkSize = 0; } chunkSize += size; }
Example #8
Source File: Ac3Reader.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * Parses the sample header. */ @SuppressWarnings("ReferenceEquality") private void parseHeader() { headerScratchBits.setPosition(0); SyncFrameInfo frameInfo = Ac3Util.parseAc3SyncframeInfo(headerScratchBits); if (format == null || frameInfo.channelCount != format.channelCount || frameInfo.sampleRate != format.sampleRate || frameInfo.mimeType != format.sampleMimeType) { format = Format.createAudioSampleFormat(trackFormatId, frameInfo.mimeType, null, Format.NO_VALUE, Format.NO_VALUE, frameInfo.channelCount, frameInfo.sampleRate, null, null, 0, language); output.format(format); } sampleSize = frameInfo.frameSize; // In this class a sample is an access unit (syncframe in AC-3), but the MediaFormat sample rate // specifies the number of PCM audio samples per second. sampleDurationUs = C.MICROS_PER_SECOND * frameInfo.sampleCount / format.sampleRate; }
Example #9
Source File: MatroskaExtractor.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public void startSample(ExtractorInput input, @C.BufferFlags int blockFlags, int size) throws IOException, InterruptedException { if (!foundSyncframe) { input.peekFully(syncframePrefix, 0, Ac3Util.TRUEHD_SYNCFRAME_PREFIX_LENGTH); input.resetPeekPosition(); if ((Ac3Util.parseTrueHdSyncframeAudioSampleCount(syncframePrefix) == C.INDEX_UNSET)) { return; } foundSyncframe = true; sampleCount = 0; } if (sampleCount == 0) { // This is the first sample in the chunk, so reset the block flags and chunk size. this.blockFlags = blockFlags; chunkSize = 0; } chunkSize += size; }
Example #10
Source File: Ac3Reader.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * Parses the sample header. */ @SuppressWarnings("ReferenceEquality") private void parseHeader() { headerScratchBits.setPosition(0); SyncFrameInfo frameInfo = Ac3Util.parseAc3SyncframeInfo(headerScratchBits); if (format == null || frameInfo.channelCount != format.channelCount || frameInfo.sampleRate != format.sampleRate || frameInfo.mimeType != format.sampleMimeType) { format = Format.createAudioSampleFormat(trackFormatId, frameInfo.mimeType, null, Format.NO_VALUE, Format.NO_VALUE, frameInfo.channelCount, frameInfo.sampleRate, null, null, 0, language); output.format(format); } sampleSize = frameInfo.frameSize; // In this class a sample is an access unit (syncframe in AC-3), but the MediaFormat sample rate // specifies the number of PCM audio samples per second. sampleDurationUs = C.MICROS_PER_SECOND * frameInfo.sampleCount / format.sampleRate; }
Example #11
Source File: MatroskaExtractor.java From MediaSDK with Apache License 2.0 | 6 votes |
public void sampleMetadata( Track track, long timeUs, @C.BufferFlags int flags, int size, int offset) { if (!foundSyncframe) { return; } if (chunkSampleCount++ == 0) { // This is the first sample in the chunk. chunkTimeUs = timeUs; chunkFlags = flags; chunkSize = 0; } chunkSize += size; chunkOffset = offset; // The offset is to the end of the sample. if (chunkSampleCount >= Ac3Util.TRUEHD_RECHUNK_SAMPLE_COUNT) { // We haven't read enough samples to output a chunk. return; } outputPendingSampleMetadata(track); }
Example #12
Source File: MatroskaExtractor.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void sampleMetadata(Track track, long timeUs) { if (!foundSyncframe) { return; } if (sampleCount++ == 0) { // This is the first sample in the chunk, so update the timestamp. this.timeUs = timeUs; } if (sampleCount < Ac3Util.TRUEHD_RECHUNK_SAMPLE_COUNT) { // We haven't read enough samples to output a chunk. return; } track.output.sampleMetadata(this.timeUs, blockFlags, chunkSize, 0, track.cryptoData); sampleCount = 0; }
Example #13
Source File: MatroskaExtractor.java From Telegram with GNU General Public License v2.0 | 5 votes |
public void sampleMetadata(Track track, long timeUs) { if (!foundSyncframe) { return; } if (sampleCount++ == 0) { // This is the first sample in the chunk, so update the timestamp. this.timeUs = timeUs; } if (sampleCount < Ac3Util.TRUEHD_RECHUNK_SAMPLE_COUNT) { // We haven't read enough samples to output a chunk. return; } track.output.sampleMetadata(this.timeUs, blockFlags, chunkSize, 0, track.cryptoData); sampleCount = 0; }
Example #14
Source File: MatroskaExtractor.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void sampleMetadata(Track track, long timeUs) { if (!foundSyncframe) { return; } if (sampleCount++ == 0) { // This is the first sample in the chunk, so update the timestamp. this.timeUs = timeUs; } if (sampleCount < Ac3Util.TRUEHD_RECHUNK_SAMPLE_COUNT) { // We haven't read enough samples to output a chunk. return; } track.output.sampleMetadata(this.timeUs, blockFlags, chunkSize, 0, track.cryptoData); sampleCount = 0; }
Example #15
Source File: MatroskaExtractor.java From MediaSDK with Apache License 2.0 | 5 votes |
public void startSample(ExtractorInput input) throws IOException, InterruptedException { if (foundSyncframe) { return; } input.peekFully(syncframePrefix, 0, Ac3Util.TRUEHD_SYNCFRAME_PREFIX_LENGTH); input.resetPeekPosition(); if (Ac3Util.parseTrueHdSyncframeAudioSampleCount(syncframePrefix) == 0) { return; } foundSyncframe = true; }
Example #16
Source File: MatroskaExtractor.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void sampleMetadata(Track track, long timeUs) { if (!foundSyncframe) { return; } if (sampleCount++ == 0) { // This is the first sample in the chunk, so update the timestamp. this.timeUs = timeUs; } if (sampleCount < Ac3Util.TRUEHD_RECHUNK_SAMPLE_COUNT) { // We haven't read enough samples to output a chunk. return; } track.output.sampleMetadata(this.timeUs, blockFlags, chunkSize, 0, track.cryptoData); sampleCount = 0; }
Example #17
Source File: Ac3Extractor.java From K-Sonic with MIT License | 4 votes |
@Override public boolean sniff(ExtractorInput input) throws IOException, InterruptedException { // Skip any ID3 headers. ParsableByteArray scratch = new ParsableByteArray(10); int startPosition = 0; while (true) { input.peekFully(scratch.data, 0, 10); scratch.setPosition(0); if (scratch.readUnsignedInt24() != ID3_TAG) { break; } scratch.skipBytes(3); int length = scratch.readSynchSafeInt(); startPosition += 10 + length; input.advancePeekPosition(length); } input.resetPeekPosition(); input.advancePeekPosition(startPosition); int headerPosition = startPosition; int validFramesCount = 0; while (true) { input.peekFully(scratch.data, 0, 5); scratch.setPosition(0); int syncBytes = scratch.readUnsignedShort(); if (syncBytes != AC3_SYNC_WORD) { validFramesCount = 0; input.resetPeekPosition(); if (++headerPosition - startPosition >= MAX_SNIFF_BYTES) { return false; } input.advancePeekPosition(headerPosition); } else { if (++validFramesCount >= 4) { return true; } int frameSize = Ac3Util.parseAc3SyncframeSize(scratch.data); if (frameSize == C.LENGTH_UNSET) { return false; } input.advancePeekPosition(frameSize - 5); } } }
Example #18
Source File: Ac3Extractor.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public boolean sniff(ExtractorInput input) throws IOException, InterruptedException { // Skip any ID3 headers. ParsableByteArray scratch = new ParsableByteArray(10); int startPosition = 0; while (true) { input.peekFully(scratch.data, 0, 10); scratch.setPosition(0); if (scratch.readUnsignedInt24() != ID3_TAG) { break; } scratch.skipBytes(3); int length = scratch.readSynchSafeInt(); startPosition += 10 + length; input.advancePeekPosition(length); } input.resetPeekPosition(); input.advancePeekPosition(startPosition); int headerPosition = startPosition; int validFramesCount = 0; while (true) { input.peekFully(scratch.data, 0, 5); scratch.setPosition(0); int syncBytes = scratch.readUnsignedShort(); if (syncBytes != AC3_SYNC_WORD) { validFramesCount = 0; input.resetPeekPosition(); if (++headerPosition - startPosition >= MAX_SNIFF_BYTES) { return false; } input.advancePeekPosition(headerPosition); } else { if (++validFramesCount >= 4) { return true; } int frameSize = Ac3Util.parseAc3SyncframeSize(scratch.data); if (frameSize == C.LENGTH_UNSET) { return false; } input.advancePeekPosition(frameSize - 5); } } }
Example #19
Source File: Ac3Extractor.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@Override public boolean sniff(ExtractorInput input) throws IOException, InterruptedException { // Skip any ID3 headers. ParsableByteArray scratch = new ParsableByteArray(10); int startPosition = 0; while (true) { input.peekFully(scratch.data, 0, 10); scratch.setPosition(0); if (scratch.readUnsignedInt24() != ID3_TAG) { break; } scratch.skipBytes(3); // version, flags int length = scratch.readSynchSafeInt(); startPosition += 10 + length; input.advancePeekPosition(length); } input.resetPeekPosition(); input.advancePeekPosition(startPosition); int headerPosition = startPosition; int validFramesCount = 0; while (true) { input.peekFully(scratch.data, 0, 6); scratch.setPosition(0); int syncBytes = scratch.readUnsignedShort(); if (syncBytes != AC3_SYNC_WORD) { validFramesCount = 0; input.resetPeekPosition(); if (++headerPosition - startPosition >= MAX_SNIFF_BYTES) { return false; } input.advancePeekPosition(headerPosition); } else { if (++validFramesCount >= 4) { return true; } int frameSize = Ac3Util.parseAc3SyncframeSize(scratch.data); if (frameSize == C.LENGTH_UNSET) { return false; } input.advancePeekPosition(frameSize - 6); } } }
Example #20
Source File: MatroskaExtractor.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public TrueHdSampleRechunker() { syncframePrefix = new byte[Ac3Util.TRUEHD_SYNCFRAME_PREFIX_LENGTH]; }
Example #21
Source File: MatroskaExtractor.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public TrueHdSampleRechunker() { syncframePrefix = new byte[Ac3Util.TRUEHD_SYNCFRAME_PREFIX_LENGTH]; }
Example #22
Source File: MatroskaExtractor.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public TrueHdSampleRechunker() { syncframePrefix = new byte[Ac3Util.TRUEHD_SYNCFRAME_PREFIX_LENGTH]; }
Example #23
Source File: Ac3Extractor.java From Telegram with GNU General Public License v2.0 | 4 votes |
@Override public boolean sniff(ExtractorInput input) throws IOException, InterruptedException { // Skip any ID3 headers. ParsableByteArray scratch = new ParsableByteArray(10); int startPosition = 0; while (true) { input.peekFully(scratch.data, 0, 10); scratch.setPosition(0); if (scratch.readUnsignedInt24() != ID3_TAG) { break; } scratch.skipBytes(3); // version, flags int length = scratch.readSynchSafeInt(); startPosition += 10 + length; input.advancePeekPosition(length); } input.resetPeekPosition(); input.advancePeekPosition(startPosition); int headerPosition = startPosition; int validFramesCount = 0; while (true) { input.peekFully(scratch.data, 0, 6); scratch.setPosition(0); int syncBytes = scratch.readUnsignedShort(); if (syncBytes != AC3_SYNC_WORD) { validFramesCount = 0; input.resetPeekPosition(); if (++headerPosition - startPosition >= MAX_SNIFF_BYTES) { return false; } input.advancePeekPosition(headerPosition); } else { if (++validFramesCount >= 4) { return true; } int frameSize = Ac3Util.parseAc3SyncframeSize(scratch.data); if (frameSize == C.LENGTH_UNSET) { return false; } input.advancePeekPosition(frameSize - 6); } } }
Example #24
Source File: MatroskaExtractor.java From MediaSDK with Apache License 2.0 | 4 votes |
public TrueHdSampleRechunker() { syncframePrefix = new byte[Ac3Util.TRUEHD_SYNCFRAME_PREFIX_LENGTH]; }
Example #25
Source File: MatroskaExtractor.java From Telegram with GNU General Public License v2.0 | 4 votes |
public TrueHdSampleRechunker() { syncframePrefix = new byte[Ac3Util.TRUEHD_SYNCFRAME_PREFIX_LENGTH]; }
Example #26
Source File: Ac3Extractor.java From MediaSDK with Apache License 2.0 | 4 votes |
@Override public boolean sniff(ExtractorInput input) throws IOException, InterruptedException { // Skip any ID3 headers. ParsableByteArray scratch = new ParsableByteArray(ID3_HEADER_LENGTH); int startPosition = 0; while (true) { input.peekFully(scratch.data, /* offset= */ 0, ID3_HEADER_LENGTH); scratch.setPosition(0); if (scratch.readUnsignedInt24() != ID3_TAG) { break; } scratch.skipBytes(3); // version, flags int length = scratch.readSynchSafeInt(); startPosition += 10 + length; input.advancePeekPosition(length); } input.resetPeekPosition(); input.advancePeekPosition(startPosition); int headerPosition = startPosition; int validFramesCount = 0; while (true) { input.peekFully(scratch.data, 0, 6); scratch.setPosition(0); int syncBytes = scratch.readUnsignedShort(); if (syncBytes != AC3_SYNC_WORD) { validFramesCount = 0; input.resetPeekPosition(); if (++headerPosition - startPosition >= MAX_SNIFF_BYTES) { return false; } input.advancePeekPosition(headerPosition); } else { if (++validFramesCount >= 4) { return true; } int frameSize = Ac3Util.parseAc3SyncframeSize(scratch.data); if (frameSize == C.LENGTH_UNSET) { return false; } input.advancePeekPosition(frameSize - 6); } } }
Example #27
Source File: Ac3Extractor.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public boolean sniff(ExtractorInput input) throws IOException, InterruptedException { // Skip any ID3 headers. ParsableByteArray scratch = new ParsableByteArray(10); int startPosition = 0; while (true) { input.peekFully(scratch.data, 0, 10); scratch.setPosition(0); if (scratch.readUnsignedInt24() != ID3_TAG) { break; } scratch.skipBytes(3); int length = scratch.readSynchSafeInt(); startPosition += 10 + length; input.advancePeekPosition(length); } input.resetPeekPosition(); input.advancePeekPosition(startPosition); int headerPosition = startPosition; int validFramesCount = 0; while (true) { input.peekFully(scratch.data, 0, 5); scratch.setPosition(0); int syncBytes = scratch.readUnsignedShort(); if (syncBytes != AC3_SYNC_WORD) { validFramesCount = 0; input.resetPeekPosition(); if (++headerPosition - startPosition >= MAX_SNIFF_BYTES) { return false; } input.advancePeekPosition(headerPosition); } else { if (++validFramesCount >= 4) { return true; } int frameSize = Ac3Util.parseAc3SyncframeSize(scratch.data); if (frameSize == C.LENGTH_UNSET) { return false; } input.advancePeekPosition(frameSize - 5); } } }