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
d6b60637
authored
Feb 12, 2019
by
olly
Committed by
Andrew Lewis
Feb 18, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Allow specifying number of decoding threads to libvpx library.
PiperOrigin-RevId: 233653857
parent
edabbd52
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
6 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/jni/vpx_jni.cc
extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/LibvpxVideoRenderer.java
View file @
d6b60637
...
@@ -15,6 +15,8 @@
...
@@ -15,6 +15,8 @@
*/
*/
package
com
.
google
.
android
.
exoplayer2
.
ext
.
vp9
;
package
com
.
google
.
android
.
exoplayer2
.
ext
.
vp9
;
import
static
java
.
lang
.
Runtime
.
getRuntime
;
import
android.os.Handler
;
import
android.os.Handler
;
import
android.os.Looper
;
import
android.os.Looper
;
import
android.os.SystemClock
;
import
android.os.SystemClock
;
...
@@ -116,6 +118,7 @@ public class LibvpxVideoRenderer extends BaseRenderer {
...
@@ -116,6 +118,7 @@ public class LibvpxVideoRenderer extends BaseRenderer {
private
final
TimedValueQueue
<
Format
>
formatQueue
;
private
final
TimedValueQueue
<
Format
>
formatQueue
;
private
final
DecoderInputBuffer
flagsOnlyBuffer
;
private
final
DecoderInputBuffer
flagsOnlyBuffer
;
private
final
DrmSessionManager
<
ExoMediaCrypto
>
drmSessionManager
;
private
final
DrmSessionManager
<
ExoMediaCrypto
>
drmSessionManager
;
private
final
int
threads
;
private
Format
format
;
private
Format
format
;
private
Format
pendingFormat
;
private
Format
pendingFormat
;
...
@@ -209,12 +212,51 @@ public class LibvpxVideoRenderer extends BaseRenderer {
...
@@ -209,12 +212,51 @@ public class LibvpxVideoRenderer extends BaseRenderer {
DrmSessionManager
<
ExoMediaCrypto
>
drmSessionManager
,
DrmSessionManager
<
ExoMediaCrypto
>
drmSessionManager
,
boolean
playClearSamplesWithoutKeys
,
boolean
playClearSamplesWithoutKeys
,
boolean
disableLoopFilter
)
{
boolean
disableLoopFilter
)
{
this
(
allowedJoiningTimeMs
,
eventHandler
,
eventListener
,
maxDroppedFramesToNotify
,
drmSessionManager
,
playClearSamplesWithoutKeys
,
disableLoopFilter
,
getRuntime
().
availableProcessors
());
}
/**
* @param allowedJoiningTimeMs The maximum duration in milliseconds for which this video renderer
* can attempt to seamlessly join an ongoing playback.
* @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
* null if delivery of events is not required.
* @param eventListener A listener of events. May be null if delivery of events is not required.
* @param maxDroppedFramesToNotify The maximum number of frames that can be dropped between
* invocations of {@link VideoRendererEventListener#onDroppedFrames(int, long)}.
* @param drmSessionManager For use with encrypted media. May be null if support for encrypted
* media is not required.
* @param playClearSamplesWithoutKeys Encrypted media may contain clear (un-encrypted) regions.
* For example a media file may start with a short clear region so as to allow playback to
* begin in parallel with key acquisition. This parameter specifies whether the renderer is
* permitted to play clear regions of encrypted media files before {@code drmSessionManager}
* has obtained the keys necessary to decrypt encrypted regions of the media.
* @param disableLoopFilter Disable the libvpx in-loop smoothing filter.
* @param threads Number of threads libvpx will use to decode.
*/
public
LibvpxVideoRenderer
(
long
allowedJoiningTimeMs
,
Handler
eventHandler
,
VideoRendererEventListener
eventListener
,
int
maxDroppedFramesToNotify
,
DrmSessionManager
<
ExoMediaCrypto
>
drmSessionManager
,
boolean
playClearSamplesWithoutKeys
,
boolean
disableLoopFilter
,
int
threads
)
{
super
(
C
.
TRACK_TYPE_VIDEO
);
super
(
C
.
TRACK_TYPE_VIDEO
);
this
.
disableLoopFilter
=
disableLoopFilter
;
this
.
disableLoopFilter
=
disableLoopFilter
;
this
.
allowedJoiningTimeMs
=
allowedJoiningTimeMs
;
this
.
allowedJoiningTimeMs
=
allowedJoiningTimeMs
;
this
.
maxDroppedFramesToNotify
=
maxDroppedFramesToNotify
;
this
.
maxDroppedFramesToNotify
=
maxDroppedFramesToNotify
;
this
.
drmSessionManager
=
drmSessionManager
;
this
.
drmSessionManager
=
drmSessionManager
;
this
.
playClearSamplesWithoutKeys
=
playClearSamplesWithoutKeys
;
this
.
playClearSamplesWithoutKeys
=
playClearSamplesWithoutKeys
;
this
.
threads
=
threads
;
joiningDeadlineMs
=
C
.
TIME_UNSET
;
joiningDeadlineMs
=
C
.
TIME_UNSET
;
clearReportedVideoSize
();
clearReportedVideoSize
();
formatHolder
=
new
FormatHolder
();
formatHolder
=
new
FormatHolder
();
...
@@ -721,7 +763,8 @@ public class LibvpxVideoRenderer extends BaseRenderer {
...
@@ -721,7 +763,8 @@ public class LibvpxVideoRenderer extends BaseRenderer {
NUM_OUTPUT_BUFFERS
,
NUM_OUTPUT_BUFFERS
,
initialInputBufferSize
,
initialInputBufferSize
,
mediaCrypto
,
mediaCrypto
,
disableLoopFilter
);
disableLoopFilter
,
threads
);
decoder
.
setOutputMode
(
outputMode
);
decoder
.
setOutputMode
(
outputMode
);
TraceUtil
.
endSection
();
TraceUtil
.
endSection
();
long
decoderInitializedTimestamp
=
SystemClock
.
elapsedRealtime
();
long
decoderInitializedTimestamp
=
SystemClock
.
elapsedRealtime
();
...
...
extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/VpxDecoder.java
View file @
d6b60637
...
@@ -51,6 +51,7 @@ import java.nio.ByteBuffer;
...
@@ -51,6 +51,7 @@ import java.nio.ByteBuffer;
* @param exoMediaCrypto The {@link ExoMediaCrypto} object required for decoding encrypted
* @param exoMediaCrypto The {@link ExoMediaCrypto} object required for decoding encrypted
* content. Maybe null and can be ignored if decoder does not handle encrypted content.
* content. Maybe null and can be ignored if decoder does not handle encrypted content.
* @param disableLoopFilter Disable the libvpx in-loop smoothing filter.
* @param disableLoopFilter Disable the libvpx in-loop smoothing filter.
* @param threads Number of threads libvpx will use to decode.
* @throws VpxDecoderException Thrown if an exception occurs when initializing the decoder.
* @throws VpxDecoderException Thrown if an exception occurs when initializing the decoder.
*/
*/
public
VpxDecoder
(
public
VpxDecoder
(
...
@@ -58,7 +59,8 @@ import java.nio.ByteBuffer;
...
@@ -58,7 +59,8 @@ import java.nio.ByteBuffer;
int
numOutputBuffers
,
int
numOutputBuffers
,
int
initialInputBufferSize
,
int
initialInputBufferSize
,
ExoMediaCrypto
exoMediaCrypto
,
ExoMediaCrypto
exoMediaCrypto
,
boolean
disableLoopFilter
)
boolean
disableLoopFilter
,
int
threads
)
throws
VpxDecoderException
{
throws
VpxDecoderException
{
super
(
new
VpxInputBuffer
[
numInputBuffers
],
new
VpxOutputBuffer
[
numOutputBuffers
]);
super
(
new
VpxInputBuffer
[
numInputBuffers
],
new
VpxOutputBuffer
[
numOutputBuffers
]);
if
(!
VpxLibrary
.
isAvailable
())
{
if
(!
VpxLibrary
.
isAvailable
())
{
...
@@ -68,7 +70,7 @@ import java.nio.ByteBuffer;
...
@@ -68,7 +70,7 @@ import java.nio.ByteBuffer;
if
(
exoMediaCrypto
!=
null
&&
!
VpxLibrary
.
vpxIsSecureDecodeSupported
())
{
if
(
exoMediaCrypto
!=
null
&&
!
VpxLibrary
.
vpxIsSecureDecodeSupported
())
{
throw
new
VpxDecoderException
(
"Vpx decoder does not support secure decode."
);
throw
new
VpxDecoderException
(
"Vpx decoder does not support secure decode."
);
}
}
vpxDecContext
=
vpxInit
(
disableLoopFilter
);
vpxDecContext
=
vpxInit
(
disableLoopFilter
,
threads
);
if
(
vpxDecContext
==
0
)
{
if
(
vpxDecContext
==
0
)
{
throw
new
VpxDecoderException
(
"Failed to initialize decoder"
);
throw
new
VpxDecoderException
(
"Failed to initialize decoder"
);
}
}
...
@@ -165,7 +167,7 @@ import java.nio.ByteBuffer;
...
@@ -165,7 +167,7 @@ import java.nio.ByteBuffer;
}
}
}
}
private
native
long
vpxInit
(
boolean
disableLoopFilter
);
private
native
long
vpxInit
(
boolean
disableLoopFilter
,
int
threads
);
private
native
long
vpxClose
(
long
context
);
private
native
long
vpxClose
(
long
context
);
private
native
long
vpxDecode
(
long
context
,
ByteBuffer
encoded
,
int
length
);
private
native
long
vpxDecode
(
long
context
,
ByteBuffer
encoded
,
int
length
);
...
...
extensions/vp9/src/main/jni/vpx_jni.cc
View file @
d6b60637
...
@@ -433,11 +433,11 @@ int vpx_release_frame_buffer(void* priv, vpx_codec_frame_buffer_t* fb) {
...
@@ -433,11 +433,11 @@ int vpx_release_frame_buffer(void* priv, vpx_codec_frame_buffer_t* fb) {
return
buffer_manager
->
release
(
*
(
int
*
)
fb
->
priv
);
return
buffer_manager
->
release
(
*
(
int
*
)
fb
->
priv
);
}
}
DECODER_FUNC
(
jlong
,
vpxInit
,
jboolean
disableLoopFilter
)
{
DECODER_FUNC
(
jlong
,
vpxInit
,
jboolean
disableLoopFilter
,
jint
threads
)
{
JniCtx
*
context
=
new
JniCtx
();
JniCtx
*
context
=
new
JniCtx
();
context
->
decoder
=
new
vpx_codec_ctx_t
();
context
->
decoder
=
new
vpx_codec_ctx_t
();
vpx_codec_dec_cfg_t
cfg
=
{
0
,
0
,
0
};
vpx_codec_dec_cfg_t
cfg
=
{
0
,
0
,
0
};
cfg
.
threads
=
android_getCpuCount
()
;
cfg
.
threads
=
threads
;
errorCode
=
0
;
errorCode
=
0
;
vpx_codec_err_t
err
=
vpx_codec_err_t
err
=
vpx_codec_dec_init
(
context
->
decoder
,
&
vpx_codec_vp9_dx_algo
,
&
cfg
,
0
);
vpx_codec_dec_init
(
context
->
decoder
,
&
vpx_codec_vp9_dx_algo
,
&
cfg
,
0
);
...
...
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