FFmpeg
vf_zoompan.c
Go to the documentation of this file.
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 
21 #include "libavutil/avassert.h"
22 #include "libavutil/eval.h"
23 #include "libavutil/opt.h"
24 #include "libavutil/pixdesc.h"
25 #include "avfilter.h"
26 #include "filters.h"
27 #include "formats.h"
28 #include "internal.h"
29 #include "video.h"
30 #include "libswscale/swscale.h"
31 
32 static const char *const var_names[] = {
33  "in_w", "iw",
34  "in_h", "ih",
35  "out_w", "ow",
36  "out_h", "oh",
37  "in",
38  "on",
39  "duration",
40  "pduration",
41  "time",
42  "frame",
43  "zoom",
44  "pzoom",
45  "x", "px",
46  "y", "py",
47  "a",
48  "sar",
49  "dar",
50  "hsub",
51  "vsub",
52  NULL
53 };
54 
55 enum var_name {
76 };
77 
78 typedef struct ZPcontext {
79  const AVClass *class;
81  char *x_expr_str;
82  char *y_expr_str;
84 
86 
87  int w, h;
88  double x, y;
89  double prev_zoom;
91  struct SwsContext *sws;
92  int64_t frame_count;
96  int nb_frames;
98  int finished;
100 } ZPContext;
101 
102 #define OFFSET(x) offsetof(ZPContext, x)
103 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
104 static const AVOption zoompan_options[] = {
105  { "zoom", "set the zoom expression", OFFSET(zoom_expr_str), AV_OPT_TYPE_STRING, {.str = "1" }, .flags = FLAGS },
106  { "z", "set the zoom expression", OFFSET(zoom_expr_str), AV_OPT_TYPE_STRING, {.str = "1" }, .flags = FLAGS },
107  { "x", "set the x expression", OFFSET(x_expr_str), AV_OPT_TYPE_STRING, {.str="0"}, .flags = FLAGS },
108  { "y", "set the y expression", OFFSET(y_expr_str), AV_OPT_TYPE_STRING, {.str="0"}, .flags = FLAGS },
109  { "d", "set the duration expression", OFFSET(duration_expr_str), AV_OPT_TYPE_STRING, {.str="90"}, .flags = FLAGS },
110  { "s", "set the output image size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, .flags = FLAGS },
111  { "fps", "set the output framerate", OFFSET(framerate), AV_OPT_TYPE_VIDEO_RATE, { .str = "25" }, 0, INT_MAX, .flags = FLAGS },
112  { NULL }
113 };
114 
115 AVFILTER_DEFINE_CLASS(zoompan);
116 
118 {
119  ZPContext *s = ctx->priv;
120 
121  s->prev_zoom = 1;
122  return 0;
123 }
124 
125 static int config_output(AVFilterLink *outlink)
126 {
127  AVFilterContext *ctx = outlink->src;
128  ZPContext *s = ctx->priv;
129  int ret;
130 
131  outlink->w = s->w;
132  outlink->h = s->h;
133  outlink->time_base = av_inv_q(s->framerate);
134  outlink->frame_rate = s->framerate;
135  s->desc = av_pix_fmt_desc_get(outlink->format);
136  s->finished = 1;
137 
138  ret = av_expr_parse(&s->zoom_expr, s->zoom_expr_str, var_names, NULL, NULL, NULL, NULL, 0, ctx);
139  if (ret < 0)
140  return ret;
141 
142  ret = av_expr_parse(&s->x_expr, s->x_expr_str, var_names, NULL, NULL, NULL, NULL, 0, ctx);
143  if (ret < 0)
144  return ret;
145 
146  ret = av_expr_parse(&s->y_expr, s->y_expr_str, var_names, NULL, NULL, NULL, NULL, 0, ctx);
147  if (ret < 0)
148  return ret;
149 
150  return 0;
151 }
152 
153 static int output_single_frame(AVFilterContext *ctx, AVFrame *in, double *var_values, int i,
154  double *zoom, double *dx, double *dy)
155 {
156  ZPContext *s = ctx->priv;
157  AVFilterLink *outlink = ctx->outputs[0];
158  int64_t pts = s->frame_count;
159  int k, x, y, w, h, ret = 0;
160  uint8_t *input[4];
161  int px[4], py[4];
162  AVFrame *out;
163 
164  var_values[VAR_PX] = s->x;
165  var_values[VAR_PY] = s->y;
166  var_values[VAR_PZOOM] = s->prev_zoom;
167  var_values[VAR_PDURATION] = s->prev_nb_frames;
168  var_values[VAR_TIME] = pts * av_q2d(outlink->time_base);
169  var_values[VAR_FRAME] = i;
170  var_values[VAR_ON] = outlink->frame_count_in;
171 
172  *zoom = av_expr_eval(s->zoom_expr, var_values, NULL);
173 
174  *zoom = av_clipd(*zoom, 1, 10);
175  var_values[VAR_ZOOM] = *zoom;
176  w = in->width * (1.0 / *zoom);
177  h = in->height * (1.0 / *zoom);
178 
179  *dx = av_expr_eval(s->x_expr, var_values, NULL);
180 
181  x = *dx = av_clipd(*dx, 0, FFMAX(in->width - w, 0));
182  var_values[VAR_X] = *dx;
183  x &= ~((1 << s->desc->log2_chroma_w) - 1);
184 
185  *dy = av_expr_eval(s->y_expr, var_values, NULL);
186 
187  y = *dy = av_clipd(*dy, 0, FFMAX(in->height - h, 0));
188  var_values[VAR_Y] = *dy;
189  y &= ~((1 << s->desc->log2_chroma_h) - 1);
190 
191  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
192  if (!out) {
193  ret = AVERROR(ENOMEM);
194  return ret;
195  }
196 
197  px[1] = px[2] = AV_CEIL_RSHIFT(x, s->desc->log2_chroma_w);
198  px[0] = px[3] = x;
199 
200  py[1] = py[2] = AV_CEIL_RSHIFT(y, s->desc->log2_chroma_h);
201  py[0] = py[3] = y;
202 
203  s->sws = sws_alloc_context();
204  if (!s->sws) {
205  ret = AVERROR(ENOMEM);
206  goto error;
207  }
208 
209  for (k = 0; in->data[k]; k++)
210  input[k] = in->data[k] + py[k] * in->linesize[k] + px[k];
211 
212  av_opt_set_int(s->sws, "srcw", w, 0);
213  av_opt_set_int(s->sws, "srch", h, 0);
214  av_opt_set_int(s->sws, "src_format", in->format, 0);
215  av_opt_set_int(s->sws, "dstw", outlink->w, 0);
216  av_opt_set_int(s->sws, "dsth", outlink->h, 0);
217  av_opt_set_int(s->sws, "dst_format", outlink->format, 0);
218  av_opt_set_int(s->sws, "sws_flags", SWS_BICUBIC, 0);
219 
220  if ((ret = sws_init_context(s->sws, NULL, NULL)) < 0)
221  goto error;
222 
223  sws_scale(s->sws, (const uint8_t *const *)&input, in->linesize, 0, h, out->data, out->linesize);
224 
225  out->pts = pts;
226  s->frame_count++;
227 
228  ret = ff_filter_frame(outlink, out);
229  sws_freeContext(s->sws);
230  s->sws = NULL;
231  s->current_frame++;
232 
233  if (s->current_frame >= s->nb_frames) {
234  if (*dx != -1)
235  s->x = *dx;
236  if (*dy != -1)
237  s->y = *dy;
238  if (*zoom != -1)
239  s->prev_zoom = *zoom;
240  s->prev_nb_frames = s->nb_frames;
241  s->nb_frames = 0;
242  s->current_frame = 0;
243  av_frame_free(&s->in);
244  s->finished = 1;
245  }
246  return ret;
247 error:
248  sws_freeContext(s->sws);
249  s->sws = NULL;
250  av_frame_free(&out);
251  return ret;
252 }
253 
255 {
256  ZPContext *s = ctx->priv;
257  AVFilterLink *inlink = ctx->inputs[0];
258  AVFilterLink *outlink = ctx->outputs[0];
259  int status, ret = 0;
260  int64_t pts;
261 
263 
264  if (s->in && ff_outlink_frame_wanted(outlink)) {
265  double zoom = -1, dx = -1, dy = -1;
266 
267  ret = output_single_frame(ctx, s->in, s->var_values, s->current_frame,
268  &zoom, &dx, &dy);
269  if (ret < 0)
270  return ret;
271  }
272 
273  if (!s->in && (ret = ff_inlink_consume_frame(inlink, &s->in)) > 0) {
274  double zoom = -1, dx = -1, dy = -1, nb_frames;
275 
276  s->finished = 0;
277  s->var_values[VAR_IN_W] = s->var_values[VAR_IW] = s->in->width;
278  s->var_values[VAR_IN_H] = s->var_values[VAR_IH] = s->in->height;
279  s->var_values[VAR_OUT_W] = s->var_values[VAR_OW] = s->w;
280  s->var_values[VAR_OUT_H] = s->var_values[VAR_OH] = s->h;
281  s->var_values[VAR_IN] = inlink->frame_count_out - 1;
282  s->var_values[VAR_ON] = outlink->frame_count_in;
283  s->var_values[VAR_PX] = s->x;
284  s->var_values[VAR_PY] = s->y;
285  s->var_values[VAR_X] = 0;
286  s->var_values[VAR_Y] = 0;
287  s->var_values[VAR_PZOOM] = s->prev_zoom;
288  s->var_values[VAR_ZOOM] = 1;
289  s->var_values[VAR_PDURATION] = s->prev_nb_frames;
290  s->var_values[VAR_A] = (double) s->in->width / s->in->height;
291  s->var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ?
292  (double) inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1;
293  s->var_values[VAR_DAR] = s->var_values[VAR_A] * s->var_values[VAR_SAR];
294  s->var_values[VAR_HSUB] = 1 << s->desc->log2_chroma_w;
295  s->var_values[VAR_VSUB] = 1 << s->desc->log2_chroma_h;
296 
297  if ((ret = av_expr_parse_and_eval(&nb_frames, s->duration_expr_str,
298  var_names, s->var_values,
299  NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0) {
300  av_frame_free(&s->in);
301  return ret;
302  }
303 
304  s->var_values[VAR_DURATION] = s->nb_frames = nb_frames;
305 
306  ret = output_single_frame(ctx, s->in, s->var_values, s->current_frame,
307  &zoom, &dx, &dy);
308  if (ret < 0)
309  return ret;
310  }
311  if (ret < 0) {
312  return ret;
313  } else if (s->finished && ff_inlink_acknowledge_status(inlink, &status, &pts)) {
314  ff_outlink_set_status(outlink, status, pts);
315  return 0;
316  } else {
317  if (ff_outlink_frame_wanted(outlink) && s->finished)
319  return 0;
320  }
321 }
322 
324 {
325  static const enum AVPixelFormat pix_fmts[] = {
337  };
338 
340  if (!fmts_list)
341  return AVERROR(ENOMEM);
342  return ff_set_common_formats(ctx, fmts_list);
343 }
344 
346 {
347  ZPContext *s = ctx->priv;
348 
349  sws_freeContext(s->sws);
350  s->sws = NULL;
351  av_expr_free(s->x_expr);
352  av_expr_free(s->y_expr);
353  av_expr_free(s->zoom_expr);
354  av_frame_free(&s->in);
355 }
356 
357 static const AVFilterPad inputs[] = {
358  {
359  .name = "default",
360  .type = AVMEDIA_TYPE_VIDEO,
361  },
362  { NULL }
363 };
364 
365 static const AVFilterPad outputs[] = {
366  {
367  .name = "default",
368  .type = AVMEDIA_TYPE_VIDEO,
369  .config_props = config_output,
370  },
371  { NULL }
372 };
373 
375  .name = "zoompan",
376  .description = NULL_IF_CONFIG_SMALL("Apply Zoom & Pan effect."),
377  .priv_size = sizeof(ZPContext),
378  .priv_class = &zoompan_class,
379  .init = init,
380  .uninit = uninit,
382  .activate = activate,
383  .inputs = inputs,
384  .outputs = outputs,
385 };
error
static void error(const char *err)
Definition: target_bsf_fuzzer.c:29
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:99
inputs
static const AVFilterPad inputs[]
Definition: vf_zoompan.c:357
ZPcontext::current_frame
int current_frame
Definition: vf_zoompan.c:97
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
status
they must not be accessed directly The fifo field contains the frames that are queued in the input for processing by the filter The status_in and status_out fields contains the queued status(EOF or error) of the link
ZPcontext::y_expr
AVExpr * y_expr
Definition: vf_zoompan.c:85
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
VAR_ZOOM
@ VAR_ZOOM
Definition: vf_zoompan.c:66
ff_make_format_list
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:300
VAR_ON
@ VAR_ON
Definition: vf_zoompan.c:61
out
FILE * out
Definition: movenc.c:54
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1075
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2549
VAR_IN
@ VAR_IN
Definition: vf_zoompan.c:60
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
offset must point to AVRational
Definition: opt.h:236
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
VAR_PZOOM
@ VAR_PZOOM
Definition: vf_zoompan.c:67
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:203
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:300
pixdesc.h
VAR_IH
@ VAR_IH
Definition: vf_zoompan.c:57
w
uint8_t w
Definition: llviddspenc.c:38
AVOption
AVOption.
Definition: opt.h:246
VAR_TIME
@ VAR_TIME
Definition: vf_zoompan.c:64
VAR_IW
@ VAR_IW
Definition: vf_zoompan.c:56
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
sws_scale
int attribute_align_arg sws_scale(struct SwsContext *c, const uint8_t *const srcSlice[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
swscale wrapper, so we don't need to export the SwsContext.
Definition: swscale.c:744
ZPcontext
Definition: vf_zoompan.c:78
ZPcontext::desc
const AVPixFmtDescriptor * desc
Definition: vf_zoompan.c:93
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:148
outputs
static const AVFilterPad outputs[]
Definition: vf_zoompan.c:365
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(zoompan)
VAR_VSUB
@ VAR_VSUB
Definition: vf_zoompan.c:74
video.h
FF_FILTER_FORWARD_STATUS_BACK
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
Definition: filters.h:199
VAR_OH
@ VAR_OH
Definition: vf_zoompan.c:59
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
formats.h
av_expr_parse
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
Definition: eval.c:685
VAR_PY
@ VAR_PY
Definition: vf_zoompan.c:69
VARS_NB
@ VARS_NB
Definition: vf_zoompan.c:75
framerate
int framerate
Definition: h264_levels.c:65
ff_inlink_consume_frame
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Definition: avfilter.c:1476
VAR_A
@ VAR_A
Definition: vf_zoompan.c:70
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:215
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_zoompan.c:117
VAR_IN_H
@ VAR_IN_H
Definition: vf_zoompan.c:57
pts
static int64_t pts
Definition: transcode_aac.c:647
av_expr_free
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
Definition: eval.c:336
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:54
AV_PIX_FMT_YUVJ411P
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:258
VAR_DURATION
@ VAR_DURATION
Definition: vf_zoompan.c:62
avassert.h
ZPcontext::nb_frames
int nb_frames
Definition: vf_zoompan.c:96
av_cold
#define av_cold
Definition: attributes.h:90
ff_set_common_formats
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:605
ZPcontext::x_expr_str
char * x_expr_str
Definition: vf_zoompan.c:81
VAR_PX
@ VAR_PX
Definition: vf_zoompan.c:68
AV_PIX_FMT_YUVJ422P
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:79
ZPcontext::y
double y
Definition: vf_zoompan.c:88
ff_outlink_set_status
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
Definition: filters.h:189
ff_inlink_request_frame
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Definition: avfilter.c:1602
s
#define s(width, name)
Definition: cbs_vp9.c:257
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
activate
static int activate(AVFilterContext *ctx)
Definition: vf_zoompan.c:254
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
ZPcontext::finished
int finished
Definition: vf_zoompan.c:98
av_q2d
static double av_q2d(AVRational a)
Convert an AVRational to a double.
Definition: rational.h:104
VAR_SAR
@ VAR_SAR
Definition: vf_zoompan.c:71
ZPcontext::var_values
double var_values[VARS_NB]
Definition: vf_zoompan.c:95
filters.h
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:275
ctx
AVFormatContext * ctx
Definition: movenc.c:48
av_expr_eval
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
Definition: eval.c:766
AVExpr
Definition: eval.c:157
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
VAR_IN_W
@ VAR_IN_W
Definition: vf_zoompan.c:56
AV_PIX_FMT_YUVJ444P
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:80
VAR_Y
@ VAR_Y
Definition: vf_zoompan.c:69
ZPcontext::frame_count
int64_t frame_count
Definition: vf_zoompan.c:92
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
ZPcontext::framerate
AVRational framerate
Definition: vf_zoompan.c:99
NULL
#define NULL
Definition: coverity.c:32
output_single_frame
static int output_single_frame(AVFilterContext *ctx, AVFrame *in, double *var_values, int i, double *zoom, double *dx, double *dy)
Definition: vf_zoompan.c:153
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AV_PIX_FMT_YUVJ420P
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:78
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive integers
Definition: opt.h:233
VAR_OUT_H
@ VAR_OUT_H
Definition: vf_zoompan.c:59
sws_alloc_context
struct SwsContext * sws_alloc_context(void)
Allocate an empty SwsContext.
Definition: utils.c:1084
zoompan_options
static const AVOption zoompan_options[]
Definition: vf_zoompan.c:104
ZPcontext::x_expr
AVExpr * x_expr
Definition: vf_zoompan.c:85
ZPcontext::prev_zoom
double prev_zoom
Definition: vf_zoompan.c:89
ZPcontext::in
AVFrame * in
Definition: vf_zoompan.c:94
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
ff_inlink_acknowledge_status
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
Definition: avfilter.c:1431
FLAGS
#define FLAGS
Definition: vf_zoompan.c:103
av_opt_set_int
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
Definition: opt.c:586
VAR_FRAME
@ VAR_FRAME
Definition: vf_zoompan.c:65
eval.h
var_names
static const char *const var_names[]
Definition: vf_zoompan.c:32
ZPcontext::zoom_expr
AVExpr * zoom_expr
Definition: vf_zoompan.c:85
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:188
av_expr_parse_and_eval
int av_expr_parse_and_eval(double *d, const char *s, const char *const *const_names, const double *const_values, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), void *opaque, int log_offset, void *log_ctx)
Parse and evaluate an expression.
Definition: eval.c:776
var_name
var_name
Definition: aeval.c:46
FFMAX
#define FFMAX(a, b)
Definition: common.h:94
VAR_OW
@ VAR_OW
Definition: vf_zoompan.c:58
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:177
VAR_X
@ VAR_X
Definition: vf_zoompan.c:68
input
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
Definition: filter_design.txt:172
VAR_OUT_W
@ VAR_OUT_W
Definition: vf_zoompan.c:58
internal.h
in
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
Definition: audio_convert.c:326
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
ff_vf_zoompan
AVFilter ff_vf_zoompan
Definition: vf_zoompan.c:374
AV_PIX_FMT_YUVJ440P
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition: pixfmt.h:100
uint8_t
uint8_t
Definition: audio_convert.c:194
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_zoompan.c:323
av_inv_q
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
ZPcontext::sws
struct SwsContext * sws
Definition: vf_zoompan.c:91
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:60
AVFilter
Filter definition.
Definition: avfilter.h:144
VAR_HSUB
@ VAR_HSUB
Definition: vf_zoompan.c:73
ret
ret
Definition: filter_design.txt:187
ZPcontext::duration_expr_str
char * duration_expr_str
Definition: vf_zoompan.c:83
sws_init_context
av_warn_unused_result int sws_init_context(struct SwsContext *sws_context, SwsFilter *srcFilter, SwsFilter *dstFilter)
Initialize the swscaler context sws_context.
Definition: utils.c:1170
sws_freeContext
void sws_freeContext(struct SwsContext *swsContext)
Free the swscaler context swsContext.
Definition: utils.c:2319
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
avfilter.h
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_zoompan.c:125
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
AVFilterContext
An instance of a filter.
Definition: avfilter.h:338
OFFSET
#define OFFSET(x)
Definition: vf_zoompan.c:102
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:168
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
ZPcontext::prev_nb_frames
int prev_nb_frames
Definition: vf_zoompan.c:90
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
ZPcontext::h
int h
Definition: vf_zoompan.c:87
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
ZPcontext::y_expr_str
char * y_expr_str
Definition: vf_zoompan.c:82
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_zoompan.c:345
VAR_PDURATION
@ VAR_PDURATION
Definition: vf_zoompan.c:63
h
h
Definition: vp9dsp_template.c:2038
ff_outlink_frame_wanted
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:227
ZPcontext::zoom_expr_str
char * zoom_expr_str
Definition: vf_zoompan.c:80
SwsContext
Definition: swscale_internal.h:280
ZPcontext::x
double x
Definition: vf_zoompan.c:88
SWS_BICUBIC
#define SWS_BICUBIC
Definition: swscale.h:60
swscale.h
AV_PIX_FMT_YUVA422P
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:176
ZPcontext::w
int w
Definition: vf_zoompan.c:87
VAR_DAR
@ VAR_DAR
Definition: vf_zoompan.c:72