Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 47 additions & 15 deletions src/lib_ccx/ccx_demuxer_mxf.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ static int mxf_read_vanc_data(struct ccx_demuxer *demux, uint64_t size, struct d
unsigned char vanc_header[16];
uint8_t DID;
uint8_t SDID;
struct MXFContext *ctx = demux->private_data;

// uint8_t count; /* Currently unused */

if (size < 19)
Expand All @@ -378,14 +380,19 @@ static int mxf_read_vanc_data(struct ccx_demuxer *demux, uint64_t size, struct d
{
goto error;
}

SDID = buffered_get_byte(demux);
len++;
if (SDID == 0x01)
debug("Caption Type 708\n");
else if (SDID == 0x02)
debug("Caption Type 608\n");

SDID = buffered_get_byte(demux);
len++;
if (SDID == 0x01){
debug("Caption Type 708\n");
ctx->found_anc_captions = 1;
}
else if (SDID == 0x02){
debug("Caption Type 608\n");
ctx->found_anc_captions = 1;
}



cdp_size = buffered_get_byte(demux);
if (cdp_size + 19 > size)
{
Expand Down Expand Up @@ -555,6 +562,7 @@ int ccx_mxf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata)
{
int ret = 0;
struct demuxer_data *data;
struct MXFContext *mxf;

if (!*ppdata)
{
Expand All @@ -575,7 +583,15 @@ int ccx_mxf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata)
}

ret = read_packet(ctx->demux_ctx, data);

/* If MXF ANC captions were detected but no caption data was emitted yet,
avoid reporting a false "no captions found".
*/
mxf = ctx->demux_ctx->private_data;
if (ret <= 0 && mxf && mxf->found_anc_captions)
{
return 0;
}

return ret;
}

Expand All @@ -592,14 +608,30 @@ int ccx_probe_mxf(struct ccx_demuxer *ctx)
return CCX_FALSE;
}

// struct MXFContext *ccx_mxf_init(struct ccx_demuxer *demux)
// {
// struct MXFContext *ctx = NULL;

// ctx = malloc(sizeof(*ctx));
// if (!ctx)
// return NULL;

// memset(ctx, 0, sizeof(struct MXFContext));
// return ctx;
// }
struct MXFContext *ccx_mxf_init(struct ccx_demuxer *demux)
{
struct MXFContext *ctx = NULL;
struct MXFContext *ctx = NULL;

ctx = malloc(sizeof(*ctx));
if (!ctx)
return NULL;
ctx = malloc(sizeof(*ctx));
if (!ctx)
return NULL;

memset(ctx, 0, sizeof(struct MXFContext));
return ctx;
memset(ctx, 0, sizeof(struct MXFContext));

/* Track whether ANC caption packets are present */
ctx->found_anc_captions = 0;

return ctx;
}

1 change: 1 addition & 0 deletions src/lib_ccx/ccx_demuxer_mxf.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ typedef struct MXFContext
MXFTrack tracks[32];
int nb_tracks;
int cap_count;
int found_anc_captions; // Flag to indicate if ANC captions have been found
struct ccx_rational edit_rate;
} MXFContext;

Expand Down