diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2013-09-14 23:46:09 +0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2013-09-14 23:46:09 +0400 |
commit | 36a21ed53636ed4471aa62a8d06dcf175d6ff395 (patch) | |
tree | ea6217f4abaec2a0b3ef62176dc2a6e530d77748 | |
parent | 6fbfed6a0b927f0b54340081675c116955dd3705 (diff) |
Very basic surround rate calibration
-rw-r--r-- | celt/celt_encoder.c | 2 | ||||
-rw-r--r-- | src/opus_encoder.c | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/celt/celt_encoder.c b/celt/celt_encoder.c index 12b5581a..189b4129 100644 --- a/celt/celt_encoder.c +++ b/celt/celt_encoder.c @@ -1559,6 +1559,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, } } mask_avg = DIV32_16(mask_avg,count); + mask_avg += QCONST16(.2f, DB_SHIFT); diff = diff*6/(C*(mask_end-1)*(mask_end+1)*mask_end); /* Again, being conservative */ diff = HALF32(diff); @@ -1601,6 +1602,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, surround_dynalloc[i] = MAX16(0, surround_dynalloc[i]-QCONST16(.25f, DB_SHIFT)); } } + mask_avg += QCONST16(.2f, DB_SHIFT); /* Convert to 1/64th units used for the trim */ surround_trim = 64*diff; /*printf("%d %d ", mask_avg, surround_trim);*/ diff --git a/src/opus_encoder.c b/src/opus_encoder.c index 07115677..3823272c 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -1510,9 +1510,9 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ } /* Conservative rate reduction, we cut the masking in half */ masking_depth = HALF16(mask_sum / end*st->channels); - masking_depth = MAX16(QCONST16(-2.f, DB_SHIFT), MIN16(masking_depth, QCONST16(0.f, DB_SHIFT))); rate_offset = PSHR32(MULT16_16(srate, masking_depth), DB_SHIFT); rate_offset = MAX32(rate_offset, -2*st->silk_mode.bitRate/3); + rate_offset += QCONST16(.4f, DB_SHIFT); st->silk_mode.bitRate += rate_offset; bytes_target += rate_offset * frame_size / (8 * st->Fs); } |