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
d8781a0f
Commit
d8781a0f
authored
8 years ago
by
Jean-Marc Valin
Browse files
Options
Downloads
Patches
Plain Diff
CBR: lock the gain on a subframe when the number of pulses stops going down
parent
0a698d65
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
silk/fixed/encode_frame_FIX.c
+25
-1
25 additions, 1 deletion
silk/fixed/encode_frame_FIX.c
silk/float/encode_frame_FLP.c
+25
-1
25 additions, 1 deletion
silk/float/encode_frame_FLP.c
with
50 additions
and
2 deletions
silk/fixed/encode_frame_FIX.c
+
25
−
1
View file @
d8781a0f
...
...
@@ -94,6 +94,9 @@ opus_int silk_encode_frame_FIX(
opus_int16
ec_prevLagIndex_copy
;
opus_int
ec_prevSignalType_copy
;
opus_int8
LastGainIndex_copy2
;
opus_int
gain_lock
[
MAX_NB_SUBFR
]
=
{
0
};
opus_int16
best_gain_mult
[
MAX_NB_SUBFR
];
opus_int
best_sum
[
MAX_NB_SUBFR
];
SAVE_STACK
;
/* This is totally unnecessary but many compilers (including gcc) are too dumb to realise it */
...
...
@@ -258,6 +261,21 @@ opus_int silk_encode_frame_FIX(
break
;
}
if
(
!
found_lower
&&
nBits
>
maxBits
)
{
int
j
;
for
(
i
=
0
;
i
<
psEnc
->
sCmn
.
nb_subfr
;
i
++
)
{
int
sum
=
0
;
for
(
j
=
i
*
psEnc
->
sCmn
.
subfr_length
;
j
<
(
i
+
1
)
*
psEnc
->
sCmn
.
subfr_length
;
j
++
)
{
sum
+=
abs
(
psEnc
->
sCmn
.
pulses
[
j
]
);
}
if
(
iter
==
0
||
(
sum
<
best_sum
[
i
]
&&
!
gain_lock
[
i
])
)
{
best_sum
[
i
]
=
sum
;
best_gain_mult
[
i
]
=
gainMult_Q8
;
}
else
{
gain_lock
[
i
]
=
1
;
}
}
}
if
(
(
found_lower
&
found_upper
)
==
0
)
{
/* Adjust gain according to high-rate rate/distortion curve */
if
(
nBits
>
maxBits
)
{
...
...
@@ -285,7 +303,13 @@ opus_int silk_encode_frame_FIX(
}
for
(
i
=
0
;
i
<
psEnc
->
sCmn
.
nb_subfr
;
i
++
)
{
sEncCtrl
.
Gains_Q16
[
i
]
=
silk_LSHIFT_SAT32
(
silk_SMULWB
(
sEncCtrl
.
GainsUnq_Q16
[
i
],
gainMult_Q8
),
8
);
opus_int16
tmp
;
if
(
gain_lock
[
i
]
)
{
tmp
=
best_gain_mult
[
i
];
}
else
{
tmp
=
gainMult_Q8
;
}
sEncCtrl
.
Gains_Q16
[
i
]
=
silk_LSHIFT_SAT32
(
silk_SMULWB
(
sEncCtrl
.
GainsUnq_Q16
[
i
],
tmp
),
8
);
}
/* Quantize gains */
...
...
This diff is collapsed.
Click to expand it.
silk/float/encode_frame_FLP.c
+
25
−
1
View file @
d8781a0f
...
...
@@ -96,6 +96,9 @@ opus_int silk_encode_frame_FLP(
opus_int8
LastGainIndex_copy2
;
opus_int32
pGains_Q16
[
MAX_NB_SUBFR
];
opus_uint8
ec_buf_copy
[
1275
];
opus_int
gain_lock
[
MAX_NB_SUBFR
]
=
{
0
};
opus_int16
best_gain_mult
[
MAX_NB_SUBFR
];
opus_int
best_sum
[
MAX_NB_SUBFR
];
/* This is totally unnecessary but many compilers (including gcc) are too dumb to realise it */
LastGainIndex_copy2
=
nBits_lower
=
nBits_upper
=
gainMult_lower
=
gainMult_upper
=
0
;
...
...
@@ -246,6 +249,21 @@ opus_int silk_encode_frame_FLP(
break
;
}
if
(
!
found_lower
&&
nBits
>
maxBits
)
{
int
j
;
for
(
i
=
0
;
i
<
psEnc
->
sCmn
.
nb_subfr
;
i
++
)
{
int
sum
=
0
;
for
(
j
=
i
*
psEnc
->
sCmn
.
subfr_length
;
j
<
(
i
+
1
)
*
psEnc
->
sCmn
.
subfr_length
;
j
++
)
{
sum
+=
abs
(
psEnc
->
sCmn
.
pulses
[
j
]
);
}
if
(
iter
==
0
||
(
sum
<
best_sum
[
i
]
&&
!
gain_lock
[
i
])
)
{
best_sum
[
i
]
=
sum
;
best_gain_mult
[
i
]
=
gainMult_Q8
;
}
else
{
gain_lock
[
i
]
=
1
;
}
}
}
if
(
(
found_lower
&
found_upper
)
==
0
)
{
/* Adjust gain according to high-rate rate/distortion curve */
if
(
nBits
>
maxBits
)
{
...
...
@@ -272,7 +290,13 @@ opus_int silk_encode_frame_FLP(
}
for
(
i
=
0
;
i
<
psEnc
->
sCmn
.
nb_subfr
;
i
++
)
{
pGains_Q16
[
i
]
=
silk_LSHIFT_SAT32
(
silk_SMULWB
(
sEncCtrl
.
GainsUnq_Q16
[
i
],
gainMult_Q8
),
8
);
opus_int16
tmp
;
if
(
gain_lock
[
i
]
)
{
tmp
=
best_gain_mult
[
i
];
}
else
{
tmp
=
gainMult_Q8
;
}
pGains_Q16
[
i
]
=
silk_LSHIFT_SAT32
(
silk_SMULWB
(
sEncCtrl
.
GainsUnq_Q16
[
i
],
tmp
),
8
);
}
/* Quantize gains */
...
...
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