[PR #1943] [MERGED] perf(dvb): Lazy OCR initialization for DVB subtitle decoder #2740

Open
opened 2026-01-29 17:23:41 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/CCExtractor/ccextractor/pull/1943
Author: @cfsmp3
Created: 1/1/2026
Status: Merged
Merged: 1/1/2026
Merged by: @cfsmp3

Base: masterHead: fix/lazy-ocr-initialization


📝 Commits (1)

  • b56ab00 perf(dvb): Lazy OCR initialization for DVB subtitle decoder

📊 Changes

1 file changed (+12 additions, -1 deletions)

View changed files

📝 src/lib_ccx/dvb_subtitle_decoder.c (+12 -1)

📄 Description

Summary

  • Defers Tesseract OCR initialization until a DVB bitmap region actually needs OCR processing
  • Eliminates ~10 second startup overhead for files with DVB streams that don't produce bitmap output

Problem

Previously, OCR was initialized eagerly in dvbsub_init_decoder() whenever a DVB subtitle stream was detected. This caused performance issues:

  1. Unnecessary startup cost: Files with DVB streams but no actual bitmap subtitles (or alongside CEA-608 text captions) paid a ~10 second Tesseract initialization penalty
  2. Valgrind test timeouts: Tesseract's OpenMP thread pool generated 747,000+ futex syscalls, causing valgrind tests 238/239 to take 15+ minutes and timeout

Solution

Move init_ocr() call from dvbsub_init_decoder() to the first actual OCR usage point in dvbsub_decode_region_segment(). An ocr_initialized flag ensures single initialization.

Performance Results

File Type Before After
Pure CEA-608 (no DVB streams) ~10s 0.1s
DVB + CEA-608 (11MB M2TS) ~10s 3s
DVB + CEA-608 (18MB M2TS) ~15s 1s

Test plan

  • Build succeeds
  • Pure CEA-608 files: No OCR initialization, instant processing
  • DVB+CEA-608 files: OCR initialized only when bitmap regions processed
  • OCR still works correctly when DVB bitmaps are present

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/CCExtractor/ccextractor/pull/1943 **Author:** [@cfsmp3](https://github.com/cfsmp3) **Created:** 1/1/2026 **Status:** ✅ Merged **Merged:** 1/1/2026 **Merged by:** [@cfsmp3](https://github.com/cfsmp3) **Base:** `master` ← **Head:** `fix/lazy-ocr-initialization` --- ### 📝 Commits (1) - [`b56ab00`](https://github.com/CCExtractor/ccextractor/commit/b56ab005a8a74e913c43c828c4b6ff34b081841f) perf(dvb): Lazy OCR initialization for DVB subtitle decoder ### 📊 Changes **1 file changed** (+12 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/lib_ccx/dvb_subtitle_decoder.c` (+12 -1) </details> ### 📄 Description ## Summary - Defers Tesseract OCR initialization until a DVB bitmap region actually needs OCR processing - Eliminates ~10 second startup overhead for files with DVB streams that don't produce bitmap output ## Problem Previously, OCR was initialized eagerly in `dvbsub_init_decoder()` whenever a DVB subtitle stream was detected. This caused performance issues: 1. **Unnecessary startup cost**: Files with DVB streams but no actual bitmap subtitles (or alongside CEA-608 text captions) paid a ~10 second Tesseract initialization penalty 2. **Valgrind test timeouts**: Tesseract's OpenMP thread pool generated 747,000+ futex syscalls, causing valgrind tests 238/239 to take 15+ minutes and timeout ## Solution Move `init_ocr()` call from `dvbsub_init_decoder()` to the first actual OCR usage point in `dvbsub_decode_region_segment()`. An `ocr_initialized` flag ensures single initialization. ## Performance Results | File Type | Before | After | |-----------|--------|-------| | Pure CEA-608 (no DVB streams) | ~10s | **0.1s** | | DVB + CEA-608 (11MB M2TS) | ~10s | **3s** | | DVB + CEA-608 (18MB M2TS) | ~15s | **1s** | ## Test plan - [x] Build succeeds - [x] Pure CEA-608 files: No OCR initialization, instant processing - [x] DVB+CEA-608 files: OCR initialized only when bitmap regions processed - [x] OCR still works correctly when DVB bitmaps are present 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 17:23:41 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2740