summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2017-05-24 01:07:20 -0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2017-05-24 01:07:20 -0400
commita671ac5582fe598f3a46e659873eb7bbc9010cb1 (patch)
tree49e976bbd4172ce127743b9b517b8ebaa3c80654
parent9bb2820d74674eb34113ec3d36cb17631383c9f6 (diff)
downloadopus-a671ac5582fe598f3a46e659873eb7bbc9010cb1.tar.gz
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
-rw-r--r--celt/celt_encoder.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/celt/celt_encoder.c b/celt/celt_encoder.c
index afee5aac..6d884726 100644
--- a/celt/celt_encoder.c
+++ b/celt/celt_encoder.c
@@ -780,7 +780,7 @@ static void tf_encode(int start, int end, int isTransient, int *tf_res, int LM,
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 @@ static int alloc_trim_analysis(const CELTMode *m, const celt_norm *X,
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 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm,
} 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);