mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-02-03 21:23:48 +00:00
[PR #2059] Fix/dvb subtitle ocr and spupng #2871
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?
Original Pull Request: https://github.com/CCExtractor/ccextractor/pull/2059
State: closed
Merged: No
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
DVB subtitle OCR extraction was failing in the options test on Linux due to three bugs:
The write_dvb_sub function used an undefined region variable when calling ocr_rect, causing crashes or incorrect OCR results.
The SPUPNG encoder wrote the closing tags immediately after the opening tags in write_spumux_header, so the output file had no subtitle content between the subpictures tags.
DVB subtitle regions were not marked as processed after OCR extraction, causing them to be processed multiple times and creating duplicate subtitle entries.
Solution
Fixed the undefined region variable by finding the first valid region from the display list and using that for the bgcolor parameter in ocr_rect.
Removed the code that prematurely wrote the footer in write_spumux_header. The footer now writes during normal cleanup in write_spumux_footer.
Added a loop at the end of write_dvb_sub to clear the dirty flag for all processed regions, preventing duplicate processing.
Added safety code for builds without OCR support to set ocr_text pointers to NULL, preventing use-after-free errors.
Testing
Tested with the failed test sample of linux platform https://sampleplatform.ccextractor.org/test/7992# SPUPNG output has proper XML structure with subpictures wrapper tags and all subtitle entries with OCR comments. PNG files are generated correctly.
As per what I know PR has to be raised to test the updated code. I will promptly close this PR if changes made by me prove to be invaluable :)