[PR #2013] [MERGED] docs: Clarify PS probe limit calculation (explain magic number) #2814

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

📋 Pull Request Information

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

Base: masterHead: docs/explain-ps-probe-limit-magic-number


📝 Commits (1)

  • d5201b1 docs: Clarify PS probe limit calculation with inline comment

📊 Changes

1 file changed (+6 additions, -2 deletions)

View changed files

📝 src/rust/src/demuxer/stream_functions.rs (+6 -2)

📄 Description

Summary

Replaces the magic number 49997 with 50000 - 3 and adds a clear inline comment explaining the PS stream probe limit calculation.

Changes

// Before:
} else {
    49997
}

// After:
} else {
    50000 - 3 // Don't scan huge buffers entirely; 50KB is enough
}

Why This Matters

The number 49997 appears arbitrary without context. The new code makes it clear that:

  1. Why subtract 3: The loop checks startbytes[i], [i+1], [i+2], [i+3], so we must stop 3 bytes before the end to avoid out-of-bounds access

  2. Why 50000: We cap the scan range for large buffers (no need to scan megabytes when 50KB is sufficient to detect the format)

  3. Why saturating_sub: Handles edge case of tiny buffers (< 3 bytes) without underflow

Testing

  • Build passes
  • No functional change (50000 - 3 = 49997)

🤖 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/2013 **Author:** [@cfsmp3](https://github.com/cfsmp3) **Created:** 1/10/2026 **Status:** ✅ Merged **Merged:** 1/11/2026 **Merged by:** [@cfsmp3](https://github.com/cfsmp3) **Base:** `master` ← **Head:** `docs/explain-ps-probe-limit-magic-number` --- ### 📝 Commits (1) - [`d5201b1`](https://github.com/CCExtractor/ccextractor/commit/d5201b11291f11fc2906d1b351eaabe45d9a4ade) docs: Clarify PS probe limit calculation with inline comment ### 📊 Changes **1 file changed** (+6 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/rust/src/demuxer/stream_functions.rs` (+6 -2) </details> ### 📄 Description ## Summary Replaces the magic number `49997` with `50000 - 3` and adds a clear inline comment explaining the PS stream probe limit calculation. ## Changes ```rust // Before: } else { 49997 } // After: } else { 50000 - 3 // Don't scan huge buffers entirely; 50KB is enough } ``` ## Why This Matters The number 49997 appears arbitrary without context. The new code makes it clear that: 1. **Why subtract 3**: The loop checks `startbytes[i], [i+1], [i+2], [i+3]`, so we must stop 3 bytes before the end to avoid out-of-bounds access 2. **Why 50000**: We cap the scan range for large buffers (no need to scan megabytes when 50KB is sufficient to detect the format) 3. **Why saturating_sub**: Handles edge case of tiny buffers (< 3 bytes) without underflow ## Testing - Build passes - No functional change (50000 - 3 = 49997) 🤖 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:24:03 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2814