Remove more low hanging fruit from nullness blacklist
PiperOrigin-RevId: 256573352
This commit is contained in:
parent
b1790f9dcc
commit
924cfac966
@ -15,8 +15,10 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.extractor.flv;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.ParserException;
|
||||
import com.google.android.exoplayer2.extractor.DummyTrackOutput;
|
||||
import com.google.android.exoplayer2.util.ParsableByteArray;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@ -44,7 +46,7 @@ import java.util.Map;
|
||||
private long durationUs;
|
||||
|
||||
public ScriptTagPayloadReader() {
|
||||
super(null);
|
||||
super(new DummyTrackOutput());
|
||||
durationUs = C.TIME_UNSET;
|
||||
}
|
||||
|
||||
@ -138,7 +140,10 @@ import java.util.Map;
|
||||
ArrayList<Object> list = new ArrayList<>(count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
int type = readAmfType(data);
|
||||
list.add(readAmfData(data, type));
|
||||
Object value = readAmfData(data, type);
|
||||
if (value != null) {
|
||||
list.add(value);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@ -157,7 +162,10 @@ import java.util.Map;
|
||||
if (type == AMF_TYPE_END_MARKER) {
|
||||
break;
|
||||
}
|
||||
array.put(key, readAmfData(data, type));
|
||||
Object value = readAmfData(data, type);
|
||||
if (value != null) {
|
||||
array.put(key, value);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
@ -174,7 +182,10 @@ import java.util.Map;
|
||||
for (int i = 0; i < count; i++) {
|
||||
String key = readAmfString(data);
|
||||
int type = readAmfType(data);
|
||||
array.put(key, readAmfData(data, type));
|
||||
Object value = readAmfData(data, type);
|
||||
if (value != null) {
|
||||
array.put(key, value);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
@ -191,6 +202,7 @@ import java.util.Map;
|
||||
return date;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Object readAmfData(ParsableByteArray data, int type) {
|
||||
switch (type) {
|
||||
case AMF_TYPE_NUMBER:
|
||||
@ -208,8 +220,8 @@ import java.util.Map;
|
||||
case AMF_TYPE_DATE:
|
||||
return readAmfDate(data);
|
||||
default:
|
||||
// We don't log a warning because there are types that we knowingly don't support.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -123,6 +123,7 @@ public final class Track {
|
||||
* @return The {@link TrackEncryptionBox} for the given sample description index. Maybe null if no
|
||||
* such entry exists.
|
||||
*/
|
||||
@Nullable
|
||||
public TrackEncryptionBox getSampleDescriptionEncryptionBox(int sampleDescriptionIndex) {
|
||||
return sampleDescriptionEncryptionBoxes == null ? null
|
||||
: sampleDescriptionEncryptionBoxes[sampleDescriptionIndex];
|
||||
|
@ -52,7 +52,7 @@ public final class TrackEncryptionBox {
|
||||
* If {@link #perSampleIvSize} is 0, holds the default initialization vector as defined in the
|
||||
* track encryption box or sample group description box. Null otherwise.
|
||||
*/
|
||||
public final byte[] defaultInitializationVector;
|
||||
@Nullable public final byte[] defaultInitializationVector;
|
||||
|
||||
/**
|
||||
* @param isEncrypted See {@link #isEncrypted}.
|
||||
|
@ -29,9 +29,10 @@ import java.lang.annotation.RetentionPolicy;
|
||||
*/
|
||||
public class Cue {
|
||||
|
||||
/**
|
||||
* An unset position or width.
|
||||
*/
|
||||
/** The empty cue. */
|
||||
public static final Cue EMPTY = new Cue("");
|
||||
|
||||
/** An unset position or width. */
|
||||
public static final float DIMEN_UNSET = Float.MIN_VALUE;
|
||||
|
||||
/**
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.text;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.decoder.SimpleDecoder;
|
||||
import java.nio.ByteBuffer;
|
||||
@ -69,6 +70,7 @@ public abstract class SimpleSubtitleDecoder extends
|
||||
|
||||
@SuppressWarnings("ByteBufferBackingArray")
|
||||
@Override
|
||||
@Nullable
|
||||
protected final SubtitleDecoderException decode(
|
||||
SubtitleInputBuffer inputBuffer, SubtitleOutputBuffer outputBuffer, boolean reset) {
|
||||
try {
|
||||
|
@ -18,6 +18,7 @@ package com.google.android.exoplayer2.text;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
import com.google.android.exoplayer2.decoder.OutputBuffer;
|
||||
import com.google.android.exoplayer2.util.Assertions;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -46,22 +47,22 @@ public abstract class SubtitleOutputBuffer extends OutputBuffer implements Subti
|
||||
|
||||
@Override
|
||||
public int getEventTimeCount() {
|
||||
return subtitle.getEventTimeCount();
|
||||
return Assertions.checkNotNull(subtitle).getEventTimeCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEventTime(int index) {
|
||||
return subtitle.getEventTime(index) + subsampleOffsetUs;
|
||||
return Assertions.checkNotNull(subtitle).getEventTime(index) + subsampleOffsetUs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNextEventTimeIndex(long timeUs) {
|
||||
return subtitle.getNextEventTimeIndex(timeUs - subsampleOffsetUs);
|
||||
return Assertions.checkNotNull(subtitle).getNextEventTimeIndex(timeUs - subsampleOffsetUs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Cue> getCues(long timeUs) {
|
||||
return subtitle.getCues(timeUs - subsampleOffsetUs);
|
||||
return Assertions.checkNotNull(subtitle).getCues(timeUs - subsampleOffsetUs);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,6 +16,7 @@
|
||||
package com.google.android.exoplayer2.text.pgs;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.text.Cue;
|
||||
import com.google.android.exoplayer2.text.SimpleSubtitleDecoder;
|
||||
import com.google.android.exoplayer2.text.Subtitle;
|
||||
@ -41,7 +42,7 @@ public final class PgsDecoder extends SimpleSubtitleDecoder {
|
||||
private final ParsableByteArray inflatedBuffer;
|
||||
private final CueBuilder cueBuilder;
|
||||
|
||||
private Inflater inflater;
|
||||
@Nullable private Inflater inflater;
|
||||
|
||||
public PgsDecoder() {
|
||||
super("PgsDecoder");
|
||||
@ -76,6 +77,7 @@ public final class PgsDecoder extends SimpleSubtitleDecoder {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Cue readNextSection(ParsableByteArray buffer, CueBuilder cueBuilder) {
|
||||
int limit = buffer.limit();
|
||||
int sectionType = buffer.readUnsignedByte();
|
||||
@ -197,6 +199,7 @@ public final class PgsDecoder extends SimpleSubtitleDecoder {
|
||||
bitmapY = buffer.readUnsignedShort();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Cue build() {
|
||||
if (planeWidth == 0
|
||||
|| planeHeight == 0
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.text.ssa;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.text.Cue;
|
||||
@ -50,7 +51,7 @@ public final class SsaDecoder extends SimpleSubtitleDecoder {
|
||||
private int formatTextIndex;
|
||||
|
||||
public SsaDecoder() {
|
||||
this(null);
|
||||
this(/* initializationData= */ null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -59,7 +60,7 @@ public final class SsaDecoder extends SimpleSubtitleDecoder {
|
||||
* format line. The second must contain an SSA header that will be assumed common to all
|
||||
* samples.
|
||||
*/
|
||||
public SsaDecoder(List<byte[]> initializationData) {
|
||||
public SsaDecoder(@Nullable List<byte[]> initializationData) {
|
||||
super("SsaDecoder");
|
||||
if (initializationData != null && !initializationData.isEmpty()) {
|
||||
haveInitializationData = true;
|
||||
@ -202,7 +203,7 @@ public final class SsaDecoder extends SimpleSubtitleDecoder {
|
||||
cues.add(new Cue(text));
|
||||
cueTimesUs.add(startTimeUs);
|
||||
if (endTimeUs != C.TIME_UNSET) {
|
||||
cues.add(null);
|
||||
cues.add(Cue.EMPTY);
|
||||
cueTimesUs.add(endTimeUs);
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ import java.util.List;
|
||||
private final long[] cueTimesUs;
|
||||
|
||||
/**
|
||||
* @param cues The cues in the subtitle. Null entries may be used to represent empty cues.
|
||||
* @param cues The cues in the subtitle.
|
||||
* @param cueTimesUs The cue times, in microseconds.
|
||||
*/
|
||||
public SsaSubtitle(Cue[] cues, long[] cueTimesUs) {
|
||||
@ -61,7 +61,7 @@ import java.util.List;
|
||||
@Override
|
||||
public List<Cue> getCues(long timeUs) {
|
||||
int index = Util.binarySearchFloor(cueTimesUs, timeUs, true, false);
|
||||
if (index == -1 || cues[index] == null) {
|
||||
if (index == -1 || cues[index] == Cue.EMPTY) {
|
||||
// timeUs is earlier than the start of the first cue, or we have an empty cue.
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
|
@ -112,11 +112,13 @@ public final class SubripDecoder extends SimpleSubtitleDecoder {
|
||||
// Read and parse the text and tags.
|
||||
textBuilder.setLength(0);
|
||||
tags.clear();
|
||||
while (!TextUtils.isEmpty(currentLine = subripData.readLine())) {
|
||||
currentLine = subripData.readLine();
|
||||
while (!TextUtils.isEmpty(currentLine)) {
|
||||
if (textBuilder.length() > 0) {
|
||||
textBuilder.append("<br>");
|
||||
}
|
||||
textBuilder.append(processLine(currentLine, tags));
|
||||
currentLine = subripData.readLine();
|
||||
}
|
||||
|
||||
Spanned text = Html.fromHtml(textBuilder.toString());
|
||||
@ -133,7 +135,7 @@ public final class SubripDecoder extends SimpleSubtitleDecoder {
|
||||
cues.add(buildCue(text, alignmentTag));
|
||||
|
||||
if (haveEndTimecode) {
|
||||
cues.add(null);
|
||||
cues.add(Cue.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ import java.util.List;
|
||||
private final long[] cueTimesUs;
|
||||
|
||||
/**
|
||||
* @param cues The cues in the subtitle. Null entries may be used to represent empty cues.
|
||||
* @param cues The cues in the subtitle.
|
||||
* @param cueTimesUs The cue times, in microseconds.
|
||||
*/
|
||||
public SubripSubtitle(Cue[] cues, long[] cueTimesUs) {
|
||||
@ -61,7 +61,7 @@ import java.util.List;
|
||||
@Override
|
||||
public List<Cue> getCues(long timeUs) {
|
||||
int index = Util.binarySearchFloor(cueTimesUs, timeUs, true, false);
|
||||
if (index == -1 || cues[index] == null) {
|
||||
if (index == -1 || cues[index] == Cue.EMPTY) {
|
||||
// timeUs is earlier than the start of the first cue, or we have an empty cue.
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
|
@ -65,6 +65,7 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder {
|
||||
private static final float DEFAULT_VERTICAL_PLACEMENT = 0.85f;
|
||||
|
||||
private final ParsableByteArray parsableByteArray;
|
||||
|
||||
private boolean customVerticalPlacement;
|
||||
private int defaultFontFace;
|
||||
private int defaultColorRgba;
|
||||
@ -80,10 +81,7 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder {
|
||||
public Tx3gDecoder(List<byte[]> initializationData) {
|
||||
super("Tx3gDecoder");
|
||||
parsableByteArray = new ParsableByteArray();
|
||||
decodeInitializationData(initializationData);
|
||||
}
|
||||
|
||||
private void decodeInitializationData(List<byte[]> initializationData) {
|
||||
if (initializationData != null && initializationData.size() == 1
|
||||
&& (initializationData.get(0).length == 48 || initializationData.get(0).length == 53)) {
|
||||
byte[] initializationBytes = initializationData.get(0);
|
||||
@ -151,8 +149,16 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder {
|
||||
}
|
||||
parsableByteArray.setPosition(position + atomSize);
|
||||
}
|
||||
return new Tx3gSubtitle(new Cue(cueText, null, verticalPlacement, Cue.LINE_TYPE_FRACTION,
|
||||
Cue.ANCHOR_TYPE_START, Cue.DIMEN_UNSET, Cue.TYPE_UNSET, Cue.DIMEN_UNSET));
|
||||
return new Tx3gSubtitle(
|
||||
new Cue(
|
||||
cueText,
|
||||
/* textAlignment= */ null,
|
||||
verticalPlacement,
|
||||
Cue.LINE_TYPE_FRACTION,
|
||||
Cue.ANCHOR_TYPE_START,
|
||||
Cue.DIMEN_UNSET,
|
||||
Cue.TYPE_UNSET,
|
||||
Cue.DIMEN_UNSET));
|
||||
}
|
||||
|
||||
private static String readSubtitleText(ParsableByteArray parsableByteArray)
|
||||
|
Loading…
x
Reference in New Issue
Block a user