mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-13 04:51:38 -10:00
A FLAC stream wider than 16 bits was taken to 16 bits by shifting its left-justified samples right by 16, which rounds down: every sample of a 24-bit stream came out half a step low on average. Every 16-bit output path (independent, left/side, side/right and mid/side stereo, the 33-bit side channel of 32-bit streams, mono and more channels; scalar, SSE2 and NEON) now rounds to the nearest step, halves up, and clamps the top. A stream of 16 bits or fewer is unchanged, and the decode is no slower (60 s of 24-bit stereo: 19.2 ms before, 19.1 ms after, best of 15). The 33-bit side channel's reconstruction shifted negative int64 values left, which is undefined and which UBSan reports on the new fixtures; those shifts go through uint64_t. New sample formats/rflac: rflac_s16_test decodes FLAC streams of 16, 24 and 32 bits (stereo fixtures holding all four channel codings, mono, six channels) and checks every sample against the PCM they were made from, rebuilt from the same integer formulas as mkfixtures.py (flac and metaflac made them). It is built with the target's SIMD and again with RFLAC_NO_SIMD; the NEON loops were run under qemu-aarch64. It fails before this change.