Ticket #531 (new enhancement)

Opened 4 years ago

Last modified 4 years ago

AC3 channel layout (again) proposal & implementation

Reported by: rovers Owned by:
Priority: normal Milestone:
Component: Perian-Main Version: 1.2.2
Severity: normal Keywords:
Cc:

Description

Problem: Apple's AC3 importer and MP4 files assume a channel layout as in the AC3 specs. This makes sense as it is an AC3 bitstream. Codecs can specify which channel layout they expect at input and which they produce at the output, but this is not used by QuickTime. Instead QuickTime assumes the same channel layout after decompressing and codecs are never told the layout. Unfortunately Perian's AC3 importer that existed before Apple's uses a different channel layout for importing, which QuickTime uses as the output layout. But the AC3 bitstream decodes to a fixed layout and as QuickTime does not tell the used input layout or the requested output layout, we don't know which to layout to use for the output.

Proposal: Add an "Apple compatibility mode" as a preference. When enabled it will import and assume everything with the Apple layout. Attached is a diff that is tested with Apple's AC3 import and MP4 files on stereo and passthrough SPDIF output. Also changing the import layout for avi and Matroska files in Perian in this mode, allow you to use this mode for all files.

Advantages:

  • no more layout problems with Apple by giving in...
  • works also for MP4 files, and with Apple's AC3 importer.

Disadvantages:

  • breaks previously imported .mov files.
  • downmixing to stereo or dolby pro logic does not work anymore, because apple thinks the layout is "Left, Center" for 2 channel outputs of multi-channel AC3-files with center channels, so downmixing is disabled and left to QuickTime (which works fine).

Enable with: defaults write org.perian.Perian compatabilityMode 1

Disable with: defaults write org.perian.Perian compatabilityMode 0

Hope it's useful. Would make my life easier if it is included.

Regards, Kenneth

Attachments

a52codec.diff Download (24.3 KB) - added by rovers 4 years ago.
perian.diff Download (5.5 KB) - added by rovers 4 years ago.

Change History

Changed 4 years ago by rovers

Changed 4 years ago by rovers

comment:1 in reply to: ↑ description ; follow-up: ↓ 2 Changed 4 years ago by gbooker

Replying to rovers:

Apple's AC3 importer and MP4 files assume a channel layout as in the AC3 specs.

WRONG! The specs refer to channel order in the file format but explicitly state that they do not define the channel order between the decoder and other layers. They mention that this negotiation must be done between those components, a step which Apple has failed to accomplish.

codecs are never told the layout.

Actually, before QT X, three codec instances were created, one was told the layout, and a different one was given the task of decoding. Clearly Apple didn't know what to do with multi-channel audio.

Unfortunately Perian's AC3 importer that existed before Apple's uses a different channel layout for importing, which QuickTime uses as the output layout.

Clarification: Perian's AC3 importer existed before the other layouts existed.

  • no more layout problems with Apple by giving in...

Giving in by doing the wrong thing and breaking other cases.

  • works also for MP4 files, and with Apple's AC3 importer.

Until they break it again.

Disadvantages:

  • breaks previously imported .mov files.

A rather bad disadvantage. I have over a hundred of these.

  • downmixing to stereo or dolby pro logic does not work anymore, because apple thinks the layout is "Left, Center" for 2 channel outputs of multi-channel AC3-files with center channels, so downmixing is disabled and left to QuickTime (which works fine).

Actually, it doesn't work fine. Apple's downmix is a bastardized mix of DPLI and DPLII that isn't truly either.

Now for the most critical point about lack of downmix: passthrough uses the same mechanism, and nothing that breaks passthrough will be accepted.

Would make my life easier if it is included.

It would make everyone's life easier if Apple did the right thing, especially since I've provided them two different mechanisms for doing the right thing and neither break anything.

comment:2 in reply to: ↑ 1 ; follow-up: ↓ 3 Changed 4 years ago by rovers

Replying to gbooker:

Replying to rovers:

Apple's AC3 importer and MP4 files assume a channel layout as in the AC3 specs.

WRONG! The specs refer to channel order in the file format but explicitly state that they do not define the channel order between the decoder and other layers. They mention that this negotiation must be done between those components, a step which Apple has failed to accomplish.

I understand that you get tired of answering these questions and I agree that there is a difference between the order of the channels in the file format and between the output of the decoder and quicktime. I don't know which one of these a .mov file channel layout is supposed to indicate, but clearly Apple thinks it is the file format order or that they are the same. So in that sense they assume a channel layout as in the AC3 specs. I'm not saying anything about that being the right assumption.

codecs are never told the layout.

Actually, before QT X, three codec instances were created, one was told the layout, and a different one was given the task of decoding. Clearly Apple didn't know what to do with multi-channel audio.

Clearly they didn't :)

Unfortunately Perian's AC3 importer that existed before Apple's uses a different channel layout for importing, which QuickTime uses as the output layout.

Clarification: Perian's AC3 importer existed before the other layouts existed.

  • no more layout problems with Apple by giving in...

Giving in by doing the wrong thing and breaking other cases.

What other cases break?

  • works also for MP4 files, and with Apple's AC3 importer.

Until they break it again.

Disadvantages:

  • breaks previously imported .mov files.

A rather bad disadvantage. I have over a hundred of these.

Yep, that's why it's implemented as a preference switch.

  • downmixing to stereo or dolby pro logic does not work anymore, because apple thinks the layout is "Left, Center" for 2 channel outputs of multi-channel AC3-files with center channels, so downmixing is disabled and left to QuickTime (which works fine).

Actually, it doesn't work fine. Apple's downmix is a bastardized mix of DPLI and DPLII that isn't truly either.

Now for the most critical point about lack of downmix: passthrough uses the same mechanism, and nothing that breaks passthrough will be accepted.

But it doesn't break passthrough. At least not at my system.

Would make my life easier if it is included.

It would make everyone's life easier if Apple did the right thing, especially since I've provided them two different mechanisms for doing the right thing and neither break anything.

Agree! But it seems unclear if it's ever going to be fixed.

comment:3 in reply to: ↑ 2 Changed 4 years ago by gbooker

Replying to rovers:

I understand that you get tired of answering these questions and I agree that there is a difference between the order of the channels in the file format and between the output of the decoder and quicktime. I don't know which one of these a .mov file channel layout is supposed to indicate, but clearly Apple thinks it is the file format order or that they are the same. So in that sense they assume a channel layout as in the AC3 specs. I'm not saying anything about that being the right assumption.

Apple seems to believe that that the two layouts are one and the same, even though the file format one doesn't always apply. I believe this was intended for codecs which encode channels separately (like PCM which is no compression) rather than codecs which encode channels together (like AC3).

But it doesn't break passthrough. At least not at my system.

You said it broke stereo, so I assumed it would break passthrough as well since they pretty much work the same way in terms of channel layouts.

It would make everyone's life easier if Apple did the right thing, especially since I've provided them two different mechanisms for doing the right thing and neither break anything.

Agree! But it seems unclear if it's ever going to be fixed.

I seriously believe that since it doesn't affect them, then they have no reason to care. I have two tickets open on this, and they only get activity once every 6 months or so. One is to fix the layout, and the other is to provide a mechanism for CA to know the layout. They can't be bothered to do either.

Note: See TracTickets for help on using tickets.