edith_codecs
Clone
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
Lane ac3shimtail: multi-syncframe packets in the AC-3 shim
Branch lane/ac3shimtail, base 8fb9fb6c (main).
Goal
cargo test --release in shims/oxideav-ac3 failed
edith_surface::the_replicas_open_path_lands_on_audible_pcm with
"a second syncframe in the tail of the packet". Find the root cause, and make
multi-syncframe packets decode if that is the right fix.
Root cause
Both halves were involved, and the test is where the packet came from.
- The test (
shims/oxideav-ac3/tests/edith_surface.rs, the "second frame" step) passesdata[size..]as one packet. That is the whole rest of the fixture, about 100 syncframes, not one frame. Its own comment says "a second frame". - The decoder refused any packet whose tail begins a syncframe
(
reject_tailincrates/ec-ac3/src/decoder.rs), by design: "one packet is one syncframe". - edith does not send multi-frame packets. It calls
ec_ac3::Ac3Decoder::decode_frameonce per MKV block or MP4 sample (crates/engine/src/audio.rs,run_ac3andrun_mkv_ac3), so one syncframe per packet is its real shape. The failing packet came from this test only.
Changes
crates/ec-ac3/src/decoder.rs- New
Ac3Decoder::decode_packet: walks every syncframe in the packet against one decoder state and concatenates the interleaved PCM. Padding after the last syncframe is ignored. A following syncframe must share the first one's channel layout, or it is refused by name. An E-AC-3 independent substream withsubstreamid1 and up (another program) is refused by name. A truncated trailing syncframe isError::Corrupt, notNeedMore. Decoder::send_packetnow callsdecode_packet. The shim's registry decoder goes through this path, so it handles multi-syncframe packets.decode_framekeeps its one-syncframe contract. Existing tests pin the refusal there:decode_matrix::a_concatenated_tail_is_refused_by_name_not_dropped,dependent::a_second_independent_substream_in_the_packet_is_still_refused. edith callsdecode_framedirectly, so its behaviour is unchanged.- Refactor:
decode_syncframe(decode one frame, returns bytes consumed),audio_frame(builds theAudioFrameand updates params),begins_syncframe(the testreject_tailused, now shared).
- New
crates/ec-ac3/tests/packet_walk.rs(new, 6 tests): AC-3 5.1 and E-AC-3 5.1 packets of 2 and 3 syncframes, and E-AC-3 7.1 (independent + dependent) packets of 2 and 3, each compared bit-exact with the same frames decoded one at a time. Also padding after 3 frames, a 5.1 + stereo packet refused by name, anddecode_framestill refusing a 2-frame packet.shims/oxideav-ac3/tests/edith_surface.rs: new testa_packet_of_two_and_three_syncframes_decodes_to_its_frames(AC-3 and E-AC-3, through the registry path with the stereo fold). Thechunks_exactindecode_ac3is nowas_chunks, for clippy.shims/oxideav-ac3/src/lib.rs:chunks_exactreplaced byas_chunksins16le, the S16 readback and the round-trip test. These were clippy-D warningsfailures already on main (chunks_exact_to_as_chunks).
The existing shim test the_replicas_open_path_lands_on_audible_pcm is unchanged.
It now passes because its remainder packet is walked. I left the test body as it
was rather than narrowing it to one frame.
Verify commands and results (server, scripts/remote-run.sh ac3shimtail --host auto, host c)
Run with EC_REQUIRE_FIXTURES=1, CARGO_TARGET_DIR=~/.cache/tgt-ac3shimtail,
TMPDIR=~/.cache/tmp-ac3shimtail.
- Before the change:
cd shims/oxideav-ac3 && cargo test --release-> theedith_surfacetest FAILED with the "second syncframe" error (reproduced). cargo test --release -p ec-ac3: lib 48 passed; decode_matrix 8; dependent 7; encode_matrix 6; packet_walk 6; real_library 1. All passed, 0 failed.cd shims/oxideav-ac3 && cargo test --release: lib 3 passed; edith_surface 2 passed (the_replicas_open_path_lands_on_audible_pcmand the new packet test).cargo clippy -p ec-ac3 --all-targets -- -D warnings: clean.cd shims/oxideav-ac3 && cargo clippy --all-targets -- -D warnings: clean (exit 0). Before, it failed on 4 pre-existingchunks_exactlints.
Parity
The new tests check packet-walk output against per-frame decode bit-exact. The per-frame decoder is already held to ffmpeg by the existing matrix and real-library tests, so the multi-frame output inherits that tolerance. I did not add a new ffmpeg comparison for multi-frame packets.
Left
- edith still calls
decode_frameone sample at a time, so the decoder change does not reach edith's path. To use it, edith would switch todecode_packetorsend_packet. Edith is read-only in this lane. - E-AC-3 programs 2 and up in a packet are still refused by name, and no fixture exercises that refusal.
- Not pushed. Commit is local on
lane/ac3shimtail.