Browse code

avfilter/vf_blend: add extremity blend mode

Signed-off-by: Paul B Mahol <onemda@gmail.com>

Paul B Mahol authored on 2017/06/25 23:39:10
Showing 3 changed files
... ...
@@ -4859,6 +4859,7 @@ Available values for component modes are:
4859 4859
 @item dodge
4860 4860
 @item freeze
4861 4861
 @item exclusion
4862
+@item extremity
4862 4863
 @item glow
4863 4864
 @item hardlight
4864 4865
 @item hardmix
... ...
@@ -58,6 +58,7 @@ enum BlendMode {
58 58
     BLEND_MULTIPLY128,
59 59
     BLEND_HEAT,
60 60
     BLEND_FREEZE,
61
+    BLEND_EXTREMITY,
61 62
     BLEND_NB
62 63
 };
63 64
 
... ...
@@ -76,6 +76,7 @@ typedef struct ThreadData {
76 76
     { "divide",     "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DIVIDE},     0, 0, FLAGS, "mode" },\
77 77
     { "dodge",      "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DODGE},      0, 0, FLAGS, "mode" },\
78 78
     { "exclusion",  "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_EXCLUSION},  0, 0, FLAGS, "mode" },\
79
+    { "extremity",  "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_EXTREMITY},  0, 0, FLAGS, "mode" },\
79 80
     { "freeze",     "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_FREEZE},     0, 0, FLAGS, "mode" },\
80 81
     { "glow",       "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_GLOW},       0, 0, FLAGS, "mode" },\
81 82
     { "hardlight",  "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HARDLIGHT},  0, 0, FLAGS, "mode" },\
... ...
@@ -241,6 +242,7 @@ DEFINE_BLEND8(subtract,   FFMAX(0, A - B))
241 241
 DEFINE_BLEND8(multiply,   MULTIPLY(1, A, B))
242 242
 DEFINE_BLEND8(multiply128,av_clip_uint8((A - 128) * B / 32. + 128))
243 243
 DEFINE_BLEND8(negation,   255 - FFABS(255 - A - B))
244
+DEFINE_BLEND8(extremity,  FFABS(255 - A - B))
244 245
 DEFINE_BLEND8(difference, FFABS(A - B))
245 246
 DEFINE_BLEND8(difference128, av_clip_uint8(128 + A - B))
246 247
 DEFINE_BLEND8(screen,     SCREEN(1, A, B))
... ...
@@ -283,6 +285,7 @@ DEFINE_BLEND16(subtract,   FFMAX(0, A - B))
283 283
 DEFINE_BLEND16(multiply,   MULTIPLY(1, A, B))
284 284
 DEFINE_BLEND16(multiply128, av_clip_uint16((A - 32768) * B / 8192. + 32768))
285 285
 DEFINE_BLEND16(negation,   65535 - FFABS(65535 - A - B))
286
+DEFINE_BLEND16(extremity,  FFABS(65535 - A - B))
286 287
 DEFINE_BLEND16(difference, FFABS(A - B))
287 288
 DEFINE_BLEND16(difference128, av_clip_uint16(32768 + A - B))
288 289
 DEFINE_BLEND16(screen,     SCREEN(1, A, B))
... ...
@@ -457,6 +460,7 @@ void ff_blend_init(FilterParams *param, int is_16bit)
457 457
     case BLEND_DIVIDE:     param->blend = is_16bit ? blend_divide_16bit     : blend_divide_8bit;     break;
458 458
     case BLEND_DODGE:      param->blend = is_16bit ? blend_dodge_16bit      : blend_dodge_8bit;      break;
459 459
     case BLEND_EXCLUSION:  param->blend = is_16bit ? blend_exclusion_16bit  : blend_exclusion_8bit;  break;
460
+    case BLEND_EXTREMITY:  param->blend = is_16bit ? blend_extremity_16bit  : blend_extremity_8bit;  break;
460 461
     case BLEND_FREEZE:     param->blend = is_16bit ? blend_freeze_16bit     : blend_freeze_8bit;     break;
461 462
     case BLEND_GLOW:       param->blend = is_16bit ? blend_glow_16bit       : blend_glow_8bit;       break;
462 463
     case BLEND_HARDLIGHT:  param->blend = is_16bit ? blend_hardlight_16bit  : blend_hardlight_8bit;  break;