Skip to content

[FIX] Report mode: parse H.264 captions instead of skipping them - #2504

Open
cfsmp3 wants to merge 1 commit into
masterfrom
fix/report-avc-608
Open

cfsmp3 wants to merge 1 commit into
masterfrom
fix/report-avc-608

Conversation

@cfsmp3

@cfsmp3 cfsmp3 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

In raising this pull request, I confirm the following (please check boxes):

Reason for this PR:

  • This PR adds new functionality.
  • This PR fixes a bug that I have personally experienced or that a real user has reported and for which a sample exists.
  • This PR is porting code from C to Rust.

Sanity check:

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • If the PR adds new functionality, I've added it to the changelog. If it's just a bug fix, I have NOT added it to the changelog.
  • I am NOT adding new C code unless it's to fix an existing, reproducible bug.

Repro instructions:

ccextractor 7236304c….ts --out=report

On master:

PID: 256, Program: 1, H.264 video
...
EIA-608: No
CEA-708: No

The same file extracts 30 608 captions, plus 708 service 1.

Problem

--out=report creates no encoder, so ccxr_process_avc() gets enc_ctx = NULL. Since fecd24d (#2023) it returns early in that case. That avoided a NULL dereference, but it also skips all H.264/HEVC parsing. The report's 608/708 lines come from what the decoder saw, so every H.264 file reports "No".

Fix

The encoder was really used in only one place: enc_ctx.timing in ccxr_set_fts(). Every caller sets enc_ctx->timing = dec_ctx->timing before process_data() (general_loop.c 1257, 1542), and the original C code used dec_ctx->timing, so this uses that. Everywhere else enc_ctx is only forwarded to C (store_hdcc(), process_hdcc()), which accepts NULL. It is now kept as a raw pointer, and the early return is removed.

This is the same pattern as #2502 (MPEG-2 ES path). The two PRs touch different files.

Verification

  • Test first: avc::tests::test_null_enc_ctx_still_parses feeds an SPS with a NULL enc_ctx and checks got_seq_para. It fails on master (0) and passes with the fix. The full cargo test passes, as does cargo clippy -- -D warnings.

  • Report sweep over 52 local samples (.ts, .mpg, .vob, .wtv, .dvr-ms, .mp4, .mov): 47 reports are byte-identical. The other 5 are exactly the H.264 ones. They change from EIA-608: No / CEA-708: No to Yes, with CC1 and service 1 detail, and each has 608 captions in an SRT extraction:

    Sample 608 cues
    31a4ca6a 137
    5c70576b 37
    7236304c 30
    8e8229b8 25
    c4dd893c 1
  • SRT/708 outputs: all 93 files from the same 52 samples are byte-identical to master.

  • ASan: report mode on 3 of those H.264 files shows no errors, and the leaks are the same as master's (612/613 bytes).

  • HEVC goes through the same function. I had no local HEVC sample with captions to check it with.

--out=report creates no encoder, so ccxr_process_avc() gets a NULL
enc_ctx. Since fecd24d it returned early in that case, which avoided
a NULL dereference but also skipped all H.264 parsing. The report
then said "EIA-608: No" / "CEA-708: No" for every H.264 file, even
when it has captions.

The only real use of the encoder was enc_ctx.timing in ccxr_set_fts().
Every caller sets enc_ctx->timing = dec_ctx->timing before
process_data(), and the C code this was ported from used
dec_ctx->timing, so use that. Everything else just forwards enc_ctx to
C (store_hdcc, process_hdcc), which accepts NULL; keep it a raw
pointer and drop the early return.
@ccextractor-bot

Copy link
Copy Markdown
Collaborator
CCExtractor CI platform finished running the test files on windows. 171/238 tests matched the approved output:
Report Name Tests Passed
Broken 9/13
CEA-708 2/14
DVB 0/7
DVD 3/3
DVR-MS 2/2
General 26/28
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 68/86
Teletext 0/21
WTV 12/13
XDS 32/34

67 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 10181, commit 2c1c1c6:

  • 0 pass there and fail here
  • 0 fail there and pass here
  • 0 fail on both, with different output
  • 67 fail on both, byte for byte the same

Compared with the commit this branch was cut from: the same run as the tip of master (test 10181), 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-bot

Copy link
Copy Markdown
Collaborator
CCExtractor CI platform finished running the test files on linux. 171/238 tests matched the approved output:
Report Name Tests Passed
Broken 9/13
CEA-708 2/14
DVB 0/7
DVD 3/3
DVR-MS 2/2
General 26/28
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 68/86
Teletext 0/21
WTV 12/13
XDS 32/34

67 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 10178, commit f56427e:

  • 0 pass there and fail here
  • 0 fail there and pass here
  • 0 fail on both, with different output
  • 67 fail on both, byte for byte the same

Compared with the commit this branch was cut from: the same run as the tip of master (test 10178), 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants