#9297(undetermined:new): Decoded flac file ends up sounding distorted
#9297: Decoded flac file ends up sounding distorted -------------------------------------+------------------------------------- Reporter: Mattias | Type: defect Wadman | Status: new | Priority: normal Component: | Version: git- undetermined | master Keywords: flac | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+------------------------------------- Summary of the bug: flac_decode_bug.flac is a flac file with the first flac frame extracted from a longer file that I unfortunately can't share. Metadata suggest it was encoded using "reference libFLAC 1.2.1 20070917". Some debugging findings: Most diffing samples are reference decoded 0xffff vs ffmpeg 0x7fff Some residual samples are quite large 65535 and -65535. If I change "int need32 = s->flac_stream_info.bps > 16" to "int need32 = s->flac_stream_info.bps >= 16" in flac_set_bps it seems to decode fine. How to reproduce: {{{ $ ls -l flac_decode_bug.flac -rw-r--r-- 1 root root 12329 Jun 21 10:19 flac_decode_bug.flac $ flac -t flac_decode_bug.flac flac 1.3.3 Copyright (C) 2000-2009 Josh Coalson, 2011-2016 Xiph.Org Foundation flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. Type `flac' for details. flac_decode_bug.flac: ok $ flac -d -o flac_decode_bug.flac.ref.wav flac_decode_bug.flac flac 1.3.3 Copyright (C) 2000-2009 Josh Coalson, 2011-2016 Xiph.Org Foundation flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. Type `flac' for details. flac_decode_bug.flac: done $ ./ffmpeg_g -i flac_decode_bug.flac flac_decode_bug.flac.ffmpeg.wav ffmpeg version N-102781-g05f9b3a0a5 Copyright (c) 2000-2021 the FFmpeg developers built with gcc 10.2.1 (Alpine 10.2.1_pre1) 20201203 configuration: --enable-debug --disable-optimizations libavutil 57. 0.100 / 57. 0.100 libavcodec 59. 1.102 / 59. 1.102 libavformat 59. 3.101 / 59. 3.101 libavdevice 59. 0.100 / 59. 0.100 libavfilter 8. 0.102 / 8. 0.102 libswscale 6. 0.100 / 6. 0.100 libswresample 4. 0.100 / 4. 0.100 Input #0, flac, from 'flac_decode_bug.flac': Duration: 00:00:00.09, bitrate: 1061 kb/s Stream #0:0: Audio: flac, 44100 Hz, stereo, s16 Stream mapping: Stream #0:0 -> #0:0 (flac (native) -> pcm_s16le (native)) Press [q] to stop, [?] for help Output #0, wav, to 'flac_decode_bug.flac.ffmpeg.wav': Metadata: ISFT : Lavf59.3.101 Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s Metadata: encoder : Lavc59.1.102 pcm_s16le size= 16kB time=00:00:00.09 bitrate=1417.9kbits/s speed=11.8x video:0kB audio:16kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.476074% $ ./ffmpeg_with_fix_g -i flac_decode_bug.flac flac_decode_bug.flac.ffmpeg_with_fix.wav ffmpeg version N-102781-g05f9b3a0a5 Copyright (c) 2000-2021 the FFmpeg developers built with gcc 10.2.1 (Alpine 10.2.1_pre1) 20201203 configuration: --enable-debug --disable-optimizations libavutil 57. 0.100 / 57. 0.100 libavcodec 59. 1.102 / 59. 1.102 libavformat 59. 3.101 / 59. 3.101 libavdevice 59. 0.100 / 59. 0.100 libavfilter 8. 0.102 / 8. 0.102 libswscale 6. 0.100 / 6. 0.100 libswresample 4. 0.100 / 4. 0.100 Input #0, flac, from 'flac_decode_bug.flac': Duration: 00:00:00.09, bitrate: 1061 kb/s Stream #0:0: Audio: flac, 44100 Hz, stereo, s32 (16 bit) Stream mapping: Stream #0:0 -> #0:0 (flac (native) -> pcm_s16le (native)) Press [q] to stop, [?] for help Output #0, wav, to 'flac_decode_bug.flac.ffmpeg_with_fix.wav': Metadata: ISFT : Lavf59.3.101 Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s Metadata: encoder : Lavc59.1.102 pcm_s16le size= 16kB time=00:00:00.09 bitrate=1417.9kbits/s speed=18.3x video:0kB audio:16kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.476074% $ ./ffmpeg_g -i flac_decode_bug.flac.ref.wav -f s16le flac_decode_bug.flac.ref.wav.pcm $ ./ffmpeg_g -i flac_decode_bug.flac.ffmpeg.wav -f s16le flac_decode_bug.flac.ffmpeg.wav.pcm $ ./ffmpeg_g -i flac_decode_bug.flac.ffmpeg_with_fix.wav -f s16le flac_decode_bug.flac.ffmpeg_with_fix.wav.pcm $ md5sum *.pcm d1076c476bcd12c1d6944d0e19c60000 flac_decode_bug.flac.ffmpeg.wav.pcm e5ca6f718f932e3a95461bd7dc690829 flac_decode_bug.flac.ffmpeg_with_fix.wav.pcm e5ca6f718f932e3a95461bd7dc690829 flac_decode_bug.flac.ref.wav.pcm }}} -- Ticket URL: <https://trac.ffmpeg.org/ticket/9297> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker