mcc encoder improperly handles cdp sequence numbers #834

Closed
opened 2026-01-29 16:54:41 +00:00 by claunia · 5 comments
Owner

Originally created by @programmerjake on GitHub (Jul 9, 2025).

the mcc encoder currently tries to use 8 bits split across two bytes, which is incorrect. the correct way to handle it is to use a 16-bit counter:
81fdecd5af/src/lib_ccx/ccx_encoders_mcc.c (L326-L334)

according to the specification: https://pub.smpte.org/latest/st334-2/st0334-2-2015.pdf

cdp_hdr_sequence_cntr – This is an unsigned 16-bit integer which shall be set to a value of 1 plus the value
of cdp_hdr_sequence_cntr in the previous CDP. The value of this counter shall wrap from 65535 to 0. For the
first CDP in a sequence of CDPs, cdp_hdr_sequence_cntr may be set to any 16-bit value.

Originally created by @programmerjake on GitHub (Jul 9, 2025). the mcc encoder currently tries to use 8 bits split across two bytes, which is incorrect. the correct way to handle it is to use a 16-bit counter: https://github.com/CCExtractor/ccextractor/blob/81fdecd5af683ff25b953339fdb0d84e141d60c1/src/lib_ccx/ccx_encoders_mcc.c#L326-L334 according to the specification: https://pub.smpte.org/latest/st334-2/st0334-2-2015.pdf > __cdp_hdr_sequence_cntr__ – This is an unsigned 16-bit integer which shall be set to a value of 1 plus the value of cdp_hdr_sequence_cntr in the previous CDP. The value of this counter shall wrap from 65535 to 0. For the first CDP in a sequence of CDPs, cdp_hdr_sequence_cntr may be set to any 16-bit value.
Author
Owner

@Ari1009 commented on GitHub (Jul 29, 2025):

It should be like this right ?

buff_ptr[8]  = (uint8)((ctx->cdp_hdr_seq >> 8) & 0xFF);
buff_ptr[9]  = (uint8)(ctx->cdp_hdr_seq & 0xFF);

...

data_ptr[1] = (uint8)((ctx->cdp_hdr_seq >> 8) & 0xFF);
data_ptr[2] = (uint8)(ctx->cdp_hdr_seq & 0xFF);
@Ari1009 commented on GitHub (Jul 29, 2025): It should be like this right ? ``` buff_ptr[8] = (uint8)((ctx->cdp_hdr_seq >> 8) & 0xFF); buff_ptr[9] = (uint8)(ctx->cdp_hdr_seq & 0xFF); ... data_ptr[1] = (uint8)((ctx->cdp_hdr_seq >> 8) & 0xFF); data_ptr[2] = (uint8)(ctx->cdp_hdr_seq & 0xFF); ```
Author
Owner

@programmerjake commented on GitHub (Jul 29, 2025):

It should be like this right ?

buff_ptr[8]  = (uint8)((ctx->cdp_hdr_seq >> 8) & 0xFF);
buff_ptr[9]  = (uint8)(ctx->cdp_hdr_seq & 0xFF);

...

data_ptr[1] = (uint8)((ctx->cdp_hdr_seq >> 8) & 0xFF);
data_ptr[2] = (uint8)(ctx->cdp_hdr_seq & 0xFF);

yes, that looks right.

@programmerjake commented on GitHub (Jul 29, 2025): > It should be like this right ? > > ``` > buff_ptr[8] = (uint8)((ctx->cdp_hdr_seq >> 8) & 0xFF); > buff_ptr[9] = (uint8)(ctx->cdp_hdr_seq & 0xFF); > > ... > > data_ptr[1] = (uint8)((ctx->cdp_hdr_seq >> 8) & 0xFF); > data_ptr[2] = (uint8)(ctx->cdp_hdr_seq & 0xFF); > ``` yes, that looks right.
Author
Owner

@Ari1009 commented on GitHub (Jul 29, 2025):

So are you working on it or waiting for approval ?

@Ari1009 commented on GitHub (Jul 29, 2025): So are you working on it or waiting for approval ?
Author
Owner

@programmerjake commented on GitHub (Jul 29, 2025):

So are you working on it or waiting for approval ?

no, I noticed it while working on the new mcc muxer in ffmpeg and looking at what other projects did. feel free to change it if you like, I most likely won't be creating a PR to change it.

@programmerjake commented on GitHub (Jul 29, 2025): > So are you working on it or waiting for approval ? no, I noticed it while working on the [new mcc muxer in ffmpeg](https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20024) and looking at what other projects did. feel free to change it if you like, I most likely won't be creating a PR to change it.
Author
Owner

@Ari1009 commented on GitHub (Jul 29, 2025):

So are you working on it or waiting for approval ?

no, I noticed it while working on the new mcc muxer in ffmpeg and looking at what other projects did. feel free to change it if you like, I most likely won't be creating a PR to change it.

Oh alright then i will raise a PR for it, Thnx

@Ari1009 commented on GitHub (Jul 29, 2025): > > So are you working on it or waiting for approval ? > > no, I noticed it while working on the [new mcc muxer in ffmpeg](https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20024) and looking at what other projects did. feel free to change it if you like, I most likely won't be creating a PR to change it. Oh alright then i will raise a PR for it, Thnx
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#834