My fix for AC3 passthrough issues

The Perian forums have moved to Google Groups, this forum is read only.
Skully321
Harmless
Posts: 2
Joined: Sun Apr 26, 2009 4:26 pm

My fix for AC3 passthrough issues

Postby Skully321 » Sun Apr 26, 2009 4:39 pm

Using QT 7.6(472), Perian 1.1.3
Intel MacBookPro 2.6GHz Intel Core 2 Duo, 4GB RAM, Leopard 10.5.6

Hi All,
This is my 1st post but I was compelled to contribute to this forum. I had some issues getting AC3 5.1 passthrough from Quicktime out to my home theater receiver using the optical output on the MacBook Pro. Only one ac3 file I had sounded fine, everything else was the bad digital noise coming through.

I had followed all of the directions here: http://www.cod3r.com/2008/02/the-correc ... quicktime/
...and still had problems...

Then I compared the one ac3 file I had that worked with every other ac3 file (embedded or not) that did not work. Then I found a fix. (again, it's my fix and I can't guarantee that it will work for you!)

Apparently the order of the sound channel assignments inside Quicktime's properties is critical!

To do this:
1) open your movie in Quicktime and let it play.
2) Press Command-J to pull open the properties window.
3) Click on "Sound track" or "surround track" or whatever seems to indicate your multichannel ac3 track.
4) Select Audio Settings below and look at the channel list, numbered 1-6.
5) Ensure that this is the following order from one to six: Left, Right, Center, LFE, Left Surround, RIght Surround.

As soon as I changed this order, every ac3 file I throw at it works perfectly! I couldn't help but share this finding. Hopefully it helps someone here...


-Skully321

SHRIKEE
Muffin
Posts: 35
Joined: Mon Jun 25, 2007 3:11 am
Location: Netherlands
Contact:

Re: My fix for AC3 passthrough issues

Postby SHRIKEE » Sat May 02, 2009 3:22 pm

How is that a fix?

AC3 by default has that order of channels. If yours were different your files were wrong all the time.

Also, the wrong channel order just makes the sound play through the wrong speaker. Which is annoying ofcourse but does not cover much of the "problems" most people have.

gbooker
Cocoaforge Admin
Posts: 723
Joined: Sat May 06, 2006 2:47 am
Contact:

Re: My fix for AC3 passthrough issues

Postby gbooker » Sat May 02, 2009 6:43 pm

This is a fix because certain parts of Apple's code gives the incorrect channel order. I've reported this to Apple over a year ago, in rdar 5799879, and they've not only ignored it, but instead have added another place where they use the incorrect channel layout. Report this to them http://bugreport.apple.com/

P.S. There is no need to make 4 posts on this.

weriusaa
Latté
Posts: 72
Joined: Mon Dec 03, 2007 9:11 pm

Re: My fix for AC3 passthrough issues

Postby weriusaa » Sun Jan 23, 2011 3:03 pm

apologies for resurrecting this, thought i'd chip in as I just ripped a DVD to AC3 passthrough and it came back with the wrong channel order.

Before rolling eyes, please note the two common channel layouts - ITU (L C R Ls Rs LFE), and Film (L R C LFE Ls Rs) (edit: ITU=LRCLsRsLfe, Film=LCRLfeLsRs). Whatever the efforts for standardisation, the film industry (and some popular DAWs) stick to the latter (Film) format for surround. Even if AC3 spec defines a certain channel order, everyone into a/v "standards" knows the amount of afterthought and hacks, and that there is practically never a single standard.

I think for 5.1 audio, Perian would benefit from a way to remap the channel order to one of these two mappings (99% of cases). I realise there are expectations towards Apple to fix their code and "do the thing right", but Apple have decided to "do the right thing" from their POV instead, and make it work for the 99% of their users. If Apple assume film layout on 5.1 just give us a "map decoded 5.1 to.." {ITU, Film} option, so this issue won't come back..

Hope this helps.
Last edited by weriusaa on Mon Jan 24, 2011 9:00 am, edited 1 time in total.

