Skip to content
Permalink
Browse files

[IMPROVEMENT] MXF caption frame rates (#1101)

* Decode cdp frame rates in mxf files for accurate caption timings.

* Update changelog re: MXF frame rate parsing.
  • Loading branch information...
jgreer authored and cfsmp3 committed Aug 16, 2019
1 parent e461c14 commit 2bcd993c0f9ba97fe33f5bdb43d4596b9b927fa3
Showing with 28 additions and 5 deletions.
  1. +4 −0 docs/CHANGES.TXT
  2. +24 −5 src/lib_ccx/ccx_demuxer_mxf.c
@@ -1,3 +1,7 @@
0.89 (TBD)
-----------------
- Fix: ccx_demuxer_mxf.c: Parse framerate from MXF captions to fix caption timings.

0.88 (2019-05-21)
-----------------
- New: More tapping points for debug image in ccextractor.
@@ -76,6 +76,19 @@ static const MXFCodecUL mxf_caption_essence_container[] = {
{ {0x6,0xE,0x2B,0x34,0x04,0x01,0x01,0x09,0xD,0x1,0x3,0x1,0x2,0xE,0x0,0x0}, MXF_CT_ANC },
};

static const struct ccx_rational framerate_rationals[16] = {
{0, 0},
{1001, 24000},
{1, 24},
{1, 25},
{1001, 30000},
{1, 30},
{1, 50},
{1001, 60000},
{1, 60},
{0, 0}
};

/* Only Used Tags defined in enum */
enum MXFLocalTag
{
@@ -294,10 +307,16 @@ static int mxf_read_cdp_data(struct ccx_demuxer *demux, int size, struct demuxer
log("Incomplete CDP packet\n");
goto error;
}
//skip framerate, flag and hdr_seq_cntr
buffered_skip(demux, 4);
demux->past += 4;
len += 4;

// framerate - top 4 bits are cdp_framing_rate
ret = buffered_get_byte(demux);
len++;
data->tb = framerate_rationals[ret >> 4];

//skip flag and hdr_seq_cntr
buffered_skip(demux, 3);
demux->past += 3;
len += 3;

ret = buffered_get_byte(demux);
len ++;
@@ -307,7 +326,7 @@ static int mxf_read_cdp_data(struct ccx_demuxer *demux, int size, struct demuxer
cc_count = buffered_get_byte(demux) & 0x1F;
len++;
// -4 for cdp footer length
if ( (cc_count * 3) != (size - len - 4))
if ( (cc_count * 3) > (size - len - 4))
log("Incomplete CDP packet\n");

ret = buffered_read(demux, data->buffer+data->len, cc_count*3);

0 comments on commit 2bcd993

Please sign in to comment.
You can’t perform that action at this time.