-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lavrresample always performs resampling process, leading to non-bitexact output #4716
Comments
There appear to be two problems:
The output of --ao=lavc is identical to that of --ao=pcm, so it doesn't look like the problem is in writing the file. |
Thanks for testing. Could you please also try this sample (24/96/7.1/<DTS_DELAY> = 0)? Perhaps the cutting off is due to the file itself. There is a Also tried TrueHD, no problem. (The Amplitude Statistics shows WAV is 24-bit and bitexact) |
Tried the second sample on Lin
mpv's WAV https://0x0.st/dHD.wav |
Yeah, the 24/96t7.1 is now correctly aligned, but the samples still differ. Looking at mpv's audio filter chain, I see that lavresample is inserted in order to convert from planar (which comes out of ffmpeg's decoder) to interleaved for output. There's no reason why that shouldn't be lossless, but maybe something strange is going on. I guess I'll have to try dumping the raw data at various stages in the code to see where it's getting altered. |
@kevmitch It's quite possible that mpv's planar to interleaved conversion is not lossless. Update: |
If I change the lavresample option |
Audiophiles will kill someone for it... @macdavis Does your workaround fix the issue? Does it work with multichannel too? In my system I sent multichannel PCM to a soundbar that seems to accept (almost) all formats. |
@fhlfibh |
Could you post your libavfilter configuration? |
@roberth1990 |
@macdavis |
@macdavis Tried your workaround, but it looks like it just added more mess http://sprunge.us/KSeW |
I'm not sure what's going on here (and I didn't read most of the issue), but mpv code in af_lavrresample clamps float values to range. This is for making sure non-normalized downmixing does not output out of range values, which in turn could lead to unpredictable behavior in AOs. On the pother hand it sounds like floats are not involved? Also, I guess avresample_set_compensation() might force reinit to resampling unnecessarily. |
@fhlfibh Try |
Yeah, that's the issue I wanna report. Unnecessary resampling process deteriorates the sound quality. Downmixing and planar to interleaved conversion shouldn't have triggered resampling.
No, it's not about floating point issue. I didn't test floating point. |
I would have expected that swr_set_compensation() (what avresample_set_compensation is defined to) does not enable resampling when it's not needed. But I guess swr doesn't agree. |
Thanks @wm4 that is now bit-exact for --ao=pcm. @macdavis I see you've altered the original issue to talk about getting s32. You should probably have opened a separate issue for this as significant editing of posts is generally frowned upon since people receive only the initial post via email. In any case, this is expected since neither ffmpeg nor mpv has has an internal representation for packed s24. Instead, s32 is used with least significant bits set to 0. Unfortunately, there is currently no way for mpv to differentiate between true s32 and s24 in s32, so --ao=pcm just outputs the samples exactly as they're stored. This is still lossless. @roberth1990 what you want is |
@kevmitch Thanks for your detailed explanation and sorry for the confusion. Next time, I will open a separate issue instead. |
@kevmitch I am a bit confused about the alignment on MacOS.
On MacOS, |
mpv version and platform
mpv git 56742ec
MacOS 10.12.6 (16G29)
Reproduction steps
Problem 1
-ao=pcm -no-config -ao-pcm-waveheader=yes -ao-pcm-file=/Volumes/RamDisk/dts_hd_ma_mpv.wav
ffmpeg -i 16_48_2.0.dtshd -acodec flac dts_ha_ma_ffmpeg.flac
)Problem 2
Play this 8 channels FLAC sample with
-ao=pcm -no-config -ao-pcm-waveheader=yes -audio-channels=stereo -ao-pcm-file=/Volumes/RamDisk/stereo_downmix_mpv.wav
.Expected behavior
Problem 1
In Adobe Audition, Amplitude Statistics should be identical.
Problem 2
The original FLAC is 24-bit. mpv should also produce 24-bit WAV.
Actual behavior
Problem 1
Amplitude Statistics are different.
WAV (mpv)
FLAC (FFmpeg)
Problem 2
The original FLAC is 24-bit, but mpv produces a 32-bit WAV.
Log file
Problem 1
Log file: http://sprunge.us/CBDC
Problem 2
Log: http://sprunge.us/VLER
Sample files
Problem 1
DTS-HD MA sample
Problem 2
8 channels FLAC sample
The text was updated successfully, but these errors were encountered: