diff --git a/crates/ec-ac3/src/decoder.rs b/crates/ec-ac3/src/decoder.rs index fa56bfdc..3bcf5aef 100644 --- a/crates/ec-ac3/src/decoder.rs +++ b/crates/ec-ac3/src/decoder.rs @@ -398,7 +398,17 @@ impl Ac3Decoder { /// The layout of a frame whose channels sit at `positions` (canonical order). fn layout(&self, positions: &[ChannelPosition]) -> ChannelLayout { match self.options.downmix { - Downmix::Native => layout_of(positions), + Downmix::Native => match positions { + [ChannelPosition::FrontCenter] => ChannelLayout::Mono, + [ChannelPosition::FrontLeft, ChannelPosition::FrontRight] => ChannelLayout::Stereo, + _ if positions == ChannelLayout::Surround5_1.positions() => { + ChannelLayout::Surround5_1 + } + _ if positions == ChannelLayout::Surround7_1.positions() => { + ChannelLayout::Surround7_1 + } + _ => ChannelLayout::Custom(positions.to_vec()), + }, Downmix::Stereo => ChannelLayout::Stereo, Downmix::Mono => ChannelLayout::Mono, } @@ -513,18 +523,6 @@ impl Decoder for Ac3Decoder { } } -/// The layout of canonically ordered `positions`: the named layouts where they -/// match, a custom one otherwise. -fn layout_of(positions: &[ChannelPosition]) -> ChannelLayout { - match positions { - [ChannelPosition::FrontCenter] => ChannelLayout::Mono, - [ChannelPosition::FrontLeft, ChannelPosition::FrontRight] => ChannelLayout::Stereo, - _ if positions == ChannelLayout::Surround5_1.positions() => ChannelLayout::Surround5_1, - _ if positions == ChannelLayout::Surround7_1.positions() => ChannelLayout::Surround7_1, - _ => ChannelLayout::Custom(positions.to_vec()), - } -} - /// One syncframe as decoded: its interleaved samples in the requested layout, /// the header summary, and the bytes its independent and dependent substreams /// took.