Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4482db40
authored
Aug 02, 2019
by
sofijajvc
Committed by
Oliver Woodman
Aug 02, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Move output modes to constants file
PiperOrigin-RevId: 261295173
parent
39317048
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
24 deletions
extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/LibvpxVideoRenderer.java
extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/VpxDecoder.java
extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/VpxOutputBuffer.java
library/core/src/main/java/com/google/android/exoplayer2/C.java
extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/LibvpxVideoRenderer.java
View file @
4482db40
...
...
@@ -137,7 +137,7 @@ public class LibvpxVideoRenderer extends BaseRenderer {
private
long
joiningDeadlineMs
;
private
Surface
surface
;
private
VpxOutputBufferRenderer
outputBufferRenderer
;
private
int
outputMode
;
@C
.
VideoOutputMode
private
int
outputMode
;
private
boolean
waitingForKeys
;
private
boolean
inputStreamEnded
;
...
...
@@ -275,7 +275,7 @@ public class LibvpxVideoRenderer extends BaseRenderer {
formatQueue
=
new
TimedValueQueue
<>();
flagsOnlyBuffer
=
DecoderInputBuffer
.
newFlagsOnlyInstance
();
eventDispatcher
=
new
EventDispatcher
(
eventHandler
,
eventListener
);
outputMode
=
VpxDecoder
.
OUTPUT_MODE_NONE
;
outputMode
=
C
.
VIDEO_
OUTPUT_MODE_NONE
;
decoderReinitializationState
=
REINITIALIZATION_STATE_NONE
;
}
...
...
@@ -349,8 +349,9 @@ public class LibvpxVideoRenderer extends BaseRenderer {
if
(
waitingForKeys
)
{
return
false
;
}
if
(
format
!=
null
&&
(
isSourceReady
()
||
outputBuffer
!=
null
)
&&
(
renderedFirstFrame
||
outputMode
==
VpxDecoder
.
OUTPUT_MODE_NONE
))
{
if
(
format
!=
null
&&
(
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.
joiningDeadlineMs
=
C
.
TIME_UNSET
;
return
true
;
...
...
@@ -628,8 +629,8 @@ public class LibvpxVideoRenderer extends BaseRenderer {
*/
protected
void
renderOutputBuffer
(
VpxOutputBuffer
outputBuffer
)
throws
VpxDecoderException
{
int
bufferMode
=
outputBuffer
.
mode
;
boolean
renderSurface
=
bufferMode
==
VpxDecoder
.
OUTPUT_MODE_SURFACE_YUV
&&
surface
!=
null
;
boolean
renderYuv
=
bufferMode
==
VpxDecoder
.
OUTPUT_MODE_YUV
&&
outputBufferRenderer
!=
null
;
boolean
renderSurface
=
bufferMode
==
C
.
VIDEO_
OUTPUT_MODE_SURFACE_YUV
&&
surface
!=
null
;
boolean
renderYuv
=
bufferMode
==
C
.
VIDEO_
OUTPUT_MODE_YUV
&&
outputBufferRenderer
!=
null
;
lastRenderTimeUs
=
SystemClock
.
elapsedRealtime
()
*
1000
;
if
(!
renderYuv
&&
!
renderSurface
)
{
dropOutputBuffer
(
outputBuffer
);
...
...
@@ -713,12 +714,12 @@ public class LibvpxVideoRenderer extends BaseRenderer {
this
.
surface
=
surface
;
this
.
outputBufferRenderer
=
outputBufferRenderer
;
if
(
surface
!=
null
)
{
outputMode
=
VpxDecoder
.
OUTPUT_MODE_SURFACE_YUV
;
outputMode
=
C
.
VIDEO_
OUTPUT_MODE_SURFACE_YUV
;
}
else
{
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
)
{
decoder
.
setOutputMode
(
outputMode
);
}
...
...
@@ -735,7 +736,7 @@ public class LibvpxVideoRenderer extends BaseRenderer {
clearReportedVideoSize
();
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
// rendered to the output, report these again immediately.
maybeRenotifyVideoSizeChanged
();
...
...
@@ -915,7 +916,7 @@ public class LibvpxVideoRenderer extends BaseRenderer {
}
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.
if
(
isBufferLate
(
earlyUs
))
{
skipOutputBuffer
(
outputBuffer
);
...
...
extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/VpxDecoder.java
View file @
4482db40
...
...
@@ -29,10 +29,6 @@ import java.nio.ByteBuffer;
/* package */
final
class
VpxDecoder
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
DECODE_ERROR
=
1
;
private
static
final
int
DRM_ERROR
=
2
;
...
...
@@ -40,7 +36,7 @@ import java.nio.ByteBuffer;
private
final
ExoMediaCrypto
exoMediaCrypto
;
private
final
long
vpxDecContext
;
private
volatile
int
outputMode
;
@C
.
VideoOutputMode
private
volatile
int
outputMode
;
/**
* Creates a VP9 decoder.
...
...
@@ -87,10 +83,9 @@ import java.nio.ByteBuffer;
/**
* Sets the output mode for frames rendered by the decoder.
*
* @param outputMode The output mode. One of {@link #OUTPUT_MODE_NONE} and {@link
* #OUTPUT_MODE_YUV}.
* @param outputMode The output mode.
*/
public
void
setOutputMode
(
int
outputMode
)
{
public
void
setOutputMode
(
@C
.
VideoOutputMode
int
outputMode
)
{
this
.
outputMode
=
outputMode
;
}
...
...
@@ -108,7 +103,7 @@ import java.nio.ByteBuffer;
protected
void
releaseOutputBuffer
(
VpxOutputBuffer
buffer
)
{
// Decode only frames do not acquire a reference on the internal decoder buffer and thus do not
// 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
);
}
super
.
releaseOutputBuffer
(
buffer
);
...
...
extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/VpxOutputBuffer.java
View file @
4482db40
...
...
@@ -15,6 +15,7 @@
*/
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.video.ColorInfo
;
import
java.nio.ByteBuffer
;
...
...
@@ -31,7 +32,8 @@ public final class VpxOutputBuffer extends OutputBuffer {
/** Decoder private data. */
public
int
decoderPrivate
;
public
int
mode
;
/** Output mode. */
@C
.
VideoOutputMode
public
int
mode
;
/**
* RGB buffer for RGB mode.
*/
...
...
@@ -60,10 +62,10 @@ public final class VpxOutputBuffer extends OutputBuffer {
* Initializes the buffer.
*
* @param timeUs The presentation timestamp for the buffer, in microseconds.
* @param mode The output mode. One of {@link
VpxDecoder#
OUTPUT_MODE_NONE}, {@link
*
VpxDecoder#OUTPUT_MODE_YUV} and {@link VpxDecoder#
OUTPUT_MODE_SURFACE_YUV}.
* @param mode The output mode. One of {@link
C#VIDEO_
OUTPUT_MODE_NONE}, {@link
*
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
.
mode
=
mode
;
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/C.java
View file @
4482db40
...
...
@@ -500,6 +500,21 @@ public final class C {
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_MODE_SCALE_TO_FIT} or {@link #VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING}.
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment