mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-26 10:19:47 -04:00
e5a4e9643c
Replace the O(N^3) reference IDCT in idct_block (1024 multiplies per 8x8 block) with FFmpeg's simple_idct butterfly decomposition (~64 multiplies per block). Both row and column passes ported to produce int16_t output so the rest of mdec.c (to_output_u8, append_color_macroblock, append_luma_block) keeps working unchanged. Source: FFmpeg libavcodec/simple_idct_template.c (BIT_DEPTH=8), LGPL-2.1+. Previously imported into legacy runner/src/fmv_player.cpp on the legacy-2026-05-11 branch; salvaged into v4's hardware-emulated MDEC path. Attribution preserved in the source comment. Side effect: the new IDCT computes cosines from the W1..W7 constants directly and no longer depends on mdec.scale. The prior implementation treated SET_SCALE input as the cosine matrix; real PSX hardware ignores SET_SCALE for IDCT (it only seeds the dequant tables), so the new code matches hardware more closely as well. Verified visually: Tomba boots through Sony splash + Whoopee Camp FMV; intro FMV reaches the mountain-valley scene with correct colors. No visual regression vs the prior implementation. This addresses one piece of TombaRecomp ISSUES.md #3.D / FMV-speed goal. Whether the IDCT was the actual FMV bottleneck still needs an A/B timing test; this is a clean CPU win regardless. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>