forge
Explore
Log in

Don't you dare go Hollow

shim(ruopus): the Opus decoder seat edith consumes, over ec-opus

Browse files at this commit

88cf2a7c0fd587d22213a5fe48d3d171c206f59aAhmet Kaan GümüşParent: 7a75a9b
The last audio shim the replica's [patch.crates-io] table was missing. It
is one re-export -- `MultistreamDecoder` -- because `ec-opus`'s already
has the incumbent's signature and, more to the point, its semantics:
`with_rate(rate, streams, coupled, &mapping)` with the same layout rules
and the same panic on one the RFC forbids, and output in the *mapping's*
channel order rather than the product's.

That last one is the only decision here. Both decoders emit Vorbis order
for RFC 7845 family 1 (FL, FC, FR, BL, BR, LFE), and edith permutes it
into film order at the call site (`audio.rs:vorbis_to_film_order`), so
the shim permutes nothing: putting it here would fold every surround
track twice. The doc comment says so, since a future reader's first
instinct will be to move it.

The incumbent's feature names are declared and empty. `spectrograms` was
its FFT backend, default-on because CELT synthesis is an N/4 complex FFT
per block and the fallback decoded a 5.1 film at 0.95x realtime; the
transform behind this crate is not behind a feature at all. They are
declared regardless because a [patch.crates-io] consumer that names a
feature the patch lacks fails to *resolve*.
Cargo.lockmodified+7 -0
@@ -1143,6 +1143,13 @@ version = "0.8.53"
1143 source = "registry+https://github.com/rust-lang/crates.io-index"1143 source = "registry+https://github.com/rust-lang/crates.io-index"
1144 checksum = "47b34b781b31e5d73e9fbc8689c70551fd1ade9a19e3e28cfec8580a79290cc4"1144 checksum = "47b34b781b31e5d73e9fbc8689c70551fd1ade9a19e3e28cfec8580a79290cc4"
1145 1145
1146+[[package]]
1147+name = "ruopus"
1148+version = "0.1.2"
1149+dependencies = [
1150+ "ec-opus",
1151+]
1152+
1146 [[package]]1153 [[package]]
1147 name = "rustversion"1154 name = "rustversion"
1148 version = "1.0.23"1155 version = "1.0.23"
shims/ruopus/Cargo.tomladded+22 -0
@@ -0,0 +1,22 @@
1+[package]
2+name = "ruopus"
3+description = "Compatibility shim: the ruopus 0.1.2 surface edith consumes, served by ec-opus."
4+version = "0.1.2"
5+edition.workspace = true
6+license.workspace = true
7+authors.workspace = true
8+publish = false
9+
10+[dependencies]
11+ec-opus = { path = "../../crates/ec-opus", version = "0.1.0" }
12+
13+# The incumbent's feature names, all no-ops here. A `[patch.crates-io]` consumer
14+# that names a feature the patch lacks fails to *resolve*, so the swap needs
15+# them declared even though nothing behind them is optional in this crate:
16+# `spectrograms` bought the incumbent an FFT-backed MDCT (fifteen crates), and
17+# `ec-opus` has that path unconditionally through `ec-dsp`.
18+[features]
19+default = ["std", "spectrograms"]
20+std = []
21+spectrograms = ["std"]
22+libm = []
shims/ruopus/src/lib.rsadded+31 -0
@@ -0,0 +1,31 @@
1+//! `ruopus` as edith consumes it, over [`ec_opus`].
2+//!
3+//! A shim, not a port: it carries the incumbent's package name and version so
4+//! the swap is a `[patch.crates-io]` line, and it exposes exactly the one item
5+//! the replica names — [`MultistreamDecoder`], built with `with_rate` and fed
6+//! one packet at a time with `decode_packet` (`audio.rs:1575`, `1694`;
7+//! `export.rs:1950`, the fidelity gate's own decoder).
8+//!
9+//! A re-export is the whole adapter, and that is a claim about two things
10+//! rather than about the names:
11+//!
12+//! * **Layout arguments.** `with_rate(rate, streams, coupled, &mapping)` means
13+//! the same thing in both: the first `coupled` elementary streams are stereo,
14+//! `mapping[c]` names the decoded channel output channel `c` reads (255 =
15+//! silent), and an impossible layout panics rather than returning — which is
16+//! why the replica checks the `OpusHead` it read from a file before it gets
17+//! here (`audio.rs:opus_layout`).
18+//! * **Channel order.** Both decoders emit the *mapping's* order, which for RFC
19+//! 7845 family 1 is Vorbis order (FL, FC, FR, BL, BR, LFE for 5.1) and not
20+//! the product's FL/FR/FC/LFE/BL/BR. The permutation stays where the
21+//! incumbent's behaviour already put it, at the call site
22+//! (`audio.rs:vorbis_to_film_order`); a shim that permuted here would fold
23+//! surround twice.
24+//!
25+//! Errors differ in type and not in use: `ec_core::Error` where the incumbent
26+//! had `PacketError`, both `Display` and both consumed as `{e}` or as a
27+//! refused packet.
28+
29+#![forbid(unsafe_code)]
30+
31+pub use ec_opus::MultistreamDecoder;