aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Vignali <martin.vignali@gmail.com>2018-11-17 17:57:27 +0100
committerPaul B Mahol <onemda@gmail.com>2018-11-17 18:06:58 +0100
commitd3621b232142165d6641708de14c51b78bf2b2df (patch)
tree439a4cd4260b4baf0d6d3a705c629643882c2a69
parent420ab946ace27e4b4bfb6c2be0a65a4ffd6e05a1 (diff)
downloadffmpeg-d3621b232142165d6641708de14c51b78bf2b2df.tar.gz
avfilter: use av_clip_uintp2 instead of av_clip for 10b and 12b
-rw-r--r--libavfilter/vf_blend.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c
index c00773c924..80d3e24699 100644
--- a/libavfilter/vf_blend.c
+++ b/libavfilter/vf_blend.c
@@ -326,15 +326,15 @@ DEFINE_BLEND16(linearlight,av_clip_uint16((B < 32768) ? B + 2 * A - 65535 : B +
#define DODGE(a, b) (((a) == 1023) ? (a) : FFMIN(1023, (((b) << 10) / (1023 - (a)))))
DEFINE_BLEND16(addition, FFMIN(1023, A + B), 10)
-DEFINE_BLEND16(grainmerge, av_clip(A + B - 512, 0, 1023), 10)
+DEFINE_BLEND16(grainmerge, (int)av_clip_uintp2(A + B - 512, 10), 10)
DEFINE_BLEND16(average, (A + B) / 2, 10)
DEFINE_BLEND16(subtract, FFMAX(0, A - B), 10)
DEFINE_BLEND16(multiply, MULTIPLY(1, A, B), 10)
-DEFINE_BLEND16(multiply128, av_clip((A - 512) * B / 128. + 512, 0, 1023), 10)
+DEFINE_BLEND16(multiply128, (int)av_clip_uintp2((A - 512) * B / 128. + 512, 10), 10)
DEFINE_BLEND16(negation, 1023 - FFABS(1023 - A - B), 10)
DEFINE_BLEND16(extremity, FFABS(1023 - A - B), 10)
DEFINE_BLEND16(difference, FFABS(A - B), 10)
-DEFINE_BLEND16(grainextract, av_clip(512 + A - B, 0, 1023), 10)
+DEFINE_BLEND16(grainextract, (int)av_clip_uintp2(512 + A - B, 10), 10)
DEFINE_BLEND16(screen, SCREEN(1, A, B), 10)
DEFINE_BLEND16(overlay, (A < 512) ? MULTIPLY(2, A, B) : SCREEN(2, A, B), 10)
DEFINE_BLEND16(hardlight, (B < 512) ? MULTIPLY(2, B, A) : SCREEN(2, B, A), 10)
@@ -343,7 +343,7 @@ DEFINE_BLEND16(heat, (A == 0) ? 0 : 1023 - FFMIN(((1023 - B) * (1023 - B))
DEFINE_BLEND16(freeze, (B == 0) ? 0 : 1023 - FFMIN(((1023 - A) * (1023 - A)) / B, 1023), 10)
DEFINE_BLEND16(darken, FFMIN(A, B), 10)
DEFINE_BLEND16(lighten, FFMAX(A, B), 10)
-DEFINE_BLEND16(divide, av_clip(B == 0 ? 1023 : 1023 * A / B, 0, 1023), 10)
+DEFINE_BLEND16(divide, (int)av_clip_uintp2(B == 0 ? 1023 : 1023 * A / B, 10), 10)
DEFINE_BLEND16(dodge, DODGE(A, B), 10)
DEFINE_BLEND16(burn, BURN(A, B), 10)
DEFINE_BLEND16(softlight, (A > 511) ? B + (1023 - B) * (A - 511.5) / 511.5 * (0.5 - fabs(B - 511.5) / 1023): B - B * ((511.5 - A) / 511.5) * (0.5 - fabs(B - 511.5)/1023), 10)
@@ -356,7 +356,7 @@ DEFINE_BLEND16(and, A & B, 10)
DEFINE_BLEND16(or, A | B, 10)
DEFINE_BLEND16(xor, A ^ B, 10)
DEFINE_BLEND16(vividlight, (A < 512) ? BURN(2 * A, B) : DODGE(2 * (A - 512), B), 10)
-DEFINE_BLEND16(linearlight,av_clip((B < 512) ? B + 2 * A - 1023 : B + 2 * (A - 512), 0, 1023), 10)
+DEFINE_BLEND16(linearlight,(int)av_clip_uintp2((B < 512) ? B + 2 * A - 1023 : B + 2 * (A - 512), 10), 10)
#undef MULTIPLY
#undef SCREEN
@@ -369,15 +369,15 @@ DEFINE_BLEND16(linearlight,av_clip((B < 512) ? B + 2 * A - 1023 : B + 2 * (A - 5
#define DODGE(a, b) (((a) == 4095) ? (a) : FFMIN(4095, (((b) << 12) / (4095 - (a)))))
DEFINE_BLEND16(addition, FFMIN(4095, A + B), 12)
-DEFINE_BLEND16(grainmerge, av_clip(A + B - 2048, 0, 4095), 12)
+DEFINE_BLEND16(grainmerge, (int)av_clip_uintp2(A + B - 2048, 12), 12)
DEFINE_BLEND16(average, (A + B) / 2, 12)
DEFINE_BLEND16(subtract, FFMAX(0, A - B), 12)
DEFINE_BLEND16(multiply, MULTIPLY(1, A, B), 12)
-DEFINE_BLEND16(multiply128, av_clip((A - 2048) * B / 512. + 2048, 0, 4095), 12)
+DEFINE_BLEND16(multiply128, (int)av_clip_uintp2((A - 2048) * B / 512. + 2048, 12), 12)
DEFINE_BLEND16(negation, 4095 - FFABS(4095 - A - B), 12)
DEFINE_BLEND16(extremity, FFABS(4095 - A - B), 12)
DEFINE_BLEND16(difference, FFABS(A - B), 12)
-DEFINE_BLEND16(grainextract, av_clip(2048 + A - B, 0, 4095), 12)
+DEFINE_BLEND16(grainextract, (int)av_clip_uintp2(2048 + A - B, 12), 12)
DEFINE_BLEND16(screen, SCREEN(1, A, B), 12)
DEFINE_BLEND16(overlay, (A < 2048) ? MULTIPLY(2, A, B) : SCREEN(2, A, B), 12)
DEFINE_BLEND16(hardlight, (B < 2048) ? MULTIPLY(2, B, A) : SCREEN(2, B, A), 12)
@@ -386,7 +386,7 @@ DEFINE_BLEND16(heat, (A == 0) ? 0 : 4095 - FFMIN(((4095 - B) * (4095 - B))
DEFINE_BLEND16(freeze, (B == 0) ? 0 : 4095 - FFMIN(((4095 - A) * (4095 - A)) / B, 4095), 12)
DEFINE_BLEND16(darken, FFMIN(A, B), 12)
DEFINE_BLEND16(lighten, FFMAX(A, B), 12)
-DEFINE_BLEND16(divide, av_clip(B == 0 ? 4095 : 4095 * A / B, 0, 4095), 12)
+DEFINE_BLEND16(divide, (int)av_clip_uintp2(B == 0 ? 4095 : 4095 * A / B, 12), 12)
DEFINE_BLEND16(dodge, DODGE(A, B), 12)
DEFINE_BLEND16(burn, BURN(A, B), 12)
DEFINE_BLEND16(softlight, (A > 2047) ? B + (4095 - B) * (A - 2047.5) / 2047.5 * (0.5 - fabs(B - 2047.5) / 4095): B - B * ((2047.5 - A) / 2047.5) * (0.5 - fabs(B - 2047.5)/4095), 12)
@@ -399,7 +399,7 @@ DEFINE_BLEND16(and, A & B, 12)
DEFINE_BLEND16(or, A | B, 12)
DEFINE_BLEND16(xor, A ^ B, 12)
DEFINE_BLEND16(vividlight, (A < 2048) ? BURN(2 * A, B) : DODGE(2 * (A - 2048), B), 12)
-DEFINE_BLEND16(linearlight,av_clip((B < 2048) ? B + 2 * A - 4095 : B + 2 * (A - 2048), 0, 4095), 12)
+DEFINE_BLEND16(linearlight,(int)av_clip_uintp2((B < 2048) ? B + 2 * A - 4095 : B + 2 * (A - 2048), 12), 12)
#define DEFINE_BLEND_EXPR(type, name, div) \
static void blend_expr_## name(const uint8_t *_top, ptrdiff_t top_linesize, \