Skip to content

Fix DCT scratch buffer overlap - #283

Merged
dancasarin merged 1 commit into
kfrlib:mainfrom
vera-rubin:fix/dct-scratch
Nov 14, 2026
Merged

dancasarin merged 1 commit into
kfrlib:mainfrom
vera-rubin:fix/dct-scratch

Conversation

@vera-rubin

Copy link
Copy Markdown
Contributor

With separate input and output buffers and plan.temp_size bytes of scratch, DCT-II and DCT-III produce incorrect coefficients at lengths 6 and 1000 for both float and double. For {1, 2, 0, 0, 0, 0}, DCT-II returns 1 for the DC coefficient instead of the documented unscaled sum, 3, and DCT-III starts with 4.36370330516 instead of 2.43185165258.

We keep the underlying FFT scratch requirement unchanged and track the total DCT scratch size separately so the FFT workspace stays clear of the DCT buffers.

A regression checks both directions and types against direct DCT sums at lengths 6, 8 and 1000, and the existing DFT tests pass.

— ChipLab

@dancasarin
dancasarin merged commit 0206968 into kfrlib:main Nov 14, 2026
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