Skully321
Harmless
Posts: 2
Joined: Sun Apr 26, 2009 4:26 pm

Re: My fix for AC3 passthrough issues

Postby Skully321 » Sun Jan 23, 2011 7:03 pm

I had no idea there were two standards. Good info.

gbooker
Cocoaforge Admin
Posts: 723
Joined: Sat May 06, 2006 2:47 am
Contact:

Re: My fix for AC3 passthrough issues

Postby gbooker » Sun Jan 23, 2011 11:25 pm

weriusaa wrote:ITU (L C R Ls Rs LFE), and Film (L R C LFE Ls Rs)

You got these wrong, according to Apple's definitions. Apple defines ITU as L R C LFE Cs Ls Rs Rls Rrs (unused channels skipped).

Weriusaa, it's worse than that. There are more than 2 standards defined in OS X. First of all, these are the definitions for the layout between the decoder and the playback mechanims, not between the file and the decoder. Storing these layout in the file is inaccurate at best, but that's another story. Perian (A52Codec) uses the ITU standards because these were defined in OS X long before anything ever used them. This selection was painstakingly chosen for the set of layouts which both defined all valid AC3 channel modes and were grouped simply. They have the further advantage of being aliased by the names kAudioChannelLayoutTag_DVD_*. Apple, when they added their AC3 interpretation into .mp4, created a new layout for that OS only, that used a different channel ordering (meaning these layouts don't exist on previous OS versions but the ones Perian used do). This meant they explicitly broke any possibility of backwards compatibility with older OSs.

weriusaa wrote:Even if AC3 spec defines a certain channel order

It doesn't. On the other hand, it explicitly states that the ordering between the decoder and upper layers in not part of the AC3 spec. I've repeatedly attempted to get Apple to understand this, but they seem to be incapable of doing so.

weriusaa wrote: think for 5.1 audio, Perian would benefit from a way to remap the channel order to one of these two mappings (99% of cases).

Perian uses ITU, so it's doing that. Now, if you are talking about it detecting which is in use, Apple is again at fault for not telling the decoder which it should use. The decoder has code to do the remapping, but alas Apple's code never tells it which layout it should be using so that code goes unused. I've repeatedly asked them to do this, but they have simply ignored me for 6 months to a year at a time.

weriusaa wrote: Apple have decided to "do the right thing" from their POV instead, and make it work for the 99% of their users.

Wrong. Apple makes it work for 0% of their users. They defined a different layout from what was in common use predating any of their code using AC3. Furthermore, they don't even use it themselves! They made AC3 that used to work for users that installed the codec to only users who also correct Apple's mistakes.

weriusaa wrote:If Apple assume film layout on 5.1 just give us a "map decoded 5.1 to.." {ITU, Film} option, so this issue won't come back..

This would have to be done for each type of file individually, and would have to put all the intelligence on the part of the user since the decoder has 0 information about how it is being used. This is a worse solution.

I have given Apple two simple solutions and they have done neither.
  • Correct their mappings to the ones used. Apple doesn't even use their own mappings so this breaks nothing. If they did use them, I would not have suggested this.
  • Tell the decoder which mapping is in use. On 10.4 and 10.5, this was done, but sent to wrong instance of the decoder. It would send these commands to the instance it queried for property information instead of the one that did the actual work. In 10.6 they "corrected" this by not sending it to any of them.

Using Apple's current mappings does come with one serious problem. Apple didn't even bother to define all the possible AC3 channel modes for their kAudioChannelLayoutTag_AC3_* mappings. So what's to be done with the ones that Apple forgot? And yes, I do have a stream that fits into that category.

weriusaa
Latté
Posts: 72
Joined: Mon Dec 03, 2007 9:11 pm

Re: My fix for AC3 passthrough issues

Postby weriusaa » Mon Jan 24, 2011 1:01 am

gbooker wrote:
weriusaa wrote:ITU (L C R Ls Rs LFE), and Film (L R C LFE Ls Rs)

You got these wrong, according to Apple's definitions. Apple defines ITU as L R C LFE Cs Ls Rs Rls Rrs (unused channels skipped).


You are correct. I got them wrong, I do confuse them all the time. Film is LCRLsRsLFE and ITU is LRCLFELsRs. Still they are the two common layouts. And the film industry still goes by "Film".
I'm not saying Perian is doing anything wrong by going with ITU, but clearly Apple aren't thinking ITU in that context. Their whole a/v implementation is shaky, I've seen enough Final Cut and QTKit to know. But.. this is not strictly a technical matter. Apple is into software politics, and they wouldn't go all the way with AC-3, since Dolby will want their license money, and I guess Apple get around that by having the built-in DVD manufacturer pay that.. It makes some sense, especially when AAC does perfect multichannel.

Here's a post on Gearslutz. You're not alone in being against LCRLsRsLFE: http://www.gearslutz.com/board/4721642-post3.html
I had a look at this file I have, and there's nothing in the sound media header chunks apart from an "ac-3" tag. So if there's no channel layout specified, and Apple assume film order, why does Perian assume ITU? Again, I'm not saying it's doing anything wrong, just saying this probably works for fewer people than those for whom it doesn't work.

Here's an interesting table: http://rmworkshop.com/dvd_info/related_info/ac3hdr.html
Scroll to "acmod audio coding mode". Am I right in thinking AC-3 doesn't do ITU channel order?

gbooker
Cocoaforge Admin
Posts: 723
Joined: Sat May 06, 2006 2:47 am
Contact:

Re: My fix for AC3 passthrough issues

Postby gbooker » Mon Jan 24, 2011 2:44 am

weriusaa wrote:[Apple] wouldn't go all the way with AC-3, since Dolby will want their license money

They already pay it in a little application called DVD Player.

weriusaa wrote:when AAC does perfect multichannel.

Just lacking content and device support (catch-22).

weriusaa wrote: So if there's no channel layout specified, and Apple assume film order, why does Perian assume ITU?

I answered most of this already:
gbooker wrote:Apple, when they added their AC3 interpretation into [the] .mp4 [importer] ...

gbooker wrote:Perian (A52Codec) uses the ITU standards because these were defined in OS X long before anything ever used them. This selection was painstakingly chosen for the set of layouts which both defined all valid AC3 channel modes and were grouped simply. They have the further advantage of being aliased by the names kAudioChannelLayoutTag_DVD_*.

gbooker wrote:Apple's code never tells it which layout it should be using

Lastly, changing the way that A52Codec works will break a lot unless Apple provides a means to do it properly. The AVI and MKV importers will need changing, along with everything that's ever been written to be compatible with AC3 in Perian, along with the added bonus of breaking every single reference or self contained movie generated from these sources. The only thing that doesn't use ITU in the entire architecture is Apple's MP4 importer, and Apple has written nothing that uses it's output. The simple fact is Apple should have used ITU in the first place as it has numerous good reasons to use it and none against it.

weriusaa wrote:Am I right in thinking AC-3 doesn't do ITU channel order?

No.
gbooker wrote:[The AC3 spec] explicitly states that the ordering between the decoder and upper layers in not part of the AC3 spec.

weriusaa
Latté
Posts: 72
Joined: Mon Dec 03, 2007 9:11 pm

Re: My fix for AC3 passthrough issues

Postby weriusaa » Mon Jan 24, 2011 7:47 am

gbooker wrote:Lastly, changing the way that A52Codec works will break a lot unless Apple provides a means to do it properly. The AVI and MKV importers will need changing, along with everything that's ever been written to be compatible with AC3 in Perian, along with the added bonus of breaking every single reference or self contained movie generated from these sources. The only thing that doesn't use ITU in the entire architecture is Apple's MP4 importer, and Apple has written nothing that uses it's output. The simple fact is Apple should have used ITU in the first place as it has numerous good reasons to use it and none against it.


So in a way you're advising against using the MP4 container, or against using AC-3 as a codec, or at least using Perian to decode AC-3? That's like shooting someone in the foot. I just cannot point whom. I just cannot see AC-3 for film going ITU channel order until the International Telecommunications Union take over the film industry... don't get me wrong, I'm no fan of dual standards either.

gbooker wrote:
weriusaa wrote:Am I right in thinking AC-3 doesn't do ITU channel order?

No.
[The AC3 spec] explicitly states that the ordering between the decoder and upper layers in not part of the AC3 spec.


So what am I seeing then? I think it's a header that describes a channel array order. Are we effectively discussing why the upper layer only takes LCRLsRsLFE (under specific circumstances)? That''s different to my original suggestion/question ; Surely if AC3 works fine for everything else other than mp4 and m4v, it's a matter of sticking a little option saying "Use Film channel order for MP4 sound in 5.1" and setting that to off by default. That way the user has a means to work out their problem. Even a hidden "defaults write.." will do?

Edit: I think it wasn't Apple who defined a different layout to the ones they were expecting (i.e. all kAudioChannelLayoutTag* constants that seem to stem mostly from ITU order), they just met the reality of film sound, governed by Pro Tools and Film channel order. I had a look at the a52 sources. They all make perfect sense. But I re-opened the discussion with no academic ambition. Common sense, rather than perfect..

gbooker
Cocoaforge Admin
Posts: 723
Joined: Sat May 06, 2006 2:47 am
Contact:

Re: My fix for AC3 passthrough issues

Postby gbooker » Mon Jan 24, 2011 1:28 pm

weriusaa wrote:So in a way you're advising against using the MP4 container, or against using AC-3 as a codec, or at least using Perian to decode AC-3?

I already stated the solutions.

weriusaa wrote:So what am I seeing then? I think it's a header that describes a channel array order.

It's describing which channels are present, and at most the compressed order. This has absolutely no bearing whatsoever on what order the channels are when decoded. This is explicitly stated in the AC3 spec.

weriusaa wrote:Surely if AC3 works fine for everything else other than mp4 and m4v, it's a matter of sticking a little option saying "Use Film channel order for MP4 sound in 5.1" and setting that to off by default.

You're not getting it. How is the decompressor supposed to know that this particular AC3 stream came from an MP3 or M4V? QuickTime was explicitly designed to hide such details? It's not a matter of setting a preference and forgetting it, it's a matter of looking at which type of file you are going to open and setting that preference accordingly. Don't even think about opening two types at once because one will play incorrectly.

weriusaa wrote: think it wasn't Apple who defined a different layout to the ones they were expecting (i.e. all kAudioChannelLayoutTag* constants that seem to stem mostly from ITU order), they just met the reality of film sound, governed by Pro Tools and Film channel order.

They defined them in the sense that they created new layout tags for this ordering and created the code to handle these new layout tags. Additionally, Core Audio is designed to handle channel reordering among other things so once again, they had no good reason.

phreichmuth
Harmless
Posts: 5
Joined: Sun Apr 03, 2011 8:17 pm

Re: My fix for AC3 passthrough issues

Postby phreichmuth » Sun Apr 03, 2011 8:26 pm

Hello

Please excuse if I am a bit out of topic.

I am also looking for a solution of the 5.1 surround sound issue on OS X and found your discussion. So I tried to find "kAudioChannelLayoutTag" via the finder search function. On my iMac with sound through buil-in speakers I found it in a file in /System/Library/Frameworks/CoreAudio.framework/Versions/A/Headers/. But on the mac mini connected to the TV and my surround equipment via optical out, I did not find the folder Header in the same place.

How can that be? Is this somehow in relation to the the Xcode development tools installed on the iMac but not on the mac mini?
How can I get that folder and the files or what does it mean that I don't have that?

Regards
Philipp

gbooker
Cocoaforge Admin
Posts: 723
Joined: Sat May 06, 2006 2:47 am
Contact:

Re: My fix for AC3 passthrough issues

Postby gbooker » Sun Apr 03, 2011 11:09 pm

phreichmuth wrote:But on the mac mini connected to the TV and my surround equipment via optical out, I did not find the folder Header in the same place.

Different OS versions most likely. Check the AudioToolbox framework.

phreichmuth
Harmless
Posts: 5
Joined: Sun Apr 03, 2011 8:17 pm

Re: My fix for AC3 passthrough issues

Postby phreichmuth » Fri Apr 08, 2011 6:44 pm

No, both computers run with the same OS X version 10.6.7. But the header files are also not present on my girlfriends iMac, also with the same OS version.

In none of the two other computers the header files are in the audio toolbox framework neither.

EDIT: I doublechecked it right now. On my iMac, where I have the header files present, the link to Xcode was created at the same date as the folder with the header files. Only a 8 minutes difference. I remember that I have created that link in the program folder.

EDIT: I installed Xcode now on the Mac mini and now I have the header files...

phreichmuth
Harmless
Posts: 5
Joined: Sun Apr 03, 2011 8:17 pm

Re: My fix for AC3 passthrough issues

Postby phreichmuth » Wed Apr 13, 2011 3:09 pm

I'm sorry if the question is a bit stupide, but what would happen, if I only change the channel order in the header files?
Would the system even recognize the change as the files are only present if Xcode is installed?

gbooker
Cocoaforge Admin
Posts: 723
Joined: Sat May 06, 2006 2:47 am
Contact:

Re: My fix for AC3 passthrough issues

Postby gbooker » Wed Apr 13, 2011 5:53 pm

phreichmuth wrote:I'm sorry if the question is a bit stupide, but what would happen, if I only change the channel order in the header files?

Absolutely nothing!

phreichmuth
Harmless
Posts: 5
Joined: Sun Apr 03, 2011 8:17 pm

Re: My fix for AC3 passthrough issues

Postby phreichmuth » Fri Apr 15, 2011 11:00 am

O.K., I have read your bug report to Apple rdar:6921431 and understand a bit more now.

In that bug report you state that the correct channel order is communicated to a wrong instance of the audio frame work.
Is it not possible to catch this communication, dublicate the important part of it and send it to the correct instance? Or would that be a mailware-like action and thus be blocked by the system?

Regards
Philipp

gbooker
Cocoaforge Admin
Posts: 723
Joined: Sat May 06, 2006 2:47 am
Contact:

Re: My fix for AC3 passthrough issues

Postby gbooker » Fri Apr 15, 2011 1:06 pm

Not anymore. Apple "fixed" this report by no longer sending the channel order information to any instances.

phreichmuth
Harmless
Posts: 5
Joined: Sun Apr 03, 2011 8:17 pm

Re: My fix for AC3 passthrough issues

Postby phreichmuth » Fri Apr 15, 2011 1:45 pm

... great...!!! >:-((((

Would it be possible to reoder the audio channels by a sound server, something like JACK, http://www.jackosx.com/?

Or how did you solve the problem? Your description on cod3r does not solve the problem for Front Row without transcoding every movie.

Regards
Philipp

gbooker
Cocoaforge Admin
Posts: 723
Joined: Sat May 06, 2006 2:47 am
Contact:

Re: My fix for AC3 passthrough issues

Postby gbooker » Fri Apr 15, 2011 3:06 pm

A52Codec does now attempt to detect if the file is inside an MP4 by examining the codec cookies. If it sees this, it tries to reorder the channels within. I've tested this on a few files, but no idea if it works across the board.

As far as reordering the channels for frontrow, saving a reference movie within QT Player works just fine in frontrow.

jsarsero
Harmless
Posts: 1
Joined: Wed Apr 20, 2011 1:04 pm

Re: My fix for AC3 passthrough issues

Postby jsarsero » Wed Apr 20, 2011 1:16 pm

Excuse me if this is an inappropriate thread for my query.
Over the years I have manually changed the channel layout of hundreds of ripped DVDs to L, R, C, LFE, Ls, Rs in order to achieve AC3 passthrough via QuickTime Player or Front Row. I updated to Perian 1.2.2 this week and now only get static with these files. Is there any way to get back AC3 passthrough without converting hundreds of files or reverting to a previous version of Perian?


Return to “Perian”

Who is online

Users browsing this forum: No registered users