FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 
85  AVExpr *zoom_expr, *x_expr, *y_expr;
86 
87  int w, h;
88  double x, y;
89  double prev_zoom;
91  struct SwsContext *sws;
92  int64_t frame_count;
95  double var_values[VARS_NB];
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  av_frame_free(&out);
249  return ret;
250 }
251 
253 {
254  ZPContext *s = ctx->priv;
255  AVFilterLink *inlink = ctx->inputs[0];
256  AVFilterLink *outlink = ctx->outputs[0];
257  int status, ret = 0;
258  int64_t pts;
259 
260  if (s->in && ff_outlink_frame_wanted(outlink)) {
261  double zoom = -1, dx = -1, dy = -1;
262 
263  ret = output_single_frame(ctx, s->in, s->var_values, s->current_frame,
264  &zoom, &dx, &dy);
265  if (ret < 0)
266  return ret;
267  }
268 
269  if (!s->in && (ret = ff_inlink_consume_frame(inlink, &s->in)) > 0) {
270  double zoom = -1, dx = -1, dy = -1, nb_frames;
271 
272  s->finished = 0;
273  s->var_values[VAR_IN_W] = s->var_values[VAR_IW] = s->in->width;
274  s->var_values[VAR_IN_H] = s->var_values[VAR_IH] = s->in->height;
275  s->var_values[VAR_OUT_W] = s->var_values[VAR_OW] = s->w;
276  s->var_values[VAR_OUT_H] = s->var_values[VAR_OH] = s->h;
277  s->var_values[VAR_IN] = inlink->frame_count_out - 1;
278  s->var_values[VAR_ON] = outlink->frame_count_in;
279  s->var_values[VAR_PX] = s->x;
280  s->var_values[VAR_PY] = s->y;
281  s->var_values[VAR_X] = 0;
282  s->var_values[VAR_Y] = 0;
283  s->var_values[VAR_PZOOM] = s->prev_zoom;
284  s->var_values[VAR_ZOOM] = 1;
286  s->var_values[VAR_A] = (double) s->in->width / s->in->height;
287  s->var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ?
288  (double) inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1;
290  s->var_values[VAR_HSUB] = 1 << s->desc->log2_chroma_w;
291  s->var_values[VAR_VSUB] = 1 << s->desc->log2_chroma_h;
292 
293  if ((ret = av_expr_parse_and_eval(&nb_frames, s->duration_expr_str,
294  var_names, s->var_values,
295  NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0) {
296  av_frame_free(&s->in);
297  return ret;
298  }
299 
300  s->var_values[VAR_DURATION] = s->nb_frames = nb_frames;
301 
302  ret = output_single_frame(ctx, s->in, s->var_values, s->current_frame,
303  &zoom, &dx, &dy);
304  if (ret < 0)
305  return ret;
306  }
307  if (ret < 0) {
308  return ret;
309  } else if (s->finished && ff_inlink_acknowledge_status(inlink, &status, &pts)) {
310  ff_outlink_set_status(outlink, status, pts);
311  return 0;
312  } else {
313  if (ff_outlink_frame_wanted(outlink) && s->finished)
314  ff_inlink_request_frame(inlink);
315  return 0;
316  }
317 }
318 
320 {
321  static const enum AVPixelFormat pix_fmts[] = {
333  };
334 
335  AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
336  if (!fmts_list)
337  return AVERROR(ENOMEM);
338  return ff_set_common_formats(ctx, fmts_list);
339 }
340 
342 {
343  ZPContext *s = ctx->priv;
344 
345  sws_freeContext(s->sws);
346  s->sws = NULL;
347 }
348 
349 static const AVFilterPad inputs[] = {
350  {
351  .name = "default",
352  .type = AVMEDIA_TYPE_VIDEO,
353  },
354  { NULL }
355 };
356 
357 static const AVFilterPad outputs[] = {
358  {
359  .name = "default",
360  .type = AVMEDIA_TYPE_VIDEO,
361  .config_props = config_output,
362  },
363  { NULL }
364 };
365 
367  .name = "zoompan",
368  .description = NULL_IF_CONFIG_SMALL("Apply Zoom & Pan effect."),
369  .priv_size = sizeof(ZPContext),
370  .priv_class = &zoompan_class,
371  .init = init,
372  .uninit = uninit,
374  .activate = activate,
375  .inputs = inputs,
376  .outputs = outputs,
377 };
AVExpr * y_expr
Definition: vf_zoompan.c:85
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:1481
#define NULL
Definition: coverity.c:32
struct SwsContext * sws
Definition: vf_zoompan.c:91
double var_values[VARS_NB]
Definition: vf_zoompan.c:95
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2446
This structure describes decoded (raw) audio or video data.
Definition: frame.h:226
#define SWS_BICUBIC
Definition: swscale.h:60
AVOption.
Definition: opt.h:246
static int activate(AVFilterContext *ctx)
Definition: vf_zoompan.c:252
int prev_nb_frames
Definition: vf_zoompan.c:90
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
char * zoom_expr_str
Definition: vf_zoompan.c:80
Main libavfilter public API header.
AVRational framerate
Definition: vf_zoompan.c:99
static int query_formats(AVFilterContext *ctx)
Definition: vf_zoompan.c:319
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:168
int num
Numerator.
Definition: rational.h:59
int nb_frames
Definition: vf_zoompan.c:96
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:679
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
static const AVFilterPad inputs[]
Definition: vf_zoompan.c:349
double y
Definition: vf_zoompan.c:88
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:92
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
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Definition: avfilter.c:1607
static int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
Definition: filters.h:172
int current_frame
Definition: vf_zoompan.c:97
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
AVFrame * in
Definition: vf_zoompan.c:94
const char * name
Pad name.
Definition: internal.h:60
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:346
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1080
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
uint8_t
#define av_cold
Definition: attributes.h:82
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:1159
AVOptions.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:319
Definition: eval.c:157
#define FLAGS
Definition: vf_zoompan.c:103
static double av_q2d(AVRational a)
Convert an AVRational to a double.
Definition: rational.h:104
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
Definition: pixfmt.h:100
AVExpr * x_expr
Definition: vf_zoompan.c:85
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:79
external API header
A filter pad used for either input or output.
Definition: internal.h:54
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:1436
const AVPixFmtDescriptor * desc
Definition: vf_zoompan.c:93
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:744
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:176
int width
Definition: frame.h:284
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:568
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:101
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:202
static const char *const var_names[]
Definition: vf_zoompan.c:32
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
void * priv
private data for use by the filter
Definition: avfilter.h:353
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
Definition: opt.c:568
double x
Definition: vf_zoompan.c:88
simple assert() macros that are a bit more flexible than ISO C assert().
static const AVOption zoompan_options[]
Definition: vf_zoompan.c:104
static int config_output(AVFilterLink *outlink)
Definition: vf_zoompan.c:125
#define FFMAX(a, b)
Definition: common.h:94
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
var_name
Definition: aeval.c:46
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:78
uint8_t w
Definition: llviddspenc.c:38
AVFormatContext * ctx
Definition: movenc.c:48
void sws_freeContext(struct SwsContext *swsContext)
Free the swscaler context swsContext.
Definition: utils.c:2305
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_zoompan.c:341
#define s(width, name)
Definition: cbs_vp9.c:257
int finished
Definition: vf_zoompan.c:98
char * y_expr_str
Definition: vf_zoompan.c:82
#define OFFSET(x)
Definition: vf_zoompan.c:102
static void error(const char *err)
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
char * duration_expr_str
Definition: vf_zoompan.c:83
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
Definition: frame.h:299
AVExpr * zoom_expr
Definition: vf_zoompan.c:85
AVFilter ff_vf_zoompan
Definition: vf_zoompan.c:366
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:257
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:177
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
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:759
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
Describe the class of an AVClass context structure.
Definition: log.h:67
Filter definition.
Definition: avfilter.h:144
static const AVFilterPad outputs[]
Definition: vf_zoompan.c:357
Rational number (pair of numerator and denominator).
Definition: rational.h:58
offset must point to AVRational
Definition: opt.h:236
const char * name
Filter name.
Definition: avfilter.h:148
int64_t frame_count
Definition: vf_zoompan.c:92
offset must point to two consecutive integers
Definition: opt.h:233
struct SwsContext * sws_alloc_context(void)
Allocate an empty SwsContext.
Definition: utils.c:1073
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:350
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:266
static int64_t pts
static av_cold int init(AVFilterContext *ctx)
Definition: vf_zoompan.c:117
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:240
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
Y , 8bpp.
Definition: pixfmt.h:74
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:215
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:80
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
int den
Denominator.
Definition: rational.h:60
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
Definition: eval.c:734
A list of supported formats for one end of a filter link.
Definition: formats.h:64
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:258
An instance of a filter.
Definition: avfilter.h:338
int height
Definition: frame.h:284
FILE * out
Definition: movenc.c:54
char * x_expr_str
Definition: vf_zoompan.c:81
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
internal API functions
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
AVFILTER_DEFINE_CLASS(zoompan)
simple arithmetic expression evaluator
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
double prev_zoom
Definition: vf_zoompan.c:89