1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-11-23 21:54:53 +02:00
Go to file
Martin Storsjö 3ea6c2fe25 aacencdsp: Improve consistency with assembly, for x87 math
Currently, the aacencdsp checkasm tests fails for many seeds,
if the C code has been built with x87 math. This happens because
the excess precision of x87 math can make it end up rounding
to a different integer, and the checkasm tests checks that the
output integers match exactly between C and assembly.

One such failing case is "tests/checkasm/checkasm --test=aacencdsp
41" when compiled with GCC. When compiled with Clang, the test
seed 21 produces a failure.

To avoid the issue, we need to limit the precision of intermediates
to their nominal float range, matching the assembly implementations.

This can be achieved when compiling with GCC, by just adding a single
cast.

To observe the effect of this cast, compile the following
snippet,

    int cast(float a, float b) {
        return (int)
    #ifdef CAST
            (float)
    #endif
            (a + b);
    }

with "gcc -m32 -std=c17 -O2", with/without -DCAST. For x86_64
cases (without the "-m32"), the cast doesn't make any difference
on the generated code.

This cast would seem to not have any effect, as a binary expression
with float inputs also would have the type float.

However, if compiling with GCC with -fexcess-precision=standard,
the cast forces limiting the precision according to the language
standard here - according to the GCC docs [1]:

> When compiling C or C++, if -fexcess-precision=standard is
> specified then excess precision follows the rules specified in
> ISO C99 or C++; in particular, both casts and assignments cause
> values to be rounded to their semantic types (whereas -ffloat-store
> only affects assignments). This option is enabled by default for
> C or C++ if a strict conformance option such as -std=c99 or
> -std=c++17 is used.

Ffmpeg's configure scripts enables -std=c17 by default.

This only helps with GCC though - the cast doesn't make any
difference for Clang. (Although, upstream Clang seems to default
to SSE math, while Ubuntu provided Clang defaults to x87 math.)
Limiting the precision with Clang would require casting to volatile
float for both intermediates here - and that does have a code
generation effect on all architectures.

[1] https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
2025-09-01 09:22:39 +00:00
2025-08-08 21:51:15 +00:00
2016-09-18 10:02:13 +01:00
2023-03-01 21:59:10 +01:00
2025-06-23 14:48:40 +02:00
2025-08-03 13:48:47 +02:00
2025-05-07 15:35:47 +02:00
2025-05-26 20:33:10 +02:00
2025-08-14 08:42:29 -04:00

FFmpeg README

FFmpeg is a collection of libraries and tools to process multimedia content such as audio, video, subtitles and related metadata.

Libraries

  • libavcodec provides implementation of a wider range of codecs.
  • libavformat implements streaming protocols, container formats and basic I/O access.
  • libavutil includes hashers, decompressors and miscellaneous utility functions.
  • libavfilter provides means to alter decoded audio and video through a directed graph of connected filters.
  • libavdevice provides an abstraction to access capture and playback devices.
  • libswresample implements audio mixing and resampling routines.
  • libswscale implements color conversion and scaling routines.

Tools

  • ffmpeg is a command line toolbox to manipulate, convert and stream multimedia content.
  • ffplay is a minimalistic multimedia player.
  • ffprobe is a simple analysis tool to inspect multimedia content.
  • Additional small tools such as aviocat, ismindex and qt-faststart.

Documentation

The offline documentation is available in the doc/ directory.

The online documentation is available in the main website and in the wiki.

Examples

Coding examples are available in the doc/examples directory.

License

FFmpeg codebase is mainly LGPL-licensed with optional components licensed under GPL. Please refer to the LICENSE file for detailed information.

Contributing

Patches should be submitted to the ffmpeg-devel mailing list using git format-patch or git send-email. Github pull requests should be avoided because they are not part of our review process and will be ignored.

Languages
C 89.9%
Assembly 8.1%
Makefile 1.3%
C++ 0.3%
Objective-C 0.1%
Other 0.1%