1
0
mirror of https://git.ffmpeg.org/ffmpeg.git synced 2026-10-24 02:09:03 +03:00

simple_idct: add a 16-bit output variant with 32-bit intermediates

For coefficients and output that both span 16 bits, like those of ProRes
RAW. The template's 16-bit intermediates cannot hold more fractional
bits than the output needs, and the constants of the 12-bit transform,
scaled to 15 bits, make W4 32767 rather than 32768, which alone costs
0.8 LSB RMS of a 16-bit output.

The new variant uses the 10-bit transform's constants, scaled to 14
bits and exact at W4, with a row shift of 13 and a column shift of 15,
the most fractional bits the 32-bit sums of a 16-bit result allow.
Against an exact transform, it is within 0.49 LSB RMS and 2.3 LSB peak
on real content, with no bias, and passes every IEEE 1180 criterion in
the standard's 8-bit units by three orders of magnitude.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016LFnYMstwe4woBzpxfzDzg
This commit is contained in:
Lynne
2026-09-20 23:39:32 +09:00
parent f714986c29
commit 71db131782

View File

@@ -60,9 +60,9 @@
#define MUL(a, b) MUL16(a, b)
#define MAC(a, b, c) MAC16(a, b, c)
#elif BIT_DEPTH == 10 || BIT_DEPTH == 12
#elif BIT_DEPTH == 10 || BIT_DEPTH == 12 || BIT_DEPTH == 16
# if BIT_DEPTH == 10
# if BIT_DEPTH == 10 || BIT_DEPTH == 16
#define W1 22725 // 90901
#define W2 21407 // 85627
#define W3 19265 // 77062
@@ -71,7 +71,17 @@
#define W6 8867 // 35468
#define W7 4520 // 18081
# ifdef EXTRA_SHIFT
# if BIT_DEPTH == 16
/* 16-bit output from 16-bit coefficients. The rows keep two more
* fractional bits than 16-bit intermediates could hold, and the columns
* are shifted by as little as the 32-bit sums of a 16-bit result allow */
# if IN_IDCT_DEPTH != 32
#error "The 16-bit iDCT needs 32-bit intermediates"
# endif
#define ROW_SHIFT 13
#define COL_SHIFT 15
#define DC_SHIFT 1
# elif defined(EXTRA_SHIFT)
#define ROW_SHIFT 13
#define COL_SHIFT 18
#define DC_SHIFT 1