[PR #1850] [FIX] -out=spupng with EIA608/teletext: offset values in XML may be not correct #893 #2616

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

Original Pull Request: https://github.com/CCExtractor/ccextractor/pull/1850

State: closed
Merged: Yes


[FIX]

In raising this pull request, I confirm the following (please check boxes):

  • [ ✔] I have read and understood the contributors guide.
  • [ ✔] I have checked that another pull request for this purpose does not exist.
  • [ ✔] I have considered, and confirmed that this submission will be valuable to others.
  • [✔ ] I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  • [✔ ] I give this submission freely, and claim no ownership to its content.
  • I have mentioned this change in the changelog.

My familiarity with the project is as follows (check one):

  • I have never used CCExtractor.
  • I have used CCExtractor just a couple of times.
  • I absolutely love CCExtractor, but have not contributed previously.
  • [ ✔] I am an active contributor to CCExtractor.

[FIX] -out=spupng with EIA608/teletext: offset values in XML may be not correct #893

The issue occurs because the offsets were hardcoded for a 544×390 subtitle image centered on a 720×480 NTSC screen, while the text-to-PNG renderer generates PNGs with different (dynamic) dimensions (e.g. 600px wide and variable height). This results in visibly misaligned subtitles, especially for Teletext (PAL) sources.

This PR removes the hardcoded NTSC assumptions and calculates SPUPNG offsets dynamically based on the actual rendered PNG geometry and the target screen resolution.

Key changes =>

  1. Store the real PNG dimensions (img_w, img_h) in spupng_t

2 .Introduce an is_pal flag in encoder_ctx to distinguish PAL (576 lines) vs NTSC (480 lines)

  1. Capture final canvas dimensions during text-to-PNG rendering

4.Add a helper to compute centered xOffset / yOffset dynamically

  1. Enforce even yOffset to prevent interlacing flicker on DVD/SPU

  2. Apply the new logic only to the text-to-SPUPNG pipeline, leaving the bitmap path unchanged

  3. This aligns the text-based SPUPNG output with the already-correct bitmap SPUPNG behavior.

So ,Subtitles are correctly positioned regardless of PNG width/height (PNG size decides the offset — not hardcoded values.).

in the given image i have drawn the flow of this fix .
IMG_1181

**Original Pull Request:** https://github.com/CCExtractor/ccextractor/pull/1850 **State:** closed **Merged:** Yes --- **[FIX]** **In raising this pull request, I confirm the following (please check boxes):** - [ ✔] I have read and understood the [contributors guide](https://github.com/CCExtractor/ccextractor/blob/master/.github/CONTRIBUTING.md). - [ ✔] I have checked that another pull request for this purpose does not exist. - [ ✔] I have considered, and confirmed that this submission will be valuable to others. - [✔ ] I accept that this submission may not be used, and the pull request closed at the will of the maintainer. - [✔ ] I give this submission freely, and claim no ownership to its content. - [ ] **I have mentioned this change in the [changelog](https://github.com/CCExtractor/ccextractor/blob/master/docs/CHANGES.TXT).** **My familiarity with the project is as follows (check one):** - [ ] I have never used CCExtractor. - [ ] I have used CCExtractor just a couple of times. - [x] I absolutely love CCExtractor, but have not contributed previously. - [ ✔] I am an active contributor to CCExtractor. --- [FIX] -out=spupng with EIA608/teletext: offset values in XML may be not correct #893 The issue occurs because the offsets were hardcoded for a 544×390 subtitle image centered on a 720×480 NTSC screen, while the text-to-PNG renderer generates PNGs with different (dynamic) dimensions (e.g. 600px wide and variable height). This results in visibly misaligned subtitles, especially for Teletext (PAL) sources. This PR removes the hardcoded NTSC assumptions and calculates SPUPNG offsets dynamically based on the actual rendered PNG geometry and the target screen resolution. Key changes => 1. Store the real PNG dimensions (img_w, img_h) in spupng_t 2 .Introduce an is_pal flag in encoder_ctx to distinguish PAL (576 lines) vs NTSC (480 lines) 3. Capture final canvas dimensions during text-to-PNG rendering 4.Add a helper to compute centered xOffset / yOffset dynamically 5. Enforce even yOffset to prevent interlacing flicker on DVD/SPU 6. Apply the new logic only to the text-to-SPUPNG pipeline, leaving the bitmap path unchanged 7. This aligns the text-based SPUPNG output with the already-correct bitmap SPUPNG behavior. **So ,Subtitles are correctly positioned regardless of PNG width/height (PNG size decides the offset — not hardcoded values.).** in the given image i have drawn the flow of this fix . ![IMG_1181](https://github.com/user-attachments/assets/39e7c651-d29d-4add-a73e-0dab16189e10)
claunia added the pull-request label 2026-01-29 17:23:06 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2616