mirror of
https://github.com/androidx/media.git
synced 2025-05-14 02:59:52 +08:00
Remove Mp4Extractor from nullness exclusion list
PiperOrigin-RevId: 322310474
This commit is contained in:
parent
73df8e4a26
commit
8dd564c9a8
@ -16,6 +16,8 @@
|
|||||||
package com.google.android.exoplayer2.extractor.mp4;
|
package com.google.android.exoplayer2.extractor.mp4;
|
||||||
|
|
||||||
import static com.google.android.exoplayer2.extractor.mp4.AtomParsers.parseTraks;
|
import static com.google.android.exoplayer2.extractor.mp4.AtomParsers.parseTraks;
|
||||||
|
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
||||||
|
import static com.google.android.exoplayer2.util.Util.castNonNull;
|
||||||
|
|
||||||
import androidx.annotation.IntDef;
|
import androidx.annotation.IntDef;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@ -46,6 +48,7 @@ import java.util.ArrayDeque;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts data from the MP4 container format.
|
* Extracts data from the MP4 container format.
|
||||||
@ -118,8 +121,8 @@ public final class Mp4Extractor implements Extractor, SeekMap {
|
|||||||
|
|
||||||
// Extractor outputs.
|
// Extractor outputs.
|
||||||
private @MonotonicNonNull ExtractorOutput extractorOutput;
|
private @MonotonicNonNull ExtractorOutput extractorOutput;
|
||||||
private Mp4Track[] tracks;
|
private Mp4Track @MonotonicNonNull [] tracks;
|
||||||
private long[][] accumulatedSampleSizes;
|
private long @MonotonicNonNull [][] accumulatedSampleSizes;
|
||||||
private int firstVideoTrackIndex;
|
private int firstVideoTrackIndex;
|
||||||
private long durationUs;
|
private long durationUs;
|
||||||
private boolean isQuickTime;
|
private boolean isQuickTime;
|
||||||
@ -213,7 +216,7 @@ public final class Mp4Extractor implements Extractor, SeekMap {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SeekPoints getSeekPoints(long timeUs) {
|
public SeekPoints getSeekPoints(long timeUs) {
|
||||||
if (tracks.length == 0) {
|
if (checkNotNull(tracks).length == 0) {
|
||||||
return new SeekPoints(SeekPoint.START);
|
return new SeekPoints(SeekPoint.START);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,6 +349,7 @@ public final class Mp4Extractor implements Extractor, SeekMap {
|
|||||||
long atomPayloadSize = atomSize - atomHeaderBytesRead;
|
long atomPayloadSize = atomSize - atomHeaderBytesRead;
|
||||||
long atomEndPosition = input.getPosition() + atomPayloadSize;
|
long atomEndPosition = input.getPosition() + atomPayloadSize;
|
||||||
boolean seekRequired = false;
|
boolean seekRequired = false;
|
||||||
|
@Nullable ParsableByteArray atomData = this.atomData;
|
||||||
if (atomData != null) {
|
if (atomData != null) {
|
||||||
input.readFully(atomData.data, atomHeaderBytesRead, (int) atomPayloadSize);
|
input.readFully(atomData.data, atomHeaderBytesRead, (int) atomPayloadSize);
|
||||||
if (atomType == Atom.TYPE_ftyp) {
|
if (atomType == Atom.TYPE_ftyp) {
|
||||||
@ -418,6 +422,7 @@ public final class Mp4Extractor implements Extractor, SeekMap {
|
|||||||
isQuickTime,
|
isQuickTime,
|
||||||
/* modifyTrackFunction= */ track -> track);
|
/* modifyTrackFunction= */ track -> track);
|
||||||
|
|
||||||
|
ExtractorOutput extractorOutput = checkNotNull(this.extractorOutput);
|
||||||
int trackCount = trackSampleTables.size();
|
int trackCount = trackSampleTables.size();
|
||||||
for (int i = 0; i < trackCount; i++) {
|
for (int i = 0; i < trackCount; i++) {
|
||||||
TrackSampleTable trackSampleTable = trackSampleTables.get(i);
|
TrackSampleTable trackSampleTable = trackSampleTables.get(i);
|
||||||
@ -483,7 +488,7 @@ public final class Mp4Extractor implements Extractor, SeekMap {
|
|||||||
return RESULT_END_OF_INPUT;
|
return RESULT_END_OF_INPUT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Mp4Track track = tracks[sampleTrackIndex];
|
Mp4Track track = castNonNull(tracks)[sampleTrackIndex];
|
||||||
TrackOutput trackOutput = track.trackOutput;
|
TrackOutput trackOutput = track.trackOutput;
|
||||||
int sampleIndex = track.sampleIndex;
|
int sampleIndex = track.sampleIndex;
|
||||||
long position = track.sampleTable.offsets[sampleIndex];
|
long position = track.sampleTable.offsets[sampleIndex];
|
||||||
@ -583,14 +588,14 @@ public final class Mp4Extractor implements Extractor, SeekMap {
|
|||||||
long minAccumulatedBytes = Long.MAX_VALUE;
|
long minAccumulatedBytes = Long.MAX_VALUE;
|
||||||
boolean minAccumulatedBytesRequiresReload = true;
|
boolean minAccumulatedBytesRequiresReload = true;
|
||||||
int minAccumulatedBytesTrackIndex = C.INDEX_UNSET;
|
int minAccumulatedBytesTrackIndex = C.INDEX_UNSET;
|
||||||
for (int trackIndex = 0; trackIndex < tracks.length; trackIndex++) {
|
for (int trackIndex = 0; trackIndex < castNonNull(tracks).length; trackIndex++) {
|
||||||
Mp4Track track = tracks[trackIndex];
|
Mp4Track track = tracks[trackIndex];
|
||||||
int sampleIndex = track.sampleIndex;
|
int sampleIndex = track.sampleIndex;
|
||||||
if (sampleIndex == track.sampleTable.sampleCount) {
|
if (sampleIndex == track.sampleTable.sampleCount) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
long sampleOffset = track.sampleTable.offsets[sampleIndex];
|
long sampleOffset = track.sampleTable.offsets[sampleIndex];
|
||||||
long sampleAccumulatedBytes = accumulatedSampleSizes[trackIndex][sampleIndex];
|
long sampleAccumulatedBytes = castNonNull(accumulatedSampleSizes)[trackIndex][sampleIndex];
|
||||||
long skipAmount = sampleOffset - inputPosition;
|
long skipAmount = sampleOffset - inputPosition;
|
||||||
boolean requiresReload = skipAmount < 0 || skipAmount >= RELOAD_MINIMUM_SEEK_DISTANCE;
|
boolean requiresReload = skipAmount < 0 || skipAmount >= RELOAD_MINIMUM_SEEK_DISTANCE;
|
||||||
if ((!requiresReload && preferredRequiresReload)
|
if ((!requiresReload && preferredRequiresReload)
|
||||||
@ -616,6 +621,7 @@ public final class Mp4Extractor implements Extractor, SeekMap {
|
|||||||
/**
|
/**
|
||||||
* Updates every track's sample index to point its latest sync sample before/at {@code timeUs}.
|
* Updates every track's sample index to point its latest sync sample before/at {@code timeUs}.
|
||||||
*/
|
*/
|
||||||
|
@RequiresNonNull("tracks")
|
||||||
private void updateSampleIndices(long timeUs) {
|
private void updateSampleIndices(long timeUs) {
|
||||||
for (Mp4Track track : tracks) {
|
for (Mp4Track track : tracks) {
|
||||||
TrackSampleTable sampleTable = track.sampleTable;
|
TrackSampleTable sampleTable = track.sampleTable;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user