[FFmpeg-devel] [PATCH 11/12] avfilter/vf_setparams: add alpha_mode parameter
Niklas Haas
ffmpeg at haasn.xyz
Wed Feb 19 22:45:47 EET 2025
From: Niklas Haas <git at haasn.dev>
---
doc/filters.texi | 13 +++++++++++++
libavfilter/vf_setparams.c | 10 ++++++++++
2 files changed, 23 insertions(+)
diff --git a/doc/filters.texi b/doc/filters.texi
index fa23c10b2d..6e8272fd81 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -22231,6 +22231,19 @@ Keep the same chroma location (default).
@item bottomleft
@item bottom
@end table
+
+ at item alpha_mode
+Set the alpha moda.
+Available values are:
+
+ at table @samp
+ at item auto
+Keep the same alpha mode (default).
+
+ at item unspecified, unknown
+ at item premultiplied
+ at item straight
+ at end table
@end table
@section sharpen_npp
diff --git a/libavfilter/vf_setparams.c b/libavfilter/vf_setparams.c
index 34583b1d10..01902da763 100644
--- a/libavfilter/vf_setparams.c
+++ b/libavfilter/vf_setparams.c
@@ -42,6 +42,7 @@ typedef struct SetParamsContext {
int color_trc;
int colorspace;
int chroma_location;
+ int alpha_mode;
} SetParamsContext;
#define OFFSET(x) offsetof(SetParamsContext, x)
@@ -131,6 +132,13 @@ static const AVOption setparams_options[] = {
{"top", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_TOP}, 0, 0, FLAGS, .unit = "chroma_location"},
{"bottomleft", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_BOTTOMLEFT}, 0, 0, FLAGS, .unit = "chroma_location"},
{"bottom", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_BOTTOM}, 0, 0, FLAGS, .unit = "chroma_location"},
+
+ {"alpha_mode", "select alpha moda", OFFSET(alpha_mode), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVALPHA_MODE_NB-1, FLAGS, .unit = "alpha_mode"},
+ {"auto", "keep the same alpha mode", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, FLAGS, .unit = "alpha_mode"},
+ {"unspecified", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVALPHA_MODE_UNSPECIFIED}, 0, 0, FLAGS, .unit = "alpha_mode"},
+ {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVALPHA_MODE_UNSPECIFIED}, 0, 0, FLAGS, .unit = "alpha_mode"},
+ {"premultiplied", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVALPHA_MODE_PREMULTIPLIED}, 0, 0, FLAGS, .unit = "alpha_mode"},
+ {"straight", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVALPHA_MODE_STRAIGHT}, 0, 0, FLAGS, .unit = "alpha_mode"},
{NULL}
};
@@ -198,6 +206,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
frame->colorspace = s->colorspace;
if (s->chroma_location >= 0)
frame->chroma_location = s->chroma_location;
+ if (s->alpha_mode >= 0)
+ frame->alpha_mode = s->alpha_mode;
return ff_filter_frame(ctx->outputs[0], frame);
}
--
2.47.0
More information about the ffmpeg-devel
mailing list