1 /*
2 * Copyright (c) 2013 Paul B Mahol
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
29
31 "in_w", "iw",
32 "in_h", "ih",
33 "out_w", "ow",
34 "out_h", "oh",
35 "in",
36 "on",
37 "duration",
38 "pduration",
39 "time",
40 "frame",
41 "zoom",
42 "pzoom",
43 "x", "px",
44 "y", "py",
45 "a",
46 "sar",
47 "dar",
48 "hsub",
49 "vsub",
51 };
52
74 };
75
76 typedef struct ZPcontext {
89
90 #define OFFSET(x) offsetof(ZPContext, x)
91 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
100 };
101
103
105 {
107
109 return 0;
110 }
111
113 {
116
119
120 return 0;
121 }
122
124 {
128 double var_values[
VARS_NB], nb_frames, zoom, dx, dy;
131 int i, k, x,
y, w, h,
ret = 0;
132
141 var_values[
VAR_X] = 0;
142 var_values[
VAR_Y] = 0;
152
156 goto fail;
157
159 for (i = 0; i < nb_frames; i++) {
160 int px[4];
161 int py[4];
165
172 goto fail;
173
174 zoom = av_clipd(zoom, 1, 10);
176 w = in->
width * (1.0 / zoom);
177 h = in->
height * (1.0 / zoom);
178
182 goto fail;
183 x = dx = av_clipd(dx, 0,
FFMAX(in->
width - w, 0));
184 var_values[
VAR_X] = dx;
186
190 goto fail;
191 y = dy = av_clipd(dy, 0,
FFMAX(in->
height - h, 0));
192 var_values[
VAR_Y] = dy;
194
196 if (!out) {
198 goto fail;
199 }
200
202 px[0] = px[3] = x;
203
206
210 goto fail;
211 }
212
213 for (k = 0; in->
data[k]; k++)
214 input[k] = in->
data[k] + py[k] * in->
linesize[k] + px[k];
215
223
225 goto fail;
226
228
231
233 if (ret < 0)
234 break;
235
238 }
239
244
245 fail:
250 }
251
253 {
265 };
266
267
269 return 0;
270 }
271
273 {
275
278 }
279
281 {
285 },
287 };
288
290 {
294 },
296 };
297
302 .priv_class = &zoompan_class,
306 .inputs = inputs,
307 .outputs = outputs,
309 };