Skip to content

Commit a2d2c4f

Browse files
authored
Merge branch 'master' into release/0.96.4
2 parents 4ab6c83 + e66a018 commit a2d2c4f

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

docs/CHANGES.TXT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Fix: Prevent heap buffer overflow in Teletext processing (security fix)
99
- Fix: Lazy OCR initialization - only initialize when first DVB subtitle is encountered
1010
- Build: Optimized Windows CI workflow for faster builds
11+
- Fix: Updated GUI with version 0.7.1. A blind attempt to fix a hang on start on some Windows.
1112

1213
0.96.3 (2025-12-29)
1314
-------------------

src/lib_ccx/dvb_subtitle_decoder.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ typedef struct DVBSubContext
182182
LLONG time_out;
183183
#ifdef ENABLE_OCR
184184
void *ocr_ctx;
185+
int ocr_initialized; // Flag to track if OCR has been lazily initialized
185186
#endif
186187
DVBSubRegion *region_list;
187188
DVBSubCLUT *clut_list;
@@ -442,7 +443,11 @@ void *dvbsub_init_decoder(struct dvb_config *cfg)
442443
}
443444

444445
#ifdef ENABLE_OCR
445-
ctx->ocr_ctx = init_ocr(ctx->lang_index);
446+
// Lazy OCR initialization: don't init here, wait until a bitmap actually needs OCR
447+
// This avoids ~10 second Tesseract startup overhead for files that have DVB streams
448+
// but don't actually produce any bitmap subtitles (e.g., files with CEA-608 captions)
449+
ctx->ocr_ctx = NULL;
450+
ctx->ocr_initialized = 0;
446451
#endif
447452
ctx->version = -1;
448453

@@ -1701,6 +1706,12 @@ static int write_dvb_sub(struct lib_cc_decode *dec_ctx, struct cc_subtitle *sub)
17011706
// Perform OCR
17021707
#ifdef ENABLE_OCR
17031708
char *ocr_str = NULL;
1709+
// Lazy OCR initialization: only init when we actually have a bitmap to process
1710+
if (!ctx->ocr_initialized)
1711+
{
1712+
ctx->ocr_ctx = init_ocr(ctx->lang_index);
1713+
ctx->ocr_initialized = 1; // Mark as initialized even if init_ocr returns NULL
1714+
}
17041715
if (ctx->ocr_ctx)
17051716
{
17061717
int ret = ocr_rect(ctx->ocr_ctx, rect, &ocr_str, region->bgcolor, dec_ctx->ocr_quantmode);

src/lib_ccx/ts_functions.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "dvb_subtitle_decoder.h"
77
#include "ccx_decoders_isdb.h"
88
#include "file_buffer.h"
9+
#include <inttypes.h>
910

1011
#ifdef DEBUG_SAVE_TS_PACKETS
1112
#include <sys/types.h>
@@ -568,6 +569,13 @@ int copy_capbuf_demux_data(struct ccx_demuxer *ctx, struct demuxer_data **data,
568569

569570
if (cinfo->codec == CCX_CODEC_TELETEXT)
570571
{
572+
if (cinfo->capbuflen > BUFSIZE - ptr->len)
573+
{
574+
fatal(CCX_COMMON_EXIT_BUG_BUG,
575+
"Teletext packet (%" PRId64 ") larger than remaining buffer (%" PRId64 ").\n",
576+
cinfo->capbuflen, (int64_t)(BUFSIZE - ptr->len));
577+
}
578+
571579
memcpy(ptr->buffer + ptr->len, cinfo->capbuf, cinfo->capbuflen);
572580
ptr->len += cinfo->capbuflen;
573581
return CCX_OK;

src/rust/lib_ccxr/src/common/constants.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,11 @@ pub const CCX_DECODER_608_SCREEN_WIDTH: usize = 32;
147147
pub const ONEPASS: usize = 120; // Bytes we can always look ahead without going out of limits
148148
pub const BUFSIZE: usize = 2048 * 1024 + ONEPASS; // 2 Mb plus the safety pass
149149
pub const MAX_CLOSED_CAPTION_DATA_PER_PICTURE: usize = 32;
150-
pub const EIA_708_BUFFER_LENGTH: usize = 2048; // TODO: Find out what the real limit is
150+
/// CEA-708 Service Input Buffer size.
151+
/// Specification minimum is 128 bytes per service, but we use 2048 bytes
152+
/// (16x the minimum) to provide a safety margin for buffer management.
153+
/// Reference: CEA-708-E Section 8.4.3 - Service Input Buffers
154+
pub const EIA_708_BUFFER_LENGTH: usize = 2048;
151155
pub const TS_PACKET_PAYLOAD_LENGTH: usize = 184; // From specs
152156
pub const SUBLINESIZE: usize = 2048; // Max. length of a .srt line - TODO: Get rid of this
153157
pub const STARTBYTESLENGTH: usize = 1024 * 1024;

src/rust/lib_ccxr/src/net/target.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ impl<'a> SendTarget<'a> {
8282
"Unable to connect, address passed is null\n"
8383
);
8484
}
85-
info!("Target address: {}\n", config.target_addr); // TODO remove this
8685
info!("Target port: {}\n", config.port.unwrap_or(DEFAULT_TCP_PORT));
8786
let tcp_stream = TcpStream::connect((
8887
config.target_addr,

0 commit comments

Comments
 (0)