FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
f_drawgraph.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 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 "float.h"
22 
23 #include "libavutil/eval.h"
24 #include "libavutil/intreadwrite.h"
25 #include "libavutil/opt.h"
26 #include "avfilter.h"
27 #include "formats.h"
28 #include "internal.h"
29 #include "video.h"
30 
31 typedef struct DrawGraphContext {
32  const AVClass *class;
33 
34  char *key[4];
35  float min, max;
36  char *fg_str[4];
38  uint8_t bg[4];
39  int mode;
40  int slide;
41  int w, h;
42 
44  int x;
45  int prev_y[4];
46  int first;
48 
49 #define OFFSET(x) offsetof(DrawGraphContext, x)
50 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
51 
52 static const AVOption drawgraph_options[] = {
53  { "m1", "set 1st metadata key", OFFSET(key[0]), AV_OPT_TYPE_STRING, {.str=""}, CHAR_MIN, CHAR_MAX, FLAGS },
54  { "fg1", "set 1st foreground color expression", OFFSET(fg_str[0]), AV_OPT_TYPE_STRING, {.str="0xffff0000"}, CHAR_MIN, CHAR_MAX, FLAGS },
55  { "m2", "set 2nd metadata key", OFFSET(key[1]), AV_OPT_TYPE_STRING, {.str=""}, CHAR_MIN, CHAR_MAX, FLAGS },
56  { "fg2", "set 2nd foreground color expression", OFFSET(fg_str[1]), AV_OPT_TYPE_STRING, {.str="0xff00ff00"}, CHAR_MIN, CHAR_MAX, FLAGS },
57  { "m3", "set 3rd metadata key", OFFSET(key[2]), AV_OPT_TYPE_STRING, {.str=""}, CHAR_MIN, CHAR_MAX, FLAGS },
58  { "fg3", "set 3rd foreground color expression", OFFSET(fg_str[2]), AV_OPT_TYPE_STRING, {.str="0xffff00ff"}, CHAR_MIN, CHAR_MAX, FLAGS },
59  { "m4", "set 4th metadata key", OFFSET(key[3]), AV_OPT_TYPE_STRING, {.str=""}, CHAR_MIN, CHAR_MAX, FLAGS },
60  { "fg4", "set 4th foreground color expression", OFFSET(fg_str[3]), AV_OPT_TYPE_STRING, {.str="0xffffff00"}, CHAR_MIN, CHAR_MAX, FLAGS },
61  { "bg", "set background color", OFFSET(bg), AV_OPT_TYPE_COLOR, {.str="white"}, CHAR_MIN, CHAR_MAX, FLAGS },
62  { "min", "set minimal value", OFFSET(min), AV_OPT_TYPE_FLOAT, {.dbl=-1.}, INT_MIN, INT_MAX, FLAGS },
63  { "max", "set maximal value", OFFSET(max), AV_OPT_TYPE_FLOAT, {.dbl=1.}, INT_MIN, INT_MAX, FLAGS },
64  { "mode", "set graph mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=2}, 0, 2, FLAGS, "mode" },
65  {"bar", "draw bars", OFFSET(mode), AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "mode"},
66  {"dot", "draw dots", OFFSET(mode), AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "mode"},
67  {"line", "draw lines", OFFSET(mode), AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "mode"},
68  { "slide", "set slide mode", OFFSET(slide), AV_OPT_TYPE_INT, {.i64=0}, 0, 3, FLAGS, "slide" },
69  {"frame", "draw new frames", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "slide"},
70  {"replace", "replace old columns with new", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "slide"},
71  {"scroll", "scroll from right to left", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "slide"},
72  {"rscroll", "scroll from left to right", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, FLAGS, "slide"},
73  { "size", "set graph size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="900x256"}, 0, 0, FLAGS },
74  { "s", "set graph size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="900x256"}, 0, 0, FLAGS },
75  { NULL }
76 };
77 
78 static const char *const var_names[] = { "MAX", "MIN", "VAL", NULL };
80 
81 static av_cold int init(AVFilterContext *ctx)
82 {
83  DrawGraphContext *s = ctx->priv;
84  int ret, i;
85 
86  if (s->max <= s->min) {
87  av_log(ctx, AV_LOG_ERROR, "max is same or lower than min\n");
88  return AVERROR(EINVAL);
89  }
90 
91  for (i = 0; i < 4; i++) {
92  if (s->fg_str[i]) {
93  ret = av_expr_parse(&s->fg_expr[i], s->fg_str[i], var_names,
94  NULL, NULL, NULL, NULL, 0, ctx);
95 
96  if (ret < 0)
97  return ret;
98  }
99  }
100 
101  s->first = 1;
102 
103  return 0;
104 }
105 
107 {
108  AVFilterLink *outlink = ctx->outputs[0];
109  static const enum AVPixelFormat pix_fmts[] = {
112  };
113 
114  AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
115  if (!fmts_list)
116  return AVERROR(ENOMEM);
117  ff_formats_ref(fmts_list, &outlink->in_formats);
118 
119  return 0;
120 }
121 
123 {
124  int i, j;
125  int bg = AV_RN32(s->bg);
126 
127  for (i = 0; i < out->height; i++)
128  for (j = 0; j < out->width; j++)
129  AV_WN32(out->data[0] + i * out->linesize[0] + j * 4, bg);
130 }
131 
132 static inline void draw_dot(int fg, int x, int y, AVFrame *out)
133 {
134  AV_WN32(out->data[0] + y * out->linesize[0] + x * 4, fg);
135 }
136 
137 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
138 {
139  AVFilterContext *ctx = inlink->dst;
140  DrawGraphContext *s = ctx->priv;
141  AVFilterLink *outlink = ctx->outputs[0];
142  AVDictionary *metadata;
144  AVFrame *out = s->out;
145  int i;
146 
147  if (!s->out || s->out->width != outlink->w ||
148  s->out->height != outlink->h) {
149  av_frame_free(&s->out);
150  s->out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
151  out = s->out;
152  if (!s->out) {
153  av_frame_free(&in);
154  return AVERROR(ENOMEM);
155  }
156 
157  clear_image(s, out, outlink);
158  }
159  av_frame_copy_props(out, in);
160 
161  metadata = av_frame_get_metadata(in);
162 
163  for (i = 0; i < 4; i++) {
164  double values[VAR_VARS_NB];
165  int j, y, x, old;
166  uint32_t fg, bg;
167  float vf;
168 
169  e = av_dict_get(metadata, s->key[i], NULL, 0);
170  if (!e || !e->value)
171  continue;
172 
173  if (sscanf(e->value, "%f", &vf) != 1)
174  continue;
175 
176  vf = av_clipf(vf, s->min, s->max);
177 
178  values[VAR_MIN] = s->min;
179  values[VAR_MAX] = s->max;
180  values[VAR_VAL] = vf;
181 
182  fg = av_expr_eval(s->fg_expr[i], values, NULL);
183  bg = AV_RN32(s->bg);
184 
185  if (i == 0 && (s->x >= outlink->w || s->slide == 3)) {
186  if (s->slide == 0 || s->slide == 1)
187  s->x = 0;
188 
189  if (s->slide == 2) {
190  s->x = outlink->w - 1;
191  for (j = 0; j < outlink->h; j++) {
192  memmove(out->data[0] + j * out->linesize[0] ,
193  out->data[0] + j * out->linesize[0] + 4,
194  (outlink->w - 1) * 4);
195  }
196  } else if (s->slide == 3) {
197  s->x = 0;
198  for (j = 0; j < outlink->h; j++) {
199  memmove(out->data[0] + j * out->linesize[0] + 4,
200  out->data[0] + j * out->linesize[0],
201  (outlink->w - 1) * 4);
202  }
203  } else if (s->slide == 0) {
204  clear_image(s, out, outlink);
205  }
206  }
207 
208  x = s->x;
209  y = (outlink->h - 1) * (1 - ((vf - s->min) / (s->max - s->min)));
210 
211  switch (s->mode) {
212  case 0:
213  if (i == 0 && (s->slide > 0))
214  for (j = 0; j < outlink->h; j++)
215  draw_dot(bg, x, j, out);
216 
217  old = AV_RN32(out->data[0] + y * out->linesize[0] + x * 4);
218  for (j = y; j < outlink->h; j++) {
219  if (old != bg &&
220  (AV_RN32(out->data[0] + j * out->linesize[0] + x * 4) != old) ||
221  AV_RN32(out->data[0] + FFMIN(j+1, outlink->h - 1) * out->linesize[0] + x * 4) != old) {
222  draw_dot(fg, x, j, out);
223  break;
224  }
225  draw_dot(fg, x, j, out);
226  }
227  break;
228  case 1:
229  if (i == 0 && (s->slide > 0))
230  for (j = 0; j < outlink->h; j++)
231  draw_dot(bg, x, j, out);
232  draw_dot(fg, x, y, out);
233  break;
234  case 2:
235  if (s->first) {
236  s->first = 0;
237  s->prev_y[i] = y;
238  }
239 
240  if (i == 0 && (s->slide > 0)) {
241  for (j = 0; j < y; j++)
242  draw_dot(bg, x, j, out);
243  for (j = outlink->h - 1; j > y; j--)
244  draw_dot(bg, x, j, out);
245  }
246  if (y <= s->prev_y[i]) {
247  for (j = y; j <= s->prev_y[i]; j++)
248  draw_dot(fg, x, j, out);
249  } else {
250  for (j = s->prev_y[i]; j <= y; j++)
251  draw_dot(fg, x, j, out);
252  }
253  s->prev_y[i] = y;
254  break;
255  }
256  }
257 
258  s->x++;
259 
260  av_frame_free(&in);
261  return ff_filter_frame(outlink, av_frame_clone(s->out));
262 }
263 
264 static int config_output(AVFilterLink *outlink)
265 {
266  DrawGraphContext *s = outlink->src->priv;
267 
268  outlink->w = s->w;
269  outlink->h = s->h;
270  outlink->sample_aspect_ratio = (AVRational){1,1};
271 
272  return 0;
273 }
274 
275 static av_cold void uninit(AVFilterContext *ctx)
276 {
277  DrawGraphContext *s = ctx->priv;
278  int i;
279 
280  for (i = 0; i < 4; i++)
281  av_expr_free(s->fg_expr[i]);
282  av_frame_free(&s->out);
283 }
284 
285 #if CONFIG_DRAWGRAPH_FILTER
286 
287 AVFILTER_DEFINE_CLASS(drawgraph);
288 
289 static const AVFilterPad drawgraph_inputs[] = {
290  {
291  .name = "default",
292  .type = AVMEDIA_TYPE_VIDEO,
293  .filter_frame = filter_frame,
294  },
295  { NULL }
296 };
297 
298 static const AVFilterPad drawgraph_outputs[] = {
299  {
300  .name = "default",
301  .type = AVMEDIA_TYPE_VIDEO,
302  .config_props = config_output,
303  },
304  { NULL }
305 };
306 
307 AVFilter ff_vf_drawgraph = {
308  .name = "drawgraph",
309  .description = NULL_IF_CONFIG_SMALL("Draw a graph using input video metadata."),
310  .priv_size = sizeof(DrawGraphContext),
311  .priv_class = &drawgraph_class,
313  .init = init,
314  .uninit = uninit,
315  .inputs = drawgraph_inputs,
316  .outputs = drawgraph_outputs,
317 };
318 
319 #endif // CONFIG_DRAWGRAPH_FILTER
320 
321 #if CONFIG_ADRAWGRAPH_FILTER
322 
323 #define adrawgraph_options drawgraph_options
324 AVFILTER_DEFINE_CLASS(adrawgraph);
325 
326 static const AVFilterPad adrawgraph_inputs[] = {
327  {
328  .name = "default",
329  .type = AVMEDIA_TYPE_AUDIO,
330  .filter_frame = filter_frame,
331  },
332  { NULL }
333 };
334 
335 static const AVFilterPad adrawgraph_outputs[] = {
336  {
337  .name = "default",
338  .type = AVMEDIA_TYPE_VIDEO,
339  .config_props = config_output,
340  },
341  { NULL }
342 };
343 
344 AVFilter ff_avf_adrawgraph = {
345  .name = "adrawgraph",
346  .description = NULL_IF_CONFIG_SMALL("Draw a graph using input audio metadata."),
347  .priv_size = sizeof(DrawGraphContext),
348  .priv_class = &adrawgraph_class,
350  .init = init,
351  .uninit = uninit,
352  .inputs = adrawgraph_inputs,
353  .outputs = adrawgraph_outputs,
354 };
355 #endif // CONFIG_ADRAWGRAPH_FILTER
#define NULL
Definition: coverity.c:32
const char * s
Definition: avisynth_c.h:631
static av_cold int init(AVFilterContext *ctx)
Definition: f_drawgraph.c:81
This structure describes decoded (raw) audio or video data.
Definition: frame.h:171
static void draw_dot(int fg, int x, int y, AVFrame *out)
Definition: f_drawgraph.c:132
AVOption.
Definition: opt.h:255
AVFrame * out
Definition: f_drawgraph.c:43
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:248
Main libavfilter public API header.
static const char *const var_names[]
Definition: f_drawgraph.c:78
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:653
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 int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: f_drawgraph.c:137
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
const char * name
Pad name.
Definition: internal.h:69
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1158
static const AVOption drawgraph_options[]
Definition: f_drawgraph.c:52
uint8_t
#define av_cold
Definition: attributes.h:74
mode
Definition: f_perms.c:27
AVOptions.
Definition: eval.c:144
static void clear_image(DrawGraphContext *s, AVFrame *out, AVFilterLink *outlink)
Definition: f_drawgraph.c:122
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition: dict.c:39
char * key[4]
Definition: f_drawgraph.c:34
static av_cold void uninit(AVFilterContext *ctx)
Definition: f_drawgraph.c:275
#define av_log(a,...)
A filter pad used for either input or output.
Definition: internal.h:63
static int config_output(AVFilterLink *outlink)
Definition: f_drawgraph.c:264
int width
width and height of the video frame
Definition: frame.h:220
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
#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:148
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:175
void * priv
private data for use by the filter
Definition: avfilter.h:654
uint8_t bg[4]
Definition: f_drawgraph.c:38
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:95
#define FFMIN(a, b)
Definition: common.h:81
float y
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add *ref as a new reference to formats.
Definition: formats.c:422
#define FLAGS
Definition: f_drawgraph.c:50
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:451
#define OFFSET(x)
Definition: f_drawgraph.c:49
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
Definition: eval.c:313
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:199
AVExpr * fg_expr[4]
Definition: f_drawgraph.c:37
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
AVDictionary * av_frame_get_metadata(const AVFrame *frame)
Describe the class of an AVClass context structure.
Definition: log.h:67
Filter definition.
Definition: avfilter.h:470
static const AVFilterPad inputs[]
Definition: af_ashowinfo.c:239
rational number numerator/denominator
Definition: rational.h:43
const char * name
Filter name.
Definition: avfilter.h:474
offset must point to two consecutive integers
Definition: opt.h:232
#define AV_RN32(p)
Definition: intreadwrite.h:364
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:648
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:209
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:182
#define AV_WN32(p, v)
Definition: intreadwrite.h:376
static int query_formats(AVFilterContext *ctx)
Definition: f_drawgraph.c:106
char * value
Definition: dict.h:88
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
Definition: eval.c:708
#define AVFILTER_DEFINE_CLASS(fname)
Definition: internal.h:334
A list of supported formats for one end of a filter link.
Definition: formats.h:64
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-> out
An instance of a filter.
Definition: avfilter.h:633
int height
Definition: frame.h:220
char * fg_str[4]
Definition: f_drawgraph.c:36
internal API functions
float min
AVPixelFormat
Pixel format.
Definition: pixfmt.h:61
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:553
simple arithmetic expression evaluator