deadbeef icon indicating copy to clipboard operation
deadbeef copied to clipboard

DSD plays at 16 bit resolution on Linux when 32 bit format is available

Open ghost opened this issue 6 years ago • 14 comments

Steps to reproduce the problem

Play 32 bit dsf

What's going on? Describe the problem in as much detail as possible.

Output is ALSA hw:CARD=Slim,DEV=0 DACport Slim officially supports up to 192000 @ 24bit

When playing dsf files (ripped from iso w/ sacd_extract) that have 32 bit depth the following happens: cat /proc/asound/card2/pcm0p/sub0/hw_params access: RW_INTERLEAVED format: S16_LE subformat: STD channels: 2 rate: 192000 (192000/1) period_size: 1024 buffer_size: 8192

When playing 24 bit FLAC: ... format: S32_LE ...

I'm using deadbeef's resampler for 192000 with auto checked and SINC_BEST_QUALITY

Why is it dropping 32bit to 16 instead of 24?

Information about the software:

Deadbeef version: 0.7.2 OS: Ubuntu 16.04

ghost avatar May 15 '18 04:05 ghost

could be that ffmpeg is decoding DSD at 16 bit resolution

Oleksiy-Yakovenko avatar May 15 '18 04:05 Oleksiy-Yakovenko

You may be right, what to do?

cat /proc/asound/card2/stream0 CEntrance CEntrance DACport Slim at usb-0000:00:1d.0-1.6, high speed : USB Audio

Playback: Status: Running Interface = 1 Altset = 1 Packet Size = 120 Momentary freq = 95999 Hz (0xb.fff8) Feedback Format = 16.16 Interface 1 Altset 1 Format: S32_LE Channels: 2 Endpoint: 1 OUT (ASYNC) Rates: 44100, 48000, 88200, 96000, 176400, 192000 Data packet interval: 125 us Interface 1 Altset 2 Format: S16_LE Channels: 2 Endpoint: 1 OUT (ASYNC) Rates: 44100, 48000, 88200, 96000, 176400, 192000 Data packet interval: 125 us

ghost avatar May 15 '18 04:05 ghost

If you can verify that ffmpeg is doing that, then there's not much we can do. That's just the way things are.

Oleksiy-Yakovenko avatar May 15 '18 04:05 Oleksiy-Yakovenko

I just played the same file with mpv with this in the config: audio-device='alsa/hw:CARD=Slim,DEV=0'

access: RW_INTERLEAVED format: S32_LE subformat: STD channels: 2 rate: 192000 (192000/1) period_size: 3000 buffer_size: 48000

Also I didn't specify 192000 anywhere, failure to do so in deadbeef resampler (by removing it) results in getting the audio slowed. Not sure what mpv does under the hood.

ghost avatar May 15 '18 04:05 ghost

resampling doesn't have anything to do with bit depth (just FYI). I don't know whether mpv is using ffmpeg for DSD playback.

Oleksiy-Yakovenko avatar May 15 '18 04:05 Oleksiy-Yakovenko

I pointed it out to demonstrate that mpv does something behind the scene prior to sending it off to the DAC.

It seems awkward that deadbeef can't playback a 24 or 32 bit DSD even if it uses ffmpeg, maybe use dsf2flac in an online fashion on a buffer?

ghost avatar May 15 '18 05:05 ghost

It seems awkward that deadbeef can't playback a 24 or 32 bit DSD

Which according to you is not the case, since deadbeef can play it just fine, except it gets played at 16 bit resolution for some reason.

BTW, all DSD files encode the data as 1 bit per sample. Just for your information. There's no such thing as 24 or 32 bit DSD.

Anyway.. I just looked at the code, and tested on mac.. The DSD files are decoded as 32 bit float always. So the problem seems to be somewhere else, not related to the actual decoding.

I suggest trying deadbeef 1.8 alpha, maybe that issue is already fixed.

Oleksiy-Yakovenko avatar May 15 '18 06:05 Oleksiy-Yakovenko

I just tried the master branch build from SF (last updated 14 hours ago) and the same problem.

It actually has another problem also, when playing dsf files it now has a seemingly random defect (micro pause) every 1-10 seconds.

ghost avatar May 15 '18 18:05 ghost

Assigning bug status. Can't help you atm though, I don't have an immediately available Linux machine with 32 bit audio support to verify this.

Oleksiy-Yakovenko avatar May 15 '18 18:05 Oleksiy-Yakovenko

Just for reference the mpv player:

