[FFmpeg-cvslog] avfilter: use av_clip_uintp2 instead of av_clip for 10b and 12b
Martin Vignali
git at videolan.org
Sat Nov 17 19:07:08 EET 2018
ffmpeg | branch: master | Martin Vignali <martin.vignali at gmail.com> | Sat Nov 17 17:57:27 2018 +0100| [d3621b232142165d6641708de14c51b78bf2b2df] | committer: Paul B Mahol
avfilter: use av_clip_uintp2 instead of av_clip for 10b and 12b
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d3621b232142165d6641708de14c51b78bf2b2df
---
libavfilter/vf_blend.c | 20 ++++++++++----------
1 file 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, \
More information about the ffmpeg-cvslog
mailing list