[PR #1855] [MERGED] fix(raw): Fix premature EOF and timing overflow in raw_loop #2620

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

📋 Pull Request Information

Original PR: https://github.com/CCExtractor/ccextractor/pull/1855
Author: @cfsmp3
Created: 12/20/2025
Status: Merged
Merged: 12/20/2025
Merged by: @cfsmp3

Base: masterHead: fix/issue-1565-raw-loop-eof


📝 Commits (1)

  • ebfa31c fix(raw): Fix premature EOF and timing overflow in raw_loop (#1565)

📊 Changes

1 file changed (+21 additions, -5 deletions)

View changed files

📝 src/lib_ccx/general_loop.c (+21 -5)

📄 Description

Summary

Fixes #1565 - CCExtractor stops processing raw caption files at exactly 9:43:00 (2MB).

Root causes found and fixed:

  1. Premature EOF bug: After processing the first chunk (BUFSIZE = ~2MB), data->len was never reset to 0. On the next iteration, general_get_more_data() calculated want = BUFSIZE - data->len = 0 and returned EOF immediately.

    • Fix: Added data->len = 0 after processing each chunk and changed loop condition from while (data->len) to while (1) with explicit breaks.
  2. 32-bit integer overflow: The calculation cb_field1 * 1001 / 30 * (MPEG_CLOCK_FREQ / 1000) overflowed when cb_field1 was large (>1 million). For example, 34,989,487 * 90 = 3,149,053,830 exceeds the 32-bit signed integer max (2,147,483,647).

    • Fix: Cast cb_field1 to LLONG before the multiplication.
  3. Timing initialization: Raw mode needs proper initialization (min_pts=0, sync_pts=0, pts_set=MinPtsSet) for the Rust timing code to calculate fts_now correctly.

Test plan

Tested with sample files from issue #1565:

  • DTV3.raw: Now processes to 17:59:56 (was stopping at 9:43)
  • DTV4.raw: Now processes to 14:00:00 (was stopping at 9:43)
  • DTV5.raw: Now processes to 13:19:59 (was stopping at 9:43)
  • All Rust tests pass (286 tests)

🤖 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/1855 **Author:** [@cfsmp3](https://github.com/cfsmp3) **Created:** 12/20/2025 **Status:** ✅ Merged **Merged:** 12/20/2025 **Merged by:** [@cfsmp3](https://github.com/cfsmp3) **Base:** `master` ← **Head:** `fix/issue-1565-raw-loop-eof` --- ### 📝 Commits (1) - [`ebfa31c`](https://github.com/CCExtractor/ccextractor/commit/ebfa31c333af7a76e10c050ea7377766aa3870dd) fix(raw): Fix premature EOF and timing overflow in raw_loop (#1565) ### 📊 Changes **1 file changed** (+21 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `src/lib_ccx/general_loop.c` (+21 -5) </details> ### 📄 Description ## Summary Fixes #1565 - CCExtractor stops processing raw caption files at exactly 9:43:00 (2MB). ### Root causes found and fixed: 1. **Premature EOF bug**: After processing the first chunk (BUFSIZE = ~2MB), `data->len` was never reset to 0. On the next iteration, `general_get_more_data()` calculated `want = BUFSIZE - data->len = 0` and returned EOF immediately. - **Fix**: Added `data->len = 0` after processing each chunk and changed loop condition from `while (data->len)` to `while (1)` with explicit breaks. 2. **32-bit integer overflow**: The calculation `cb_field1 * 1001 / 30 * (MPEG_CLOCK_FREQ / 1000)` overflowed when `cb_field1` was large (>1 million). For example, `34,989,487 * 90 = 3,149,053,830` exceeds the 32-bit signed integer max (2,147,483,647). - **Fix**: Cast `cb_field1` to `LLONG` before the multiplication. 3. **Timing initialization**: Raw mode needs proper initialization (`min_pts=0`, `sync_pts=0`, `pts_set=MinPtsSet`) for the Rust timing code to calculate `fts_now` correctly. ## Test plan Tested with sample files from issue #1565: - [x] DTV3.raw: Now processes to 17:59:56 (was stopping at 9:43) - [x] DTV4.raw: Now processes to 14:00:00 (was stopping at 9:43) - [x] DTV5.raw: Now processes to 13:19:59 (was stopping at 9:43) - [x] All Rust tests pass (286 tests) 🤖 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:07 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2620