Skip to content

Conversation

@cfsmp3
Copy link
Contributor

@cfsmp3 cfsmp3 commented Dec 29, 2025

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

Change bswap16 and bswap32 to use int16_t and int32_t instead of
short and long for consistent behavior across platforms.

On Windows x64, `long` is 4 bytes (LLP64 model), while on Linux x64
`long` is 8 bytes (LP64 model). This difference could cause
inconsistent NAL unit length parsing in MP4/MOV files, potentially
affecting timestamp calculations.

This fix ensures the byte-swapping functions work identically on
both platforms by using fixed-width integer types from <stdint.h>.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ccextractor-bot
Copy link
Collaborator

CCExtractor CI platform finished running the test files on linux. Below is a summary of the test results, when compared to test for commit 63dde6f...:
Report Name Tests Passed
Broken 13/13
CEA-708 14/14
DVB 7/7
DVD 3/3
DVR-MS 2/2
General 27/27
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 86/86
Teletext 21/21
WTV 13/13
XDS 34/34

All tests passed completely.

Check the result page for more info.

@ccextractor-bot
Copy link
Collaborator

CCExtractor CI platform finished running the test files on windows. Below is a summary of the test results, when compared to test for commit 63dde6f...:
Report Name Tests Passed
Broken 13/13
CEA-708 14/14
DVB 6/7
DVD 3/3
DVR-MS 2/2
General 25/27
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 80/86
Teletext 21/21
WTV 13/13
XDS 34/34

NOTE: The following tests have been failing on the master branch as well as the PR:


This PR does not introduce any new test failures. However, some tests are failing on both master and this PR (see above).

Check the result page for more info.

@cfsmp3 cfsmp3 merged commit 434cd39 into master Dec 29, 2025
42 checks passed
@cfsmp3 cfsmp3 deleted the fix/bswap32-windows-type-consistency branch December 29, 2025 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants