forge
Explore
Log in

Don't you dare go Hollow

S11: ac3 merge layout_of into layout (one place maps positions to ChannelLayout)

Browse files at this commit

e47879364dd5606d536a1a7388b338a62576c94cAhmet Kaan GümüşParent: c42e165
crates/ec-ac3/src/decoder.rsmodified+11 -13
@@ -398,7 +398,17 @@ impl Ac3Decoder {
398 /// The layout of a frame whose channels sit at `positions` (canonical order).398 /// The layout of a frame whose channels sit at `positions` (canonical order).
399 fn layout(&self, positions: &[ChannelPosition]) -> ChannelLayout {399 fn layout(&self, positions: &[ChannelPosition]) -> ChannelLayout {
400 match self.options.downmix {400 match self.options.downmix {
401- Downmix::Native => layout_of(positions),401+ Downmix::Native => match positions {
402+ [ChannelPosition::FrontCenter] => ChannelLayout::Mono,
403+ [ChannelPosition::FrontLeft, ChannelPosition::FrontRight] => ChannelLayout::Stereo,
404+ _ if positions == ChannelLayout::Surround5_1.positions() => {
405+ ChannelLayout::Surround5_1
406+ }
407+ _ if positions == ChannelLayout::Surround7_1.positions() => {
408+ ChannelLayout::Surround7_1
409+ }
410+ _ => ChannelLayout::Custom(positions.to_vec()),
411+ },
402 Downmix::Stereo => ChannelLayout::Stereo,412 Downmix::Stereo => ChannelLayout::Stereo,
403 Downmix::Mono => ChannelLayout::Mono,413 Downmix::Mono => ChannelLayout::Mono,
404 }414 }
@@ -513,18 +523,6 @@ impl Decoder for Ac3Decoder {
513 }523 }
514 }524 }
515 525
516-/// The layout of canonically ordered `positions`: the named layouts where they
517-/// match, a custom one otherwise.
518-fn layout_of(positions: &[ChannelPosition]) -> ChannelLayout {
519- match positions {
520- [ChannelPosition::FrontCenter] => ChannelLayout::Mono,
521- [ChannelPosition::FrontLeft, ChannelPosition::FrontRight] => ChannelLayout::Stereo,
522- _ if positions == ChannelLayout::Surround5_1.positions() => ChannelLayout::Surround5_1,
523- _ if positions == ChannelLayout::Surround7_1.positions() => ChannelLayout::Surround7_1,
524- _ => ChannelLayout::Custom(positions.to_vec()),
525- }
526-}
527-
528 /// One syncframe as decoded: its interleaved samples in the requested layout,526 /// One syncframe as decoded: its interleaved samples in the requested layout,
529 /// the header summary, and the bytes its independent and dependent substreams527 /// the header summary, and the bytes its independent and dependent substreams
530 /// took.528 /// took.