#9958 closed defect (fixed)
thd encoder bug: Plex and LG C9 have same artefacts
| Reported by: | Balling | Owned by: | |
|---|---|---|---|
| Priority: | minor | Component: | avcodec |
| Version: | git-master | Keywords: | thd |
| Cc: | Blocked By: | ||
| Blocking: | Reproduced by developer: | no | |
| Analyzed by developer: | no |
Description (last modified by )
Summary of the bug: first of all there is no bug with our ffmpeg decoder, it is all 24 bits lossless and gapless. But that is an illusion: for a very long time Plex Transcoder.exe with EasyAudioEncoder.exe decoder could not decode produced by ffmpeg thd. Now it can thanks to Paul's fixes, so it is now obvious it has same artefacts SAME AS in LG C9 HW decoder, bitstreamed by Lavfilters. I would imagine drp.exe (Dolby reference player) will also have those. Official encoder does not have such artefacts (DEE or Dolby media encoder).
How to reproduce: buy LG C9 or use instruction to get EAE.exe decoder. https://forum.doom9.org/showpost.php?p=1974530&postcount=185
Then decode this sample, encoded with git-master ffmpeg (48k has the same artefacts): https://0x0.st/oJBN.thd
and compare how ffmpeg decodes it with how Plex and LG C9 does, here is it (16 bit has the same artefacts, artefacts start at 00:01:02): https://0x0.st/oJBb.wav
Dolby Media Encoder at least appears to be without artefacts, alas it cannot encode 44.1, so I did on 16 bits ffmpeg.exe -i "sample.thd" -ar 48000 48.wav (https://0x0.st/oJBA.wav) and encoded with Dolby Media Encoder: https://0x0.st/oJBa.mlp
I will just mention how much bigger the ffmpeg file is, compared to oJBa.mlp. https://0x0.st/oJBM.thd
Mono does not have such artefacts.
Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.
Change History (20)
comment:1 by , 4 years ago
| Resolution: | → needs_more_info |
|---|---|
| Status: | new → closed |
comment:2 by , 4 years ago
| Resolution: | needs_more_info |
|---|---|
| Status: | closed → reopened |
comment:3 by , 4 years ago
| Resolution: | → needs_more_info |
|---|---|
| Status: | reopened → closed |
comment:4 by , 4 years ago
| Resolution: | needs_more_info |
|---|---|
| Status: | closed → reopened |
This is how I encoded 48 sample, e.g.
PS ffmpeg.exe -i 48_2.wav -strict -2 awsfdafda1.thd
ffmpeg version N-108353-g7cd252ee41-20220925 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 12.1.0 (crosstool-NG 1.25.0.55_3defb7b)
configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --enable-shared --disable-static --disable-w32threads --enable-pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --disable-libpulse --enable-libvmaf --disable-libxcb --disable-xlib --enable-amf --enable-libaom --enable-libaribb24 --enable-avisynth --enable-libdav1d --enable-libdavs2 --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme --enable-libkvazaar --enable-libass --enable-libbluray --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librist --enable-libssh --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --disable-libdrm --disable-vaapi --enable-libvidstab --enable-vulkan --enable-libshaderc --enable-libplacebo --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-ldexeflags= --extra-libs=-lgomp --extra-version=20220925
libavutil 57. 36.102 / 57. 36.102
libavcodec 59. 46.100 / 59. 46.100
libavformat 59. 33.100 / 59. 33.100
libavdevice 59. 8.101 / 59. 8.101
libavfilter 8. 49.100 / 8. 49.100
libswscale 6. 8.112 / 6. 8.112
libswresample 4. 9.100 / 4. 9.100
libpostproc 56. 7.100 / 56. 7.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, wav, from '48_2.wav':
Metadata:
artist : Николай Басков
date : 2018
genre : Gospel Pop
title : Молите Господа О Нас
album : Верую
track : 08
encoder : Lavf59.33.100
Duration: 00:04:33.39, bitrate: 1536 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 2 channels, s16, 1536 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s16le (native) -> truehd (native))
Press [q] to stop, [?] for help
Output #0, truehd, to 'awsfdafda1.thd':
Metadata:
artist : Николай Басков
date : 2018
genre : Gospel Pop
title : Молите Господа О Нас
album : Верую
track : 08
encoder : Lavf59.33.100
Stream #0:0: Audio: truehd, 48000 Hz, stereo, s16, 128 kb/s
Metadata:
encoder : Lavc59.46.100 truehd
size= 39907kB time=00:04:33.39 bitrate=1195.8kbits/s speed=95.6x
video:0kB audio:39907kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
comment:5 by , 4 years ago
| Component: | undetermined → avcodec |
|---|---|
| Priority: | normal → minor |
The usage of strict -2 indicates a minor issue.
follow-up: 12 comment:6 by , 4 years ago
That is what can remove experemental status. You did get Plex, Carl? Then you can check some older encodes, those were not even decoding at all in Plex, it did not like the bitstream, even though it was just a couple of flags.
BTW, it would be nice to get all those samples somewhere safer. :)
comment:7 by , 4 years ago
Also, I cut mono from the stereo with -af channelmap=channel_layout=mono:map=0 and the encoded by ffmpeg mono thd has no difference with decoding by Plex. No artefacts. Bitperfect, except for some zero bytes in the end.
comment:8 by , 4 years ago
| Description: | modified (diff) |
|---|
comment:9 by , 4 years ago
| Owner: | set to |
|---|---|
| Status: | reopened → open |
Assigning to owner of Twitter. Is it possible that our decoder of official thd is still partially lossy? Off-by-ones are either on our side on Dolby's. We need to know.
Carl, can you backup the 0x0 links? Or should I?
comment:12 by , 4 years ago
Replying to Balling:
Then you can check some older encodes, those were not even decoding at all in Plex, it did not like the bitstream, even though it was just a couple of flags.
I got the confirmation that some commit fixed Oppo stereo thd playback too. Not only Plex. https://forum.doom9.org/showpost.php?p=1976413&postcount=24
I also got Dolby Reference player and there artefacts are much less profound, at least in 32 bit float. But I still think there is a bug, AT LEAST compression algorithm code is horrible. BUT!! https://0x0.st/oJBa.mlp is not apparently lossless, it has some small amount of byte differences (!). So there is also a bug in Dolby Media Encoder or there is an additional off-by-one bug in our decoder.
comment:14 by , 3 years ago
| Resolution: | needs_more_info |
|---|---|
| Status: | closed → reopened |
7z with 2 files: https://0x0.st/HWH7.7z
I hope you do have Plex.
comment:15 by , 3 years ago
The 16bit encoder mode producing invalid bitstream have been fixed in another recent commit.
So are all those files you uploaded actual ffmpeg encoded files? If yes they are no longer relevant. Please provide input files (not produced by experimental new or older mlp/thd encoder) that still gives invalid output when encoded by FFmpeg's thd/mlp encoder and gives artifacts on hw decoders.
comment:16 by , 3 years ago
Checked HEAD of master the files are encoded the same (will also check 0be5da9cfa745ca734c50d75491fd2d79c374789 tomorrow). Which you could have checked yourself, BTW.
Again, do you need Plex? You did not answer so I will attach Plex decoder flac for you, it has artefacts at 00:01:02, so FFmpeg encoder is wrong. Again, same happens with HW decoder in LG C9.
comment:17 by , 3 years ago
Very bad your recent 3 thd encoder changes broke it all, the decoding is mostly noise now.
Same in plex and DRP and LG C9: [truehd_eae @ 00000171d45ae340] EAE output unaligned (got 40, expected 640)
Same for -lpc_type cholesky
comment:18 by , 3 years ago
| Resolution: | → fixed |
|---|---|
| Status: | reopened → closed |
Was buggy matrix code, disabled until properly resolved.
comment:19 by , 3 years ago
Cool. Fixed (even cholesky), indeed :) Checked Plex, lossless with the source (even some zero samples in the end in our ffmpeg TrueHD decoder are fixed). Insane code skills.
comment:20 by , 3 years ago
Added back somehow limited stereo decorrelation code, to help compress fully mono/out of phase stereo parts and when left is rational multiple of right channel.



Please reread. The command line is not done with ffmpeg. But with plex. In fact nothing is done with ffmpeg, except encoding.