FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vf_datascope.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 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/intreadwrite.h"
23 #include "libavutil/opt.h"
24 #include "libavutil/parseutils.h"
25 #include "libavutil/pixdesc.h"
27 #include "avfilter.h"
28 #include "drawutils.h"
29 #include "formats.h"
30 #include "internal.h"
31 #include "video.h"
32 
33 typedef struct DatascopeContext {
34  const AVClass *class;
35  int ow, oh;
36  int x, y;
37  int mode;
38  int axis;
39  float opacity;
40 
41  int nb_planes;
42  int nb_comps;
43  int chars;
49 
52  int (*filter)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
54 
55 #define OFFSET(x) offsetof(DatascopeContext, x)
56 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
57 
58 static const AVOption datascope_options[] = {
59  { "size", "set output size", OFFSET(ow), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, FLAGS },
60  { "s", "set output size", OFFSET(ow), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, FLAGS },
61  { "x", "set x offset", OFFSET(x), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
62  { "y", "set y offset", OFFSET(y), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
63  { "mode", "set scope mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, FLAGS, "mode" },
64  { "mono", NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "mode" },
65  { "color", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "mode" },
66  { "color2", NULL, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "mode" },
67  { "axis", "draw column/row numbers", OFFSET(axis), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
68  { "opacity", "set background opacity", OFFSET(opacity), AV_OPT_TYPE_FLOAT, {.dbl=0.75}, 0, 1, FLAGS },
69  { NULL }
70 };
71 
72 AVFILTER_DEFINE_CLASS(datascope);
73 
75 {
77 }
78 
80  int x0, int y0, const uint8_t *text, int vertical)
81 {
82  int x = x0;
83 
84  for (; *text; text++) {
85  if (*text == '\n') {
86  x = x0;
87  y0 += 8;
88  continue;
89  }
90  ff_blend_mask(&s->draw, color, frame->data, frame->linesize,
91  frame->width, frame->height,
92  avpriv_cga_font + *text * 8, 1, 8, 8, 0, 0, x, y0);
93  if (vertical) {
94  x = x0;
95  y0 += 8;
96  } else {
97  x += 8;
98  }
99  }
100 }
101 
102 static void pick_color8(FFDrawContext *draw, FFDrawColor *color, AVFrame *in, int x, int y, int *value)
103 {
104  int p, i;
105 
106  color->rgba[3] = 255;
107  for (p = 0; p < draw->nb_planes; p++) {
108  if (draw->nb_planes == 1) {
109  for (i = 0; i < 4; i++) {
110  value[i] = in->data[0][y * in->linesize[0] + x * draw->pixelstep[0] + i];
111  color->comp[0].u8[i] = value[i];
112  }
113  } else {
114  value[p] = in->data[p][(y >> draw->vsub[p]) * in->linesize[p] + (x >> draw->hsub[p])];
115  color->comp[p].u8[0] = value[p];
116  }
117  }
118 }
119 
120 static void pick_color16(FFDrawContext *draw, FFDrawColor *color, AVFrame *in, int x, int y, int *value)
121 {
122  int p, i;
123 
124  color->rgba[3] = 255;
125  for (p = 0; p < draw->nb_planes; p++) {
126  if (draw->nb_planes == 1) {
127  for (i = 0; i < 4; i++) {
128  value[i] = AV_RL16(in->data[0] + y * in->linesize[0] + x * draw->pixelstep[0] + i * 2);
129  color->comp[0].u16[i] = value[i];
130  }
131  } else {
132  value[p] = AV_RL16(in->data[p] + (y >> draw->vsub[p]) * in->linesize[p] + (x >> draw->hsub[p]) * 2);
133  color->comp[p].u16[0] = value[p];
134  }
135  }
136 }
137 
139 {
140  int p;
141 
142  reverse->rgba[3] = 255;
143  for (p = 0; p < draw->nb_planes; p++) {
144  reverse->comp[p].u8[0] = color->comp[p].u8[0] > 127 ? 0 : 255;
145  reverse->comp[p].u8[1] = color->comp[p].u8[1] > 127 ? 0 : 255;
146  reverse->comp[p].u8[2] = color->comp[p].u8[2] > 127 ? 0 : 255;
147  }
148 }
149 
151 {
152  int p;
153 
154  reverse->rgba[3] = 255;
155  for (p = 0; p < draw->nb_planes; p++) {
156  const unsigned max = (1 << draw->desc->comp[p].depth) - 1;
157  const unsigned mid = (max + 1) / 2;
158 
159  reverse->comp[p].u16[0] = color->comp[p].u16[0] > mid ? 0 : max;
160  reverse->comp[p].u16[1] = color->comp[p].u16[1] > mid ? 0 : max;
161  reverse->comp[p].u16[2] = color->comp[p].u16[2] > mid ? 0 : max;
162  }
163 }
164 
165 typedef struct ThreadData {
166  AVFrame *in, *out;
167  int xoff, yoff;
168 } ThreadData;
169 
170 static int filter_color2(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
171 {
172  DatascopeContext *s = ctx->priv;
173  AVFilterLink *outlink = ctx->outputs[0];
174  AVFilterLink *inlink = ctx->inputs[0];
175  ThreadData *td = arg;
176  AVFrame *in = td->in;
177  AVFrame *out = td->out;
178  const int xoff = td->xoff;
179  const int yoff = td->yoff;
180  const int P = FFMAX(s->nb_planes, s->nb_comps);
181  const int C = s->chars;
182  const int W = (outlink->w - xoff) / (C * 10);
183  const int H = (outlink->h - yoff) / (P * 12);
184  const char *format[2] = {"%02X\n", "%04X\n"};
185  const int slice_start = (W * jobnr) / nb_jobs;
186  const int slice_end = (W * (jobnr+1)) / nb_jobs;
187  int x, y, p;
188 
189  for (y = 0; y < H && (y + s->y < inlink->h); y++) {
190  for (x = slice_start; x < slice_end && (x + s->x < inlink->w); x++) {
191  FFDrawColor color = { { 0 } };
192  FFDrawColor reverse = { { 0 } };
193  int value[4] = { 0 };
194 
195  s->pick_color(&s->draw, &color, in, x + s->x, y + s->y, value);
196  s->reverse_color(&s->draw, &color, &reverse);
197  ff_fill_rectangle(&s->draw, &color, out->data, out->linesize,
198  xoff + x * C * 10, yoff + y * P * 12, C * 10, P * 12);
199 
200  for (p = 0; p < P; p++) {
201  char text[256];
202 
203  snprintf(text, sizeof(text), format[C>>2], value[p]);
204  draw_text(s, out, &reverse, xoff + x * C * 10 + 2, yoff + y * P * 12 + p * 10 + 2, text, 0);
205  }
206  }
207  }
208 
209  return 0;
210 }
211 
212 static int filter_color(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
213 {
214  DatascopeContext *s = ctx->priv;
215  AVFilterLink *outlink = ctx->outputs[0];
216  AVFilterLink *inlink = ctx->inputs[0];
217  ThreadData *td = arg;
218  AVFrame *in = td->in;
219  AVFrame *out = td->out;
220  const int xoff = td->xoff;
221  const int yoff = td->yoff;
222  const int P = FFMAX(s->nb_planes, s->nb_comps);
223  const int C = s->chars;
224  const int W = (outlink->w - xoff) / (C * 10);
225  const int H = (outlink->h - yoff) / (P * 12);
226  const char *format[2] = {"%02X\n", "%04X\n"};
227  const int slice_start = (W * jobnr) / nb_jobs;
228  const int slice_end = (W * (jobnr+1)) / nb_jobs;
229  int x, y, p;
230 
231  for (y = 0; y < H && (y + s->y < inlink->h); y++) {
232  for (x = slice_start; x < slice_end && (x + s->x < inlink->w); x++) {
233  FFDrawColor color = { { 0 } };
234  int value[4] = { 0 };
235 
236  s->pick_color(&s->draw, &color, in, x + s->x, y + s->y, value);
237 
238  for (p = 0; p < P; p++) {
239  char text[256];
240 
241  snprintf(text, sizeof(text), format[C>>2], value[p]);
242  draw_text(s, out, &color, xoff + x * C * 10 + 2, yoff + y * P * 12 + p * 10 + 2, text, 0);
243  }
244  }
245  }
246 
247  return 0;
248 }
249 
250 static int filter_mono(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
251 {
252  DatascopeContext *s = ctx->priv;
253  AVFilterLink *outlink = ctx->outputs[0];
254  AVFilterLink *inlink = ctx->inputs[0];
255  ThreadData *td = arg;
256  AVFrame *in = td->in;
257  AVFrame *out = td->out;
258  const int xoff = td->xoff;
259  const int yoff = td->yoff;
260  const int P = FFMAX(s->nb_planes, s->nb_comps);
261  const int C = s->chars;
262  const int W = (outlink->w - xoff) / (C * 10);
263  const int H = (outlink->h - yoff) / (P * 12);
264  const char *format[2] = {"%02X\n", "%04X\n"};
265  const int slice_start = (W * jobnr) / nb_jobs;
266  const int slice_end = (W * (jobnr+1)) / nb_jobs;
267  int x, y, p;
268 
269  for (y = 0; y < H && (y + s->y < inlink->h); y++) {
270  for (x = slice_start; x < slice_end && (x + s->x < inlink->w); x++) {
271  FFDrawColor color = { { 0 } };
272  int value[4] = { 0 };
273 
274  s->pick_color(&s->draw, &color, in, x + s->x, y + s->y, value);
275  for (p = 0; p < P; p++) {
276  char text[256];
277 
278  snprintf(text, sizeof(text), format[C>>2], value[p]);
279  draw_text(s, out, &s->white, xoff + x * C * 10 + 2, yoff + y * P * 12 + p * 10 + 2, text, 0);
280  }
281  }
282  }
283 
284  return 0;
285 }
286 
287 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
288 {
289  AVFilterContext *ctx = inlink->dst;
290  DatascopeContext *s = ctx->priv;
291  AVFilterLink *outlink = ctx->outputs[0];
292  ThreadData td = { 0 };
293  int ymaxlen = 0;
294  int xmaxlen = 0;
295  AVFrame *out;
296 
297  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
298  if (!out) {
299  av_frame_free(&in);
300  return AVERROR(ENOMEM);
301  }
302  out->pts = in->pts;
303 
304  ff_fill_rectangle(&s->draw, &s->black, out->data, out->linesize,
305  0, 0, outlink->w, outlink->h);
306 
307  if (s->axis) {
308  const int P = FFMAX(s->nb_planes, s->nb_comps);
309  const int C = s->chars;
310  int Y = outlink->h / (P * 12);
311  int X = outlink->w / (C * 10);
312  char text[256] = { 0 };
313  int x, y;
314 
315  snprintf(text, sizeof(text), "%d", s->y + Y);
316  ymaxlen = strlen(text);
317  ymaxlen *= 10;
318  snprintf(text, sizeof(text), "%d", s->x + X);
319  xmaxlen = strlen(text);
320  xmaxlen *= 10;
321 
322  Y = (outlink->h - xmaxlen) / (P * 12);
323  X = (outlink->w - ymaxlen) / (C * 10);
324 
325  for (y = 0; y < Y; y++) {
326  snprintf(text, sizeof(text), "%d", s->y + y);
327 
328  ff_fill_rectangle(&s->draw, &s->gray, out->data, out->linesize,
329  0, xmaxlen + y * P * 12 + (P + 1) * P - 2, ymaxlen, 10);
330 
331  draw_text(s, out, &s->yellow, 2, xmaxlen + y * P * 12 + (P + 1) * P, text, 0);
332  }
333 
334  for (x = 0; x < X; x++) {
335  snprintf(text, sizeof(text), "%d", s->x + x);
336 
337  ff_fill_rectangle(&s->draw, &s->gray, out->data, out->linesize,
338  ymaxlen + x * C * 10 + 2 * C - 2, 0, 10, xmaxlen);
339 
340  draw_text(s, out, &s->yellow, ymaxlen + x * C * 10 + 2 * C, 2, text, 1);
341  }
342  }
343 
344  td.in = in; td.out = out, td.yoff = xmaxlen, td.xoff = ymaxlen;
345  ctx->internal->execute(ctx, s->filter, &td, NULL, FFMIN(ff_filter_get_nb_threads(ctx), FFMAX(outlink->w / 20, 1)));
346 
347  av_frame_free(&in);
348  return ff_filter_frame(outlink, out);
349 }
350 
351 static int config_input(AVFilterLink *inlink)
352 {
353  DatascopeContext *s = inlink->dst->priv;
354  uint8_t alpha = s->opacity * 255;
355 
357  ff_draw_init(&s->draw, inlink->format, 0);
358  ff_draw_color(&s->draw, &s->white, (uint8_t[]){ 255, 255, 255, 255} );
359  ff_draw_color(&s->draw, &s->black, (uint8_t[]){ 0, 0, 0, alpha} );
360  ff_draw_color(&s->draw, &s->yellow, (uint8_t[]){ 255, 255, 0, 255} );
361  ff_draw_color(&s->draw, &s->gray, (uint8_t[]){ 77, 77, 77, 255} );
362  s->chars = (s->draw.desc->comp[0].depth + 7) / 8 * 2;
363  s->nb_comps = s->draw.desc->nb_components;
364 
365  switch (s->mode) {
366  case 0: s->filter = filter_mono; break;
367  case 1: s->filter = filter_color; break;
368  case 2: s->filter = filter_color2; break;
369  }
370 
371  if (s->draw.desc->comp[0].depth <= 8) {
372  s->pick_color = pick_color8;
373  s->reverse_color = reverse_color8;
374  } else {
375  s->pick_color = pick_color16;
376  s->reverse_color = reverse_color16;
377  }
378 
379  return 0;
380 }
381 
382 static int config_output(AVFilterLink *outlink)
383 {
384  DatascopeContext *s = outlink->src->priv;
385 
386  outlink->h = s->oh;
387  outlink->w = s->ow;
388  outlink->sample_aspect_ratio = (AVRational){1,1};
389 
390  return 0;
391 }
392 
393 static const AVFilterPad inputs[] = {
394  {
395  .name = "default",
396  .type = AVMEDIA_TYPE_VIDEO,
397  .filter_frame = filter_frame,
398  .config_props = config_input,
399  },
400  { NULL }
401 };
402 
403 static const AVFilterPad outputs[] = {
404  {
405  .name = "default",
406  .type = AVMEDIA_TYPE_VIDEO,
407  .config_props = config_output,
408  },
409  { NULL }
410 };
411 
413  .name = "datascope",
414  .description = NULL_IF_CONFIG_SMALL("Video data analysis."),
415  .priv_size = sizeof(DatascopeContext),
416  .priv_class = &datascope_class,
418  .inputs = inputs,
419  .outputs = outputs,
421 };
AVFilterFormats * ff_draw_supported_pixel_formats(unsigned flags)
Return the list of pixel formats supported by the draw functions.
Definition: drawutils.c:721
#define NULL
Definition: coverity.c:32
const char * s
Definition: avisynth_c.h:768
#define P
AVFrame * out
Definition: af_sofalizer.c:587
This structure describes decoded (raw) audio or video data.
Definition: frame.h:187
AVOption.
Definition: opt.h:246
#define C
uint16_t u16[8]
Definition: drawutils.h:65
uint8_t hsub[MAX_PLANES]
Definition: drawutils.h:54
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2373
Main libavfilter public API header.
static int filter_color2(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_datascope.c:170
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:92
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
Definition: bytestream.h:87
void(* pick_color)(FFDrawContext *draw, FFDrawColor *color, AVFrame *in, int x, int y, int *value)
Definition: vf_datascope.c:50
static int filter_mono(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_datascope.c:250
const char * name
Pad name.
Definition: internal.h:60
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:331
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1125
AVFrame * in
Definition: af_sofalizer.c:587
#define OFFSET(x)
Definition: vf_datascope.c:55
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:117
static void pick_color16(FFDrawContext *draw, FFDrawColor *color, AVFrame *in, int x, int y, int *value)
Definition: vf_datascope.c:120
uint8_t
static void pick_color8(FFDrawContext *draw, FFDrawColor *color, AVFrame *in, int x, int y, int *value)
Definition: vf_datascope.c:102
FFDrawColor gray
Definition: vf_datascope.c:48
AVOptions.
#define Y
Definition: vf_boxblur.c:76
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
Definition: log.c:94
static uint32_t reverse(uint32_t num, int bits)
Definition: speedhq.c:562
static int filter_color(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_datascope.c:212
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:271
int(* filter)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_datascope.c:52
static AVFrame * frame
void(* reverse_color)(FFDrawContext *draw, FFDrawColor *color, FFDrawColor *reverse)
Definition: vf_datascope.c:51
static int flags
Definition: log.c:57
static const AVFilterPad inputs[]
Definition: vf_datascope.c:393
A filter pad used for either input or output.
Definition: internal.h:54
static const AVOption datascope_options[]
Definition: vf_datascope.c:58
static double alpha(void *priv, double x, double y)
Definition: vf_geq.c:99
int width
width and height of the video frame
Definition: frame.h:239
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
#define td
Definition: regdef.h:70
const uint8_t avpriv_cga_font[2048]
Definition: xga_font_data.c:29
#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:163
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:179
void * priv
private data for use by the filter
Definition: avfilter.h:338
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:116
const char * arg
Definition: jacosubdec.c:66
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4])
Prepare a color.
Definition: drawutils.c:224
simple assert() macros that are a bit more flexible than ISO C assert().
#define FFMAX(a, b)
Definition: common.h:94
uint8_t u8[16]
Definition: drawutils.h:66
static void reverse_color16(FFDrawContext *draw, FFDrawColor *color, FFDrawColor *reverse)
Definition: vf_datascope.c:150
FFDrawContext draw
Definition: vf_datascope.c:44
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:831
#define FFMIN(a, b)
Definition: common.h:96
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_datascope.c:287
static void draw_text(DatascopeContext *s, AVFrame *frame, FFDrawColor *color, int x0, int y0, const uint8_t *text, int vertical)
Definition: vf_datascope.c:79
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
GLsizei GLboolean const GLfloat * value
Definition: opengl_enc.c:109
AVFormatContext * ctx
Definition: movenc.c:48
static int config_input(AVFilterLink *inlink)
Definition: vf_datascope.c:351
static int query_formats(AVFilterContext *ctx)
Definition: vf_datascope.c:74
union FFDrawColor::@173 comp[MAX_PLANES]
AVFILTER_DEFINE_CLASS(datascope)
#define FLAGS
Definition: vf_datascope.c:56
void ff_blend_mask(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_w, int dst_h, const uint8_t *mask, int mask_linesize, int mask_w, int mask_h, int l2depth, unsigned endianness, int x0, int y0)
Blend an alpha mask with an uniform color.
Definition: drawutils.c:612
static const AVFilterPad outputs[]
Definition: vf_datascope.c:403
misc drawing utilities
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:218
unsigned nb_planes
Definition: drawutils.h:51
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
static const char * format
Definition: movenc.c:47
Describe the class of an AVClass context structure.
Definition: log.h:67
Filter definition.
Definition: avfilter.h:144
#define W(a, i, v)
Definition: jpegls.h:122
Rational number (pair of numerator and denominator).
Definition: rational.h:58
const char * name
Filter name.
Definition: avfilter.h:148
int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags)
Init a draw context.
Definition: drawutils.c:176
#define snprintf
Definition: snprintf.h:34
offset must point to two consecutive integers
Definition: opt.h:233
misc parsing utilities
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:335
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
Definition: avfilter.h:363
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:201
int
FFDrawColor white
Definition: vf_datascope.c:46
static int config_output(AVFilterLink *outlink)
Definition: vf_datascope.c:382
avfilter_execute_func * execute
Definition: internal.h:155
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:2051
FFDrawColor yellow
Definition: vf_datascope.c:45
FFDrawColor black
Definition: vf_datascope.c:47
AVFilter ff_vf_datascope
Definition: vf_datascope.c:412
int pixelstep[MAX_PLANES]
Definition: drawutils.h:52
#define H
Definition: pixlet.c:37
const struct AVPixFmtDescriptor * desc
Definition: drawutils.h:49
void ff_fill_rectangle(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_x, int dst_y, int w, int h)
Fill a rectangle with an uniform color.
Definition: drawutils.c:308
An instance of a filter.
Definition: avfilter.h:323
int height
Definition: frame.h:239
FILE * out
Definition: movenc.c:54
uint8_t vsub[MAX_PLANES]
Definition: drawutils.h:55
internal API functions
int depth
Number of bits in the component.
Definition: pixdesc.h:58
mode
Use these values in ebur128_init (or'ed).
Definition: ebur128.h:83
CGA/EGA/VGA ROM font data.
static void reverse_color8(FFDrawContext *draw, FFDrawColor *color, FFDrawColor *reverse)
Definition: vf_datascope.c:138
uint8_t rgba[4]
Definition: drawutils.h:62