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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Thomas Daede
Opus
Commits
ab04fbb1
Unverified
Commit
ab04fbb1
authored
2 years ago
by
Jean-Marc Valin
Browse files
Options
Downloads
Patches
Plain Diff
Smooth out the LBRR rate estimate
Reduces fluctuations in the non-FEC target bitrate.
parent
fd9c0f1e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
silk/enc_API.c
+13
-2
13 additions, 2 deletions
silk/enc_API.c
with
13 additions
and
2 deletions
silk/enc_API.c
+
13
−
2
View file @
ab04fbb1
...
...
@@ -270,6 +270,7 @@ opus_int silk_Encode( /* O Returns error co
psEnc
->
state_Fxx
[
0
].
sCmn
.
fs_kHz
*
1000
);
ALLOC
(
buf
,
nSamplesFromInputMax
,
opus_int16
);
while
(
1
)
{
int
curr_nBitsUsedLBRR
=
0
;
nSamplesToBuffer
=
psEnc
->
state_Fxx
[
0
].
sCmn
.
frame_length
-
psEnc
->
state_Fxx
[
0
].
sCmn
.
inputBufIx
;
nSamplesToBuffer
=
silk_min
(
nSamplesToBuffer
,
nSamplesToBufferMax
);
nSamplesFromInput
=
silk_DIV32_16
(
nSamplesToBuffer
*
psEnc
->
state_Fxx
[
0
].
sCmn
.
API_fs_Hz
,
psEnc
->
state_Fxx
[
0
].
sCmn
.
fs_kHz
*
1000
);
...
...
@@ -342,6 +343,7 @@ opus_int silk_Encode( /* O Returns error co
opus_uint8
iCDF
[
2
]
=
{
0
,
0
};
iCDF
[
0
]
=
256
-
silk_RSHIFT
(
256
,
(
psEnc
->
state_Fxx
[
0
].
sCmn
.
nFramesPerPacket
+
1
)
*
encControl
->
nChannelsInternal
);
ec_enc_icdf
(
psRangeEnc
,
0
,
iCDF
,
8
);
curr_nBitsUsedLBRR
=
ec_tell
(
psRangeEnc
);
/* Encode any LBRR data from previous packet */
/* Encode LBRR flags */
...
...
@@ -386,8 +388,7 @@ opus_int silk_Encode( /* O Returns error co
for
(
n
=
0
;
n
<
encControl
->
nChannelsInternal
;
n
++
)
{
silk_memset
(
psEnc
->
state_Fxx
[
n
].
sCmn
.
LBRR_flags
,
0
,
sizeof
(
psEnc
->
state_Fxx
[
n
].
sCmn
.
LBRR_flags
)
);
}
psEnc
->
nBitsUsedLBRR
=
ec_tell
(
psRangeEnc
);
curr_nBitsUsedLBRR
=
ec_tell
(
psRangeEnc
)
-
curr_nBitsUsedLBRR
;
}
silk_HP_variable_cutoff
(
psEnc
->
state_Fxx
);
...
...
@@ -396,6 +397,16 @@ opus_int silk_Encode( /* O Returns error co
nBits
=
silk_DIV32_16
(
silk_MUL
(
encControl
->
bitRate
,
encControl
->
payloadSize_ms
),
1000
);
/* Subtract bits used for LBRR */
if
(
!
prefillFlag
)
{
/* psEnc->nBitsUsedLBRR is an exponential moving average of the LBRR usage,
except that for the first LBRR frame it does no averaging and for the first
frame after after LBRR, it goes back to zero immediately. */
if
(
curr_nBitsUsedLBRR
<
10
)
{
psEnc
->
nBitsUsedLBRR
=
0
;
}
else
if
(
psEnc
->
nBitsUsedLBRR
<
10
)
{
psEnc
->
nBitsUsedLBRR
=
curr_nBitsUsedLBRR
;
}
else
{
psEnc
->
nBitsUsedLBRR
=
(
psEnc
->
nBitsUsedLBRR
+
curr_nBitsUsedLBRR
)
/
2
;
}
nBits
-=
psEnc
->
nBitsUsedLBRR
;
}
/* Divide by number of uncoded frames left in packet */
...
...
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