[LINUX] LPCM over HDMI audio resampling questions?
#16
alanwww1 Wrote:With the patched file currently 16bit, 48khz 8channel lossless sound is available, except the channel mapping is wrong and mixed up. With a little modification to the patch i was able to get full 192khz/24bit 6 channel, full hd lossless sound over hdmi cable. To use this feature you need to have an AV receiver with the minimum hdmi 1.0 standard input.

Alan,
What did you do to the patch to get 192khz/24bit?

-Will
Reply
#17
Weel done Will, you found the solution for the greates problem we have, the channel mapping.

Well the solution for supporting other formats than 48k/16bits, i know form Nvidia developer Wei Ni, who we should thank all this great thing happaning to hdmi audio on nvidia hardware.

You have to change 6 lines in the patch_nvidia.c file

Code:
sudo nano /usr/src/Alsa-1.0.20/alsa-driver-1.0.20/sound/pci/hda/patch_nvhdmi.c

Both of the sections where you find 48000 you have to change like this:

Code:
    .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000,
    .maxbps = 24,
    .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,

Thank you need to recompile the kernel module. Just repeat my steps in the first post, after you
Code:
cd /usr/src/Alsa-1.0.20/alsa-driver-1.0.20/
sudo make clean
sudo make

Just copy the ko file to where it belongs, reboot than you will have a device supporting from 48/16 to 192/24 formats. You can test it with this:

Code:
speaker-test -Dhdmi -c8 -r192000 FS32_LE

Channel mapping will be wrong because you only changed the asound.conf in xbmc dir. To make a general remaping of channels there is a solution to have a .asoundrc filr in your home dir. But your solution is a lot better because it routes the channels into the right place already in xbmc. So far i don't want to use this device other than in xbmc. I think Wei will find a solution in the driver so that we won't need this anymore in the future.

I still have the following issues need to be solved.

- When i play 44khz CD flacs i have the music played slightly faster because the hdmi device does not support 44khz. I tried to put it in the patch_nvidia.c file but it won't even compile as i think these lines SNDRV_PCM_RATE_48000 are defined somewhere in alsa as constants and there is no constant named SNDRV_PCM_RATE_44000. So i want to have all by 44khz playbacks resampled by nvidia (or xbmc) to 192khz, but in a way that other formats (which are supported by nvidia hdmi) should NOT be touched (resampled). I know a way to make a .asoundrc file with resampling EVERYTHING to a certain format, but that is no solution. I don't know how to make conditions in that file.

Software mixing of course needed if we want to have crossfade for example with music playing. I don't know how to make it in a way that quality won't degrade. We can try to put in .asoundrc file a device that upsamples and software mixes everything into 192/24 but still i think we will loose quality.

I think for both of these problems we could have a solution in xbmc's Masteraudio branch. I already started this discussion in the Masteraudio branch.

Other problem i have is that ffmpeg (so xbmc) can not decode dts 96/24 tracks. If i have this passthroughed to the AV Receiver it shows 96/24 DTS info, but when i decode it with xbmc (and mplayer) also shows only 48/16 track. Here are some samples

https://www.mplayerhq.hu/MPlayer/samples...s/DTS/dts/
So i think i need to recode them to for example flac files. But that would result a bigger file for the same quality as DTS is a lossy codec.

Will, which tools have you used for reencoding tru-HD tracks to flac ?
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#18
I solved the 44khz problem. It was actually 44100 in the patch_nvidia.c file we have to use and i found some other formats as well. It is in the /usr/src/Alsa-1.0.20/alsa-driver-1.0.20/sound/pci/hda/hda_codec.c/usr/src/Alsa-1.0.20/alsa-driver-1.0.20/sound/pci/hda/hda_codec.c

