mirror of
https://github.com/samsonjs/media.git
synced 2026-03-29 10:05:48 +00:00
Fix detection of TrueHD syncframe in MatroskaExtractor
MatroskaExtractor was checking for INDEX_UNSET as the sample count for buffers not containing syncframes, but actually 0 was returned for these. Theoretically this could prevent us starting to play a TrueHD stream as we wait until we can read the sample count from a syncframe before accepting the audio in DefaultAudioSink, but it seems that rechunking avoided this issue arising in practice. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=206575462
This commit is contained in:
parent
656c2172dd
commit
68add98c23
2 changed files with 47 additions and 1 deletions
|
|
@ -1551,7 +1551,7 @@ public final class MatroskaExtractor implements Extractor {
|
|||
if (!foundSyncframe) {
|
||||
input.peekFully(syncframePrefix, 0, Ac3Util.TRUEHD_SYNCFRAME_PREFIX_LENGTH);
|
||||
input.resetPeekPosition();
|
||||
if ((Ac3Util.parseTrueHdSyncframeAudioSampleCount(syncframePrefix) == C.INDEX_UNSET)) {
|
||||
if ((Ac3Util.parseTrueHdSyncframeAudioSampleCount(syncframePrefix) == 0)) {
|
||||
return;
|
||||
}
|
||||
foundSyncframe = true;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.android.exoplayer2.audio;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
/** Unit tests for {@link Ac3Util}. */
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public final class Ac3UtilTest {
|
||||
|
||||
private static final int TRUEHD_SYNCFRAME_SAMPLE_COUNT = 40;
|
||||
private static final byte[] TRUEHD_SYNCFRAME_HEADER =
|
||||
Util.getBytesFromHexString("C07504D8F8726FBA0097C00FB7520000");
|
||||
private static final byte[] TRUEHD_NON_SYNCFRAME_HEADER =
|
||||
Util.getBytesFromHexString("A025048860224E6F6DEDB6D5B6DBAFE6");
|
||||
|
||||
@Test
|
||||
public void testParseTrueHdSyncframeAudioSampleCount_nonSyncframe() {
|
||||
assertThat(Ac3Util.parseTrueHdSyncframeAudioSampleCount(TRUEHD_NON_SYNCFRAME_HEADER))
|
||||
.isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseTrueHdSyncframeAudioSampleCount_syncframe() {
|
||||
assertThat(Ac3Util.parseTrueHdSyncframeAudioSampleCount(TRUEHD_SYNCFRAME_HEADER))
|
||||
.isEqualTo(TRUEHD_SYNCFRAME_SAMPLE_COUNT);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue