Kodi Community Forum
[WINDOWS][PATCH]Bitstream output of HD audio formats - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93)
+--- Thread: [WINDOWS][PATCH]Bitstream output of HD audio formats (/showthread.php?tid=121877)



- DDDamian - 2012-02-06

fezster Wrote:Thanks for the primer, and sorry if this is answered in the above - but how does this patch (combined with WASAPI audio output) deal with multichannel flac files ? As said above, I am getting 2 ch output on a multichannel audio file (confirmed by bringing up the codec info during playback). Am I doing something wrong ?

Hey fezster - looking at the code it's currently hard-coded for exclusive mode, and I can confirm it's doing that correctly on my rig. If I set to 2ch in Windows this version does indeed play a multi-channel FLAC as multi-channel despite what the Windows settings are. So on my rig it's working correctly and in exclusive mode.

I assume you're running at least Vista w/Service Pack 1? That is required for WASAPI exclusive. If so, post a debug log - open XBMC wait 10sec then play a multichannel FLAC, close it and post your log.


- fezster - 2012-02-06

Running Windows 7 here. Wasapi exclusive works as expected in AE build and dsplayer using reclock.

I will post a debug log when Im home. It's positive to hear it *should* work. Thanks.


- voip-ninja - 2012-02-06

Has anyone tested this patch yet with an i3 rig? I have one but didn't want to install and test if it was known to have issues. I currently have no other issues with the i3 other than a small bit of lip sync which it sounds like is a known problem.


- nikc0069 - 2012-02-06

Likely being thick here, but if I want my amp to do all the processing, should I set dts to lpcm or decoded? Won't decoded just work my cpu past what it is comfortable with? (only had a quick look at this last night so please forgive me if I've missed something obvious here)


- voip-ninja - 2012-02-06

nikc0069 Wrote:Likely being thick here, but if I want my amp to do all the processing, should I set dts to lpcm or decoded? Won't decoded just work my cpu past what it is comfortable with? (only had a quick look at this last night so please forgive me if I've missed something obvious here)

LPCM vs. Decoded?

Do you mean LPCM vs. Bitstream?

If you want your amp to do the 'lifting' then you have to use bitstream, as it sends the raw data to the amp for decoding.

LPCM means that the stream is decoded on the PC and then sent to your amp as audio information.

Both should sound identical unless there is something in the decoding that is messed up.

Remember that XBMC, without something like this generous work, does not convert DTS-MA to LPCM anyways, and it also cannot bitstream it. It simply sends the core DTS as bitstream data. For Dolby True, XBMC has had the ability (at least in Windows) to decode Dolby True-HD to LPCM and send it to the AVR for quite a long time now.

The problem is that there are something like 9 titles with DTS-MA for every one that is out there with Dolby True, so bitstream/LPCM decode of DTS-MA has been very very desirable for XBMC for quite a long while... at least for those of us who rip our own BDs and have good surround setups.


- DanielaE - 2012-02-06

A small clarification from my side: as I said before, this patch does audio processing just the same as baseline code from the main development trunk, it only adds the capability of passing a few more encoded audio stream formats as-is to an external decoder (usually an AVR). At least it was meant this way Wink Baseline WASAPI renderer opens the device in exclusive mode, so does the patched one. LPCM and AC3/dts bitstream output to S/PDIF or HDMI is exactly as before.

Regarding stereo and multichannel FLAC, I ran a test with two files. The first one is 96kHz, 24bit, 5.1:

