Skip to content

Commit 82daa7f

Browse files
authored
fix: Properly handle ATSC CC in private MPEG-2 streams
2 parents 26e0f64 + 25162fe commit 82daa7f

File tree

4 files changed

+11
-24
lines changed

4 files changed

+11
-24
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ CVS
1717
mac/ccextractor
1818
linux/ccextractor
1919
linux/depend
20+
linux/build_scan/
2021
windows/x86_64-pc-windows-msvc/**
2122
windows/Debug/**
2223
windows/Debug-OCR/**
@@ -28,6 +29,7 @@ windows/Debug-Full/**
2829
windows/x64/**
2930
windows/ccextractor.VC.db
3031
build/
32+
build_*/
3133

3234
####
3335
# Python

src/lib_ccx/avc_functions.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,10 @@ void sei_rbsp(struct avc_ctx *ctx, unsigned char *seibuf, unsigned char *seiend)
379379
}
380380
else
381381
{
382-
// TODO: This really really looks bad
383-
mprint("WARNING: Unexpected SEI unit length...trying to continue.");
384-
temp_debug = 1;
385-
mprint("\n Failed block (at sei_rbsp) was:\n");
386-
dump(CCX_DMT_GENERIC_NOTICES, (unsigned char *)seibuf, seiend - seibuf, 0, 0);
382+
// Unexpected SEI length - common with malformed streams, don't spam output
383+
dbg_print(CCX_DMT_VERBOSE, "WARNING: Unexpected SEI unit length (parsed to %p, expected %p)...trying to continue.\n",
384+
(void *)tbuf, (void *)(seiend - 1));
385+
dump(CCX_DMT_VERBOSE, (unsigned char *)seibuf, seiend - seibuf, 0, 0);
387386

388387
ctx->num_unexpected_sei_length++;
389388
}

src/lib_ccx/general_loop.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ int ps_get_more_data(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata)
7575
if (!ctx->demux_ctx->strangeheader)
7676
{
7777
mprint("\nNot a recognized header. Searching for next header.\n");
78-
dump(CCX_DMT_GENERIC_NOTICES, nextheader, 6, 0, 0);
78+
dump(CCX_DMT_PARSE, nextheader, 6, 0, 0);
7979
// Only print the message once per loop / unrecognized header
8080
ctx->demux_ctx->strangeheader = 1;
8181
}
@@ -809,10 +809,6 @@ int process_data(struct encoder_ctx *enc_ctx, struct lib_cc_decode *dec_ctx, str
809809
got = data_node->len;
810810
}
811811
}
812-
else if (data_node->bufferdatatype == CCX_PRIVATE_MPEG2_CC)
813-
{
814-
got = data_node->len; // Do nothing. Still don't know how to process it
815-
}
816812
else if (data_node->bufferdatatype == CCX_RAW) // Raw two byte 608 data from DVR-MS/ASF
817813
{
818814
// The asf_get_more_data() loop sets current_pts when possible

src/lib_ccx/ts_functions.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,11 @@ enum ccx_bufferdata_type get_buffer_type(struct cap_info *cinfo)
153153
{
154154
return CCX_TELETEXT;
155155
}
156-
else if (cinfo->stream == CCX_STREAM_TYPE_PRIVATE_MPEG2 && cinfo->codec == CCX_CODEC_ATSC_CC)
157-
{
158-
return CCX_PRIVATE_MPEG2_CC;
159-
}
160-
else if (cinfo->stream == CCX_STREAM_TYPE_PRIVATE_USER_MPEG2 && cinfo->codec == CCX_CODEC_ATSC_CC)
156+
else if ((cinfo->stream == CCX_STREAM_TYPE_PRIVATE_MPEG2 ||
157+
cinfo->stream == CCX_STREAM_TYPE_PRIVATE_USER_MPEG2) &&
158+
cinfo->codec == CCX_CODEC_ATSC_CC)
161159
{
160+
// ATSC CC can be in either private stream type - process both as PES
162161
return CCX_PES;
163162
}
164163
else
@@ -567,15 +566,6 @@ int copy_capbuf_demux_data(struct ccx_demuxer *ctx, struct demuxer_data **data,
567566
if (!cinfo->capbuf || !cinfo->capbuflen)
568567
return -1;
569568

570-
if (ptr->bufferdatatype == CCX_PRIVATE_MPEG2_CC)
571-
{
572-
dump(CCX_DMT_GENERIC_NOTICES, cinfo->capbuf, cinfo->capbuflen, 0, 1);
573-
// Bogus data, so we return something
574-
ptr->buffer[ptr->len++] = 0xFA;
575-
ptr->buffer[ptr->len++] = 0x80;
576-
ptr->buffer[ptr->len++] = 0x80;
577-
return CCX_OK;
578-
}
579569
if (cinfo->codec == CCX_CODEC_TELETEXT)
580570
{
581571
memcpy(ptr->buffer + ptr->len, cinfo->capbuf, cinfo->capbuflen);

0 commit comments

Comments
 (0)