Move output modes to constants file
PiperOrigin-RevId: 261295173
This commit is contained in:
parent
39317048e9
commit
4482db40e1
@ -137,7 +137,7 @@ public class LibvpxVideoRenderer extends BaseRenderer {
|
|||||||
private long joiningDeadlineMs;
|
private long joiningDeadlineMs;
|
||||||
private Surface surface;
|
private Surface surface;
|
||||||
private VpxOutputBufferRenderer outputBufferRenderer;
|
private VpxOutputBufferRenderer outputBufferRenderer;
|
||||||
private int outputMode;
|
@C.VideoOutputMode private int outputMode;
|
||||||
private boolean waitingForKeys;
|
private boolean waitingForKeys;
|
||||||
|
|
||||||
private boolean inputStreamEnded;
|
private boolean inputStreamEnded;
|
||||||
@ -275,7 +275,7 @@ public class LibvpxVideoRenderer extends BaseRenderer {
|
|||||||
formatQueue = new TimedValueQueue<>();
|
formatQueue = new TimedValueQueue<>();
|
||||||
flagsOnlyBuffer = DecoderInputBuffer.newFlagsOnlyInstance();
|
flagsOnlyBuffer = DecoderInputBuffer.newFlagsOnlyInstance();
|
||||||
eventDispatcher = new EventDispatcher(eventHandler, eventListener);
|
eventDispatcher = new EventDispatcher(eventHandler, eventListener);
|
||||||
outputMode = VpxDecoder.OUTPUT_MODE_NONE;
|
outputMode = C.VIDEO_OUTPUT_MODE_NONE;
|
||||||
decoderReinitializationState = REINITIALIZATION_STATE_NONE;
|
decoderReinitializationState = REINITIALIZATION_STATE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,8 +349,9 @@ public class LibvpxVideoRenderer extends BaseRenderer {
|
|||||||
if (waitingForKeys) {
|
if (waitingForKeys) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (format != null && (isSourceReady() || outputBuffer != null)
|
if (format != null
|
||||||
&& (renderedFirstFrame || outputMode == VpxDecoder.OUTPUT_MODE_NONE)) {
|
&& (isSourceReady() || outputBuffer != null)
|
||||||
|
&& (renderedFirstFrame || outputMode == C.VIDEO_OUTPUT_MODE_NONE)) {
|
||||||
// Ready. If we were joining then we've now joined, so clear the joining deadline.
|
// Ready. If we were joining then we've now joined, so clear the joining deadline.
|
||||||
joiningDeadlineMs = C.TIME_UNSET;
|
joiningDeadlineMs = C.TIME_UNSET;
|
||||||
return true;
|
return true;
|
||||||
@ -628,8 +629,8 @@ public class LibvpxVideoRenderer extends BaseRenderer {
|
|||||||
*/
|
*/
|
||||||
protected void renderOutputBuffer(VpxOutputBuffer outputBuffer) throws VpxDecoderException {
|
protected void renderOutputBuffer(VpxOutputBuffer outputBuffer) throws VpxDecoderException {
|
||||||
int bufferMode = outputBuffer.mode;
|
int bufferMode = outputBuffer.mode;
|
||||||
boolean renderSurface = bufferMode == VpxDecoder.OUTPUT_MODE_SURFACE_YUV && surface != null;
|
boolean renderSurface = bufferMode == C.VIDEO_OUTPUT_MODE_SURFACE_YUV && surface != null;
|
||||||
boolean renderYuv = bufferMode == VpxDecoder.OUTPUT_MODE_YUV && outputBufferRenderer != null;
|
boolean renderYuv = bufferMode == C.VIDEO_OUTPUT_MODE_YUV && outputBufferRenderer != null;
|
||||||
lastRenderTimeUs = SystemClock.elapsedRealtime() * 1000;
|
lastRenderTimeUs = SystemClock.elapsedRealtime() * 1000;
|
||||||
if (!renderYuv && !renderSurface) {
|
if (!renderYuv && !renderSurface) {
|
||||||
dropOutputBuffer(outputBuffer);
|
dropOutputBuffer(outputBuffer);
|
||||||
@ -713,12 +714,12 @@ public class LibvpxVideoRenderer extends BaseRenderer {
|
|||||||
this.surface = surface;
|
this.surface = surface;
|
||||||
this.outputBufferRenderer = outputBufferRenderer;
|
this.outputBufferRenderer = outputBufferRenderer;
|
||||||
if (surface != null) {
|
if (surface != null) {
|
||||||
outputMode = VpxDecoder.OUTPUT_MODE_SURFACE_YUV;
|
outputMode = C.VIDEO_OUTPUT_MODE_SURFACE_YUV;
|
||||||
} else {
|
} else {
|
||||||
outputMode =
|
outputMode =
|
||||||
outputBufferRenderer != null ? VpxDecoder.OUTPUT_MODE_YUV : VpxDecoder.OUTPUT_MODE_NONE;
|
outputBufferRenderer != null ? C.VIDEO_OUTPUT_MODE_YUV : C.VIDEO_OUTPUT_MODE_NONE;
|
||||||
}
|
}
|
||||||
if (outputMode != VpxDecoder.OUTPUT_MODE_NONE) {
|
if (outputMode != C.VIDEO_OUTPUT_MODE_NONE) {
|
||||||
if (decoder != null) {
|
if (decoder != null) {
|
||||||
decoder.setOutputMode(outputMode);
|
decoder.setOutputMode(outputMode);
|
||||||
}
|
}
|
||||||
@ -735,7 +736,7 @@ public class LibvpxVideoRenderer extends BaseRenderer {
|
|||||||
clearReportedVideoSize();
|
clearReportedVideoSize();
|
||||||
clearRenderedFirstFrame();
|
clearRenderedFirstFrame();
|
||||||
}
|
}
|
||||||
} else if (outputMode != VpxDecoder.OUTPUT_MODE_NONE) {
|
} else if (outputMode != C.VIDEO_OUTPUT_MODE_NONE) {
|
||||||
// The output is unchanged and non-null. If we know the video size and/or have already
|
// The output is unchanged and non-null. If we know the video size and/or have already
|
||||||
// rendered to the output, report these again immediately.
|
// rendered to the output, report these again immediately.
|
||||||
maybeRenotifyVideoSizeChanged();
|
maybeRenotifyVideoSizeChanged();
|
||||||
@ -915,7 +916,7 @@ public class LibvpxVideoRenderer extends BaseRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
long earlyUs = outputBuffer.timeUs - positionUs;
|
long earlyUs = outputBuffer.timeUs - positionUs;
|
||||||
if (outputMode == VpxDecoder.OUTPUT_MODE_NONE) {
|
if (outputMode == C.VIDEO_OUTPUT_MODE_NONE) {
|
||||||
// Skip frames in sync with playback, so we'll be at the right frame if the mode changes.
|
// Skip frames in sync with playback, so we'll be at the right frame if the mode changes.
|
||||||
if (isBufferLate(earlyUs)) {
|
if (isBufferLate(earlyUs)) {
|
||||||
skipOutputBuffer(outputBuffer);
|
skipOutputBuffer(outputBuffer);
|
||||||
|
@ -29,10 +29,6 @@ import java.nio.ByteBuffer;
|
|||||||
/* package */ final class VpxDecoder
|
/* package */ final class VpxDecoder
|
||||||
extends SimpleDecoder<VideoDecoderInputBuffer, VpxOutputBuffer, VpxDecoderException> {
|
extends SimpleDecoder<VideoDecoderInputBuffer, VpxOutputBuffer, VpxDecoderException> {
|
||||||
|
|
||||||
public static final int OUTPUT_MODE_NONE = -1;
|
|
||||||
public static final int OUTPUT_MODE_YUV = 0;
|
|
||||||
public static final int OUTPUT_MODE_SURFACE_YUV = 1;
|
|
||||||
|
|
||||||
private static final int NO_ERROR = 0;
|
private static final int NO_ERROR = 0;
|
||||||
private static final int DECODE_ERROR = 1;
|
private static final int DECODE_ERROR = 1;
|
||||||
private static final int DRM_ERROR = 2;
|
private static final int DRM_ERROR = 2;
|
||||||
@ -40,7 +36,7 @@ import java.nio.ByteBuffer;
|
|||||||
private final ExoMediaCrypto exoMediaCrypto;
|
private final ExoMediaCrypto exoMediaCrypto;
|
||||||
private final long vpxDecContext;
|
private final long vpxDecContext;
|
||||||
|
|
||||||
private volatile int outputMode;
|
@C.VideoOutputMode private volatile int outputMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a VP9 decoder.
|
* Creates a VP9 decoder.
|
||||||
@ -87,10 +83,9 @@ import java.nio.ByteBuffer;
|
|||||||
/**
|
/**
|
||||||
* Sets the output mode for frames rendered by the decoder.
|
* Sets the output mode for frames rendered by the decoder.
|
||||||
*
|
*
|
||||||
* @param outputMode The output mode. One of {@link #OUTPUT_MODE_NONE} and {@link
|
* @param outputMode The output mode.
|
||||||
* #OUTPUT_MODE_YUV}.
|
|
||||||
*/
|
*/
|
||||||
public void setOutputMode(int outputMode) {
|
public void setOutputMode(@C.VideoOutputMode int outputMode) {
|
||||||
this.outputMode = outputMode;
|
this.outputMode = outputMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +103,7 @@ import java.nio.ByteBuffer;
|
|||||||
protected void releaseOutputBuffer(VpxOutputBuffer buffer) {
|
protected void releaseOutputBuffer(VpxOutputBuffer buffer) {
|
||||||
// Decode only frames do not acquire a reference on the internal decoder buffer and thus do not
|
// Decode only frames do not acquire a reference on the internal decoder buffer and thus do not
|
||||||
// require a call to vpxReleaseFrame.
|
// require a call to vpxReleaseFrame.
|
||||||
if (outputMode == OUTPUT_MODE_SURFACE_YUV && !buffer.isDecodeOnly()) {
|
if (outputMode == C.VIDEO_OUTPUT_MODE_SURFACE_YUV && !buffer.isDecodeOnly()) {
|
||||||
vpxReleaseFrame(vpxDecContext, buffer);
|
vpxReleaseFrame(vpxDecContext, buffer);
|
||||||
}
|
}
|
||||||
super.releaseOutputBuffer(buffer);
|
super.releaseOutputBuffer(buffer);
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.exoplayer2.ext.vp9;
|
package com.google.android.exoplayer2.ext.vp9;
|
||||||
|
|
||||||
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.decoder.OutputBuffer;
|
import com.google.android.exoplayer2.decoder.OutputBuffer;
|
||||||
import com.google.android.exoplayer2.video.ColorInfo;
|
import com.google.android.exoplayer2.video.ColorInfo;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
@ -31,7 +32,8 @@ public final class VpxOutputBuffer extends OutputBuffer {
|
|||||||
/** Decoder private data. */
|
/** Decoder private data. */
|
||||||
public int decoderPrivate;
|
public int decoderPrivate;
|
||||||
|
|
||||||
public int mode;
|
/** Output mode. */
|
||||||
|
@C.VideoOutputMode public int mode;
|
||||||
/**
|
/**
|
||||||
* RGB buffer for RGB mode.
|
* RGB buffer for RGB mode.
|
||||||
*/
|
*/
|
||||||
@ -60,10 +62,10 @@ public final class VpxOutputBuffer extends OutputBuffer {
|
|||||||
* Initializes the buffer.
|
* Initializes the buffer.
|
||||||
*
|
*
|
||||||
* @param timeUs The presentation timestamp for the buffer, in microseconds.
|
* @param timeUs The presentation timestamp for the buffer, in microseconds.
|
||||||
* @param mode The output mode. One of {@link VpxDecoder#OUTPUT_MODE_NONE}, {@link
|
* @param mode The output mode. One of {@link C#VIDEO_OUTPUT_MODE_NONE}, {@link
|
||||||
* VpxDecoder#OUTPUT_MODE_YUV} and {@link VpxDecoder#OUTPUT_MODE_SURFACE_YUV}.
|
* C#VIDEO_OUTPUT_MODE_YUV} and {@link C#VIDEO_OUTPUT_MODE_SURFACE_YUV}.
|
||||||
*/
|
*/
|
||||||
public void init(long timeUs, int mode) {
|
public void init(long timeUs, @C.VideoOutputMode int mode) {
|
||||||
this.timeUs = timeUs;
|
this.timeUs = timeUs;
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
}
|
}
|
||||||
|
@ -499,6 +499,21 @@ public final class C {
|
|||||||
/** Indicates that a buffer should be decoded but not rendered. */
|
/** Indicates that a buffer should be decoded but not rendered. */
|
||||||
public static final int BUFFER_FLAG_DECODE_ONLY = 1 << 31; // 0x80000000
|
public static final int BUFFER_FLAG_DECODE_ONLY = 1 << 31; // 0x80000000
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Video decoder output modes. Possible modes are {@link #VIDEO_OUTPUT_MODE_NONE}, {@link
|
||||||
|
* #VIDEO_OUTPUT_MODE_YUV} and {@link #VIDEO_OUTPUT_MODE_SURFACE_YUV}.
|
||||||
|
*/
|
||||||
|
@Documented
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
@IntDef(value = {VIDEO_OUTPUT_MODE_NONE, VIDEO_OUTPUT_MODE_YUV, VIDEO_OUTPUT_MODE_SURFACE_YUV})
|
||||||
|
public @interface VideoOutputMode {}
|
||||||
|
/** Video decoder output mode is not set. */
|
||||||
|
public static final int VIDEO_OUTPUT_MODE_NONE = -1;
|
||||||
|
/** Video decoder output mode that outputs raw 4:2:0 YUV planes. */
|
||||||
|
public static final int VIDEO_OUTPUT_MODE_YUV = 0;
|
||||||
|
/** Video decoder output mode that renders 4:2:0 YUV planes directly to a surface. */
|
||||||
|
public static final int VIDEO_OUTPUT_MODE_SURFACE_YUV = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Video scaling modes for {@link MediaCodec}-based {@link Renderer}s. One of {@link
|
* Video scaling modes for {@link MediaCodec}-based {@link Renderer}s. One of {@link
|
||||||
* #VIDEO_SCALING_MODE_SCALE_TO_FIT} or {@link #VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING}.
|
* #VIDEO_SCALING_MODE_SCALE_TO_FIT} or {@link #VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING}.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user