shithub: opus

Download patch

ref: 36a21ed53636ed4471aa62a8d06dcf175d6ff395
parent: 6fbfed6a0b927f0b54340081675c116955dd3705
author: Jean-Marc Valin <[email protected]>
date: Sat Sep 14 11:46:09 EDT 2013

Very basic surround rate calibration

--- a/celt/celt_encoder.c
+++ b/celt/celt_encoder.c
@@ -1559,6 +1559,7 @@
          }
       }
       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 @@
                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);*/
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -1510,9 +1510,9 @@
            }
            /* 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);
         }