FFmpeg  2.6.3
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
vf_vignette.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Clément Bœsch
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 <float.h> /* DBL_MAX */
22 
23 #include "libavutil/opt.h"
24 #include "libavutil/eval.h"
25 #include "libavutil/avassert.h"
26 #include "libavutil/pixdesc.h"
27 #include "avfilter.h"
28 #include "formats.h"
29 #include "internal.h"
30 #include "video.h"
31 
32 static const char *const var_names[] = {
33  "w", // stream width
34  "h", // stream height
35  "n", // frame count
36  "pts", // presentation timestamp expressed in AV_TIME_BASE units
37  "r", // frame rate
38  "t", // timestamp expressed in seconds
39  "tb", // timebase
40  NULL
41 };
42 
43 enum var_name {
52 };
53 
54 typedef struct {
55  const AVClass *class;
57  int backward;
58  enum EvalMode { EVAL_MODE_INIT, EVAL_MODE_FRAME, EVAL_MODE_NB } eval_mode;
59 #define DEF_EXPR_FIELDS(name) AVExpr *name##_pexpr; char *name##_expr; double name
60  DEF_EXPR_FIELDS(angle);
61  DEF_EXPR_FIELDS(x0);
62  DEF_EXPR_FIELDS(y0);
63  double var_values[VAR_NB];
64  float *fmap;
66  double dmax;
67  float xscale, yscale;
68  uint32_t dither;
69  int do_dither;
73 
74 #define OFFSET(x) offsetof(VignetteContext, x)
75 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
76 static const AVOption vignette_options[] = {
77  { "angle", "set lens angle", OFFSET(angle_expr), AV_OPT_TYPE_STRING, {.str="PI/5"}, .flags = FLAGS },
78  { "a", "set lens angle", OFFSET(angle_expr), AV_OPT_TYPE_STRING, {.str="PI/5"}, .flags = FLAGS },
79  { "x0", "set circle center position on x-axis", OFFSET(x0_expr), AV_OPT_TYPE_STRING, {.str="w/2"}, .flags = FLAGS },
80  { "y0", "set circle center position on y-axis", OFFSET(y0_expr), AV_OPT_TYPE_STRING, {.str="h/2"}, .flags = FLAGS },
81  { "mode", "set forward/backward mode", OFFSET(backward), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, FLAGS, "mode" },
82  { "forward", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0}, INT_MIN, INT_MAX, FLAGS, "mode"},
83  { "backward", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1}, INT_MIN, INT_MAX, FLAGS, "mode"},
84  { "eval", "specify when to evaluate expressions", OFFSET(eval_mode), AV_OPT_TYPE_INT, {.i64 = EVAL_MODE_INIT}, 0, EVAL_MODE_NB-1, FLAGS, "eval" },
85  { "init", "eval expressions once during initialization", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_INIT}, .flags = FLAGS, .unit = "eval" },
86  { "frame", "eval expressions for each frame", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_FRAME}, .flags = FLAGS, .unit = "eval" },
87  { "dither", "set dithering", OFFSET(do_dither), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, FLAGS },
88  { "aspect", "set aspect ratio", OFFSET(aspect), AV_OPT_TYPE_RATIONAL, {.dbl = 1}, 0, DBL_MAX, .flags = FLAGS },
89  { NULL }
90 };
91 
92 AVFILTER_DEFINE_CLASS(vignette);
93 
94 static av_cold int init(AVFilterContext *ctx)
95 {
96  VignetteContext *s = ctx->priv;
97 
98 #define PARSE_EXPR(name) do { \
99  int ret = av_expr_parse(&s->name##_pexpr, s->name##_expr, var_names, \
100  NULL, NULL, NULL, NULL, 0, ctx); \
101  if (ret < 0) { \
102  av_log(ctx, AV_LOG_ERROR, "Unable to parse expression for '" \
103  AV_STRINGIFY(name) "'\n"); \
104  return ret; \
105  } \
106 } while (0)
107 
108  PARSE_EXPR(angle);
109  PARSE_EXPR(x0);
110  PARSE_EXPR(y0);
111  return 0;
112 }
113 
114 static av_cold void uninit(AVFilterContext *ctx)
115 {
116  VignetteContext *s = ctx->priv;
117  av_freep(&s->fmap);
118  av_expr_free(s->angle_pexpr);
119  av_expr_free(s->x0_pexpr);
120  av_expr_free(s->y0_pexpr);
121 }
122 
124 {
125  static const enum AVPixelFormat pix_fmts[] = {
132  };
134  return 0;
135 }
136 
137 static double get_natural_factor(const VignetteContext *s, int x, int y)
138 {
139  const int xx = (x - s->x0) * s->xscale;
140  const int yy = (y - s->y0) * s->yscale;
141  const double dnorm = hypot(xx, yy) / s->dmax;
142  if (dnorm > 1) {
143  return 0;
144  } else {
145  const double c = cos(s->angle * dnorm);
146  return (c*c)*(c*c); // do not remove braces, it helps compilers
147  }
148 }
149 
150 #define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
151 #define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts) * av_q2d(tb))
152 
154 {
155  int x, y;
156  float *dst = s->fmap;
157  int dst_linesize = s->fmap_linesize;
158 
159  if (frame) {
160  s->var_values[VAR_N] = inlink->frame_count;
161  s->var_values[VAR_T] = TS2T(frame->pts, inlink->time_base);
162  s->var_values[VAR_PTS] = TS2D(frame->pts);
163  } else {
164  s->var_values[VAR_N] = 0;
165  s->var_values[VAR_T] = NAN;
166  s->var_values[VAR_PTS] = NAN;
167  }
168 
169  s->angle = av_clipf(av_expr_eval(s->angle_pexpr, s->var_values, NULL), 0, M_PI_2);
170  s->x0 = av_expr_eval(s->x0_pexpr, s->var_values, NULL);
171  s->y0 = av_expr_eval(s->y0_pexpr, s->var_values, NULL);
172 
173  if (s->backward) {
174  for (y = 0; y < inlink->h; y++) {
175  for (x = 0; x < inlink->w; x++)
176  dst[x] = 1. / get_natural_factor(s, x, y);
177  dst += dst_linesize;
178  }
179  } else {
180  for (y = 0; y < inlink->h; y++) {
181  for (x = 0; x < inlink->w; x++)
182  dst[x] = get_natural_factor(s, x, y);
183  dst += dst_linesize;
184  }
185  }
186 }
187 
188 static inline double get_dither_value(VignetteContext *s)
189 {
190  double dv = 0;
191  if (s->do_dither) {
192  dv = s->dither / (double)(1LL<<32);
193  s->dither = s->dither * 1664525 + 1013904223;
194  }
195  return dv;
196 }
197 
198 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
199 {
200  unsigned x, y, direct = 0;
201  AVFilterContext *ctx = inlink->dst;
202  VignetteContext *s = ctx->priv;
203  AVFilterLink *outlink = ctx->outputs[0];
204  AVFrame *out;
205 
206  if (av_frame_is_writable(in)) {
207  direct = 1;
208  out = in;
209  } else {
210  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
211  if (!out) {
212  av_frame_free(&in);
213  return AVERROR(ENOMEM);
214  }
215  av_frame_copy_props(out, in);
216  }
217 
218  if (s->eval_mode == EVAL_MODE_FRAME)
219  update_context(s, inlink, in);
220 
221  if (s->desc->flags & AV_PIX_FMT_FLAG_RGB) {
222  uint8_t *dst = out->data[0];
223  const uint8_t *src = in ->data[0];
224  const float *fmap = s->fmap;
225  const int dst_linesize = out->linesize[0];
226  const int src_linesize = in ->linesize[0];
227  const int fmap_linesize = s->fmap_linesize;
228 
229  for (y = 0; y < inlink->h; y++) {
230  uint8_t *dstp = dst;
231  const uint8_t *srcp = src;
232 
233  for (x = 0; x < inlink->w; x++, dstp += 3, srcp += 3) {
234  const float f = fmap[x];
235 
236  dstp[0] = av_clip_uint8(srcp[0] * f + get_dither_value(s));
237  dstp[1] = av_clip_uint8(srcp[1] * f + get_dither_value(s));
238  dstp[2] = av_clip_uint8(srcp[2] * f + get_dither_value(s));
239  }
240  dst += dst_linesize;
241  src += src_linesize;
242  fmap += fmap_linesize;
243  }
244  } else {
245  int plane;
246 
247  for (plane = 0; plane < 4 && in->data[plane] && in->linesize[plane]; plane++) {
248  uint8_t *dst = out->data[plane];
249  const uint8_t *src = in ->data[plane];
250  const float *fmap = s->fmap;
251  const int dst_linesize = out->linesize[plane];
252  const int src_linesize = in ->linesize[plane];
253  const int fmap_linesize = s->fmap_linesize;
254  const int chroma = plane == 1 || plane == 2;
255  const int hsub = chroma ? s->desc->log2_chroma_w : 0;
256  const int vsub = chroma ? s->desc->log2_chroma_h : 0;
257  const int w = FF_CEIL_RSHIFT(inlink->w, hsub);
258  const int h = FF_CEIL_RSHIFT(inlink->h, vsub);
259 
260  for (y = 0; y < h; y++) {
261  uint8_t *dstp = dst;
262  const uint8_t *srcp = src;
263 
264  for (x = 0; x < w; x++) {
265  const double dv = get_dither_value(s);
266  if (chroma) *dstp++ = av_clip_uint8(fmap[x << hsub] * (*srcp++ - 127) + 127 + dv);
267  else *dstp++ = av_clip_uint8(fmap[x ] * *srcp++ + dv);
268  }
269  dst += dst_linesize;
270  src += src_linesize;
271  fmap += fmap_linesize << vsub;
272  }
273  }
274  }
275 
276  if (!direct)
277  av_frame_free(&in);
278  return ff_filter_frame(outlink, out);
279 }
280 
281 static int config_props(AVFilterLink *inlink)
282 {
283  VignetteContext *s = inlink->dst->priv;
284  AVRational sar = inlink->sample_aspect_ratio;
285 
286  s->desc = av_pix_fmt_desc_get(inlink->format);
287  s->var_values[VAR_W] = inlink->w;
288  s->var_values[VAR_H] = inlink->h;
289  s->var_values[VAR_TB] = av_q2d(inlink->time_base);
290  s->var_values[VAR_R] = inlink->frame_rate.num == 0 || inlink->frame_rate.den == 0 ?
291  NAN : av_q2d(inlink->frame_rate);
292 
293  if (!sar.num || !sar.den)
294  sar.num = sar.den = 1;
295  if (sar.num > sar.den) {
296  s->xscale = av_q2d(av_div_q(sar, s->aspect));
297  s->yscale = 1;
298  } else {
299  s->yscale = av_q2d(av_div_q(s->aspect, sar));
300  s->xscale = 1;
301  }
302  s->dmax = hypot(inlink->w / 2., inlink->h / 2.);
303  av_log(s, AV_LOG_DEBUG, "xscale=%f yscale=%f dmax=%f\n",
304  s->xscale, s->yscale, s->dmax);
305 
306  s->fmap_linesize = FFALIGN(inlink->w, 32);
307  s->fmap = av_malloc_array(s->fmap_linesize, inlink->h * sizeof(*s->fmap));
308  if (!s->fmap)
309  return AVERROR(ENOMEM);
310 
311  if (s->eval_mode == EVAL_MODE_INIT)
312  update_context(s, inlink, NULL);
313 
314  return 0;
315 }
316 
317 static const AVFilterPad vignette_inputs[] = {
318  {
319  .name = "default",
320  .type = AVMEDIA_TYPE_VIDEO,
321  .filter_frame = filter_frame,
322  .config_props = config_props,
323  },
324  { NULL }
325 };
326 
327 static const AVFilterPad vignette_outputs[] = {
328  {
329  .name = "default",
330  .type = AVMEDIA_TYPE_VIDEO,
331  },
332  { NULL }
333 };
334 
336  .name = "vignette",
337  .description = NULL_IF_CONFIG_SMALL("Make or reverse a vignette effect."),
338  .priv_size = sizeof(VignetteContext),
339  .init = init,
340  .uninit = uninit,
342  .inputs = vignette_inputs,
343  .outputs = vignette_outputs,
344  .priv_class = &vignette_class,
346 };
#define NULL
Definition: coverity.c:32
const char * s
Definition: avisynth_c.h:669
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2029
This structure describes decoded (raw) audio or video data.
Definition: frame.h:163
AVFilter ff_vf_vignette
Definition: vf_vignette.c:335
AVOption.
Definition: opt.h:255
static const AVFilterPad vignette_outputs[]
Definition: vf_vignette.c:327
enum VignetteContext::EvalMode eval_mode
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:73
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:246
Main libavfilter public API header.
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:70
static const AVOption vignette_options[]
Definition: vf_vignette.c:76
#define TS2D(ts)
Definition: vf_vignette.c:150
int num
numerator
Definition: rational.h:44
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_dlog(ac->avr,"%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
#define TS2T(ts, tb)
Definition: vf_vignette.c:151
static double get_dither_value(VignetteContext *s)
Definition: vf_vignette.c:188
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:109
static av_cold int init(AVFilterContext *ctx)
Definition: vf_vignette.c:94
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:80
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_vignette.c:114
#define FFALIGN(x, a)
Definition: common.h:71
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:294
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition: avfilter.h:451
BYTE int const BYTE * srcp
Definition: avisynth_c.h:714
const char * name
Pad name.
Definition: internal.h:67
static const AVFilterPad vignette_inputs[]
Definition: vf_vignette.c:317
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1145
uint8_t
#define av_cold
Definition: attributes.h:74
AVOptions.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:249
static double get_natural_factor(const VignetteContext *s, int x, int y)
Definition: vf_vignette.c:137
static AVFrame * frame
static double av_q2d(AVRational a)
Convert rational to double.
Definition: rational.h:80
static int query_formats(AVFilterContext *ctx)
Definition: vf_vignette.c:123
void 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:539
#define DEF_EXPR_FIELDS(name)
Definition: vf_vignette.c:59
#define av_log(a,...)
A filter pad used for either input or output.
Definition: internal.h:61
AVRational scale
Definition: vf_vignette.c:71
#define FLAGS
Definition: vf_vignette.c:75
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:89
BYTE * dstp
Definition: avisynth_c.h:714
#define AVERROR(e)
Definition: error.h:43
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
Definition: pixdesc.h:131
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:148
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:180
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
Definition: rational.c:88
void * priv
private data for use by the filter
Definition: avfilter.h:654
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:196
simple assert() macros that are a bit more flexible than ISO C assert().
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:72
var_name
Definition: aeval.c:46
double var_values[VAR_NB]
Definition: vf_vignette.c:63
float y
#define M_PI_2
Definition: mathematics.h:49
#define FF_CEIL_RSHIFT(a, b)
Definition: common.h:57
#define PARSE_EXPR(name)
#define OFFSET(x)
Definition: vf_vignette.c:74
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:71
AVRational aspect
Definition: vf_vignette.c:70
static int config_props(AVFilterLink *inlink)
Definition: vf_vignette.c:281
AVFILTER_DEFINE_CLASS(vignette)
AVS_Value src
Definition: avisynth_c.h:524
static void update_context(VignetteContext *s, AVFilterLink *inlink, AVFrame *frame)
Definition: vf_vignette.c:153
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
Definition: eval.c:312
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:403
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:191
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_vignette.c:198
uint8_t flags
Definition: pixdesc.h:90
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:74
Describe the class of an AVClass context structure.
Definition: log.h:66
Filter definition.
Definition: avfilter.h:470
static const AVFilterPad inputs[]
Definition: af_ashowinfo.c:237
rational number numerator/denominator
Definition: rational.h:43
const char * name
Filter name.
Definition: avfilter.h:474
const AVPixFmtDescriptor * desc
Definition: vf_vignette.c:56
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:648
uint32_t dither
Definition: vf_vignette.c:68
static int flags
Definition: cpu.c:47
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:174
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_dlog(ac->avr,"%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-> out
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:68
Y , 8bpp.
Definition: pixfmt.h:76
static double c[64]
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:75
int den
denominator
Definition: rational.h:45
#define NAN
Definition: math.h:28
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
Definition: eval.c:703
static const char *const var_names[]
Definition: vf_vignette.c:32
An instance of a filter.
Definition: avfilter.h:633
#define av_freep(p)
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:106
#define av_malloc_array(a, b)
internal API functions
AVPixelFormat
Pixel format.
Definition: pixfmt.h:66
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:463
simple arithmetic expression evaluator