ccextractor icon indicating copy to clipboard operation
ccextractor copied to clipboard

mcc encoder improperly handles cdp sequence numbers

Open programmerjake opened this issue 6 months ago • 5 comments

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.

programmerjake avatar Jul 09 '25 01:07 programmerjake

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 avatar Jul 29 '25 07:07 Ari1009

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 avatar Jul 29 '25 07:07 programmerjake

So are you working on it or waiting for approval ?

Ari1009 avatar Jul 29 '25 07:07 Ari1009

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 avatar Jul 29 '25 07:07 programmerjake

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 avatar Jul 29 '25 07:07 Ari1009