Skip to content

Conversation

@simoninns
Copy link
Collaborator

This PR adds a new command line switch to ld-decode: --write-test-ldf

If you have a decode with positional switches (like --start --length etc) and you want to get a snippet of the original .lds file for future tests or to reproduce decoding errors you would need to work pretty hard to create a cut-down .lds with just the interesting bit of (what could be) a massive .ldf file.

If you simply add --write-test-ldf my-test.ldf to the existing ld-decode command line, the decoder will output an .lds file containing just enough data to decode exactly the same fields (without needing any positional arguments). This is ready for attachment to a bug report.

This feature is really useful for creating .lds test files too since you can easily make .ldf files of interesting disc sections.

The PR includes both the feature and two CI/CD tests that test both PAL and NTSC decodes.

This new feature allows users to extract the exact portion of an input LDF/LDS
file that was decoded, making it easy to create reproducible test cases for
bug reporting.

Key features:
- Works with all position/length options (--start, --length, --seek, --start_fileloc)
- Outputs FLAC-compressed LDF file (compression level 6)
- Includes 1.1M sample buffer for decoder lookahead (safe for NTSC/PAL)
- Extracted LDF produces byte-for-byte identical decode results
- Prevents accidental overwriting of input file

Usage:
  ld-decode --NTSC --start 600 --length 100 --write-test-ldf problem.ldf input.ldf output

The extracted LDF can then be decoded without position switches:
  ld-decode --NTSC problem.ldf output
Adds automated tests for the --write-test-ldf option to ensure it correctly
extracts and reproduces decoded portions of LDF files.

Tests include:
- NTSC test using ggv-ntsc-mb-v2800.ldf
- PAL test using jason-testpattern.ldf

Each test verifies:
1. Extracted LDF file is created in correct format (FLAC in Ogg)
2. Extracted LDF can be decoded without position switches
3. Decoded output is byte-for-byte identical to original
4. Safety check prevents overwriting input file

Tests run as part of the standard 'ctest' suite.
@simoninns simoninns requested a review from happycube December 25, 2025 05:23
@happycube happycube merged commit 46971d6 into happycube:main Dec 26, 2025
1 check passed
@simoninns simoninns deleted the testldf-202512 branch January 2, 2026 08:33
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.

2 participants