Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * Copyright (c) 2012 Stefano Sabatini | ||
3 | * | ||
4 | * This file is part of FFmpeg. | ||
5 | * | ||
6 | * FFmpeg is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2.1 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * FFmpeg is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * Lesser General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU Lesser General Public | ||
17 | * License along with FFmpeg; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #include "config_components.h" | ||
22 | |||
23 | #include "libavutil/pixfmt.h" | ||
24 | #include "libavutil/opt.h" | ||
25 | #include "avfilter.h" | ||
26 | #include "filters.h" | ||
27 | #include "formats.h" | ||
28 | #include "video.h" | ||
29 | |||
30 | enum SetFieldMode { | ||
31 | MODE_AUTO = -1, | ||
32 | MODE_BFF, | ||
33 | MODE_TFF, | ||
34 | MODE_PROG, | ||
35 | }; | ||
36 | |||
37 | typedef struct SetParamsContext { | ||
38 | const AVClass *class; | ||
39 | int field_mode; | ||
40 | int color_range; | ||
41 | int color_primaries; | ||
42 | int color_trc; | ||
43 | int colorspace; | ||
44 | int chroma_location; | ||
45 | } SetParamsContext; | ||
46 | |||
47 | #define OFFSET(x) offsetof(SetParamsContext, x) | ||
48 | #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM | ||
49 | |||
50 | static const AVOption setparams_options[] = { | ||
51 | {"field_mode", "select interlace mode", OFFSET(field_mode), AV_OPT_TYPE_INT, {.i64=MODE_AUTO}, -1, MODE_PROG, FLAGS, .unit = "mode"}, | ||
52 | {"auto", "keep the same input field", 0, AV_OPT_TYPE_CONST, {.i64=MODE_AUTO}, 0, 0, FLAGS, .unit = "mode"}, | ||
53 | {"bff", "mark as bottom-field-first", 0, AV_OPT_TYPE_CONST, {.i64=MODE_BFF}, 0, 0, FLAGS, .unit = "mode"}, | ||
54 | {"tff", "mark as top-field-first", 0, AV_OPT_TYPE_CONST, {.i64=MODE_TFF}, 0, 0, FLAGS, .unit = "mode"}, | ||
55 | {"prog", "mark as progressive", 0, AV_OPT_TYPE_CONST, {.i64=MODE_PROG}, 0, 0, FLAGS, .unit = "mode"}, | ||
56 | |||
57 | {"range", "select color range", OFFSET(color_range), AV_OPT_TYPE_INT, {.i64=-1},-1, AVCOL_RANGE_NB-1, FLAGS, .unit = "range"}, | ||
58 | {"auto", "keep the same color range", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, FLAGS, .unit = "range"}, | ||
59 | {"unspecified", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, FLAGS, .unit = "range"}, | ||
60 | {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, FLAGS, .unit = "range"}, | ||
61 | {"limited", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, FLAGS, .unit = "range"}, | ||
62 | {"tv", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, FLAGS, .unit = "range"}, | ||
63 | {"mpeg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, FLAGS, .unit = "range"}, | ||
64 | {"full", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, FLAGS, .unit = "range"}, | ||
65 | {"pc", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, FLAGS, .unit = "range"}, | ||
66 | {"jpeg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, FLAGS, .unit = "range"}, | ||
67 | |||
68 | {"color_primaries", "select color primaries", OFFSET(color_primaries), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_PRI_NB-1, FLAGS, .unit = "color_primaries"}, | ||
69 | {"auto", "keep the same color primaries", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, FLAGS, .unit = "color_primaries"}, | ||
70 | {"bt709", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_BT709}, 0, 0, FLAGS, .unit = "color_primaries"}, | ||
71 | {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_UNSPECIFIED}, 0, 0, FLAGS, .unit = "color_primaries"}, | ||
72 | {"bt470m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_BT470M}, 0, 0, FLAGS, .unit = "color_primaries"}, | ||
73 | {"bt470bg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_BT470BG}, 0, 0, FLAGS, .unit = "color_primaries"}, | ||
74 | {"smpte170m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE170M}, 0, 0, FLAGS, .unit = "color_primaries"}, | ||
75 | {"smpte240m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE240M}, 0, 0, FLAGS, .unit = "color_primaries"}, | ||
76 | {"film", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_FILM}, 0, 0, FLAGS, .unit = "color_primaries"}, | ||
77 | {"bt2020", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_BT2020}, 0, 0, FLAGS, .unit = "color_primaries"}, | ||
78 | {"smpte428", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE428}, 0, 0, FLAGS, .unit = "color_primaries"}, | ||
79 | {"smpte431", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE431}, 0, 0, FLAGS, .unit = "color_primaries"}, | ||
80 | {"smpte432", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE432}, 0, 0, FLAGS, .unit = "color_primaries"}, | ||
81 | {"jedec-p22", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_JEDEC_P22}, 0, 0, FLAGS, .unit = "color_primaries"}, | ||
82 | {"ebu3213", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_EBU3213}, 0, 0, FLAGS, .unit = "color_primaries"}, | ||
83 | |||
84 | {"color_trc", "select color transfer", OFFSET(color_trc), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_TRC_NB-1, FLAGS, .unit = "color_trc"}, | ||
85 | {"auto", "keep the same color transfer", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, FLAGS, .unit = "color_trc"}, | ||
86 | {"bt709", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_BT709}, 0, 0, FLAGS, .unit = "color_trc"}, | ||
87 | {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_UNSPECIFIED}, 0, 0, FLAGS, .unit = "color_trc"}, | ||
88 | {"bt470m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_GAMMA22}, 0, 0, FLAGS, .unit = "color_trc"}, | ||
89 | {"bt470bg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_GAMMA28}, 0, 0, FLAGS, .unit = "color_trc"}, | ||
90 | {"smpte170m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_SMPTE170M}, 0, 0, FLAGS, .unit = "color_trc"}, | ||
91 | {"smpte240m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_SMPTE240M}, 0, 0, FLAGS, .unit = "color_trc"}, | ||
92 | {"linear", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_LINEAR}, 0, 0, FLAGS, .unit = "color_trc"}, | ||
93 | {"log100", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_LOG}, 0, 0, FLAGS, .unit = "color_trc"}, | ||
94 | {"log316", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_LOG_SQRT}, 0, 0, FLAGS, .unit = "color_trc"}, | ||
95 | {"iec61966-2-4", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_IEC61966_2_4}, 0, 0, FLAGS, .unit = "color_trc"}, | ||
96 | {"bt1361e", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_BT1361_ECG}, 0, 0, FLAGS, .unit = "color_trc"}, | ||
97 | {"iec61966-2-1", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_IEC61966_2_1}, 0, 0, FLAGS, .unit = "color_trc"}, | ||
98 | {"bt2020-10", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_BT2020_10}, 0, 0, FLAGS, .unit = "color_trc"}, | ||
99 | {"bt2020-12", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_BT2020_12}, 0, 0, FLAGS, .unit = "color_trc"}, | ||
100 | {"smpte2084", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_SMPTE2084}, 0, 0, FLAGS, .unit = "color_trc"}, | ||
101 | {"smpte428", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_SMPTE428}, 0, 0, FLAGS, .unit = "color_trc"}, | ||
102 | {"arib-std-b67", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_ARIB_STD_B67}, 0, 0, FLAGS, .unit = "color_trc"}, | ||
103 | |||
104 | {"colorspace", "select colorspace", OFFSET(colorspace), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_SPC_NB-1, FLAGS, .unit = "colorspace"}, | ||
105 | {"auto", "keep the same colorspace", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, FLAGS, .unit = "colorspace"}, | ||
106 | {"gbr", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_RGB}, 0, 0, FLAGS, .unit = "colorspace"}, | ||
107 | {"bt709", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT709}, 0, 0, FLAGS, .unit = "colorspace"}, | ||
108 | {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_UNSPECIFIED}, 0, 0, FLAGS, .unit = "colorspace"}, | ||
109 | {"fcc", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_FCC}, 0, 0, FLAGS, .unit = "colorspace"}, | ||
110 | {"bt470bg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT470BG}, 0, 0, FLAGS, .unit = "colorspace"}, | ||
111 | {"smpte170m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_SMPTE170M}, 0, 0, FLAGS, .unit = "colorspace"}, | ||
112 | {"smpte240m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_SMPTE240M}, 0, 0, FLAGS, .unit = "colorspace"}, | ||
113 | {"ycgco", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_YCGCO}, 0, 0, FLAGS, .unit = "colorspace"}, | ||
114 | {"ycgco-re", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_YCGCO_RE}, 0, 0, FLAGS, .unit = "colorspace"}, | ||
115 | {"ycgco-ro", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_YCGCO_RO}, 0, 0, FLAGS, .unit = "colorspace"}, | ||
116 | {"bt2020nc", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT2020_NCL}, 0, 0, FLAGS, .unit = "colorspace"}, | ||
117 | {"bt2020c", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT2020_CL}, 0, 0, FLAGS, .unit = "colorspace"}, | ||
118 | {"smpte2085", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_SMPTE2085}, 0, 0, FLAGS, .unit = "colorspace"}, | ||
119 | {"chroma-derived-nc", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_CHROMA_DERIVED_NCL},0, 0, FLAGS, .unit = "colorspace"}, | ||
120 | {"chroma-derived-c", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_CHROMA_DERIVED_CL}, 0, 0, FLAGS, .unit = "colorspace"}, | ||
121 | {"ictcp", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_ICTCP}, 0, 0, FLAGS, .unit = "colorspace"}, | ||
122 | {"ipt-c2", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_IPT_C2}, 0, 0, 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"}, | ||
134 | {NULL} | ||
135 | }; | ||
136 | |||
137 | AVFILTER_DEFINE_CLASS(setparams); | ||
138 | |||
139 | ✗ | static int query_formats(const AVFilterContext *ctx, | |
140 | AVFilterFormatsConfig **cfg_in, | ||
141 | AVFilterFormatsConfig **cfg_out) | ||
142 | { | ||
143 | ✗ | const SetParamsContext *s = ctx->priv; | |
144 | int ret; | ||
145 | |||
146 | ✗ | if (s->colorspace >= 0) { | |
147 | ✗ | ret = ff_formats_ref(ff_make_formats_list_singleton(s->colorspace), | |
148 | ✗ | &cfg_out[0]->color_spaces); | |
149 | ✗ | if (ret < 0) | |
150 | ✗ | return ret; | |
151 | } | ||
152 | |||
153 | ✗ | if (s->color_range >= 0) { | |
154 | ✗ | ret = ff_formats_ref(ff_make_formats_list_singleton(s->color_range), | |
155 | ✗ | &cfg_out[0]->color_ranges); | |
156 | ✗ | if (ret < 0) | |
157 | ✗ | return ret; | |
158 | } | ||
159 | |||
160 | ✗ | return 0; | |
161 | } | ||
162 | |||
163 | 262 | static int filter_frame(AVFilterLink *inlink, AVFrame *frame) | |
164 | { | ||
165 | 262 | AVFilterContext *ctx = inlink->dst; | |
166 | 262 | SetParamsContext *s = ctx->priv; | |
167 | |||
168 | /* set field */ | ||
169 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 262 times.
|
262 | if (s->field_mode == MODE_PROG) { |
170 | ✗ | frame->flags &= ~AV_FRAME_FLAG_INTERLACED; | |
171 |
1/2✓ Branch 0 taken 262 times.
✗ Branch 1 not taken.
|
262 | } else if (s->field_mode != MODE_AUTO) { |
172 | 262 | frame->flags |= AV_FRAME_FLAG_INTERLACED; | |
173 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 236 times.
|
262 | if (s->field_mode) |
174 | 26 | frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST; | |
175 | else | ||
176 | 236 | frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST; | |
177 | } | ||
178 | |||
179 | /* set straightforward parameters */ | ||
180 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 262 times.
|
262 | if (s->color_range >= 0) |
181 | ✗ | frame->color_range = s->color_range; | |
182 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 262 times.
|
262 | if (s->color_primaries >= 0) |
183 | ✗ | frame->color_primaries = s->color_primaries; | |
184 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 262 times.
|
262 | if (s->color_trc >= 0) |
185 | ✗ | frame->color_trc = s->color_trc; | |
186 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 262 times.
|
262 | if (s->colorspace >= 0) |
187 | ✗ | frame->colorspace = s->colorspace; | |
188 |
1/2✓ Branch 0 taken 262 times.
✗ Branch 1 not taken.
|
262 | if (s->chroma_location >= 0) |
189 | 262 | frame->chroma_location = s->chroma_location; | |
190 | |||
191 | 262 | return ff_filter_frame(ctx->outputs[0], frame); | |
192 | } | ||
193 | |||
194 | static const AVFilterPad inputs[] = { | ||
195 | { | ||
196 | .name = "default", | ||
197 | .type = AVMEDIA_TYPE_VIDEO, | ||
198 | .filter_frame = filter_frame, | ||
199 | }, | ||
200 | }; | ||
201 | |||
202 | const FFFilter ff_vf_setparams = { | ||
203 | .p.name = "setparams", | ||
204 | .p.description = NULL_IF_CONFIG_SMALL("Force field, or color property for the output video frame."), | ||
205 | .p.priv_class = &setparams_class, | ||
206 | .p.flags = AVFILTER_FLAG_METADATA_ONLY, | ||
207 | .priv_size = sizeof(SetParamsContext), | ||
208 | FILTER_INPUTS(inputs), | ||
209 | FILTER_OUTPUTS(ff_video_default_filterpad), | ||
210 | FILTER_QUERY_FUNC2(query_formats), | ||
211 | }; | ||
212 | |||
213 | #if CONFIG_SETRANGE_FILTER | ||
214 | |||
215 | static const AVOption setrange_options[] = { | ||
216 | {"range", "select color range", OFFSET(color_range), AV_OPT_TYPE_INT, {.i64=-1},-1, AVCOL_RANGE_NB-1, FLAGS, .unit = "range"}, | ||
217 | {"auto", "keep the same color range", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, FLAGS, .unit = "range"}, | ||
218 | {"unspecified", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, FLAGS, .unit = "range"}, | ||
219 | {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, FLAGS, .unit = "range"}, | ||
220 | {"limited", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, FLAGS, .unit = "range"}, | ||
221 | {"tv", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, FLAGS, .unit = "range"}, | ||
222 | {"mpeg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, FLAGS, .unit = "range"}, | ||
223 | {"full", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, FLAGS, .unit = "range"}, | ||
224 | {"pc", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, FLAGS, .unit = "range"}, | ||
225 | {"jpeg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, FLAGS, .unit = "range"}, | ||
226 | {NULL} | ||
227 | }; | ||
228 | |||
229 | AVFILTER_DEFINE_CLASS(setrange); | ||
230 | |||
231 | ✗ | static av_cold int init_setrange(AVFilterContext *ctx) | |
232 | { | ||
233 | ✗ | SetParamsContext *s = ctx->priv; | |
234 | |||
235 | ✗ | s->field_mode = MODE_AUTO;/* set field mode to auto */ | |
236 | ✗ | s->color_primaries = -1; | |
237 | ✗ | s->color_trc = -1; | |
238 | ✗ | s->colorspace = -1; | |
239 | ✗ | return 0; | |
240 | } | ||
241 | |||
242 | const FFFilter ff_vf_setrange = { | ||
243 | .p.name = "setrange", | ||
244 | .p.description = NULL_IF_CONFIG_SMALL("Force color range for the output video frame."), | ||
245 | .p.priv_class = &setrange_class, | ||
246 | .p.flags = AVFILTER_FLAG_METADATA_ONLY, | ||
247 | .priv_size = sizeof(SetParamsContext), | ||
248 | .init = init_setrange, | ||
249 | FILTER_INPUTS(inputs), | ||
250 | FILTER_OUTPUTS(ff_video_default_filterpad), | ||
251 | FILTER_QUERY_FUNC2(query_formats), | ||
252 | }; | ||
253 | #endif /* CONFIG_SETRANGE_FILTER */ | ||
254 | |||
255 | #if CONFIG_SETFIELD_FILTER | ||
256 | static const AVOption setfield_options[] = { | ||
257 | {"mode", "select interlace mode", OFFSET(field_mode), AV_OPT_TYPE_INT, {.i64=MODE_AUTO}, -1, MODE_PROG, FLAGS, .unit = "mode"}, | ||
258 | {"auto", "keep the same input field", 0, AV_OPT_TYPE_CONST, {.i64=MODE_AUTO}, 0, 0, FLAGS, .unit = "mode"}, | ||
259 | {"bff", "mark as bottom-field-first", 0, AV_OPT_TYPE_CONST, {.i64=MODE_BFF}, 0, 0, FLAGS, .unit = "mode"}, | ||
260 | {"tff", "mark as top-field-first", 0, AV_OPT_TYPE_CONST, {.i64=MODE_TFF}, 0, 0, FLAGS, .unit = "mode"}, | ||
261 | {"prog", "mark as progressive", 0, AV_OPT_TYPE_CONST, {.i64=MODE_PROG}, 0, 0, FLAGS, .unit = "mode"}, | ||
262 | {NULL} | ||
263 | }; | ||
264 | |||
265 | AVFILTER_DEFINE_CLASS(setfield); | ||
266 | |||
267 | 324 | static av_cold int init_setfield(AVFilterContext *ctx) | |
268 | { | ||
269 | 324 | SetParamsContext *s = ctx->priv; | |
270 | |||
271 | 324 | s->color_range = -1;/* set range mode to auto */ | |
272 | 324 | s->color_primaries = -1; | |
273 | 324 | s->color_trc = -1; | |
274 | 324 | s->colorspace = -1; | |
275 | 324 | return 0; | |
276 | } | ||
277 | |||
278 | const FFFilter ff_vf_setfield = { | ||
279 | .p.name = "setfield", | ||
280 | .p.description = NULL_IF_CONFIG_SMALL("Force field for the output video frame."), | ||
281 | .p.priv_class = &setfield_class, | ||
282 | .p.flags = AVFILTER_FLAG_METADATA_ONLY, | ||
283 | .priv_size = sizeof(SetParamsContext), | ||
284 | .init = init_setfield, | ||
285 | FILTER_INPUTS(inputs), | ||
286 | FILTER_OUTPUTS(ff_video_default_filterpad), | ||
287 | }; | ||
288 | #endif /* CONFIG_SETFIELD_FILTER */ | ||
289 |