avfilter/vf_blend: add hardmix mode

Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
Paul B Mahol 2015-06-02 19:12:45 +00:00
parent 20cea0c7de
commit 3e04746ec3
2 changed files with 5 additions and 0 deletions

View File

@ -2749,6 +2749,7 @@ Available values for component modes are:
@item dodge @item dodge
@item exclusion @item exclusion
@item hardlight @item hardlight
@item hardmix
@item lighten @item lighten
@item multiply @item multiply
@item negation @item negation

View File

@ -59,6 +59,7 @@ enum BlendMode {
BLEND_SUBTRACT, BLEND_SUBTRACT,
BLEND_VIVIDLIGHT, BLEND_VIVIDLIGHT,
BLEND_XOR, BLEND_XOR,
BLEND_HARDMIX,
BLEND_NB BLEND_NB
}; };
@ -117,6 +118,7 @@ typedef struct {
{ "dodge", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DODGE}, 0, 0, FLAGS, "mode" },\ { "dodge", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DODGE}, 0, 0, FLAGS, "mode" },\
{ "exclusion", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_EXCLUSION}, 0, 0, FLAGS, "mode" },\ { "exclusion", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_EXCLUSION}, 0, 0, FLAGS, "mode" },\
{ "hardlight", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HARDLIGHT}, 0, 0, FLAGS, "mode" },\ { "hardlight", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HARDLIGHT}, 0, 0, FLAGS, "mode" },\
{ "hardmix", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HARDMIX}, 0, 0, FLAGS, "mode" },\
{ "lighten", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_LIGHTEN}, 0, 0, FLAGS, "mode" },\ { "lighten", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_LIGHTEN}, 0, 0, FLAGS, "mode" },\
{ "multiply", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_MULTIPLY}, 0, 0, FLAGS, "mode" },\ { "multiply", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_MULTIPLY}, 0, 0, FLAGS, "mode" },\
{ "negation", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_NEGATION}, 0, 0, FLAGS, "mode" },\ { "negation", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_NEGATION}, 0, 0, FLAGS, "mode" },\
@ -201,6 +203,7 @@ DEFINE_BLEND(difference128, av_clip_uint8(128 + A - B))
DEFINE_BLEND(screen, SCREEN(1, A, B)) DEFINE_BLEND(screen, SCREEN(1, A, B))
DEFINE_BLEND(overlay, (A < 128) ? MULTIPLY(2, A, B) : SCREEN(2, A, B)) DEFINE_BLEND(overlay, (A < 128) ? MULTIPLY(2, A, B) : SCREEN(2, A, B))
DEFINE_BLEND(hardlight, (B < 128) ? MULTIPLY(2, B, A) : SCREEN(2, B, A)) DEFINE_BLEND(hardlight, (B < 128) ? MULTIPLY(2, B, A) : SCREEN(2, B, A))
DEFINE_BLEND(hardmix, (A < (255 - B)) ? 0: 255)
DEFINE_BLEND(darken, FFMIN(A, B)) DEFINE_BLEND(darken, FFMIN(A, B))
DEFINE_BLEND(lighten, FFMAX(A, B)) DEFINE_BLEND(lighten, FFMAX(A, B))
DEFINE_BLEND(divide, av_clip_uint8(((float)A / ((float)B) * 255))) DEFINE_BLEND(divide, av_clip_uint8(((float)A / ((float)B) * 255)))
@ -326,6 +329,7 @@ static av_cold int init(AVFilterContext *ctx)
case BLEND_DODGE: param->blend = blend_dodge; break; case BLEND_DODGE: param->blend = blend_dodge; break;
case BLEND_EXCLUSION: param->blend = blend_exclusion; break; case BLEND_EXCLUSION: param->blend = blend_exclusion; break;
case BLEND_HARDLIGHT: param->blend = blend_hardlight; break; case BLEND_HARDLIGHT: param->blend = blend_hardlight; break;
case BLEND_HARDMIX: param->blend = blend_hardmix; break;
case BLEND_LIGHTEN: param->blend = blend_lighten; break; case BLEND_LIGHTEN: param->blend = blend_lighten; break;
case BLEND_MULTIPLY: param->blend = blend_multiply; break; case BLEND_MULTIPLY: param->blend = blend_multiply; break;
case BLEND_NEGATION: param->blend = blend_negation; break; case BLEND_NEGATION: param->blend = blend_negation; break;