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
26 #include "config_components.h"
27
29
36
40
42 "w",
43 "h",
44 "a",
45 "dar",
46 "sar",
47 "hsub",
48 "vsub",
50 };
51
61 };
62
70
72 {
74
75 frame->sample_aspect_ratio =
s->sar;
77 }
78
79 #define OFFSET(x) offsetof(AspectContext, x)
80 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
81
83 {
86 } else {
88 }
89 }
90
92 {
96 double var_values[
VARS_NB], res;
98
103 (
double)
inlink->sample_aspect_ratio.num /
inlink->sample_aspect_ratio.den : 1;
107
108 /* evaluate new aspect ratio*/
114 } else
115 *aspect_ratio =
av_d2q(res,
s->max);
116
119 "Error when evaluating the expression '%s'\n",
s->ratio_expr);
121 }
122 if (aspect_ratio->
num < 0 || aspect_ratio->
den <= 0) {
124 "Invalid string '%s' for aspect ratio\n",
s->ratio_expr);
126 }
127 return 0;
128 }
129
131 {
135 },
136 };
137
138 #if CONFIG_SETDAR_FILTER
139
141 {
149
152
153 if (
s->dar.num &&
s->dar.den) {
156 s->dar.den *
inlink->w, INT_MAX);
159 } else {
162 }
163
168
169 return 0;
170 }
171
172 static const AVOption setdar_options[] = {
178 };
179
181
182 static const AVFilterPad avfilter_vf_setdar_outputs[] = {
183 {
186 .config_props = setdar_config_props,
187 },
188 };
189
194 .priv_class = &setdar_class,
198 };
199
200 #endif /* CONFIG_SETDAR_FILTER */
201
202 #if CONFIG_SETSAR_FILTER
203
205 {
212
215
217
223
224 return 0;
225 }
226
227 static const AVOption setsar_options[] = {
233 };
234
236
237 static const AVFilterPad avfilter_vf_setsar_outputs[] = {
238 {
241 .config_props = setsar_config_props,
242 },
243 };
244
249 .priv_class = &setsar_class,
253 };
254
255 #endif /* CONFIG_SETSAR_FILTER */