Commit 0be3451c by olly Committed by Oliver Woodman

Change Format.createImageSampleFormat for common use case

PiperOrigin-RevId: 292570360
parent a7c6cb4a
...@@ -664,25 +664,22 @@ public final class Format implements Parcelable { ...@@ -664,25 +664,22 @@ public final class Format implements Parcelable {
public static Format createImageSampleFormat( public static Format createImageSampleFormat(
@Nullable String id, @Nullable String id,
@Nullable String sampleMimeType, @Nullable String sampleMimeType,
@Nullable String codecs,
int bitrate,
@C.SelectionFlags int selectionFlags, @C.SelectionFlags int selectionFlags,
@Nullable List<byte[]> initializationData, @Nullable List<byte[]> initializationData,
@Nullable String language, @Nullable String language) {
@Nullable DrmInitData drmInitData) {
return new Format( return new Format(
id, id,
/* label= */ null, /* label= */ null,
selectionFlags, selectionFlags,
/* roleFlags= */ 0, /* roleFlags= */ 0,
bitrate, /* bitrate= */ NO_VALUE,
codecs, /* codecs= */ null,
/* metadata=*/ null, /* metadata=*/ null,
/* containerMimeType= */ null, /* containerMimeType= */ null,
sampleMimeType, sampleMimeType,
/* maxInputSize= */ NO_VALUE, /* maxInputSize= */ NO_VALUE,
initializationData, initializationData,
drmInitData, /* drmInitData= */ null,
OFFSET_SAMPLE_RELATIVE, OFFSET_SAMPLE_RELATIVE,
/* width= */ NO_VALUE, /* width= */ NO_VALUE,
/* height= */ NO_VALUE, /* height= */ NO_VALUE,
...@@ -890,9 +887,8 @@ public final class Format implements Parcelable { ...@@ -890,9 +887,8 @@ public final class Format implements Parcelable {
this.width = width; this.width = width;
this.height = height; this.height = height;
this.frameRate = frameRate; this.frameRate = frameRate;
this.rotationDegrees = rotationDegrees == Format.NO_VALUE ? 0 : rotationDegrees; this.rotationDegrees = rotationDegrees == NO_VALUE ? 0 : rotationDegrees;
this.pixelWidthHeightRatio = this.pixelWidthHeightRatio = pixelWidthHeightRatio == NO_VALUE ? 1 : pixelWidthHeightRatio;
pixelWidthHeightRatio == Format.NO_VALUE ? 1 : pixelWidthHeightRatio;
this.projectionData = projectionData; this.projectionData = projectionData;
this.stereoMode = stereoMode; this.stereoMode = stereoMode;
this.colorInfo = colorInfo; this.colorInfo = colorInfo;
...@@ -900,8 +896,8 @@ public final class Format implements Parcelable { ...@@ -900,8 +896,8 @@ public final class Format implements Parcelable {
this.channelCount = channelCount; this.channelCount = channelCount;
this.sampleRate = sampleRate; this.sampleRate = sampleRate;
this.pcmEncoding = pcmEncoding; this.pcmEncoding = pcmEncoding;
this.encoderDelay = encoderDelay == Format.NO_VALUE ? 0 : encoderDelay; this.encoderDelay = encoderDelay == NO_VALUE ? 0 : encoderDelay;
this.encoderPadding = encoderPadding == Format.NO_VALUE ? 0 : encoderPadding; this.encoderPadding = encoderPadding == NO_VALUE ? 0 : encoderPadding;
// Audio and text specific. // Audio and text specific.
this.language = Util.normalizeLanguageCode(language); this.language = Util.normalizeLanguageCode(language);
this.accessibilityChannel = accessibilityChannel; this.accessibilityChannel = accessibilityChannel;
...@@ -1584,22 +1580,22 @@ public final class Format implements Parcelable { ...@@ -1584,22 +1580,22 @@ public final class Format implements Parcelable {
} }
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("id=").append(format.id).append(", mimeType=").append(format.sampleMimeType); builder.append("id=").append(format.id).append(", mimeType=").append(format.sampleMimeType);
if (format.bitrate != Format.NO_VALUE) { if (format.bitrate != NO_VALUE) {
builder.append(", bitrate=").append(format.bitrate); builder.append(", bitrate=").append(format.bitrate);
} }
if (format.codecs != null) { if (format.codecs != null) {
builder.append(", codecs=").append(format.codecs); builder.append(", codecs=").append(format.codecs);
} }
if (format.width != Format.NO_VALUE && format.height != Format.NO_VALUE) { if (format.width != NO_VALUE && format.height != NO_VALUE) {
builder.append(", res=").append(format.width).append("x").append(format.height); builder.append(", res=").append(format.width).append("x").append(format.height);
} }
if (format.frameRate != Format.NO_VALUE) { if (format.frameRate != NO_VALUE) {
builder.append(", fps=").append(format.frameRate); builder.append(", fps=").append(format.frameRate);
} }
if (format.channelCount != Format.NO_VALUE) { if (format.channelCount != NO_VALUE) {
builder.append(", channels=").append(format.channelCount); builder.append(", channels=").append(format.channelCount);
} }
if (format.sampleRate != Format.NO_VALUE) { if (format.sampleRate != NO_VALUE) {
builder.append(", sample_rate=").append(format.sampleRate); builder.append(", sample_rate=").append(format.sampleRate);
} }
if (format.language != null) { if (format.language != null) {
......
...@@ -2152,14 +2152,12 @@ public class MatroskaExtractor implements Extractor { ...@@ -2152,14 +2152,12 @@ public class MatroskaExtractor implements Extractor {
type = C.TRACK_TYPE_TEXT; type = C.TRACK_TYPE_TEXT;
format = format =
Format.createImageSampleFormat( Format.createImageSampleFormat(
Integer.toString(trackId), Integer.toString(trackId),
mimeType, mimeType,
null, selectionFlags,
Format.NO_VALUE, initializationData,
selectionFlags, language)
initializationData, .copyWithDrmInitData(drmInitData);
language,
drmInitData);
} else { } else {
throw new ParserException("Unexpected MIME type."); throw new ParserException("Unexpected MIME type.");
} }
......
...@@ -64,12 +64,9 @@ public final class DvbSubtitleReader implements ElementaryStreamReader { ...@@ -64,12 +64,9 @@ public final class DvbSubtitleReader implements ElementaryStreamReader {
Format.createImageSampleFormat( Format.createImageSampleFormat(
idGenerator.getFormatId(), idGenerator.getFormatId(),
MimeTypes.APPLICATION_DVBSUBS, MimeTypes.APPLICATION_DVBSUBS,
/* codecs= */ null,
Format.NO_VALUE,
/* selectionFlags= */ 0, /* selectionFlags= */ 0,
Collections.singletonList(subtitleInfo.initializationData), Collections.singletonList(subtitleInfo.initializationData),
subtitleInfo.language, subtitleInfo.language));
/* drmInitData= */ null));
outputs[i] = output; outputs[i] = output;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment