shithub: opus

Download patch

ref: 93e1096093b219e41835866a904d8ebc6a43a0ee
parent: a47d6f308ffe7a002cb9d903b2d5466854fa05fb
author: Jean-Marc Valin <[email protected]>
date: Sun Nov 24 20:52:08 EST 2013

Makes SILK surround masking a bit more aggressive in both directions

This also splits the rate adjustment between SILK and CELT (previous
code only changed SILK)

--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -1513,7 +1513,7 @@
               {
                  opus_val16 mask;
                  mask = MAX16(MIN16(st->energy_masking[21*c+i],
-                        QCONST16(.25f, DB_SHIFT)), -QCONST16(2.0f, DB_SHIFT));
+                        QCONST16(.5f, DB_SHIFT)), -QCONST16(2.0f, DB_SHIFT));
                  if (mask > 0)
                     mask = HALF16(mask);
                  mask_sum += mask;
@@ -1520,11 +1520,15 @@
               }
            }
            /* Conservative rate reduction, we cut the masking in half */
-           masking_depth = HALF16(mask_sum / end*st->channels);
-           masking_depth += QCONST16(.1f, DB_SHIFT);
+           masking_depth = mask_sum / end*st->channels;
+           masking_depth += QCONST16(.2f, DB_SHIFT);
            rate_offset = (opus_int32)PSHR32(MULT16_16(srate, masking_depth), DB_SHIFT);
            rate_offset = MAX32(rate_offset, -2*st->silk_mode.bitRate/3);
-           st->silk_mode.bitRate += rate_offset;
+           /* Split the rate change between the SILK and CELT part for hybrid. */
+           if (st->bandwidth==OPUS_BANDWIDTH_SUPERWIDEBAND || st->bandwidth==OPUS_BANDWIDTH_FULLBAND)
+              st->silk_mode.bitRate += 3*rate_offset/5;
+           else
+              st->silk_mode.bitRate += rate_offset;
            bytes_target += rate_offset * frame_size / (8 * st->Fs);
         }