[CLEANUP]: Remove redundant es_functions.c C code superseded by the Rust ES port - #2327
[CLEANUP]: Remove redundant es_functions.c C code superseded by the Rust ES port#2327x15sr71 wants to merge 1 commit into
Conversation
CCExtractor CI platform finished running the test files on linux. 167/237 tests matched the approved output:
70 tests do not match the approved output. That is the pass/fail verdict. Whether this branch caused it is a separate question, answered below.
Compared with the tip of master — test 9499, commit 3af3fc2:
Compared with the commit this branch was cut from: the same run as the tip of master (test 9499), so the comparison above already covers it. No test changes behaviour relative to the tip of master: every failure above fails there too, byte for byte. The approved output for those tests is out of date, which is a baseline to review rather than a regression in this branch. |
CCExtractor CI platform finished running the test files on windows. 167/237 tests matched the approved output:
70 tests do not match the approved output. That is the pass/fail verdict. Whether this branch caused it is a separate question, answered below.
Compared with the tip of master — test 9495, commit 3af3fc2:
Pass there, fail here:
Compared with the commit this branch was cut from: the same run as the tip of master (test 9495), so the comparison above already covers it. This branch changes the behaviour of 1 test(s) relative to the tip of master. Those are the ones worth looking at; anything else in the list fails the same way on both sides. |
In raising this pull request, I confirm the following (please check boxes):
Reason for this PR:
Sanity check:
Note — this is a verification, not a bug repro (this PR removes dead code, there's no bug to reproduce): it verifies the deletion is behavior-preserving by running the sample through the exact functions this PR touches (
process_m2v → es_video_sequence → delegates) and confirming baseline vs branch output is byte-identical.Verification
Sample: (the filename 725a49f871dc5a2 ~19 MB MPEG-2 program stream, NTSC line-21 EIA-608). Such streams route
CCX_PES → process_m2v → es_video_sequence → delegates → Rust(general_loop.c:892), exercising exactly the functions this PR touches.Deadness itself is proven statically (every deleted statement sits after an unconditional
return ccxr_…(), unreachable by C semantics). The steps below are corroboration: they confirm the sample actually drives the touched path, and that deleting the unreachable code is behavior-preserving.Expected: step 1 prints a large count (8,722 in my run — the ES path is heavily used); step 2 prints
srt: identical,ttxt: identical,sami: identical.What this removes
return ccxr_…()that forwards to the Rust implementation; every statement after it is unreachable. This PR reduces each to that single delegating line.sequence_header,sequence_ext,gop_header,pic_header,pic_coding_ext,extension_and_user_data— plus their forward declarations.So the deleted code is unreachable in two forms: each of the 7 delegate bodies sits after an unconditional
return ccxr_…(), and the 6 helpers are called only from those dead bodies.What is kept (all live, untouched)
process_m2v— the entry point (real C body: bitstream init + dispatch).es_video_sequence— the C state-machine dispatcher reached fromprocess_m2v. It calls only the delegates, never the helpers.What made this code redundant
The MPEG-2 elementary-stream parser was ported to Rust across two merged PRs:
demuxerandfile_functionsmodule #1662 — [FEAT] addeddemuxerandfile_functionsmodule. Added theexterndeclarations for the ESccxr_*functions and converted the 7 C entry points into thin delegates by prependingreturn ccxr_…(). This is what rendered the original C parser bodies unreachable.src/rust/src/es/) that those delegates now call.The old C parser bodies and helpers were left in place as unreachable reference code. The compiler can't flag them (
-Wunused-function) because the helpers are still statically referenced from the dead bodies — which is why this survived the earlier cleanup pass (#1738).What runs in its place today
The live runtime path is unchanged by this PR:
The delegates forward via FFI to the Rust ES module at
src/rust/src/es/mod.rs. The deleted C helpers correspond directly to Rust functions that already do the work:sequence_header,sequence_extread_seq_infoccxr_read_seq_info(es/mod.rs:37,es/seq.rs)gop_headerread_gop_infoccxr_read_gop_info(es/mod.rs:53,es/gop.rs)pic_header,pic_coding_extread_pic_infoccxr_read_pic_info(es/mod.rs:67,es/pic.rs)extension_and_user_dataread_eau_infoccxr_read_eau_info(es/mod.rs:81)next_start_code/search_start_codeccxr_next_start_code(es/mod.rs:19) /ccxr_search_start_code(es/mod.rs:28)read_pic_dataccxr_read_pic_data(es/mod.rs:98)The C→Rust behavioral equivalence for these functions was established and tested by #1662/#1736 when the port landed; this PR neither relies on nor changes it, since the deleted C wasn't executing in either case.
Why the removed code is never run, in any condition
1. Static / language-level (input-independent certainty).
return ccxr_…()— unreachable by C semantics. No input, CLI flag, mode, or build configuration can reach it.#if 0block inside a removed helper body.&sequence_headeretc. across the tree — zero address-of any helper. All calls were direct, and all were in the dead bodies..c/.h) and Rust (src/rust/) finds zero live references to the 6 helpers. The only mention outside the deleted code is one comment ingeneral_loop.c.es_functions.c.o).2. Empirical (executed the exact path we touched).
Built a baseline binary (master) and a branch binary (this PR), and ran both on an MPEG-2 program-stream sample carrying NTSC line-21 (EIA-608) captions — which route
CCX_PES → process_m2v → es_video_sequence → delegates → Rust(general_loop.c:892). Confirmed via--debugthat this sample driveses_video_sequence8,722 times.--debugexecution trace--out=srt--out=ttxt--out=samiIdentical execution traces prove the runtime path through the delegates→Rust is unchanged; identical output confirms no functional regression.