History

avfilter/vf_setparams: allow setting chroma location

Shockingly, there isn't currently _any_ filter for overriding this.

Niklas Haas committed 2 years ago

Commit 201f1cb1 parent 3e064f52 files · +33 −3Browse files

Unified · Split

2 files
  1. doc/filters.texi +17 −0
  2. libavfilter/vf_setparams.c +16 −3
doc/filters.texi+17−0
@@ -22073,6 +22073,23 @@ Keep the same colorspace property (default). · 22072 unmodified lines
2207322073 @item chroma-derived-c
2207422074 @item ictcp
2207522075 @end table
22076+
22077+@item chroma_location
22078+Set the chroma sample location.
22079+Available values are:
22080+
22081+@table @samp
22082+@item auto
22083+Keep the same chroma location (default).
22084+
22085+@item unspecified, unknown
22086+@item left
22087+@item center
22088+@item topleft
22089+@item top
22090+@item bottomleft
22091+@item bottom
22092+@end table
2207622093 @end table
2207722094
2207822095 @section sharpen_npp
libavfilter/vf_setparams.c+16−3
@@ -41,6 +41,7 @@ typedef struct SetParamsContext { · 40 unmodified lines
4141 int color_primaries;
4242 int color_trc;
4343 int colorspace;
44+ int chroma_location;
4445 } SetParamsContext;
4546
4647 #define OFFSET(x) offsetof(SetParamsContext, x)
@@ -119,6 +120,17 @@ static const AVOption setparams_options[] = { · 72 unmodified lines
119120 {"chroma-derived-c", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_CHROMA_DERIVED_CL}, INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"},
120121 {"ictcp", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_ICTCP}, INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"},
121122 {"ipt-c2", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_IPT_C2}, INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"},
123+
124+ {"chroma_location", "select chroma sample location", OFFSET(chroma_location), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCHROMA_LOC_NB-1, FLAGS, .unit = "chroma_location"},
125+ {"auto", "keep the same chroma location", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, FLAGS, .unit = "chroma_location"},
126+ {"unspecified", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_UNSPECIFIED}, 0, 0, FLAGS, .unit = "chroma_location"},
127+ {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_UNSPECIFIED}, 0, 0, FLAGS, .unit = "chroma_location"},
128+ {"left", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_LEFT}, 0, 0, FLAGS, .unit = "chroma_location"},
129+ {"center", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_CENTER}, 0, 0, FLAGS, .unit = "chroma_location"},
130+ {"topleft", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_TOPLEFT}, 0, 0, FLAGS, .unit = "chroma_location"},
131+ {"top", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_TOP}, 0, 0, FLAGS, .unit = "chroma_location"},
132+ {"bottomleft", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_BOTTOMLEFT}, 0, 0, FLAGS, .unit = "chroma_location"},
133+ {"bottom", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_BOTTOM}, 0, 0, FLAGS, .unit = "chroma_location"},
122134 {NULL}
123135 };
124136
@@ -174,17 +186,18 @@ FF_ENABLE_DEPRECATION_WARNINGS · 49 unmodified lines
174186 frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
175187 }
176188
177− /* set range */
189+ /* set straightforward parameters */
178190 if (s->color_range >= 0)
179191 frame->color_range = s->color_range;
180−
181− /* set color prim, trc, space */
182192 if (s->color_primaries >= 0)
183193 frame->color_primaries = s->color_primaries;
184194 if (s->color_trc >= 0)
185195 frame->color_trc = s->color_trc;
186196 if (s->colorspace >= 0)
187197 frame->colorspace = s->colorspace;
198+ if (s->chroma_location >= 0)
199+ frame->chroma_location = s->chroma_location;
200+
188201 return ff_filter_frame(ctx->outputs[0], frame);
189202 }
190203

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t