ff_filter/blend.rs
1//! Blend mode definitions for video compositing operations.
2
3// ── BlendMode ────────────────────────────────────────────────────────────────
4
5/// Specifies how two video layers are combined during compositing.
6///
7/// Each variant corresponds **1:1** to a mode of `FFmpeg`'s `blend` filter
8/// `all_mode` option (40 modes total, matching `vf_blend.c`). [`BlendMode::Normal`]
9/// is the standard alpha-over composite, built via the `overlay` filter; every
10/// other variant is built via `blend all_mode=<token>`. The canonical token for
11/// each variant is provided by `FfmpegToken` (all variants map to a valid token).
12///
13/// For **Porter-Duff alpha compositing** (over / under / in / out / atop / xor)
14/// use [`CompositeOp`](crate::CompositeOp) instead — that is a separate concept
15/// (alpha channel operators, not pixel-value blend modes). Note `BlendMode::Xor`
16/// is the *arithmetic* `xor` blend, distinct from `CompositeOp::Xor`.
17#[derive(Debug, Clone, Copy, PartialEq, Eq)]
18pub enum BlendMode {
19 // ── Standard modes ────────────────────────────────────────────────────
20 /// Standard alpha-over composite (`top * opacity + bottom * (1 − opacity)`).
21 /// Built via `overlay=format=auto:shortest=1` (token: `normal`).
22 Normal,
23 /// Multiply per-channel pixel values; darkens. `blend all_mode=multiply`.
24 Multiply,
25 /// Inverse of multiply; lightens. `blend all_mode=screen`.
26 Screen,
27 /// Multiply/Screen by base luminance. `blend all_mode=overlay`.
28 Overlay,
29 /// Gentle contrast enhancement. `blend all_mode=softlight`.
30 SoftLight,
31 /// Harsher Overlay driven by the top layer. `blend all_mode=hardlight`.
32 HardLight,
33 /// Brightens the base. `blend all_mode=dodge`.
34 ColorDodge,
35 /// Darkens the base. `blend all_mode=burn`.
36 ColorBurn,
37 /// Keeps the darker pixel per channel. `blend all_mode=darken`.
38 Darken,
39 /// Keeps the lighter pixel per channel. `blend all_mode=lighten`.
40 Lighten,
41 /// Per-channel absolute difference. `blend all_mode=difference`.
42 Difference,
43 /// Lower-contrast Difference. `blend all_mode=exclusion`.
44 Exclusion,
45 /// Linear addition, clamped. `blend all_mode=addition`.
46 Add,
47 /// Linear subtraction, clamped. `blend all_mode=subtract`.
48 Subtract,
49
50 // ── Additional FFmpeg blend modes ─────────────────────────────────────
51 /// Bitwise AND of the two pixels. `blend all_mode=and`.
52 And,
53 /// Arithmetic mean of the two pixels. `blend all_mode=average`.
54 Average,
55 /// Bleach-bypass look. `blend all_mode=bleach`.
56 Bleach,
57 /// Per-channel division. `blend all_mode=divide`.
58 Divide,
59 /// Extremity (distance from mid-grey). `blend all_mode=extremity`.
60 Extremity,
61 /// Freeze. `blend all_mode=freeze`.
62 Freeze,
63 /// Geometric mean. `blend all_mode=geometric`.
64 Geometric,
65 /// Glow. `blend all_mode=glow`.
66 Glow,
67 /// Grain extract (alias of `difference128`). `blend all_mode=grainextract`.
68 GrainExtract,
69 /// Grain merge (alias of `addition128`). `blend all_mode=grainmerge`.
70 GrainMerge,
71 /// Hard mix. `blend all_mode=hardmix`.
72 HardMix,
73 /// Hard overlay. `blend all_mode=hardoverlay`.
74 HardOverlay,
75 /// Harmonic mean. `blend all_mode=harmonic`.
76 Harmonic,
77 /// Heat. `blend all_mode=heat`.
78 Heat,
79 /// Linear interpolation. `blend all_mode=interpolate`.
80 Interpolate,
81 /// Linear light. `blend all_mode=linearlight`.
82 LinearLight,
83 /// Multiply scaled by 128. `blend all_mode=multiply128`.
84 Multiply128,
85 /// Negation. `blend all_mode=negation`.
86 Negation,
87 /// Bitwise OR of the two pixels. `blend all_mode=or`.
88 Or,
89 /// Phoenix. `blend all_mode=phoenix`.
90 Phoenix,
91 /// Pin light. `blend all_mode=pinlight`.
92 PinLight,
93 /// Reflect. `blend all_mode=reflect`.
94 Reflect,
95 /// Soft difference. `blend all_mode=softdifference`.
96 SoftDifference,
97 /// Stain. `blend all_mode=stain`.
98 Stain,
99 /// Vivid light. `blend all_mode=vividlight`.
100 VividLight,
101 /// Arithmetic XOR of the two pixels. `blend all_mode=xor`.
102 /// Distinct from the Porter-Duff [`CompositeOp::Xor`](crate::CompositeOp).
103 Xor,
104}