Skip to content

Gate the up/down OCR line splitter on ink height, not bitmap height - #14490

Merged
niksedk merged 1 commit into
mainfrom
claude/github-issue-analysis-6005b6
Sep 3, 2026
Merged

niksedk merged 1 commit into
mainfrom
claude/github-issue-analysis-6005b6

Conversation

@niksedk

@niksedk niksedk commented Sep 3, 2026

Copy link
Copy Markdown
Member

Fixes #14292 - nOCR on a one-line DVD subtitle whose leftmost glyph has a descender ("(", "J", ",", "g", "q") produced an extra unknown character.

Cause

The VobSub decoder leaves up to seven transparent rows under the text. For a DVD-sized font the adaptive minimum line height settles around 14, and that padded one-line image (31-35 rows) cleared the 2.2 x minLineHeight gate in front of SplitToLinesNew, the "allows for up/down" line splitter. Its path walked down the outer edge of the "(", and since its cut starts one row above the path it eroded the glyph's edge and left the crumbs as a bogus second line - the 2x5 blob in the reporter's screenshots.

SplitToLinesNew had been dead code until 9a917c6 (beta27) moved its started flag out of the scan loop, which is why earlier builds were fine and why "Crop transparent colors" works around it: without the margin the image never reaches the gate.

Fix

Gate on GetNonTransparentHeight() instead of the bitmap height.

Verification

On the reporter's file, first 600 subtitles, nOCR pipeline as the OCR window runs it:

One-line images split in two Genuine two-line images still split
Before 19 (all 11 reported lines among them) 315 of 315
After 0 315 of 315

A regression test rebuilds the "(" from subtitle 125 with the decoder's bottom margin; it fails on main with the 2x5 crumb and passes with the fix. All 352 libuilogic OCR tests pass. Also verified in the UI on the reporter's file.

🤖 Generated with Claude Code

Fixes #14292: nOCR on a one-line DVD subtitle whose leftmost glyph has a
descender - "(", "J", ",", "g", "q" - produced an extra unknown character.

The VobSub decoder leaves up to seven transparent rows under the text. For
a DVD-sized font the adaptive minimum line height settles around 14, and
that padded one-line image (31-35 rows) cleared the 2.2 x minLineHeight
gate in front of SplitToLinesNew, the "allows for up/down" line splitter.
Its path walked down the outer edge of the "(", and since its cut starts
one row above the path it eroded the glyph's edge and left the crumbs as a
bogus second line - the 2x5 blob in the reporter's screenshots.

SplitToLinesNew had been dead code until 9a917c6 (beta27) moved its
"started" flag out of the scan loop, which is why earlier builds were fine
and why "Crop transparent colors" works around it: without the margin the
image never reaches the gate.

Gate on GetNonTransparentHeight instead. On the reporter's file the first
600 subtitles go from 19 one-line images split in two (all 11 reported
lines among them) to 0, while all 315 genuine two-line images still split.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@niksedk
niksedk merged commit 2a844ee into main Sep 3, 2026
1 check passed
@niksedk
niksedk deleted the claude/github-issue-analysis-6005b6 branch September 3, 2026 18:15
@niksedk niksedk mentioned this pull request Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect extra characters during DVD OCR in 5.2.0-beta29

1 participant