@@ -202,6 +202,13 @@ static int process_xdvb_track(struct lib_ccx_ctx *ctx, const char *basename, GF_
202202
203203 dec_ctx = update_decoder_list (ctx );
204204 enc_ctx = update_encoder_list (ctx );
205+
206+ // Set buffer data type to CCX_PES for MP4/MOV MPEG-2 tracks.
207+ // This ensures cb_field counters are not incremented in do_cb(),
208+ // which is correct because container formats associate captions
209+ // with the frame's PTS directly.
210+ dec_ctx -> in_bufferdatatype = CCX_PES ;
211+
205212 if ((sample_count = gf_isom_get_sample_count (f , track )) < 1 )
206213 {
207214 return 0 ;
@@ -249,6 +256,12 @@ static int process_avc_track(struct lib_ccx_ctx *ctx, const char *basename, GF_I
249256
250257 dec_ctx = update_decoder_list (ctx );
251258
259+ // Set buffer data type to CCX_H264 for MP4/MOV AVC tracks.
260+ // This ensures cb_field counters are not incremented in do_cb(),
261+ // which is correct because container formats associate captions
262+ // with the frame's PTS directly.
263+ dec_ctx -> in_bufferdatatype = CCX_H264 ;
264+
252265 if ((sample_count = gf_isom_get_sample_count (f , track )) < 1 )
253266 {
254267 return 0 ;
@@ -326,6 +339,12 @@ static int process_hevc_track(struct lib_ccx_ctx *ctx, const char *basename, GF_
326339 // Enable HEVC mode
327340 dec_ctx -> avc_ctx -> is_hevc = 1 ;
328341
342+ // Set buffer data type to CCX_H264 for MP4/MOV HEVC tracks.
343+ // This ensures cb_field counters are not incremented in do_cb(),
344+ // which is correct because container formats associate captions
345+ // with the frame's PTS directly.
346+ dec_ctx -> in_bufferdatatype = CCX_H264 ;
347+
329348 if ((sample_count = gf_isom_get_sample_count (f , track )) < 1 )
330349 {
331350 return 0 ;
0 commit comments