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
22073@item chroma-derived-c22073@item chroma-derived-c
22074@item ictcp22074@item ictcp
22075@end table22075@end table
22076
22077@item chroma_location
22078Set the chroma sample location.
22079Available values are:
22080
22081@table @samp
22082@item auto
22083Keep 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
22076@end table22093@end table
22077 22094
22078@section sharpen_npp22095@section sharpen_npp
libavfilter/vf_setparams.c+16−3
@@ -41,6 +41,7 @@ typedef struct SetParamsContext { · 40 unmodified lines
41 int color_primaries;41 int color_primaries;
42 int color_trc;42 int color_trc;
43 int colorspace;43 int colorspace;
44 int chroma_location;
44} SetParamsContext;45} SetParamsContext;
45 46
46#define OFFSET(x) offsetof(SetParamsContext, x)47#define OFFSET(x) offsetof(SetParamsContext, x)
@@ -119,6 +120,17 @@ static const AVOption setparams_options[] = { · 72 unmodified lines
119 {"chroma-derived-c", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_CHROMA_DERIVED_CL}, INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"},120 {"chroma-derived-c", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_CHROMA_DERIVED_CL}, INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"},
120 {"ictcp", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_ICTCP}, INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"},121 {"ictcp", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_ICTCP}, INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"},
121 {"ipt-c2", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_IPT_C2}, INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"},122 {"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"},
122 {NULL}134 {NULL}
123};135};
124 136
@@ -174,17 +186,18 @@ FF_ENABLE_DEPRECATION_WARNINGS · 49 unmodified lines
174 frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;186 frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
175 }187 }
176 188
177 /* set range */189 /* set straightforward parameters */
178 if (s->color_range >= 0)190 if (s->color_range >= 0)
179 frame->color_range = s->color_range;191 frame->color_range = s->color_range;
180
181 /* set color prim, trc, space */
182 if (s->color_primaries >= 0)192 if (s->color_primaries >= 0)
183 frame->color_primaries = s->color_primaries;193 frame->color_primaries = s->color_primaries;
184 if (s->color_trc >= 0)194 if (s->color_trc >= 0)
185 frame->color_trc = s->color_trc;195 frame->color_trc = s->color_trc;
186 if (s->colorspace >= 0)196 if (s->colorspace >= 0)
187 frame->colorspace = s->colorspace;197 frame->colorspace = s->colorspace;
198 if (s->chroma_location >= 0)
199 frame->chroma_location = s->chroma_location;
200
188 return ff_filter_frame(ctx->outputs[0], frame);201 return ff_filter_frame(ctx->outputs[0], frame);
189}202}
190 203

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