Decoding AC3 from SPDIF on the fly

Dolby Digital


AC3 Capture

Using a PC to decode AC3 audio via a spdif from a satellite set top box has always been something that has interested me for several years, given my determination to avoid home receivers and stick with a good quality sound card driving multiple power amps instead, but until I could never get it work satisfactorily.

Some of the Creative Labs cards such as the Audigy will do SPDIF-in-decode from AC3 in Windows XP, but the feature was dropped in Vista and has only recently been restored for Windows 7. Up until recently, I used a Creative Extigy external sound card to do the AC3 decoding which it did very well, but the trouble was, the sound quality was not in the same league as my main audio sound card, an Asus Xonar D2 PCI. What I ideally wanted was some way of decoding the AC3/SPDIF signal in real-time and then sending the PCM signal to the Xonar - Fortunately I found a working solution and was able to ditch the Extigy.

I have always been fortunate that I have had in my possession a sound card that can actually capture the 2 channel AC3 encoded PCM signal via spdif and not mess with it (sadly so many soundcards do). The first soundcard I used was a CMedia 8738 based PCI card and then more recently a Asonic 7.1 USB one which is a steal from Ebuyer at under £14. Try as I might though using GraphEdit, the sound was never in sync with the television.

It was only on further reading on the internet of other people's pain and suffering in this area (most had given up), that I managed to find the reason why. Once I understood what was going on, I was able to go about the solving the latency problem. It is important to note at this stage that this will only work for AC3 streams that are not copy protected such as TV broadcasts. AC3 from a DVD player will tend to be blocked using SMCS (Serial Copy Management System) unless using Drogbert's Homebrew drivers on a CMedia 8738 based card which ignores it.

The problem arises because of direct show. By default when you use a direct show capture device, Direct Show automatically applies a 500ms buffer to the input meaning the audio will always be half a second behind. Not really a problem if you are recording, but if you wanting to decode in real-time, then this is a big problem.

AC3 Capture

The solution is to use the WDM capture driver instead which does not use such a large buffer and kernel streams the signal meaning very low latency. Other people have suggested a similar solution to this problem buy using a WDM capture driver, but where they tend to go wrong is they use the default direct sound driver to render the sound which adds more latency (roughly about 20ms). The secret is to render the audio from AC3 filter direct to the sound card using the WDM (kernel streaming) rendering device of your chosen sound card. This means AC3 filter talks direct to the sound card bypassing the kmixer/Vista/W7 mixer for improved latency and sound quality. It is obviously important that a PCM format supported by the sound card is presented by AC3 filter (usually 16bit/48khz or 24/48), but you should now have audio that is in sync with the television. In my system graph below, the SPDIF is captured on the usb device and rendered on the Xonar by connecting the AC3 filter output to the Xonar's volume pin. It will be labelled differently on each soundcard but you can check the pin info in Graph Studio for a wFormatTag of 65534 (WAVE_FORMAT_EXTENSIBLE) and nChannels of 6 to find out which one best suits.

AC3 Capture

There will be inevitably be some latency but it should be very low (<20ms), and the actual figure/performance will vary from system to system. Also it is worth remembering that so many modern televisions do video post processing which creates picture latency so there is a good chance you won't notice anything.

This entry was posted on Tuesday October 5th, 2010 at 6:00 PM and is filed under Home Cinema. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response.

2 Responses to Decoding AC3 from SPDIF on the fly

Carlos Says:
January 23rd, 2011 at 11:49 AM

Hi there,

I need someone to provide some consulting services - essentially a program that connects periodically to a hauppage TV tuner and begins to encode a TV signal in H.264. Please reach out to me at the above email address.

Fxv300 Says:
May 17th, 2011 at 11:16 PM

I have a similar issue with the ACL889 ...take a look here
http://www.manikata.com/it/realtek/realtek.htm

Leave a Reply





captcha

Subscribe to RSS feed