Code:
{ 8000, SNDRV_PCM_RATE_8000, 0x0500 }, /* 1/6 x 48 */
        { 11025, SNDRV_PCM_RATE_11025, 0x4300 }, /* 1/4 x 44 */
        { 16000, SNDRV_PCM_RATE_16000, 0x0200 }, /* 1/3 x 48 */
        { 22050, SNDRV_PCM_RATE_22050, 0x4100 }, /* 1/2 x 44 */
        { 32000, SNDRV_PCM_RATE_32000, 0x0a00 }, /* 2/3 x 48 */
        { 44100, SNDRV_PCM_RATE_44100, 0x4000 }, /* 44 */
        { 48000, SNDRV_PCM_RATE_48000, 0x0000 }, /* 48 */
        { 88200, SNDRV_PCM_RATE_88200, 0x4800 }, /* 2 x 44 */
        { 96000, SNDRV_PCM_RATE_96000, 0x0800 }, /* 2 x 48 */
        { 176400, SNDRV_PCM_RATE_176400, 0x5800 },/* 4 x 44 */
        { 192000, SNDRV_PCM_RATE_192000, 0x1800 }, /* 4 x 48 */

So i just added another column into the nvidia.c file like this:

Code:
    .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000,
    .maxbps = 24,
    .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,

I think we should add all available formats to the file (like 22,05khz and so)