mpv -v 01\ -\ Unknown\ Artist.dsf [cplayer] Command line options: '-v' '01 - Unknown Artist.dsf' [cplayer] mpv 0.28.0 (C) 2000-2017 mpv/MPlayer/mplayer2 projects [cplayer] built on UNKNOWN [cplayer] ffmpeg library versions: [cplayer] libavutil 56.15.100 [cplayer] libavcodec 58.19.100 [cplayer] libavformat 58.13.100 [cplayer] libswscale 5.2.100 [cplayer] libavfilter 7.18.100 [cplayer] libswresample 3.2.100 [cplayer] ffmpeg version: 3.4.git [cplayer] [cplayer] Configuration: ./waf -v configure --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --confdir=/etc/mpv --zshdir=/usr/share/zsh/vendor-completions --disable-build-date --enable-cdda --enable-sdl2 --enable-zsh-comp --enable-encoding --enable-vapoursynth --enable-lua [cplayer] List of enabled features: 52arch alsa asm atomics cdda cplayer cplugins cuda-hwaccel debug-build drm egl-helpers egl-x11 encoding fchmod ffmpeg gl gl-x11 glibc-thread-name glob glob-posix gnuc gpl iconv jack jpeg lcms2 libaf libass libass-osd libav-any libavcodec libavdevice libbluray libdl libm librt linux-fstatfs lua optimize oss-audio posix posix-or-mingw posix-spawn posix-spawn-native pthreads pulse rubberband sdl2 stdatomic vaapi vaapi-egl vaapi-glx vaapi-x-egl vaapi-x11 vapoursynth vapoursynth-core vapoursynth-lazy vdpau vdpau-gl-x11 vt.h x11 xv zlib zsh-comp [cplayer] Reading config file /etc/mpv/encoding-profiles.conf [cplayer] Reading config file /home//.config/mpv/mpv.conf [bdmv/bluray] Opening /home//.config/mpv/input.conf [file] Opening /home//.config/mpv/input.conf [input] Parsing input config file /home//.config/mpv/input.conf [input] Input config file /home/***/.config/mpv/input.conf parsed: 3 binds [osc] lua-settings/osc.conf not found. [osd/libass] Shaper: FriBidi 0.19.7 (SIMPLE) HarfBuzz-ng 1.0.1 (COMPLEX) [osd/libass] Setting up fonts... [ytdl_hook] lua-settings/ytdl_hook.conf not found. [stats] lua-settings/stats.conf not found. [cplayer] Playing: 01 - Unknown Artist.dsf [cplayer] Running hook: ytdl_hook/on_load [osd/libass] Using font provider fontconfig [osd/libass] Done. [bdmv/bluray] Opening 01 - Unknown Artist.dsf [file] Opening 01 - Unknown Artist.dsf [cache] Cache size set to 20000 KiB (10000 KiB backbuffer) [demux] Trying demuxers for level=normal. [lavf] Found 'dsf' at score=100 size=2048. [cache] Dropping cache at pos 1704935516, cached range: 0-5439488. [cache] Seeking underlying stream: 5439488 -> 1704935516 [cache] EOF reached. [cache] Dropping cache at pos 28, cached range: 1704935516-1704935584. [cache] Seeking underlying stream: 1704935584 -> 28 [ffmpeg/demuxer] dsf: Estimating duration from bitrate, this may be inaccurate [lavf] avformat_find_stream_info() finished after 1245212 bytes. [demux] Detected file format: dsf (libavformat) [cache] blocking for STREAM_CTRL 6 [cplayer] Opening done: 01 - Unknown Artist.dsf [find_files] Loading external files in . [cplayer] Running hook: ytdl_hook/on_preloaded [lavf] select track 0 [cplayer] (+) Audio --aid=1 (dsd_lsbf_planar 6ch 352800Hz) [display-tags] File tags: [display-tags] Genre: Other [display-tags] Track: 1 [ad] Codec list: [ad] dsd_lsbf_planar - DSD (Direct Stream Digital), least significant bit first, planar [ad] Opening audio decoder dsd_lsbf_planar [ad] Requesting 1 threads for decoding. [ad] Selected audio codec: dsd_lsbf_planar (DSD (Direct Stream Digital), least significant bit first, planar) [cplayer] Starting playback... [af] Audio filter chain: [af] [in] 352800Hz 5.1 6ch floatp [af] [out] 352800Hz 5.1 6ch floatp [af] [ao] 352800Hz 5.1 6ch floatp [ao] Trying audio driver 'alsa' [ao] Using preferred device 'hw:CARD=Slim,DEV=0' [ao/alsa] requested format: 352800 Hz, 5.1 channels, floatp [ao/alsa] using ALSA version: 1.1.0 [ao/alsa] opening device 'hw:CARD=Slim,DEV=0' [ao/alsa] trying format float/14 [ao/alsa] trying format double/16 [ao/alsa] trying format s32/10 [ao/alsa] Channel layouts: [ao/alsa] - stereo [ao/alsa] result: stereo [ao/alsa] Going to set final HW params: [ao/alsa] --- > [ao/alsa] ACCESS: RW_INTERLEAVED [ao/alsa] FORMAT: S32_LE [ao/alsa] SUBFORMAT: STD [ao/alsa] SAMPLE_BITS: 32 [ao/alsa] FRAME_BITS: 64 [ao/alsa] CHANNELS: 2 [ao/alsa] RATE: 192000 [ao/alsa] PERIOD_TIME: 15625 [ao/alsa] PERIOD_SIZE: 3000 [ao/alsa] PERIOD_BYTES: 24000 [ao/alsa] PERIODS: 16 [ao/alsa] BUFFER_TIME: 250000 [ao/alsa] BUFFER_SIZE: 48000 [ao/alsa] BUFFER_BYTES: 384000 [ao/alsa] TICK_TIME: ALL [ao/alsa] --- [ao/alsa] channel map reported by ALSA: FL FR [ao/alsa] which we understand as: stereo [ao/alsa] which is what we requested. [ao/alsa] hw pausing supported: yes [ao/alsa] buffersize: 48000 samples [ao/alsa] period size: 3000 samples [ao/alsa] device buffer: 48000 samples. [ao/alsa] using soft-buffer of 48000 samples. [cplayer] AO: [alsa] 192000Hz stereo 2ch s32 [cplayer] AO: Description: ALSA audio output [af] Adding filter lavrresample [lavrresample] Remix: 5.1 -> stereo [af] Audio filter chain: [af] [in] 352800Hz 5.1 6ch floatp [af] [lavrresample] 192000Hz stereo 2ch s32 [a] [af] [out] 192000Hz stereo 2ch s32 [af] [ao] 192000Hz stereo 2ch s32 [cplayer] starting audio playback [cplayer] playback restart complete [statusline] A: 00:01:36 / 00:13:25 (12%) Cache: 195s+409MB [lavf] queuing seek to 91.985219 [lavf] cached range 0: 0.000000 <-> 292.327622 [lavf] ...using this range for in-cache seek. [lavf] seeking stream 0 (audio) to packet 91.974244/91.974244 [cplayer] hr-seek, skipping to 91.985219 [statusline] A: 00:01:31 / 00:13:25 (11%) Cache: 200s+420MB [cplayer] starting audio playback [cplayer] playback restart complete [statusline] A: 00:02:19 / 00:13:25 (17%) Cache: 195s+409MB [cplayer] EOF code: 6
[ad] Uninit audio decoder. [af] Removing filter lavrresample [cache] Terminating cache... [cache] Cache exiting... [cplayer] finished playback, success (reason 3) [cplayer] [cplayer] [cplayer] Exiting... (Quit) [ytdl_hook] Exiting... [stats] Exiting... [osc] Exiting... [ao/alsa] draining...

