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