Skip to content

[FIX] telxcc: don't close the current page when another subtitle page's header arrives - #2427

Open
x15sr71 wants to merge 1 commit into
CCExtractor:masterfrom
x15sr71:fix/teletext-other-page-closes-caption
Open

x15sr71 wants to merge 1 commit into
CCExtractor:masterfrom
x15sr71:fix/teletext-other-page-closes-caption

Conversation

@x15sr71

@x15sr71 x15sr71 commented Oct 25, 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:

RT78, on sample 72 (dcada74…e1ce):

ccextractor <sample>.mpg --autoprogram --out=ttxt --latin1 --datets

Three captions that the RT78 reference shows for several seconds come out on master as a split second. Before #2292 they were zero-length (the third only in its first half).

Caption Reference Master
"Morsomt, Dennis, å skremme vettet av folk?" 3.70 s 40 ms
"Forretningspartneren min vil ha avtalen i havn innen en uke. Greit?" 5.62 s 40 ms
"Har dere problemer, får dere hjelp av meg personlig." 4.38 s split: "Har dere problemer," lasts 20 ms, then "får dere hjelp av meg personlig." alone

Cause

This sample carries three pages with the subtitle flag set, all in parallel transmission mode: 333 (the page RT78 extracts), 777, and 444 (headers only).

#725 added a de_ctr counter to telxcc.c (1b3598b, narrowed in 1513b7c). While our page has received rows, a subtitle-flagged header from another magazine is no longer ignored. It reaches process_page(), which ends our page at that header's timestamp and starts a new buffer.

At all three captions, a magazine-7 header (7FF, 7FF, 777) arrives 20–40 ms after page 333's header: after its rows for the first two, and between them for the third, which is why it splits. Page 333's next header comes 3.74, 5.66 and 4.42 s later, with the erase bit set and no rows.

ETS 300 706 §7.2.1, also quoted in the comment above these checks, says a page "is terminated by and excludes the next page header packet having the same magazine address in parallel transmission mode". So a magazine-7 header doesn't end page 333. FFmpeg's libzvbi decoder agrees: it shows each of the three as one page, with no change at the magazine-7 headers.

Issue #699 (last lines missing from .bin output) was fixed by #725's other change, which writes the final page at end of input (rcwt_loop(), telxcc_close()). In #725's review, alexbrt noted that "the fix for the multiple lines shouldn't affect timing at all".

Builds of #725 and its parent (the first two match the platform's output for those commits):

