Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Opus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xiph.Org
Opus
Commits
243ff0c6
Commit
243ff0c6
authored
13 years ago
by
Jean-Marc Valin
Browse files
Options
Downloads
Patches
Plain Diff
comments
parent
0734cad5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/opus_encoder.c
+10
-2
10 additions, 2 deletions
src/opus_encoder.c
with
10 additions
and
2 deletions
src/opus_encoder.c
+
10
−
2
View file @
243ff0c6
...
...
@@ -118,10 +118,12 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
int
to_celt
=
0
;
celt_int32
mono_rate
;
/* Rete-dependent mono-stereo decision */
if
(
st
->
channels
==
2
)
{
celt_int32
decision_rate
;
decision_rate
=
st
->
bitrate_bps
+
st
->
voice_ratio
*
st
->
voice_ratio
;
/* Add some hysteresis */
if
(
st
->
stream_channels
==
2
)
decision_rate
+=
4000
;
else
...
...
@@ -145,7 +147,9 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
if
(
st
->
user_mode
==
OPUS_MODE_AUTO
)
{
celt_int32
decision_rate
;
/* SILK/CELT threshold is higher for voice than for music */
decision_rate
=
mono_rate
-
3
*
st
->
voice_ratio
*
st
->
voice_ratio
;
/* Hysteresis */
if
(
st
->
prev_mode
==
MODE_CELT_ONLY
)
decision_rate
+=
4000
;
else
if
(
st
->
prev_mode
>
0
)
...
...
@@ -161,7 +165,7 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
st
->
mode
=
MODE_CELT_ONLY
;
}
/*
B
andwidth selection */
/*
Automatic (rate-dependent) b
andwidth selection */
if
(
st
->
mode
==
MODE_CELT_ONLY
)
{
if
(
mono_rate
>
35000
||
(
mono_rate
>
28000
&&
st
->
bandwidth
==
BANDWIDTH_FULLBAND
))
...
...
@@ -184,10 +188,14 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
st
->
bandwidth
=
BANDWIDTH_MEDIUMBAND
;
else
st
->
bandwidth
=
BANDWIDTH_NARROWBAND
;
/* Prevents any transition to SWB/FB until the SILK layer has fully
switched to WB mode and turned the variable LP filter off */
if
(
!
st
->
silk_mode
.
inWBmodeWithoutVariableLP
&&
st
->
bandwidth
>
BANDWIDTH_WIDEBAND
)
st
->
bandwidth
=
BANDWIDTH_WIDEBAND
;
}
/* Prevents Opus from wasting bits on frequencies that are above
the Nyquist rate of the input signal */
if
(
st
->
Fs
<=
24000
&&
st
->
bandwidth
>
BANDWIDTH_SUPERWIDEBAND
)
st
->
bandwidth
=
BANDWIDTH_SUPERWIDEBAND
;
if
(
st
->
Fs
<=
16000
&&
st
->
bandwidth
>
BANDWIDTH_WIDEBAND
)
...
...
@@ -200,7 +208,7 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
if
(
st
->
user_bandwidth
!=
BANDWIDTH_AUTO
)
st
->
bandwidth
=
st
->
user_bandwidth
;
/* Prevent
ing
non
-
sensical configurations */
/* Prevent
s
nonsensical configurations
, i.e. modes that don't exist
*/
if
(
frame_size
<
st
->
Fs
/
100
&&
st
->
mode
!=
MODE_CELT_ONLY
)
st
->
mode
=
MODE_CELT_ONLY
;
if
(
frame_size
>
st
->
Fs
/
50
&&
st
->
mode
!=
MODE_SILK_ONLY
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment