Skip to content

AudioDecoder: fix chunk decoding when split is exactly at half a sample boundary - #1616

Merged
NicolasHug merged 3 commits into
mainfrom
audio-range-boundary-rounding
Aug 12, 2026
Merged

AudioDecoder: fix chunk decoding when split is exactly at half a sample boundary#1616
NicolasHug merged 3 commits into
mainfrom
audio-range-boundary-rounding

Conversation

@NicolasHug

@NicolasHug NicolasHug commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

See non-regression test and comment. The fix is to make our round() mechanism stable across calls.

With the previous PRs below in this stack, this should correctly fix #1601

Closes #1601


Stack created with GitHub Stacks CLIGive Feedback 💬

@pytorch-bot

pytorch-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/meta-pytorch/torchcodec/1616

Note: Links to docs will display an error until the docs builds have been completed.

❌ 5 New Failures, 8 Cancelled Jobs, 3 Unclassified Failures

As of commit dab26e6 with merge base 088c229 (image):

NEW FAILURES - The following jobs have failed:

UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:

CANCELLED JOBS - The following jobs were cancelled. Please retry:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 11, 2026
@NicolasHug
NicolasHug force-pushed the audio-range-boundary-rounding branch from 1620a94 to 86a2f3d Compare August 11, 2026 18:47
@NicolasHug
NicolasHug force-pushed the audio-range-boundary-rounding branch from 86a2f3d to 001fe6e Compare August 12, 2026 08:11
@NicolasHug
NicolasHug force-pushed the audio-range-boundary-rounding branch from 001fe6e to 518c346 Compare August 12, 2026 08:34
@NicolasHug
NicolasHug force-pushed the audio-range-boundary-rounding branch from 518c346 to 6673bfa Compare August 12, 2026 08:34
Base automatically changed from audio-resampler-postroll to main August 12, 2026 09:10
@NicolasHug
NicolasHug force-pushed the audio-range-boundary-rounding branch from 6673bfa to dab26e6 Compare August 12, 2026 09:10
round() rounds ties to the nearest even sample, which isn't stable across
range requests: each one converts its boundaries into offsets from its own
first_pts, and how far that is from the boundary decides which of the two
samples is the even one. Consecutive ranges could disagree about who owns
the sample on their common boundary and return it twice, or not at all.

Round ties up instead, which is invariant to that shift. Note that this
means the two ends of a range have to be computed the same way: as an
offset from first_pts. Deriving the end from the number of samples we got,
as we did, negates the offset, and only round() is symmetric enough for
that to give the same answer.
@NicolasHug
NicolasHug force-pushed the audio-range-boundary-rounding branch from dab26e6 to ff0e666 Compare August 12, 2026 09:21
@NicolasHug NicolasHug changed the title Round chunk boundaries the same way in every range AudioDecoder: fix chunk decoding when split is exactly at half a sample boundary Aug 12, 2026
@NicolasHug
NicolasHug merged commit 574d78a into main Aug 12, 2026
52 checks passed
@NicolasHug
NicolasHug deleted the audio-range-boundary-rounding branch August 12, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AudioDecoder intermittently drops 1 sample in final fractional-second chunk

1 participant