From 8f8e41c44385989a28cf7257eb61e72fc1f9cffe Mon Sep 17 00:00:00 2001 From: Carlos Fernandez Date: Sat, 17 Oct 2026 20:34:42 -0700 Subject: [PATCH] Fix zero timestamps for GXF/MXF ancillary captions GXF and MXF hand caption data to process_data() as CCX_RAW_TYPE buffers with no video frames to anchor the timing. The caller has already run set_current_pts() for each packet, which sets pts_set to 1, and set_fts() only reaches MinPtsSet after seeing a video frame type, so the CCX_RAW_TYPE branch's "pts_set == 0" check never fired and min_pts was never established. fts stayed at 0, every GXF ancillary cue had zero length and SRT output was empty; MXF's first cues were stamped 0 until timing was set some seconds in. Establish min_pts in that branch whenever MinPtsSet hasn't been reached, and take it from timing->current_pts, which the caller has already rescaled to 90 kHz (data_node->pts is in GXF frame units). --- src/lib_ccx/general_loop.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lib_ccx/general_loop.c b/src/lib_ccx/general_loop.c index 0157098cf..1b9a4af0d 100644 --- a/src/lib_ccx/general_loop.c +++ b/src/lib_ccx/general_loop.c @@ -987,12 +987,15 @@ int process_data(struct encoder_ctx *enc_ctx, struct lib_cc_decode *dec_ctx, str // CCX_RAW_TYPE contains cc_data triplets (cc_type + 2 data bytes each) // Used by MXF and GXF demuxers - // Initialize timing if not set (use caption PTS as reference) - if (dec_ctx->timing->pts_set == 0 && data_node->pts != CCX_NOPTS) + // Use the first caption PTS as the timing reference. The caller has + // already passed it to set_current_pts() (in 90 kHz units), which sets + // pts_set to 1; with no video frames set_fts() never reaches MinPtsSet + // on its own, so check for that rather than for pts_set == 0. + if (dec_ctx->timing->pts_set != 2 && data_node->pts != CCX_NOPTS) { - dec_ctx->timing->min_pts = data_node->pts; + dec_ctx->timing->min_pts = dec_ctx->timing->current_pts; dec_ctx->timing->pts_set = 2; // MinPtsSet - dec_ctx->timing->sync_pts = data_node->pts; + dec_ctx->timing->sync_pts = dec_ctx->timing->current_pts; set_fts(dec_ctx->timing); }