Code:
17:38:58 T:2852    INFO: PAPlayer: Playing D:\Media\3 Doors Down - [2002] Away From The Sun (5.1).flac
17:38:58 T:2852   DEBUG: PAPlayer: Creating new audio renderer
17:38:58 T:2852   DEBUG: CWin32WASAPI::Initialize: endpoint device Realtek HDMI Output (ATI HDMI Audio)
17:38:58 T:2852    INFO: CPCMRemap: Configured speaker layout: 5.1
17:38:58 T:2852    INFO: CPCMRemap: I channel map: FL,FR,CE,LFE,BL,BR
17:38:58 T:2852    INFO: CPCMRemap: O channel map: FL,FR,CE,LFE,BL,BR
17:38:58 T:2852   DEBUG: CPCMRemap: Downmix normalization is disabled
17:38:58 T:2852   DEBUG: CPCMRemap: FL = FL(1.000000*)
17:38:58 T:2852   DEBUG: CPCMRemap: FR = FR(1.000000*)
17:38:58 T:2852   DEBUG: CPCMRemap: CE = CE(1.000000*)
17:38:58 T:2852   DEBUG: CPCMRemap: LFE = LFE(1.000000*)
17:38:58 T:2852   DEBUG: CPCMRemap: BL = BL(1.000000*)
17:38:58 T:2852   DEBUG: CPCMRemap: BR = BR(1.000000*)
17:38:58 T:2852   DEBUG: CWin32WASAPI::Initialize - Channels: 6 - SampleRate: 96000 - SampleBit: 16 - Resample false - IsMusic true - IsPassthrough 0 - audioDevice: Realtek HDMI Output (ATI HDMI Audio)
17:38:58 T:2852   DEBUG: CWin32WASAPI::Initialize: Packet Size = 11520. Avg Bytes Per Second = 1152000.
My AVR told me it's getting 6 channels at 96kHz sample rate - fine.

The second one is 176.4kHz, 24bit, 2.0:
Code:
17:39:15 T:2852    INFO: PAPlayer: Playing D:\Media\Brooke, Jonatha - [2001] Steady Pull (2.0).flac
17:39:15 T:2852   DEBUG: PAPlayer: Creating new audio renderer
17:39:15 T:2852   DEBUG: CWin32WASAPI::Initialize: endpoint device Realtek HDMI Output (ATI HDMI Audio)
17:39:15 T:2852    INFO: CPCMRemap: Configured speaker layout: 5.1
17:39:15 T:2852    INFO: CPCMRemap: I channel map: FL,FR
17:39:15 T:2852    INFO: CPCMRemap: O channel map: FL,FR
17:39:15 T:2852   DEBUG: CPCMRemap: Downmix normalization is disabled
17:39:15 T:2852   DEBUG: CPCMRemap: FL = FL(1.000000*)
17:39:15 T:2852   DEBUG: CPCMRemap: FR = FR(1.000000*)
17:39:15 T:2852   DEBUG: CWin32WASAPI::Initialize: Packet Size = 7168. Avg Bytes Per Second = 705600.
17:39:15 T:2852   DEBUG: CWin32WASAPI::Initialize - Channels: 2 - SampleRate: 176400 - SampleBit: 16 - Resample false - IsMusic true - IsPassthrough 0 - audioDevice: Realtek HDMI Output (ATI HDMI Audio)
My AVR was reporting 2 channels at 174.4k sample rate - fine as well.

Too bad, it seems that the FLAC decoder returns mere 16bit samples rather than the expected 24bit ones Sad

A comment on the DTS settings: baseline code has the option to select between DTS passthrough for streams up to DTS-96/24 or decoding to multichannel LPCM. DTS-HD was decoded in any case, just like Dolby Digital Plus and Dolby TrueHD. With my patch, users may select up to which level the external decoder is able (or is allowed) to handle DTS streams by itself. DTS streams with a more demanding level will then either be decoded to LPCM by XBMC (using the same decoders just as before), or the embedded non-HD stream is extracted and routed to the external decoder. So, the former 'DTS enabled' switch is equivalent to the settings pair 'DTS-96/24' plus 'decode to LPCM'.


- voip-ninja - 2012-02-06

Big thanks to Daniela, this is working great on my i3 rig with only the iGPU in use, I can now bitstream both Dolby True and DTS-MA and don't notice any stutters, frame loss, etc, as compared to the regular Beta 2 Eden version.

I did observe a problem after stopping playback to my 1080p/23.976 TV, in which the menus were flickering continuously, but I had been seeing this problem periodically before I loaded this patch, so I suspect it's an Eden issue.


- fezster - 2012-02-06

