1 /*
2 * Copyright (c) 2010 Bobby Bingham
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 /**
22 * @file
23 * aspect ratio modification video filters
24 */
25
27
34
38
40 "w",
41 "h",
42 "a", "dar",
43 "sar",
44 "hsub",
45 "vsub",
46 NULL
47 };
48
57 };
58
64 #if FF_API_OLD_FILTER_OPTS
66 #endif
69
71 {
74
75 #if FF_API_OLD_FILTER_OPTS
77 double num;
79 "num:den syntax is deprecated, please use num/den or named options instead\n");
81 NULL, NULL, NULL, NULL, NULL, 0, ctx);
82 if (ret < 0) {
85 }
87 }
88 #endif
89
90 return 0;
91 }
92
94 {
96
99 }
100
101 #define OFFSET(x) offsetof(AspectContext, x)
102 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
103
105 {
108 } else {
110 }
111 }
112
114 {
118 double var_values[
VARS_NB], res;
120
121 var_values[
VAR_W] = inlink->
w;
122 var_values[
VAR_H] = inlink->
h;
123 var_values[
VAR_A] = (double) inlink->
w / inlink->
h;
129
130 /* evaluate new aspect ratio*/
133 NULL, NULL, NULL, NULL, NULL, 0, ctx);
134 if (ret < 0) {
136 } else
138
139 if (ret < 0) {
141 "Error when evaluating the expression '%s'\n", s->
ratio_expr);
143 }
144 if (aspect_ratio->
num < 0 || aspect_ratio->
den <= 0) {
146 "Invalid string '%s' for aspect ratio\n", s->
ratio_expr);
148 }
149 return 0;
150 }
151
152 #if CONFIG_SETDAR_FILTER
153
155 {
161
162 #if FF_API_OLD_FILTER_OPTS
164 #endif
167 #if FF_API_OLD_FILTER_OPTS
168 }
169 #endif
170
174 s->
dar.
den * inlink->
w, INT_MAX);
177 } else {
180 }
181
184 inlink->
w, inlink->
h, old_dar.
num, old_dar.
den, old_sar.
num, old_sar.
den,
186
187 return 0;
188 }
189
190 static const AVOption setdar_options[] = {
194 #if FF_API_OLD_FILTER_OPTS
196 #endif
197 {
"max",
"set max value for nominator or denominator in the ratio",
OFFSET(max),
AV_OPT_TYPE_INT, {.i64=100}, 1, INT_MAX,
FLAGS },
198 { NULL }
199 };
200
202
203 static const AVFilterPad avfilter_vf_setdar_inputs[] = {
204 {
207 .config_props = setdar_config_props,
209 },
210 { NULL }
211 };
212
213 static const AVFilterPad avfilter_vf_setdar_outputs[] = {
214 {
217 },
218 { NULL }
219 };
220
226 .priv_class = &setdar_class,
227 .
inputs = avfilter_vf_setdar_inputs,
228 .
outputs = avfilter_vf_setdar_outputs,
229 };
230
231 #endif /* CONFIG_SETDAR_FILTER */
232
233 #if CONFIG_SETSAR_FILTER
234
236 {
241
242 #if FF_API_OLD_FILTER_OPTS
244 #endif
247 #if FF_API_OLD_FILTER_OPTS
248 }
249 #endif
250
252
256 inlink->
w, inlink->
h, old_sar.
num, old_sar.
den, old_dar.
num, old_dar.
den,
258
259 return 0;
260 }
261
262 static const AVOption setsar_options[] = {
266 #if FF_API_OLD_FILTER_OPTS
268 #endif
269 {
"max",
"set max value for nominator or denominator in the ratio",
OFFSET(max),
AV_OPT_TYPE_INT, {.i64=100}, 1, INT_MAX,
FLAGS },
270 { NULL }
271 };
272
274
275 static const AVFilterPad avfilter_vf_setsar_inputs[] = {
276 {
279 .config_props = setsar_config_props,
281 },
282 { NULL }
283 };
284
285 static const AVFilterPad avfilter_vf_setsar_outputs[] = {
286 {
289 },
290 { NULL }
291 };
292
298 .priv_class = &setsar_class,
299 .
inputs = avfilter_vf_setsar_inputs,
300 .
outputs = avfilter_vf_setsar_outputs,
301 };
302
303 #endif /* CONFIG_SETSAR_FILTER */