1. (1 << (c - 1)) & ~((1 << c) - 1) is always zero. This together with the fact that a square is always nonnegative (there's no overflow) allows to remove a FFMAX. 2. The discriminant of the polynomial i * i - 2^(F+1) * i + 2^(F - 1) + 2^(2 * F) is negative; hence this polynomial has no real solutions, i.e. its sign doesn't change and is always positive. This allows to remove a FFMAX.
Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@gmail.com> --- libavcodec/j2kenc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c index b5ac06b906..0a1421c844 100644 --- a/libavcodec/j2kenc.c +++ b/libavcodec/j2kenc.c @@ -522,13 +522,12 @@ static void init_luts(void) for (i = 0; i < (1 << NMSEDEC_BITS); i++){ lut_nmsedec_sig[i] = FFMAX((6 * i - (9 << (NMSEDEC_FRACBITS - 1))) * (1 << (12 - NMSEDEC_FRACBITS)), 0); - lut_nmsedec_sig0[i] = FFMAX((i*i + (1<<NMSEDEC_FRACBITS-1) & mask) << 1, 0); + lut_nmsedec_sig0[i] = 2 * i * i; a = (i >> (NMSEDEC_BITS-2)&2) + 1; lut_nmsedec_ref[i] = FFMAX((-2 * i + (1 << NMSEDEC_FRACBITS) + a * i - (a * a << (NMSEDEC_FRACBITS - 2))) * (1 << (13 - NMSEDEC_FRACBITS)), 0); - lut_nmsedec_ref0[i] = FFMAX(((i * i - (i << (NMSEDEC_FRACBITS + 1)) + (1 << (NMSEDEC_FRACBITS - 1)) + (1 << 2 * NMSEDEC_FRACBITS)) & mask) - << 1, 0); + lut_nmsedec_ref0[i] = ((i * i - (i << (NMSEDEC_FRACBITS + 1)) + (1 << (NMSEDEC_FRACBITS - 1)) + (1 << 2 * NMSEDEC_FRACBITS)) & mask) << 1; } } -- 2.20.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".