[PR #1923] [MERGED] fix(mp4): Use fixed-width integer types in bswap functions #2719

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

📋 Pull Request Information

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

Base: masterHead: fix/bswap32-windows-type-consistency


📝 Commits (1)

  • 69b7f9f fix(mp4): Use fixed-width integer types in bswap functions

📊 Changes

1 file changed (+9 additions, -7 deletions)

View changed files

📝 src/lib_ccx/mp4.c (+9 -7)

📄 Description

Summary

  • Changes bswap16 and bswap32 to use int16_t and int32_t instead of short and long
  • Ensures consistent NAL unit length parsing across Windows and Linux platforms

Problem

On Windows x64, long is 4 bytes (LLP64 model), while on Linux x64 long is 8 bytes (LP64 model). This type size difference in the bswap32 function could cause inconsistent behavior when parsing NAL unit lengths in MP4/MOV files.

When reading NAL lengths with *(long *)&s->data[i]:

  • Linux x64: Reads 8 bytes from memory
  • Windows x64: Reads 4 bytes from memory

This could potentially affect timestamp calculations and cause the timing differences observed between Windows and Linux CI tests.

Changes

Function Before After
bswap16 short int16_t
bswap32 long int32_t

All call sites in process_avc_sample() and process_hevc_sample() updated accordingly.

Test plan

  • Builds successfully on Linux
  • Verify Windows CI tests pass (particularly timing-related tests)
  • Check if tests 37, 136, 226-230 show improved results

🤖 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/1923 **Author:** [@cfsmp3](https://github.com/cfsmp3) **Created:** 12/29/2025 **Status:** ✅ Merged **Merged:** 12/29/2025 **Merged by:** [@cfsmp3](https://github.com/cfsmp3) **Base:** `master` ← **Head:** `fix/bswap32-windows-type-consistency` --- ### 📝 Commits (1) - [`69b7f9f`](https://github.com/CCExtractor/ccextractor/commit/69b7f9f4c384673eeb89a4c6b7a0a0a2bf105c08) fix(mp4): Use fixed-width integer types in bswap functions ### 📊 Changes **1 file changed** (+9 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `src/lib_ccx/mp4.c` (+9 -7) </details> ### 📄 Description ## Summary - Changes `bswap16` and `bswap32` to use `int16_t` and `int32_t` instead of `short` and `long` - Ensures consistent NAL unit length parsing across Windows and Linux platforms ## Problem On Windows x64, `long` is 4 bytes (LLP64 model), while on Linux x64 `long` is 8 bytes (LP64 model). This type size difference in the `bswap32` function could cause inconsistent behavior when parsing NAL unit lengths in MP4/MOV files. When reading NAL lengths with `*(long *)&s->data[i]`: - **Linux x64**: Reads 8 bytes from memory - **Windows x64**: Reads 4 bytes from memory This could potentially affect timestamp calculations and cause the timing differences observed between Windows and Linux CI tests. ## Changes | Function | Before | After | |----------|--------|-------| | `bswap16` | `short` | `int16_t` | | `bswap32` | `long` | `int32_t` | All call sites in `process_avc_sample()` and `process_hevc_sample()` updated accordingly. ## Test plan - [x] Builds successfully on Linux - [ ] Verify Windows CI tests pass (particularly timing-related tests) - [ ] Check if tests 37, 136, 226-230 show improved results 🤖 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:35 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2719