Quote:19:16:08 T:6080 NOTICE: Creating audio thread
19:16:08 T:6080 DEBUG: CEdl::ReadEditDecisionLists - Checking for edit decision lists (EDL) on local drive or remote share for: smb://comp/movies/300 (2006) Blu Ray FLAC/300 (2006) Blu Ray.mkv
19:16:08 T:6080 DEBUG: CDVDPlayer::SetCaching - caching state 2
19:16:08 T:3968 DEBUG: CDVDPlayerVideo - CDVDMsg::GENERAL_SYNCHRONIZE
19:16:08 T:3968 INFO: CDVDPlayerVideo - Stillframe left, switching to normal playback
19:16:08 T:3968 DEBUG: CDVDPlayerVideo - CDVDMsg::GENERAL_RESYNC(42000.000000, 0)
19:16:08 T:3968 NOTICE: fps: 23.976024, pwidth: 1920, pheight: 1080, dwidth: 1920, dheight: 1080
19:16:08 T:3968 DEBUG: CDVDPlayerVideo::OutputPicture - change configuration. 1920x1080. framerate: 23.98. format: DXVA
19:16:08 T:3968 NOTICE: Display resolution DESKTOP : 1920x1080 @ 59.94 - Full Screen (12)
19:16:08 T:3968 NOTICE: D3D: rendering method forced to DXVA2 processor
19:16:08 T:3968 DEBUG: DXVA - processor found Progressive Device
19:16:08 T:3968 DEBUG: DXVA - processor selected Progressive Device
19:16:08 T:3968 DEBUG: DXVA - processor requires 0 past frames and 0 future frames
19:16:08 T:3968 DEBUG: CWinRenderer::SelectRenderMethod: Selected render method 3: DXVA
19:16:08 T:3968 DEBUG: CVideoReferenceClock: Clock speed 100.100000%
19:16:08 T:5248 DEBUG: Thread CDVDPlayerAudio start, auto delete: 0
19:16:08 T:5248 NOTICE: running thread: CDVDPlayerAudio:Tonguerocess()
19:16:08 T:5248 INFO: CDVDAudioCodecFFmpeg::GetChannelMap - FFmpeg reported 6 channels, but the layout contains 0 ignoring
19:16:08 T:5248 NOTICE: Creating audio device with codec id: 86030, channels: 6, sample rate: 48000, no pass-through
19:16:08 T:5248 DEBUG: CWin32WASAPI::Initialize: endpoint device AMD HDMI Output (2- AMD High Definition Audio Device)
19:16:08 T:5248 INFO: CPCMRemap: Configured speaker layout: 7.1
19:16:08 T:5248 INFO: CPCMRemap: I channel map: FL,FR,CE,LFE,SL,SR
19:16:08 T:5248 INFO: CPCMRemap: O channel map: FL,FR,CE,LFE,SL,SR
19:16:08 T:5248 DEBUG: CPCMRemap: Downmix normalization is disabled
19:16:08 T:5248 DEBUG: CPCMRemap: FL = FL(1.000000*)
19:16:08 T:5248 DEBUG: CPCMRemap: FR = FR(1.000000*)
19:16:08 T:5248 DEBUG: CPCMRemap: CE = CE(1.000000*)
19:16:08 T:5248 DEBUG: CPCMRemap: LFE = LFE(1.000000*)
19:16:08 T:5248 DEBUG: CPCMRemap: SL = SL(1.000000*)
19:16:08 T:5248 DEBUG: CPCMRemap: SR = SR(1.000000*)
19:16:08 T:5248 DEBUG: CAudioContext::SetActiveDevice - SetActiveDevice from 2 to 0
19:16:08 T:5248 DEBUG: CAudioContext::RemoveActiveDevice - Removing device 2
19:16:08 T:5248 DEBUG: CGUIAudioManager:: DeInitialize
19:16:08 T:5696 DEBUG: Activating window ID: 12005
19:16:08 T:5696 DEBUG: ------ Window Deinit (MyVideoNav.xml) ------
19:16:08 T:5248 ERROR: CWin32WASAPI::Initialize: Audio format not supported by the WASAPI device. Channels: 6, Rate: 48000, Bits/sample: 16.
19:16:08 T:5248 ERROR: CWin32WASAPI::Initialize: WASAPI initialization failed.

19:16:08 T:5248 DEBUG: CAudioContext::SetActiveDevice - SetActiveDevice from 0 to 2
19:16:08 T:5248 DEBUG: CAudioContext::RemoveActiveDevice - Removing device 0
19:16:08 T:5248 DEBUG: CWDSound::direct_sound_enumerator_member_callback - found Device: Primary Sound Driver
19:16:08 T:5248 DEBUG: CWDSound::direct_sound_enumerator_member_callback - found Device: AMD HDMI Output (2- AMD High Definition Audio Device)
19:16:08 T:5248 DEBUG: CAudioContext::SetActiveDevice - selecting AMD HDMI Output (2- AMD High Definition Audio Device) as output devices
19:16:08 T:5696 DEBUG: ------ Window Init (VideoFullScreen.xml) ------


