Opened 9 years ago

Closed 2 years ago

#5039 closed defect (fixed)

Incorrect TrueHD decoding

Reported by: Carl Eugen Hoyos Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: thd
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/203994
A user uploaded a TrueHD sample that is supposed to only contain 0xFFFFFF but the two first channels of the output file always contain 0x01 or 0x02.

$ ffmpeg -i warnings_cut.thd -acodec pcm_s24le out.wav
ffmpeg version N-76844-g3885ef0 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl
  libavutil      55.  9.100 / 55.  9.100
  libavcodec     57. 16.100 / 57. 16.100
  libavformat    57. 19.100 / 57. 19.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 15.100 /  6. 15.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, truehd, from 'warnings_cut.thd':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Audio: truehd, 48000 Hz, 7.1, s32 (24 bit)
Output #0, wav, to 'out.wav':
  Metadata:
    ISFT            : Lavf57.19.100
    Stream #0:0: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 48000 Hz, 7.1, s32 (24 bit), 9216 kb/s
    Metadata:
      encoder         : Lavc57.16.100 pcm_s24le
Stream mapping:
  Stream #0:0 -> #0:0 (truehd (native) -> pcm_s24le (native))
Press [q] to stop, [?] for help
[truehd @ 0x2d32460] Lossless check failed - expected 00, calculated 05.
[truehd @ 0x2d32460] Lossless check failed - expected 00, calculated 08.
[truehd @ 0x2d32460] Lossless check failed - expected 00, calculated 0b.
[truehd @ 0x2d32460] Lossless check failed - expected 00, calculated 08.
[truehd @ 0x2d32460] Lossless check failed - expected 00, calculated 0f.
[truehd @ 0x2d32460] Lossless check failed - expected 00, calculated 08.
[truehd @ 0x2d32460] Lossless check failed - expected 00, calculated 0f.

...

...

[truehd @ 0x2d32460] Lossless check failed - expected 00, calculated 0c.
[truehd @ 0x2d32460] Lossless check failed - expected 00, calculated 09.
[truehd @ 0x2d32460] Lossless check failed - expected 00, calculated 0e.
[truehd @ 0x2d32460] Lossless check failed - expected 00, calculated 0f.
[truehd @ 0x2d32460] Lossless check failed - expected 00, calculated 04.
[truehd @ 0x2d32460] Lossless check failed - expected 00, calculated 03.
[truehd @ 0x2d32460] Lossless check failed - expected 00, calculated 0a.
[truehd @ 0x2d32460] Lossless check failed - expected 00, calculated 01.
[truehd @ 0x2d32460] Lossless check failed - expected 00, calculated 02.
[truehd @ 0x2d32460] Lossless check failed - expected 00, calculated 0a.
[truehd @ 0x2d32460] Lossless check failed - expected 00, calculated 09.
[truehd @ 0x2d32460] Lossless check failed - expected 00, calculated 05.
size=   56934kB time=00:00:50.60 bitrate=9216.0kbits/s
video:0kB audio:56933kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000175%

Attachments (1)

warnings_cut.thd (2.4 MB ) - added by Carl Eugen Hoyos 9 years ago.

Change History (13)

by Carl Eugen Hoyos, 9 years ago

Attachment: warnings_cut.thd added

comment:1 by marcusj0015, 9 years ago

I'm actually the author of that post, and decided to post here as well.

Should I delete the post I just made for this bug?

and is there any way to subscribe to this ticket?

Last edited 9 years ago by marcusj0015 (previous) (diff)

comment:2 by Samuel, 6 years ago

Similar issue here i guess.
So in case it could be of some help, here a user report log extract and sample:

DEBUG 2018-11-20 15:31:12.147 [ffmpeg-16-2] [truehd @ 0x7f86348bdc00] Lossless check failed - expected 00, calculated e4.
DEBUG 2018-11-20 15:31:12.528 [ffmpeg-16-2] size=    5544kB time=00:01:01.08 bitrate= 743.5kbits/s speed=30.5x    
TRACE 2018-11-20 15:31:12.533 [ffmpeg-16-Timer] buffered: 5,691,700 bytes / inputs: 0
DEBUG 2018-11-20 15:31:12.799 [ffmpeg-16-2] [truehd @ 0x7f86348bdc00] End of stream indicated.
DEBUG 2018-11-20 15:31:12.799 [ffmpeg-16-2] [truehd @ 0x7f86348bdc00] Lossless check failed - expected b5, calculated 6a.
DEBUG 2018-11-20 15:31:13.028 [ffmpeg-16-2] size=    6932kB time=00:01:16.37 bitrate= 743.5kbits/s speed=30.6x