Build RT78 output The three captions
4438e6c (#725's parent) 84f651b… (test 676) 3.70 / 5.62 / 4.38 s
fdd5b6b (#725 merged) 1928f66… (test 677) 0 ms, 0 ms, split
fdd5b6b, only telxcc.c reverted 84f651b… 3.70 / 5.62 / 4.38 s

Fix

Remove de_ctr and the three conditions that use it, so headers of other pages are ignored again, as before #725. The end-of-input flush and the multi-page logic from #665 are unchanged.

Testing

Rebased on master (2c1c1c6f, which includes #2356's multi-page rework). Master vs master + this commit, built from source on macOS (arm64), compared byte for byte:

  • RT78: the three captions last 3.74 / 5.66 / 4.42 s, as in the stream. The output now matches the reference apart from Fix 40ms gap in rolling teletext subtitles #2292's +40 ms on every end time and one extra space that master already has.
  • Every other teletext test is byte-identical: RT18, RT19, RT64–77, RT79–83 and RT234–236 (RT80, RT81 and RT83 built and run on Linux aarch64). A trace build (before the rebase) showed the removed check firing only at RT78's three captions, and never on any other sample.
  • --tpages-all: byte-identical to master on every sample above, RT78 included.
  • Several --tpage values: byte-identical to master on RT18 (888–891), RT79, RT82 and RT83 (398, 437), RT80 (299, 795), RT81 (199, 299, 591, 793, 794) and RT78 (333, 777).
  • Few lines missing from output of .bin file [sample attached] #699 is still fixed: on sample 67, extracting from the .bin gives the same 18 cues as the original file, on both master and this branch.

Notes

@x15sr71

x15sr71 commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

The Linux build and format failures aren't from this change: ubuntu-latest moved to Ubuntu 26.04, which has no libgpac-dev. They should be fixed by #2428.

@cfsmp3 cfsmp3 closed this Nov 10, 2026
@cfsmp3 cfsmp3 reopened this Nov 10, 2026

@cfsmp3 cfsmp3 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is Carlos' claude doing the first pass. Before Carlos takes a look, please address these issues.

The fix checks out. With the RT78 command on sample 72, the three captions go from 40 ms / 40 ms / split on master to 3.74 / 5.66 / 4.42 s, and "Har dere problemer, får dere hjelp av meg personlig." is one cue again. Across the 27 teletext samples we have, sample 72 is the only output that changes in default mode, and all 27 are byte-identical to master with --tpages-all.

One thing to fix: the project requires braces on every if body, and the three ifs this PR changes in process_telx_packet() don't have them:

if ((ctx->transmission_mode == TRANSMISSION_MODE_PARALLEL) && (data_unit_id != DATA_UNIT_EBU_TELETEXT_SUBTITLE))
{
	return;
}
...
	// In multi-page mode, check if this new page should be accepted
	if (!accept_this_page)
	{
		return;
	}
...
if (!accept_this_page)
{
	return;
}

@x15sr71
x15sr71 requested a review from cfsmp3 November 10, 2026 09:05

@cfsmp3 cfsmp3 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is Carlos' claude doing the first pass. Before Carlos takes a look, please address these issues.

Thanks for the braces. The branch now conflicts with master in src/lib_ccx/telxcc.c. #2356 (merged Nov 10) moved the page-start code into telx_begin_page() and added a multi-page path (telx_multi_page_header()) right before should_accept_page(). Please rebase on master.

After the rebase, please check that the change still behaves correctly with --tpages-all and with several --tpage values, since that code path is new. I'll re-run the 27 teletext samples on the rebased branch.

@x15sr71
x15sr71 force-pushed the fix/teletext-other-page-closes-caption branch from b8cde88 to b1cb672 Compare November 29, 2026 16:14
@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 10180, commit 2c1c1c6:

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

Fail on both but produce different output — behaviour moved even though the verdict did not:

  • ccextractor --autoprogram --out=ttxt --latin1 --datets dcada745de...

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

@x15sr71

x15sr71 commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I've rebased on master (2c1c1c6f). The change itself is the same; the only difference is that de_ctr = 0 now sits in telx_begin_page(), so it's removed from there.

As suggested, I checked the new multi-page path. With --tpages-all and with several --tpage values, the output is byte-identical to master on all the teletext samples:

  • --tpages-all: RT18, RT19, RT64–83 and RT234–236.
  • Several --tpage values: RT18 (888–891), RT79, RT82 and RT83 (398, 437), RT80 (299, 795), RT81 (199, 299, 591, 793, 794) and RT78 (333, 777).

On RT78 with --tpage 333 --tpage 777, page 333's three captions already come out correct (3.74 / 5.66 / 4.42 s), the same as the fix gives in single-page mode.

Please let me know if anything else needs a look.

@x15sr71
x15sr71 requested a review from cfsmp3 November 29, 2026 17:07
@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 10179, commit f56427e:

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

Fail on both but produce different output — behaviour moved even though the verdict did not:

  • ccextractor --autoprogram --out=ttxt --latin1 --datets dcada745de...

Compared with the commit this branch was cut from — test 10181, commit 2c1c1c6:

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

Fail on both but produce different output — behaviour moved even though the verdict did not:

  • ccextractor --autoprogram --out=ttxt --latin1 --datets dcada745de...

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.

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.

3 participants