Looks like it is failing because of the above. Any solution to this ?


- voip-ninja - 2012-02-06

fezster Wrote:Running Windows 7 here. Wasapi exclusive works as expected in AE build and dsplayer using reclock.

I will post a debug log when Im home. It's positive to hear it *should* work. Thanks.

Could it be your drivers? I just tested a title with a multi-channel FLAC track that I created (since this particular title has a huge lossy PCM track it was a good experiment) and it seems to work fine, I'm getting audio from all channels using this patched build.

Do you have your audio driver set for 5 channels?


- Alz2605 - 2012-02-06

Hmmm... I'm getting micro stutters on some of my bluray rips and others play fine. The audio is perfect though and sounds amazing and I don't see any lip sync issues on either sound formats on the rips that play correctly.

But I can't understand what is causing the micro stutters on the rips that previously played perfectly. They're a mix of mkv and m2ts files with either Dolby true hd or dts hd and all have been ripped in the same way. I've tried a combination of different settings and I've updated to catalyst 12.1 and Realteks latest ati hdmi audio driver for windows 7.

Any suggestions? I don't like the idea on missing out on this great feature.


- voip-ninja - 2012-02-06

Alz2605 Wrote:Hmmm... I'm getting micro stutters on some of my bluray rips and others play fine. The audio is perfect though and sounds amazing and I don't see any lip sync issues on either sound formats on the rips that play correctly.

But I can't understand what is causing the micro stutters on the rips that previously played perfectly. They're a mix of mkv and m2ts files with either Dolby true hd or dts hd and all have been ripped in the same way. I've tried a combination of different settings and I've updated to catalyst 12.1 and Realteks latest ati hdmi audio driver for windows 7.

Any suggestions? I don't like the idea on missing out on this great feature.

Can you provide some example titles with the problem? I would like to test them on my rig if I have them... I've only tested a handful of titles but so far they all appear to be working with no frame drops.


- fezster - 2012-02-06

voip-ninja Wrote:Do you have your audio driver set for 5 channels?

Do you mean in the Windows Sound control panel ? I'm pretty certain I should be able to leave that as stereo, as WASAPI should bypass it.


- voip-ninja - 2012-02-06

fezster Wrote:Do you mean in the Windows Sound control panel ? I'm pretty certain I should be able to leave that as stereo, as WASAPI should bypass it.

Actually I don't believe that will work. Before I went in and explicitly configured my audio for 5.1, I was only getting stereo output from multi-channel tracks on my i3 setup even though I had chosen the WASAPI source in XBMC for audio playback.

As soon as I went in and told the WASAPI driver in the control panel that I had 5.1 speakers, everything just worked.


- DDDamian - 2012-02-06

Alz2605 Wrote:Any suggestions? I don't like the idea on missing out on this great feature.

Got enough horsepower? Try syncing to the video clock under video settings.

fezster Wrote:Do you mean in the Windows Sound control panel ? I'm pretty certain I should be able to leave that as stereo, as WASAPI should bypass it.

voip-ninja Wrote:Actually I don't believe that will work. Before I went in and explicitly configured my audio for 5.1, I was only getting stereo output from multi-channel tracks on my i3 setup even though I had chosen the WASAPI source in XBMC for audio playback.

As soon as I went in and told the WASAPI driver in the control panel that I had 5.1 speakers, everything just worked.

WASAPI exlusive mode *should* be independent of the Windows channel setup. What is important is to check "Allow applications to take exclusive control of this device" and "Give exclusive mode applications priority" in the Windows sound settings under "Advanced". This is likely the cause of the error in the log posted above (against forum etiquette! pls use pastebin & post link - sry had to mention).

On my rig multichannel plays fine on all channels regardless of the channel layout in Windows, which is correct.

@Daniela - agreed - it's a shame the FLAC decoder is currently 16bit - needs rewriting as part of AE as well. I have not confirmed if this is dithered down correctly from 24-16 either. I know in AE the dithering code has just been implemented.


- fezster - 2012-02-06

It turns out setting System -> Audio Output to 5.1 solves it. I now get my FLAC files playing correctly at multichannel, and any bitstreamed audio still plays correctly at up to 7.1.

I dont have any FLAC files > 6 channels, so not sure if they'd play correctly or not.

I'm guessing this is a bug that WASAPI exclusive does not work when 7.1 is selected ?