[FFmpeg-devel] [PATCH] all: use predefined mathematics macros

Ganesh Ajjanagadde gajjanag at mit.edu
Wed Nov 11 16:33:35 CET 2015


On Wed, Nov 11, 2015 at 10:21 AM, Clément Bœsch <u at pkh.me> wrote:
> On Tue, Nov 10, 2015 at 10:35:23PM -0500, Ganesh Ajjanagadde wrote:
>> This uses M_SQRT2, M_PI, and M_E instead of the actual literals.
>> Benefits include:
>> 1. Reduced scope for copy/paste errors and improved readability.
>> 2. Consistency across the codebase.
>> 3. Actually fixes an incorrect sqrt(2) in avcodec/ppc.
>> 4. Greater precision in avcodec/ac3.
>>
>> Patch tested with FATE on x86, ppc untested.
>>
>> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
>> ---
>>  libavcodec/ac3.h                   |  2 +-
>>  libavcodec/cos_tablegen.c          |  4 +++-
>>  libavcodec/mpegaudioenc_template.c |  4 ++--
>>  libavcodec/mpegaudiotab.h          |  2 --
>>  libavcodec/mpegvideo.c             |  4 ++--
>>  libavcodec/ppc/fdctdsp.c           | 21 ++++++++++-----------
>>  libavcodec/ratecontrol.c           |  4 ----
>>  libavcodec/simple_idct.c           |  4 ++--
>>  libavfilter/af_dynaudnorm.c        |  4 +---
>>  9 files changed, 21 insertions(+), 28 deletions(-)
>>
>> diff --git a/libavcodec/ac3.h b/libavcodec/ac3.h
>> index 3f67e09..4dc7373 100644
>> --- a/libavcodec/ac3.h
>> +++ b/libavcodec/ac3.h
>> @@ -100,7 +100,7 @@
>>  #define AC3_LEVEL(x)            ROUND15((x) * FIXR15(0.7071067811865476))
>>
>>  /* pre-defined gain values */
>> -#define LEVEL_PLUS_3DB          1.4142135623730950
>> +#define LEVEL_PLUS_3DB          M_SQRT2
>>  #define LEVEL_PLUS_1POINT5DB    1.1892071150027209
>>  #define LEVEL_MINUS_1POINT5DB   0.8408964152537145
>
>>  #define LEVEL_MINUS_3DB         0.7071067811865476
>
> M_SQRT1_2?

Did not know we had this on all platforms. Good catch. I can either
submit a separate patch for this and likely other usage of 0.7071... ,
or get all of this stuff out of the way in a single commit. Whatever
you and others prefer.

>
> [...]
>
> --
> Clément B.
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


More information about the ffmpeg-devel mailing list