1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include <string.h>
20
23
30
33
35
37
38 char *
w_expr;
// width expression string
39 char *
h_expr;
// height expression string
40
43
49
55
57 {
59 #define D(name) case VA_FILTER_SCALING_ ## name: return #name
64 #undef D
65 default:
66 return "Invalid";
67 }
68 }
69
70
72 {
77 int err;
78
83 return err;
84
86 ctx->force_original_aspect_ratio,
ctx->force_divisible_by);
87
89 if (err < 0)
90 return err;
91
92 if (
inlink->sample_aspect_ratio.num)
94 else
96
97 return 0;
98 }
99
101 {
107 VAProcPipelineParameterBuffer params;
108 int err;
109
113
116
122 }
123
125 if (err < 0)
127
138
141 if (err < 0)
143
144 params.filter_flags |=
ctx->mode;
145
147 if (err < 0)
149
151
156
158
162 return err;
163 }
164
166 {
169
172
173 if (
ctx->output_format_string) {
178 }
179 } else {
180 // Use the input format once that is configured.
182 }
183
184 #define STRING_OPTION(var_name, func_name, default_value) do { \
185 if (ctx->var_name ## _string) { \
186 int var = av_ ## func_name ## _from_name(ctx->var_name ## _string); \
187 if (var < 0) { \
188 av_log(avctx, AV_LOG_ERROR, "Invalid %s.\n", #var_name); \
189 return AVERROR(EINVAL); \
190 } \
191 ctx->var_name = var; \
192 } else { \
193 ctx->var_name = default_value; \
194 } \
195 } while (0)
196
201
202 return 0;
203 }
204
205 #define OFFSET(x) offsetof(ScaleVAAPIContext, x)
206 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
208 { "w", "Output video width",
210 { "h", "Output video height",
212 { "format", "Output video format (software format of hardware frames)",
214 { "mode", "Scaling mode",
216 0, VA_FILTER_SCALING_NL_ANAMORPHIC,
FLAGS,
"mode" },
217 { "default", "Use the default (depend on the driver) scaling algorithm",
219 { "fast", "Use fast scaling algorithm",
221 { "hq", "Use high quality scaling algorithm",
223 { "nl_anamorphic", "Use nolinear anamorphic scaling algorithm",
225
226 // These colour properties match the ones of the same name in vf_scale.
227 { "out_color_matrix", "Output colour matrix coefficient set",
229 { "out_range", "Output colour range",
232 { "full", "Full range",
234 { "limited", "Limited range",
236 { "jpeg", "Full range",
238 { "mpeg", "Limited range",
240 { "tv", "Limited range",
242 { "pc", "Full range",
244 // These colour properties are new here.
245 { "out_color_primaries", "Output colour primaries",
248 { "out_color_transfer", "Output colour transfer characteristics",
251 { "out_chroma_location", "Output chroma sample location",
254 {
"force_original_aspect_ratio",
"decrease or increase w/h if necessary to keep the original AR",
OFFSET(force_original_aspect_ratio),
AV_OPT_TYPE_INT, { .i64 = 0}, 0, 2,
FLAGS,
"force_oar" },
258 {
"force_divisible_by",
"enforce that the output resolution is divisible by a defined integer when force_original_aspect_ratio is used",
OFFSET(force_divisible_by),
AV_OPT_TYPE_INT, { .i64 = 1}, 1, 256,
FLAGS },
259
261 };
262
264
266 {
271 },
272 };
273
275 {
279 },
280 };
281
283 .
name =
"scale_vaapi",
291 .priv_class = &scale_vaapi_class,
293 };