mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-07-08 18:06:30 +00:00
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/CCExtractor/ccextractor/pull/1830
Author: @cfsmp3
Created: 12/15/2025
Status: ✅ Merged
Merged: 12/16/2025
Merged by: @cfsmp3
Base:
master← Head:fix/issue-243-dvb-ocr-quality📝 Commits (1)
7e1a014fix(ocr): Improve DVB subtitle OCR quality (fixes #243)📊 Changes
7 files changed (+47 additions, -24 deletions)
View changed files
📝
src/lib_ccx/ccx_common_option.c(+1 -1)📝
src/lib_ccx/dvb_subtitle_decoder.c(+6 -1)📝
src/lib_ccx/lib_ccx.c(+13 -0)📝
src/lib_ccx/ocr.c(+4 -17)📝
src/lib_ccx/telxcc.c(+6 -1)📝
src/lib_ccx/ts_info.c(+16 -3)📝
src/rust/lib_ccxr/src/common/options.rs(+1 -1)📄 Description
Summary
This PR fixes Issue #243 where DVB subtitles from Spanish broadcasts were producing corrupt/garbled OCR output.
Before (garbage text):
After (readable text):
Problem Analysis
The original DVB bitmap images were perfectly clear and readable when examined directly. Running Tesseract directly on the exported PNG bitmaps produced good results like "para los mejores ratones del bareo del Ratón Pérez!" (only minor errors).
However, CCExtractor's preprocessing pipeline was degrading the image quality before passing it to Tesseract:
Issue 1: pixContrastNorm causing problems
The
pixContrastNorm()function from Leptonica was being applied to enhance contrast, but for some DVB sources (particularly the Spanish broadcasts), this was actually degrading the image rather than improving it.Issue 2: Aggressive color quantization
The default
ocr_quantmode=1applies CCExtractor's internalquantize_map()function which reduces the image to just 3 colors. This aggressive color reduction loses important detail that Tesseract needs for accurate character recognition.Changes Made
Core OCR improvements (
src/lib_ccx/ocr.c)pixContrastNorm()calls from both the main OCR pass and the color detection passDefault settings change
src/lib_ccx/ccx_common_option.c: Changed defaultocr_quantmodefrom 1 to 0src/rust/lib_ccxr/src/common/options.rs: Changed Rust-side default to match (the Rust parser was overriding the C default)Safety improvements
src/lib_ccx/dvb_subtitle_decoder.c: Added NULL check indvbsub_close_decoder()src/lib_ccx/telxcc.c: Added NULL check intelxcc_close()src/lib_ccx/lib_ccx.c: Added code to NULL outcinfo->codec_private_datapointers after decoder close to prevent double-free crashessrc/lib_ccx/ts_info.c: Added codec-specific cleanup indinit_cap()for DVB and Teletext decodersTesting Performed
Test 21 - English DVB subtitles
test_21_85271be4d2.mpgTest 239 - DVB timing
test_239_767b546f96.m2tsSpanish DVB - Issue #243
Cine Clan TVE Perez, el ratoncito de tus sueños 2_cortado.ts(1.3GB)alajentiegaranual dep jemios(garbage)a la entrega anual de premios(readable)Backwards Compatibility
Users who prefer the old quantization behavior can use
--quant 1on the command line to restore it.Dependencies
This PR is based on branch
fix/memory-issues-batch-2.1which should be merged first.Related Issues
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.