[opus] incorrect use of MAX16

Pedro Becerra pbecerr at gmail.com
Mon Dec 9 10:19:42 PST 2013


Hello,
in celt/celt_encoder.c line 369, the 'b' argument to MAX16
can sometimes be greater than what can be represented by
a 16bit integer.  The default definition of MAX16 is type-less,
but I am working on an architecture with hardware support for
min/max of 16bit. Changing the default definition to take
advantage of this hardware changes the result of that
computation.

Please consider the change below for inclusion in the opus
code base.

     /* *tf_estimate = 1 + MIN16(1, sqrt(MAX16(0, tf_max-30))/20); */
-   *tf_estimate = celt_sqrt(MAX16(0, 
SHL32(MULT16_16(QCONST16(0.0069,14),MIN16(163,tf_max)),14)-QCONST32(0.139,28)));
+   *tf_estimate = celt_sqrt(MAX32(0, 
SHL32(MULT16_16(QCONST16(0.0069,14),MIN16(163,tf_max)),14)-QCONST32(0.139,28)));
     /*printf("%d %f\n", tf_max, mask_metric);*/

--


More information about the opus mailing list