ref: a671ac5582fe598f3a46e659873eb7bbc9010cb1
parent: 9bb2820d74674eb34113ec3d36cb17631383c9f6
author: Jean-Marc Valin <[email protected]>
date: Tue May 23 21:07:20 EDT 2017
Reducing trim at low bitrate Some informal tests seem to confirm that reducing the trim at 32-64 kbps improves quality (better HF). It's not clear whether it's also the case at 96 kb/s and above, so we're leaving it as is for those rates. This corresponds to buildC in this thread: https://hydrogenaud.io/index.php/topic,113985.0.html Also see: https://hydrogenaud.io/index.php/topic,111798.0.html
--- a/celt/celt_encoder.c
+++ b/celt/celt_encoder.c
@@ -780,7 +780,7 @@
static int alloc_trim_analysis(const CELTMode *m, const celt_norm *X,
const opus_val16 *bandLogE, int end, int LM, int C, int N0,
AnalysisInfo *analysis, opus_val16 *stereo_saving, opus_val16 tf_estimate,
- int intensity, opus_val16 surround_trim, int arch)
+ int intensity, opus_val16 surround_trim, opus_int32 equiv_rate, int arch)
{
int i;
opus_val32 diff=0;
@@ -788,6 +788,14 @@
int trim_index;
opus_val16 trim = QCONST16(5.f, 8);
opus_val16 logXC, logXC2;
+ /* At low bitrate, reducing the trim seems to help. At higher bitrates, it's less
+ clear what's best, so we're keeping it as it was before, at least for now. */
+ if (equiv_rate < 64000) {
+ trim = QCONST16(4.f, 8);
+ } else if (equiv_rate < 80000) {
+ opus_int32 frac = (equiv_rate-64000) >> 10;
+ trim = QCONST16(4.f, 8) + QCONST16(1.f/16., 8)*frac;
+ }
if (C==2)
{
opus_val16 sum = 0; /* Q10 */
@@ -1954,7 +1962,7 @@
} else {
alloc_trim = alloc_trim_analysis(mode, X, bandLogE,
end, LM, C, N, &st->analysis, &st->stereo_saving, tf_estimate,
- st->intensity, surround_trim, st->arch);
+ st->intensity, surround_trim, equiv_rate, st->arch);
}
ec_enc_icdf(enc, alloc_trim, trim_icdf, 7);
tell = ec_tell_frac(enc);