From 3365a715a6e16a7db46a0e5b463e621237d7c40d Mon Sep 17 00:00:00 2001 From: Carlos Fernandez Date: Mon, 29 Dec 2025 21:10:11 +0100 Subject: [PATCH 1/2] fix: Properly handle ATSC CC in private MPEG-2 streams MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes two issues: 1. ATSC CC data in private MPEG-2 streams (stream type 0x06) was not being processed. The code returned CCX_PRIVATE_MPEG2_CC buffer type which was never properly implemented - it just dumped debug output and returned placeholder bytes. Fix: Treat ATSC CC in private MPEG-2 streams the same as in user-private streams (0x80-0x8F) by returning CCX_PES buffer type. Both contain the same CC data format and should use the same processing path. 2. Several dump() calls were using CCX_DMT_GENERIC_NOTICES which is enabled by default, causing binary output to flood the terminal when processing certain files. Fix: Changed to appropriate debug-only masks (CCX_DMT_VERBOSE, CCX_DMT_PARSE) so binary dumps only appear when debug mode is explicitly enabled. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/lib_ccx/avc_functions.c | 9 ++++----- src/lib_ccx/general_loop.c | 6 +----- src/lib_ccx/ts_functions.c | 18 ++++-------------- 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/src/lib_ccx/avc_functions.c b/src/lib_ccx/avc_functions.c index aa58e991d..cc195edce 100644 --- a/src/lib_ccx/avc_functions.c +++ b/src/lib_ccx/avc_functions.c @@ -379,11 +379,10 @@ void sei_rbsp(struct avc_ctx *ctx, unsigned char *seibuf, unsigned char *seiend) } else { - // TODO: This really really looks bad - mprint("WARNING: Unexpected SEI unit length...trying to continue."); - temp_debug = 1; - mprint("\n Failed block (at sei_rbsp) was:\n"); - dump(CCX_DMT_GENERIC_NOTICES, (unsigned char *)seibuf, seiend - seibuf, 0, 0); + // Unexpected SEI length - common with malformed streams, don't spam output + dbg_print(CCX_DMT_VERBOSE, "WARNING: Unexpected SEI unit length (parsed to %p, expected %p)...trying to continue.\n", + (void *)tbuf, (void *)(seiend - 1)); + dump(CCX_DMT_VERBOSE, (unsigned char *)seibuf, seiend - seibuf, 0, 0); ctx->num_unexpected_sei_length++; } diff --git a/src/lib_ccx/general_loop.c b/src/lib_ccx/general_loop.c index d82a03314..a99cfe144 100644 --- a/src/lib_ccx/general_loop.c +++ b/src/lib_ccx/general_loop.c @@ -75,7 +75,7 @@ int ps_get_more_data(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata) if (!ctx->demux_ctx->strangeheader) { mprint("\nNot a recognized header. Searching for next header.\n"); - dump(CCX_DMT_GENERIC_NOTICES, nextheader, 6, 0, 0); + dump(CCX_DMT_PARSE, nextheader, 6, 0, 0); // Only print the message once per loop / unrecognized header ctx->demux_ctx->strangeheader = 1; } @@ -809,10 +809,6 @@ int process_data(struct encoder_ctx *enc_ctx, struct lib_cc_decode *dec_ctx, str got = data_node->len; } } - else if (data_node->bufferdatatype == CCX_PRIVATE_MPEG2_CC) - { - got = data_node->len; // Do nothing. Still don't know how to process it - } else if (data_node->bufferdatatype == CCX_RAW) // Raw two byte 608 data from DVR-MS/ASF { // The asf_get_more_data() loop sets current_pts when possible diff --git a/src/lib_ccx/ts_functions.c b/src/lib_ccx/ts_functions.c index 44a199260..12702dc4c 100644 --- a/src/lib_ccx/ts_functions.c +++ b/src/lib_ccx/ts_functions.c @@ -153,12 +153,11 @@ enum ccx_bufferdata_type get_buffer_type(struct cap_info *cinfo) { return CCX_TELETEXT; } - else if (cinfo->stream == CCX_STREAM_TYPE_PRIVATE_MPEG2 && cinfo->codec == CCX_CODEC_ATSC_CC) - { - return CCX_PRIVATE_MPEG2_CC; - } - else if (cinfo->stream == CCX_STREAM_TYPE_PRIVATE_USER_MPEG2 && cinfo->codec == CCX_CODEC_ATSC_CC) + else if ((cinfo->stream == CCX_STREAM_TYPE_PRIVATE_MPEG2 || + cinfo->stream == CCX_STREAM_TYPE_PRIVATE_USER_MPEG2) && + cinfo->codec == CCX_CODEC_ATSC_CC) { + // ATSC CC can be in either private stream type - process both as PES return CCX_PES; } else @@ -567,15 +566,6 @@ int copy_capbuf_demux_data(struct ccx_demuxer *ctx, struct demuxer_data **data, if (!cinfo->capbuf || !cinfo->capbuflen) return -1; - if (ptr->bufferdatatype == CCX_PRIVATE_MPEG2_CC) - { - dump(CCX_DMT_GENERIC_NOTICES, cinfo->capbuf, cinfo->capbuflen, 0, 1); - // Bogus data, so we return something - ptr->buffer[ptr->len++] = 0xFA; - ptr->buffer[ptr->len++] = 0x80; - ptr->buffer[ptr->len++] = 0x80; - return CCX_OK; - } if (cinfo->codec == CCX_CODEC_TELETEXT) { memcpy(ptr->buffer + ptr->len, cinfo->capbuf, cinfo->capbuflen); From 25162fe40a0d8e097cebe236a8b7231db86557dd Mon Sep 17 00:00:00 2001 From: Carlos Fernandez Date: Mon, 29 Dec 2025 21:11:51 +0100 Subject: [PATCH 2/2] chore: Add build directories to .gitignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add build_*/ pattern and linux/build_scan/ to ignore various build output directories (build_ocr/, build_ocr_asan/, etc.) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index bdb5246d4..a8b4db72d 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ CVS mac/ccextractor linux/ccextractor linux/depend +linux/build_scan/ windows/x86_64-pc-windows-msvc/** windows/Debug/** windows/Debug-OCR/** @@ -28,6 +29,7 @@ windows/Debug-Full/** windows/x64/** windows/ccextractor.VC.db build/ +build_*/ #### # Python