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
b127e162
authored
Mar 31, 2017
by
ojw28
Committed by
GitHub
Mar 31, 2017
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge pull request #2329 from supercairos/dev-v2
Opus: use fixed max size in Opus decoding
parents
c3fa6d89
2cf85530
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
extensions/opus/src/main/jni/opus_jni.cc
extensions/opus/src/main/jni/opus_jni.cc
View file @
b127e162
...
@@ -59,6 +59,7 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) {
...
@@ -59,6 +59,7 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) {
}
}
static
const
int
kBytesPerSample
=
2
;
// opus fixed point uses 16 bit samples.
static
const
int
kBytesPerSample
=
2
;
// opus fixed point uses 16 bit samples.
static
const
int
kMaxOpusOutputPacketSizeSamples
=
960
*
6
;
// Maximum packet size used in Xiph's opusdec.
static
int
channelCount
;
static
int
channelCount
;
static
int
errorCode
;
static
int
errorCode
;
...
@@ -101,7 +102,7 @@ DECODER_FUNC(jint, opusDecode, jlong jDecoder, jlong jTimeUs,
...
@@ -101,7 +102,7 @@ DECODER_FUNC(jint, opusDecode, jlong jDecoder, jlong jTimeUs,
const
int32_t
inputSampleCount
=
const
int32_t
inputSampleCount
=
opus_packet_get_nb_samples
(
inputBuffer
,
inputSize
,
sampleRate
);
opus_packet_get_nb_samples
(
inputBuffer
,
inputSize
,
sampleRate
);
const
jint
outputSize
=
inputSampleCount
*
kBytesPerSample
*
channelCount
;
const
jint
outputSize
=
kMaxOpusOutputPacketSizeSamples
*
kBytesPerSample
*
channelCount
;
env
->
CallObjectMethod
(
jOutputBuffer
,
outputBufferInit
,
jTimeUs
,
outputSize
);
env
->
CallObjectMethod
(
jOutputBuffer
,
outputBufferInit
,
jTimeUs
,
outputSize
);
const
jobject
jOutputBufferData
=
env
->
CallObjectMethod
(
jOutputBuffer
,
const
jobject
jOutputBufferData
=
env
->
CallObjectMethod
(
jOutputBuffer
,
...
@@ -110,7 +111,7 @@ DECODER_FUNC(jint, opusDecode, jlong jDecoder, jlong jTimeUs,
...
@@ -110,7 +111,7 @@ DECODER_FUNC(jint, opusDecode, jlong jDecoder, jlong jTimeUs,
int16_t
*
outputBufferData
=
reinterpret_cast
<
int16_t
*>
(
int16_t
*
outputBufferData
=
reinterpret_cast
<
int16_t
*>
(
env
->
GetDirectBufferAddress
(
jOutputBufferData
));
env
->
GetDirectBufferAddress
(
jOutputBufferData
));
int
sampleCount
=
opus_multistream_decode
(
decoder
,
inputBuffer
,
inputSize
,
int
sampleCount
=
opus_multistream_decode
(
decoder
,
inputBuffer
,
inputSize
,
outputBufferData
,
outputSize
,
0
);
outputBufferData
,
kMaxOpusOutputPacketSizeSamples
,
0
);
// record error code
// record error code
errorCode
=
(
sampleCount
<
0
)
?
sampleCount
:
0
;
errorCode
=
(
sampleCount
<
0
)
?
sampleCount
:
0
;
return
(
sampleCount
<
0
)
?
sampleCount
return
(
sampleCount
<
0
)
?
sampleCount
...
...
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