Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pcmAudioField map contents and access #816

Merged
merged 2 commits into from
Nov 28, 2022

Conversation

Mikewando
Copy link
Contributor

@Mikewando Mikewando commented Nov 28, 2022

As the existing comment notes, the previous field's start and length should be used to determine the current field's start. Otherwise we may use the wrong offset.

Furthermore the maps for start and length are 0 indexed, but input sequential frame numbers are 1 indexed and should be corrected.

With the map correction it is also now possible for ld-discmap to actually try to read the last field's audio data, which is likely to be the end of the pcm file. Attempting to read the pcm input file completely would not append the last sample and would result in the program crashing. Updated this to be a warning (to avoid crash) while still appending the data since it's valid.

@Mikewando
Copy link
Contributor Author

Before these changes, providing a decoded tbc with perfectly sequential frames (e.g. by using ld-cut and then ld-decode) as input to ld-discmap would result in a mapped-output.pcm file smaller than the original input.pcm file even though the disc mapping process in this case should not change the number of video or audio samples (and indeed video samples do not change).

Repeating the scenario with the changes in this PR yields a mapped-output.pcm file which is identical to the input.pcm file.

@Mikewando Mikewando changed the title Fix pcmAudioFieldStartSampleMap Fix pcmAudioField map contents and access Nov 28, 2022
@happycube happycube merged commit 516ba8a into happycube:master Nov 28, 2022
@Mikewando Mikewando deleted the ld-discmap-fix branch November 28, 2022 03:09
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.

None yet

2 participants