From fbcc8059678eb2c8aa6bc4e451932735abb28fad Mon Sep 17 00:00:00 2001 From: Carlos Fernandez Date: Sat, 17 Oct 2026 20:36:16 -0700 Subject: [PATCH] Document why store_hdcc overwrites the slot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The comments around the reset in store_hdcc() say it was "changed to concat" with a TODO, next to a commented-out stream_mode guard, which reads as if the unconditional reset were a bug (issue #2350, PR #2351). It is load-bearing. On a real ATSC MPEG-2 stream each picture carries its 608 pairs twice, as SCTE-20 user data followed by GA94: every same-slot store_hdcc() call in that file overwrites a block whose 608 pairs are identical to the GA94 block's. Appending instead duplicates every character ("♪ S Standtandining g" for "♪ Standing"). None of the other 40 local 608/708 samples ever stores twice into one slot. Replace the stale comments with the reason and drop the dead stream_mode lines. No code change. --- src/lib_ccx/sequencing.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lib_ccx/sequencing.c b/src/lib_ccx/sequencing.c index d064dbf1b..f569cb1fb 100644 --- a/src/lib_ccx/sequencing.c +++ b/src/lib_ccx/sequencing.c @@ -22,7 +22,6 @@ void init_hdcc(struct lib_cc_decode *ctx) // Buffer caption blocks for later sorting/flushing. void store_hdcc(struct encoder_ctx *enc_ctx, struct lib_cc_decode *dec_ctx, unsigned char *cc_data, int cc_count, int sequence_number, LLONG current_fts_now, struct cc_subtitle *sub) { - // stream_mode = dec_ctx->demux_ctx->get_stream_mode(dec_ctx->demux_ctx); // Uninitialized? if (dec_ctx->anchor_seq_number < 0) { @@ -54,9 +53,6 @@ void store_hdcc(struct encoder_ctx *enc_ctx, struct lib_cc_decode *dec_ctx, unsi { if (cc_data) { - // Changed by CFS to concat, i.e. don't assume there's no data already for this seq_index. - // Needed at least for MP4 samples. // TODO: make sure we don't overflow - // if (stream_mode!=CCX_SM_MP4) // CFS: Very ugly hack, but looks like overwriting is needed for at least some ES if (dec_ctx->cc_data_count[seq_index] > 0) { // Flush buffered cc blocks before storing new ones if fts has changed @@ -66,6 +62,9 @@ void store_hdcc(struct encoder_ctx *enc_ctx, struct lib_cc_decode *dec_ctx, unsi } } dec_ctx->cc_fts[seq_index] = current_fts_now; // CFS: Maybe do even if there's no data? + // Overwrite, don't append: a picture can carry the same 608 data + // twice, e.g. as SCTE-20 followed by GA94 user data. Appending + // would duplicate every caption character. dec_ctx->cc_data_count[seq_index] = 0; memcpy(dec_ctx->cc_data_pkts[seq_index] + dec_ctx->cc_data_count[seq_index] * 3, cc_data, cc_count * 3 + 1); }