Now we can listen to CD music with untouced signal at native 44,1 khz !
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#19
Bahndit Wrote:Well if you look at the asound.conf file that XBMC uses again (/usr/share/xbmc/system/) you will notice a similar mapping in the ttable under pcm_win51:
Code:
pcm.xbmc_win51 {
   ttable {
   [color=red] 0.0= 1
    1.1= 1
    2.4= 1
    3.5= 1
    4.2= 1
    5.3= 1[/color]

When I saw this I decided to change the ttable to:
Code:
pcm.xbmc_win51 {
  ttable {
    0.0= 1
    1.1= 1
    2.2= 1
    3.3= 1
    4.4= 1
    5.5= 1
  }
}
After doing this speaker-test still doesn't work but 5.1 FLAC files in XBMC do! Anyway, try modifying your asound.conf to look like mine and let me know how it goes for you.

Well i tried to modify the asound.conf in /usr/share/xbmc/system/ according to what you suggested. I have not tested multichannel flac files, but with ac3, dts streams it is not changing anything. I still need a custom .asondrc file in the home dir like this:

Code:
pcm.ch51remap {
         slave.pcm hdmi
         type route
         ttable.0.0 1
         ttable.1.1 1
         ttable.2.4 1
         ttable.3.5 1
         ttable.4.2 1
         ttable.5.3 1
}

And i have to use "ch51remap" device instead of hdmi in xbmc.
Any Devs can help how to set channel mapping for various file formats DTS, AC3 in DVDPlayer and PAPPlayer in xbmc LINUX ?
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#20
alanwww1 Wrote:Other problem i have is that ffmpeg (so xbmc) can not decode dts 96/24 tracks. If i have this passthroughed to the AV Receiver it shows 96/24 DTS info, but when i decode it with xbmc (and mplayer) also shows only 48/16 track. Here are some samples

https://www.mplayerhq.hu/MPlayer/samples...s/DTS/dts/
So i think i need to recode them to for example flac files. But that would result a bigger file for the same quality as DTS is a lossy codec.

Alan, why don't you want your receiver to do the decoding? Personally I would rather have my receiver do the decoding where possible. If I leave the "AC3 and DTS capable" options selected then XBMC simply switches to bitstream over LPCM where capable. Is there any reason that you wouldn't want that to happen?

alanwww1 Wrote:Will, which tools have you used for reencoding tru-HD tracks to flac ?

I use the eac3to tool. I will write more on this later.

-Will
Reply
#21
One reason could be if you want to resample audio for changing playback speed (Smoothvideo function) or if you want mixing done with the sound etc. I just noted that ffmpeg does not yet support dts 24/96 format.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#22
So Smoothvideo doesn't work if you use bitstream?
Reply
#23
Bahndit Wrote:So Smoothvideo doesn't work if you use bitstream?

It works but only with skip/duplicate method which is only suitable if you have the refresh rate very near to the fps of the film (or 2x). So you can't do things like making a 24fps movie sped up to 25fps suitable for PAL system. This can only be done with resampling of audio.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#24
Alan,
Do you have any issues with VDPAU skipping on you at all when watching a movie using a lossless codec. Sometimes during an intense audio scene the movie skips like it's dropping frames but no frame drops are reported. If I watch the same scene with the standard AC3 track I don't have any issues. Any thoughts?

-Will
Reply
#25
Unfortunatelly i don't have a movie with tru-HD audio track so i can not tell. What audio sync method have you set ? Is is resampling ? What is the CPU utilization during playback. It can be that eighter decoding or resampling of HD audio is eating up too much of the cpu time.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#26
Will, Is your channel mapping ok with ac3, dts files, with the modifications you made in asound.conf ? You said that with flac files it is ok.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#27
Sorry if this comes off as stupid, but I'd like a bit of clarification if possible.

So with this and a MKV containing FLAC audio transcoded from the THD/DTS-MA track, my receiver will see 6 channel LPCM and not something like stereo PCM?

I've been having tons of fun with Vista, Reclock, and MadFLAC trying to get this to work, so this would be a nice change.

Nevertheless, thanks for all the work guys.
Reply
#28
swevo24 Wrote:Sorry if this comes off as stupid, but I'd like a bit of clarification if possible.

So with this and a MKV containing FLAC audio transcoded from the THD/DTS-MA track, my receiver will see 6 channel LPCM and not something like stereo PCM?

I've been having tons of fun with Vista, Reclock, and MadFLAC trying to get this to work, so this would be a nice change.

Nevertheless, thanks for all the work guys.

This is Exactly what it means (or even 8 channels if you have that much speakers) and it supports up to 24 bits/192khz.

I tried playing some 24/96 format multichannel flac encoded hd music tracks. It sounds really great.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#29
swevo24 Wrote:Sorry if this comes off as stupid, but I'd like a bit of clarification if possible.

So with this and a MKV containing FLAC audio transcoded from the THD/DTS-MA track, my receiver will see 6 channel LPCM and not something like stereo PCM?

I've been having tons of fun with Vista, Reclock, and MadFLAC trying to get this to work, so this would be a nice change.

Nevertheless, thanks for all the work guys.

I do this in Vista, my Mediaportal installation (i use both Mediaportal-Vista / XBMC-Ubuntu). I use ReClock and ffdshow, i pass all to my receiver as LPCM. My receiver shows: Multichannel-PCM.

It's so nice, i never have to worry. Just as long ffdshow can handle the codec my receiver will do the playback flawlessly.. Smile


alanwww1 Wrote:This is Exactly what it means (or even 8 channels if you have that much speakers) and it supports up to 24 bits/192khz.

I tried playing some 24/96 format multichannel flac encoded hd music tracks. It sounds really great.

Yes, the sound is great. No loss, and the transportation is digital all the way.
HW: Asus P5N7A-VM / E8400 / 2x2GB PC6400 --> Harman Kardon AVR-255 --> Sony 40D3000 (1080p/24-50-60Hz).
SW: Ubuntu Jaunty (32bit). XBMC SVN mainbranch. HDMI for A/V.
Reply
#30
thank you for the information on this topic, this is the only source of information on 8 channel lpcm with nvidia on linux ive been able to find.

i actually found it easier to get this working (although not working properly) then i did with windows, still didnt get it working properly with windows but i didnt spend enough time on it.

anyway i wanted to ask you guys a question, ive upgraded alsa and applied the patch and remapped the channels. however when i play the dark knight ripped strait from a bluray disk the channels were still wrong and the lpcm steam is on off, on off, on off etc. as the reciever detects it anyway. so i converted the same soundtrack to flac and that played flawlessly and sounded great. anyway im formatting my htpc now and setting up xbmc on a minimal install of jaunty and wondering if im asking to much to be able to use dumphd to dump a bluray to my hdd and play it with xbmc, with or without lossless audio? as i still havent been able to get it to work properly.

thanks for you help
Reply

Logout Mark Read Team Forum Stats Members Help
[LINUX] LPCM over HDMI audio resampling questions?0