Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 946463 - sys-devel/gcc: Compiling media-video/ffmpeg with GCC flag "-floop-nest-optimize" produces buggy MP3 decoder
Summary: sys-devel/gcc: Compiling media-video/ffmpeg with GCC flag "-floop-nest-optimi...
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal minor
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 915000
  Show dependency tree
 
Reported: 2024-12-14 11:42 UTC by Andreas Groth
Modified: 2024-12-21 07:09 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Output of 'emerge --info sys-devel/gcc ffmpeg isl' (emerge-info.txt,9.05 KB, text/plain)
2024-12-14 11:42 UTC, Andreas Groth
Details
example MP3 file (input) (example.mp3,447.75 KB, audio/mpeg)
2024-12-14 11:43 UTC, Andreas Groth
Details
Output from mp3float with -floop-nest-opimize ffmpeg (with_floop-nest-optimize_mp3float.ogg,248.80 KB, audio/ogg)
2024-12-14 11:45 UTC, Andreas Groth
Details
Output from mp3 (fixed)with -floop-nest-opimize ffmpeg -> Distorted (with_floop-nest-optimize_mp3.ogg,449.54 KB, audio/ogg)
2024-12-14 11:46 UTC, Andreas Groth
Details
Output from mp3float without -floop-nest-opimize for ffmpeg (no_floop-nest-optimize_mp3float.ogg,248.80 KB, audio/ogg)
2024-12-14 11:47 UTC, Andreas Groth
Details
Output from mp3 without -floop-nest-opimize for ffmpeg (no_floop-nest-optimize_mp3.ogg,251.41 KB, audio/ogg)
2024-12-14 11:47 UTC, Andreas Groth
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Groth 2024-12-14 11:42:27 UTC
Created attachment 914006 [details]
Output of 'emerge --info sys-devel/gcc ffmpeg isl'

I posted this earlier in the forum <https://forums.gentoo.org/viewtopic-p-8848425.html#8848425> where I was asked to report here.

I use sys-devel/gcc emerged with the `--graphite` flag (description: "Add support for the framework for loop optimizations based on a polyhedral intermediate representation"). It translates to --with-isl when gcc is build and pulls in dev-libs/isl. In order to make use of it, I added some CFLAGS in /etc/portage/make.conf like so:

### Compiler options
# Basic
CFLAGS="-O2 -pipe -march=native"
# Loop nest optimisation (need GCC with USE=graphite setting for --with-isl)
CFLAGS="${CFLAGS} -fgraphite-identity -floop-interchange -ftree-loop-distribution -floop-nest-optimize"

When emerging media-video/ffmpeg (or ffmpeg-chromium) with this, one of its two MP3 decoders produces horribly distorted output, while there are no errors reported. Removing -floop-nest-optimze from the CFLAGS (via /etc/portage/package.env/...) and re-emerging media-video/ffmpeg (or ffmpeg-chromium), the MP3 decoders work as expected. 

I have an old "Intel(R) Xeon(R) CPU E3-1225 V2 @ 3.20GHz"; an "Ivy Bridge". I get this from app-misc/resolve-march-native:

-march=ivybridge -maes --param=l1-cache-line-size=64 --param=l1-cache-size=32 --param=l2-cache-size=8192

The attached output of emerge --info sys-devel/gcc media-video/ffmpeg dev-libs/isl is from the fixed/workaround configuration.

A command for testing would be

ffmpeg  -c:a mp3 -i example.mp3 -f matroska - | ffplay -

I also (try to) attach sound samples: My input file "example.mp3" is a 20 second excerpt from a sound file labelled as public domain. The four conversions of this file to Ogg using the mp3 "fixed" decoder or the mp3float decoder, once with -floop-nest-optimize and once without. Below are the commands I used to generate  the files. "with_floop-nest-optimize_mp3.ogg" is the distorted one. 

# ffmpeg with -floop-nest-optimize 
ffmpeg -c:a mp3float   -i example.mp3 with_floop-nest-optimize_mp3float.ogg
ffmpeg -c:a mp3        -i example.mp3 with_floop-nest-optimize_mp3.ogg

# ffmpeg without -floop-nest-optimize 
ffmpeg -c:a mp3float   -i example.mp3 no_floop-nest-optimize_mp3float.ogg
ffmpeg -c:a mp3        -i example.mp3 no_floop-nest-optimize_mp3.ogg

Side note: the documentation for -floop-nest-optimize states: "This option is experimental".

Please let me know if I can provide additional information (build logs? of what?) or do some tests.
Comment 1 Andreas Groth 2024-12-14 11:43:41 UTC
Created attachment 914007 [details]
example MP3 file (input)
Comment 2 Andreas Groth 2024-12-14 11:45:16 UTC
Created attachment 914008 [details]
Output from mp3float with -floop-nest-opimize ffmpeg
Comment 3 Andreas Groth 2024-12-14 11:46:28 UTC
Created attachment 914009 [details]
Output from mp3 (fixed)with -floop-nest-opimize ffmpeg -> Distorted
Comment 4 Andreas Groth 2024-12-14 11:47:13 UTC
Created attachment 914010 [details]
Output from mp3float without -floop-nest-opimize for ffmpeg
Comment 5 Andreas Groth 2024-12-14 11:47:50 UTC
Created attachment 914011 [details]
Output from mp3 without -floop-nest-opimize for ffmpeg