Sample used by this user: (audio track n° )
https://katcr.co/torrent/627042/incredibles-2-2018-2160p-uhd-bluray-x265-10bit-hdr-truehd-7-1-atmos-iamable.html#

in reply to:  2 comment:3 by Balling, 4 years ago

Status: newopen

Oh, wow. A very funny issue with those Incredibles, considering it is both not reproducible in VLC and in MPC (that is BTW, just like here: #667, "plays too fast with -f truehd"). There is a sample right here on bt hash: 1e091ae51e2bed8b67801f741ca228c2225ff8ca

Last edited 4 years ago by Balling (previous) (diff)

comment:4 by Elon Musk, 4 years ago

You should be really banned for spamming torrent hashes.

in reply to:  4 comment:5 by Balling, 4 years ago

Replying to richardpl:

You should be really banned for spamming torrent hashes.

You said not paste magnets, this is not a magnet link. Also, maybe attach sample of that file. IMHO, it can be that those files were reencoded with ffmpeg (video in h.265?) and as they are Atmos it somehow mangled with that lossless check? VLC and LAVFilters do not check for that??

comment:6 by Balling, 3 years ago

To test this and #5054 32 bit sample rate must by activated in the ffmpeg truehd encoder as described here, this a two liner fix:

https://www.mail-archive.com/search?l=ffmpeg-user@ffmpeg.org&q=subject:%22Re%5C%3A+%5C%5BFFmpeg%5C-user%5C%5D%09MLP+encoder%5C%3A+encodes+24%5C-bit+wav+files+into+16%5C-bit+MLP%22&o=newest&f=1

https://www.mail-archive.com/ffmpeg-devel@ffmpeg.org/msg86145.html

You should compare the file produced by Dolby and by FFmpeg encoder and try to fix the decoder then.

Last edited 3 years ago by Balling (previous) (diff)

comment:7 by Balling, 3 years ago

Okay, so encoder of 24 bit files is bitperfect (yes, actual 24 bit with all bits are sometimes set, also I used -c:a pcm_s24le to convert back to wav and then back to truehd all on 32 bit activation commit) can only do up to 5.1 (not mono and stereo, as it says, it cannot do mono too, BTW). Yet, apparently my LG C9 does not recognize such 5.1 files as being TrueHD... (And no, -sample_fmt s16 does not help either.) So 5.1 is not conformant. I also suppose that indeed this issue is just a bug in the decoder, maybe in 8.1 part of it.

Last edited 3 years ago by Balling (previous) (diff)

comment:8 by Elon Musk, 3 years ago

Decoding is fine if matrix channel processing is skipped.

comment:9 by Balling, 3 years ago

2.0 mlpenc is also broken. Bitstream of any CD quality audio causes desync (due to 44100 being not 1200 fps in thd) and crazy clicks on LG C9 (that part even with -af aresample=resampler=soxr -ar 48000 and thus 1200 fps). The decode in ffmpeg is lossless, of course. Scheisse.

Last edited 3 years ago by Balling (previous) (diff)

in reply to:  8 comment:10 by Balling, 3 years ago

Replying to Elon Musk:

Decoding is fine if matrix channel processing is skipped.

BTW, Incredibles no longer reproducible. Can we have a normal sample. WTF is this.

Also, -c:a pcm_s64le and -c:a pcm_s16le also have the same problem with warnings_cut.thd​.

Looks like there is a point to a sample here: https://github.com/tuffy/libdvd-audio/issues/1

Last edited 3 years ago by Balling (previous) (diff)

comment:11 by Balling, 2 years ago

Yes. "Plex Transcoder.exe" -i C:\Users\ZAQU\Downloads\warnings_cut.thd -c:a pcm_s24le awaw.wav does indeed decode with all 0xFF. And so does #5054.

I think we need to find some other cases where that happens!

Last edited 2 years ago by Balling (previous) (diff)

comment:12 by Elon Musk, 2 years ago

Resolution: fixed
Status: openclosed
Note: See TracTickets for help on using tickets.