ghost avatar May 15 '18 19:05 ghost

As far as I remember after trying to convert some DTS audio, FFMpeg assumes that you want a 16-bit sound and produces 16-bit from any input unless you tell it to make 24 or 32. The problem is likely to be that deadbeef calls FFMpeg without giving it that instruction and the user cannot control it.

Perhaps, modifying the ffmpeg plugin by adding an option "Use SB_32LE by default" would help.

dikonov avatar Apr 23 '19 08:04 dikonov

Извините, но я не уверен, что мы друг друга понимаем на английском. Баг #2593 не является настоящим дублем 2012! Он всего лишь включает в себя #2012, как часть описываемого недостатка. #2593 -более общий запрос, решение которого одновременно закроет #2012.

Общая проблема состоит в невозможности для пользователя управлять декодированием DSD через передачу параметров ffmpeg-модулю (на самом деле libavcodec и ко.).

В #2012 речь идет о неверном умолчательном выборе типа семпла (bit depth) и только. Решение №2012 не снимает проблему #2593.

dikonov avatar May 05 '21 15:05 dikonov

Hi, for what I can see the issue is not only for DSD playback but for all 32bit files in hardware direct. I have Deadbeef set to ALSA -> Direct Hardware Without any conversion, I just created 3 test wav files in Audacity 16bit_88k.wav 24bit_88k.wav 32bit_88k.wav

Playing them in Deadbeef, I get this:

16bit_88k.wav access: RW_INTERLEAVED format: S16_LE <-- CORRECT subformat: STD channels: 2 rate: 88200 (88200/1) period_size: 1024 buffer_size: 8192

24bit_88k.wav access: RW_INTERLEAVED format: S24_3LE <-- CORRECT subformat: STD channels: 2 rate: 88200 (88200/1) period_size: 1024 buffer_size: 8192

32bit_88k.wav access: RW_INTERLEAVED format: S16_LE <-- I EXPECT S32_LE subformat: STD channels: 2 rate: 88200 (88200/1) period_size: 1024 buffer_size: 8192

If i switch ouptut to ALSA --> Hardware with all software conversion, 16 and 24 bit files same as befeore, with 32bit file i get: access: MMAP_INTERLEAVED <--- not RW format: S32_LE subformat: STD channels: 2 rate: 88200 (88200/1) period_size: 1024 buffer_size: 8192

With other software capable of outputting to alsa direct hardware I can get the desired stream access: RW_INTERLEAVED format: S32_LE subformat: STD channels: 2 rate: 88200 (88200/1) period_size: 3528 buffer_size: 131072

Thanks for your hard work

pranorre avatar Dec 27 '21 23:12 pranorre

Up! this is still there to fix!

cat /proc/asound/card2/pcm0p/sub0/hw_params access: RW_INTERLEAVED format: S16_LE subformat: STD channels: 2 rate: 352800 (352800/1) period_size: 1024 buffer_size: 8192

while playing a DSD64

c3kkos avatar Jan 18 '23 20:01 c3kkos