Propagate Format through extension video decoders

We currently propagate only ColorInfo, but propagating the whole Format
is generally useful (e.g., to get the frame-rate on the output side of
the decoder).

PiperOrigin-RevId: 310359650
This commit is contained in:
olly 2020-05-07 16:10:32 +01:00 committed by Oliver Woodman
parent 252bf43bf4
commit 9a4ec54bdf
5 changed files with 8 additions and 5 deletions

View file

@ -128,7 +128,7 @@ import java.nio.ByteBuffer;
outputBuffer.addFlag(C.BUFFER_FLAG_DECODE_ONLY); outputBuffer.addFlag(C.BUFFER_FLAG_DECODE_ONLY);
} }
if (!decodeOnly) { if (!decodeOnly) {
outputBuffer.colorInfo = inputBuffer.colorInfo; outputBuffer.format = inputBuffer.format;
} }
return null; return null;

View file

@ -170,7 +170,7 @@ import java.nio.ByteBuffer;
} else if (getFrameResult == -1) { } else if (getFrameResult == -1) {
return new VpxDecoderException("Buffer initialization failed."); return new VpxDecoderException("Buffer initialization failed.");
} }
outputBuffer.colorInfo = inputBuffer.colorInfo; outputBuffer.format = inputBuffer.format;
} }
return null; return null;
} }

View file

@ -758,7 +758,7 @@ public abstract class DecoderVideoRenderer extends BaseRenderer {
waitingForFirstSampleInFormat = false; waitingForFirstSampleInFormat = false;
} }
inputBuffer.flip(); inputBuffer.flip();
inputBuffer.colorInfo = inputFormat.colorInfo; inputBuffer.format = inputFormat;
onQueueInputBuffer(inputBuffer); onQueueInputBuffer(inputBuffer);
decoder.queueInputBuffer(inputBuffer); decoder.queueInputBuffer(inputBuffer);
buffersInCodecCount++; buffersInCodecCount++;

View file

@ -16,12 +16,13 @@
package com.google.android.exoplayer2.video; package com.google.android.exoplayer2.video;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.decoder.DecoderInputBuffer; import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
/** Input buffer to a video decoder. */ /** Input buffer to a video decoder. */
public class VideoDecoderInputBuffer extends DecoderInputBuffer { public class VideoDecoderInputBuffer extends DecoderInputBuffer {
@Nullable public ColorInfo colorInfo; @Nullable public Format format;
public VideoDecoderInputBuffer() { public VideoDecoderInputBuffer() {
super(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_DIRECT); super(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_DIRECT);

View file

@ -17,6 +17,7 @@ package com.google.android.exoplayer2.video;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.decoder.OutputBuffer; import com.google.android.exoplayer2.decoder.OutputBuffer;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@ -43,7 +44,8 @@ public class VideoDecoderOutputBuffer extends OutputBuffer {
public int width; public int width;
public int height; public int height;
@Nullable public ColorInfo colorInfo; /** The format of the input from which this output buffer was decoded. */
@Nullable public Format format;
/** YUV planes for YUV mode. */ /** YUV planes for YUV mode. */
@Nullable public ByteBuffer[] yuvPlanes; @Nullable public ByteBuffer[] yuvPlanes;