Simplify nullability in Mp4Extractor
PiperOrigin-RevId: 437002406
This commit is contained in:
parent
c83a28f260
commit
e8b0971f12
@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package androidx.media3.extractor.mp4;
|
package androidx.media3.extractor.mp4;
|
||||||
|
|
||||||
import static androidx.media3.common.util.Assertions.checkNotNull;
|
|
||||||
import static androidx.media3.common.util.Util.castNonNull;
|
import static androidx.media3.common.util.Util.castNonNull;
|
||||||
import static androidx.media3.extractor.mp4.AtomParsers.parseTraks;
|
import static androidx.media3.extractor.mp4.AtomParsers.parseTraks;
|
||||||
import static androidx.media3.extractor.mp4.Sniffer.BRAND_HEIC;
|
import static androidx.media3.extractor.mp4.Sniffer.BRAND_HEIC;
|
||||||
@ -165,8 +164,8 @@ public final class Mp4Extractor implements Extractor, SeekMap {
|
|||||||
private int sampleCurrentNalBytesRemaining;
|
private int sampleCurrentNalBytesRemaining;
|
||||||
|
|
||||||
// Extractor outputs.
|
// Extractor outputs.
|
||||||
private @MonotonicNonNull ExtractorOutput extractorOutput;
|
private ExtractorOutput extractorOutput;
|
||||||
private Mp4Track @MonotonicNonNull [] tracks;
|
private Mp4Track[] tracks;
|
||||||
|
|
||||||
private long @MonotonicNonNull [][] accumulatedSampleSizes;
|
private long @MonotonicNonNull [][] accumulatedSampleSizes;
|
||||||
private int firstVideoTrackIndex;
|
private int firstVideoTrackIndex;
|
||||||
@ -197,6 +196,8 @@ public final class Mp4Extractor implements Extractor, SeekMap {
|
|||||||
nalLength = new ParsableByteArray(4);
|
nalLength = new ParsableByteArray(4);
|
||||||
scratch = new ParsableByteArray();
|
scratch = new ParsableByteArray();
|
||||||
sampleTrackIndex = C.INDEX_UNSET;
|
sampleTrackIndex = C.INDEX_UNSET;
|
||||||
|
extractorOutput = ExtractorOutput.PLACEHOLDER;
|
||||||
|
tracks = new Mp4Track[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -227,7 +228,7 @@ public final class Mp4Extractor implements Extractor, SeekMap {
|
|||||||
sefReader.reset();
|
sefReader.reset();
|
||||||
slowMotionMetadataEntries.clear();
|
slowMotionMetadataEntries.clear();
|
||||||
}
|
}
|
||||||
} else if (tracks != null) {
|
} else {
|
||||||
for (Mp4Track track : tracks) {
|
for (Mp4Track track : tracks) {
|
||||||
updateSampleIndex(track, timeUs);
|
updateSampleIndex(track, timeUs);
|
||||||
if (track.trueHdSampleRechunker != null) {
|
if (track.trueHdSampleRechunker != null) {
|
||||||
@ -280,7 +281,7 @@ public final class Mp4Extractor implements Extractor, SeekMap {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SeekPoints getSeekPoints(long timeUs) {
|
public SeekPoints getSeekPoints(long timeUs) {
|
||||||
if (checkNotNull(tracks).length == 0) {
|
if (tracks.length == 0) {
|
||||||
return new SeekPoints(SeekPoint.START);
|
return new SeekPoints(SeekPoint.START);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -502,7 +503,6 @@ 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);
|
||||||
@ -582,7 +582,7 @@ public final class Mp4Extractor implements Extractor, SeekMap {
|
|||||||
return RESULT_END_OF_INPUT;
|
return RESULT_END_OF_INPUT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Mp4Track track = castNonNull(tracks)[sampleTrackIndex];
|
Mp4Track track = 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];
|
||||||
@ -699,7 +699,7 @@ 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 < castNonNull(tracks).length; trackIndex++) {
|
for (int trackIndex = 0; trackIndex < 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) {
|
||||||
@ -744,7 +744,6 @@ public final class Mp4Extractor implements Extractor, SeekMap {
|
|||||||
private void processEndOfStreamReadingAtomHeader() {
|
private void processEndOfStreamReadingAtomHeader() {
|
||||||
if (fileType == FILE_TYPE_HEIC && (flags & FLAG_READ_MOTION_PHOTO_METADATA) != 0) {
|
if (fileType == FILE_TYPE_HEIC && (flags & FLAG_READ_MOTION_PHOTO_METADATA) != 0) {
|
||||||
// Add image track and prepare media.
|
// Add image track and prepare media.
|
||||||
ExtractorOutput extractorOutput = checkNotNull(this.extractorOutput);
|
|
||||||
TrackOutput trackOutput = extractorOutput.track(/* id= */ 0, C.TRACK_TYPE_IMAGE);
|
TrackOutput trackOutput = extractorOutput.track(/* id= */ 0, C.TRACK_TYPE_IMAGE);
|
||||||
@Nullable
|
@Nullable
|
||||||
Metadata metadata = motionPhotoMetadata == null ? null : new Metadata(motionPhotoMetadata);
|
Metadata metadata = motionPhotoMetadata == null ? null : new Metadata(motionPhotoMetadata);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user