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
d8f9097c
Commit
d8f9097c
authored
13 years ago
by
Jean-Marc Valin
Browse files
Options
Downloads
Patches
Plain Diff
Changing the SILK bandwidth only when there's no speech
parent
d8765e54
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
silk
+1
-1
1 addition, 1 deletion
silk
src/opus_encoder.c
+31
-24
31 additions, 24 deletions
src/opus_encoder.c
src/opus_encoder.h
+1
-1
1 addition, 1 deletion
src/opus_encoder.h
with
33 additions
and
26 deletions
silk
@
34dd4c7d
Subproject commit
fcf95bac9330e8e6db1184496ae33007a7c7a9cf
Subproject commit
34dd4c7daed31808ee81352b109affc4902a07be
This diff is collapsed.
Click to expand it.
src/opus_encoder.c
+
31
−
24
View file @
d8f9097c
...
...
@@ -87,6 +87,7 @@ OpusEncoder *opus_encoder_create(int Fs, int channels)
st
->
user_mode
=
OPUS_MODE_AUTO
;
st
->
user_bandwidth
=
BANDWIDTH_AUTO
;
st
->
voice_ratio
=
90
;
st
->
bandwidth_change
=
1
;
st
->
encoder_buffer
=
st
->
Fs
/
100
;
st
->
delay_compensation
=
st
->
Fs
/
400
;
...
...
@@ -156,27 +157,30 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
}
/* Bandwidth selection */
if
(
st
->
mode
==
MODE_CELT_ONLY
)
if
(
st
->
bandwidth_change
)
{
if
(
mono_rate
>
35000
||
(
mono_rate
>
28000
&&
st
->
bandwidth
==
BANDWIDTH_FULLBAND
))
st
->
bandwidth
=
BANDWIDTH_FULLBAND
;
else
if
(
mono_rate
>
28000
||
(
mono_rate
>
24000
&&
st
->
bandwidth
==
BANDWIDTH_SUPERWIDEBAND
))
st
->
bandwidth
=
BANDWIDTH_SUPERWIDEBAND
;
else
if
(
mono_rate
>
24000
||
(
mono_rate
>
18000
&&
st
->
bandwidth
==
BANDWIDTH_WIDEBAND
))
st
->
bandwidth
=
BANDWIDTH_WIDEBAND
;
else
st
->
bandwidth
=
BANDWIDTH_NARROWBAND
;
}
else
{
if
(
mono_rate
>
28000
||
(
mono_rate
>
24000
&&
st
->
bandwidth
==
BANDWIDTH_FULLBAND
))
st
->
bandwidth
=
BANDWIDTH_FULLBAND
;
else
if
(
mono_rate
>
24000
||
(
mono_rate
>
18000
&&
st
->
bandwidth
==
BANDWIDTH_SUPERWIDEBAND
))
st
->
bandwidth
=
BANDWIDTH_SUPERWIDEBAND
;
else
if
(
mono_rate
>
18000
||
(
mono_rate
>
14000
&&
st
->
bandwidth
==
BANDWIDTH_WIDEBAND
))
st
->
bandwidth
=
BANDWIDTH_WIDEBAND
;
else
if
(
mono_rate
>
14000
||
(
mono_rate
>
11000
&&
st
->
bandwidth
==
BANDWIDTH_MEDIUMBAND
))
st
->
bandwidth
=
BANDWIDTH_MEDIUMBAND
;
else
st
->
bandwidth
=
BANDWIDTH_NARROWBAND
;
if
(
st
->
mode
==
MODE_CELT_ONLY
)
{
if
(
mono_rate
>
35000
||
(
mono_rate
>
28000
&&
st
->
bandwidth
==
BANDWIDTH_FULLBAND
))
st
->
bandwidth
=
BANDWIDTH_FULLBAND
;
else
if
(
mono_rate
>
28000
||
(
mono_rate
>
24000
&&
st
->
bandwidth
==
BANDWIDTH_SUPERWIDEBAND
))
st
->
bandwidth
=
BANDWIDTH_SUPERWIDEBAND
;
else
if
(
mono_rate
>
24000
||
(
mono_rate
>
18000
&&
st
->
bandwidth
==
BANDWIDTH_WIDEBAND
))
st
->
bandwidth
=
BANDWIDTH_WIDEBAND
;
else
st
->
bandwidth
=
BANDWIDTH_NARROWBAND
;
}
else
{
if
(
mono_rate
>
28000
||
(
mono_rate
>
24000
&&
st
->
bandwidth
==
BANDWIDTH_FULLBAND
))
st
->
bandwidth
=
BANDWIDTH_FULLBAND
;
else
if
(
mono_rate
>
24000
||
(
mono_rate
>
18000
&&
st
->
bandwidth
==
BANDWIDTH_SUPERWIDEBAND
))
st
->
bandwidth
=
BANDWIDTH_SUPERWIDEBAND
;
else
if
(
mono_rate
>
18000
||
(
mono_rate
>
14000
&&
st
->
bandwidth
==
BANDWIDTH_WIDEBAND
))
st
->
bandwidth
=
BANDWIDTH_WIDEBAND
;
else
if
(
mono_rate
>
14000
||
(
mono_rate
>
11000
&&
st
->
bandwidth
==
BANDWIDTH_MEDIUMBAND
))
st
->
bandwidth
=
BANDWIDTH_MEDIUMBAND
;
else
st
->
bandwidth
=
BANDWIDTH_NARROWBAND
;
}
}
if
(
st
->
Fs
<=
24000
&&
st
->
bandwidth
>
BANDWIDTH_SUPERWIDEBAND
)
...
...
@@ -263,12 +267,12 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
st
->
silk_mode
.
payloadSize_ms
=
1000
*
frame_size
/
st
->
Fs
;
if
(
st
->
bandwidth
==
BANDWIDTH_NARROWBAND
)
{
st
->
silk_mode
.
max
InternalSampleRate
=
8000
;
st
->
silk_mode
.
desired
InternalSampleRate
=
8000
;
}
else
if
(
st
->
bandwidth
==
BANDWIDTH_MEDIUMBAND
)
{
st
->
silk_mode
.
max
InternalSampleRate
=
12000
;
st
->
silk_mode
.
desired
InternalSampleRate
=
12000
;
}
else
{
SKP_assert
(
st
->
mode
==
MODE_HYBRID
||
st
->
bandwidth
==
BANDWIDTH_WIDEBAND
);
st
->
silk_mode
.
max
InternalSampleRate
=
16000
;
st
->
silk_mode
.
desired
InternalSampleRate
=
16000
;
}
if
(
st
->
mode
==
MODE_HYBRID
)
{
/* Don't allow bandwidth reduction at lowest bitrates in hybrid mode */
...
...
@@ -276,6 +280,7 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
}
else
{
st
->
silk_mode
.
minInternalSampleRate
=
8000
;
}
st
->
silk_mode
.
maxInternalSampleRate
=
16000
;
/* Call SILK encoder for the low band */
nBytes
=
max_data_bytes
-
1
;
...
...
@@ -290,9 +295,9 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
fprintf
(
stderr
,
"SILK encode error: %d
\n
"
,
ret
);
/* Handle error */
}
st
->
bandwidth_change
=
nBytes
==
0
||
(
enc
.
buf
[
0
]
&
0x80
)
==
0
;
if
(
nBytes
==
0
)
return
0
;
/* Extract SILK internal bandwidth for signaling in first byte */
if
(
st
->
mode
==
MODE_SILK_ONLY
)
{
if
(
st
->
silk_mode
.
internalSampleRate
==
8000
)
{
...
...
@@ -305,6 +310,8 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
}
else
{
SKP_assert
(
st
->
silk_mode
.
internalSampleRate
==
16000
);
}
}
else
{
st
->
bandwidth_change
=
1
;
}
/* CELT processing */
...
...
This diff is collapsed.
Click to expand it.
src/opus_encoder.h
+
1
−
1
View file @
d8f9097c
...
...
@@ -55,7 +55,7 @@ struct OpusEncoder {
int
bitrate_bps
;
int
encoder_buffer
;
int
delay_compensation
;
int
bandwidth_change
;
short
delay_buffer
[
MAX_ENCODER_BUFFER
*
2
];
#ifdef OPUS_TEST_RANGE_CODER_STATE
...
...
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