FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vf_lut2.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/attributes.h"
22 #include "libavutil/common.h"
23 #include "libavutil/eval.h"
24 #include "libavutil/opt.h"
25 #include "libavutil/pixdesc.h"
26 #include "avfilter.h"
27 #include "drawutils.h"
28 #include "formats.h"
29 #include "internal.h"
30 #include "video.h"
31 #include "framesync.h"
32 
33 static const char *const var_names[] = {
34  "w", ///< width of the input video
35  "h", ///< height of the input video
36  "x", ///< input value for the pixel from input #1
37  "y", ///< input value for the pixel from input #2
38  "bdx", ///< input #1 video bitdepth
39  "bdy", ///< input #2 video bitdepth
40  NULL
41 };
42 
43 enum var_name {
51 };
52 
53 typedef struct LUT2Context {
54  const AVClass *class;
56 
57  char *comp_expr_str[4];
58 
61  uint16_t *lut[4]; ///< lookup table for each component
62  int width[4], height[4];
63  int nb_planes;
65  int tlut2;
66  AVFrame *prev_frame; /* only used with tlut2 */
67 
68  void (*lut2)(struct LUT2Context *s, AVFrame *dst, AVFrame *srcx, AVFrame *srcy);
69 
70 } LUT2Context;
71 
72 #define OFFSET(x) offsetof(LUT2Context, x)
73 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
74 
75 static const AVOption options[] = {
76  { "c0", "set component #0 expression", OFFSET(comp_expr_str[0]), AV_OPT_TYPE_STRING, { .str = "x" }, .flags = FLAGS },
77  { "c1", "set component #1 expression", OFFSET(comp_expr_str[1]), AV_OPT_TYPE_STRING, { .str = "x" }, .flags = FLAGS },
78  { "c2", "set component #2 expression", OFFSET(comp_expr_str[2]), AV_OPT_TYPE_STRING, { .str = "x" }, .flags = FLAGS },
79  { "c3", "set component #3 expression", OFFSET(comp_expr_str[3]), AV_OPT_TYPE_STRING, { .str = "x" }, .flags = FLAGS },
80  { NULL }
81 };
82 
84 {
85  LUT2Context *s = ctx->priv;
86  int i;
87 
90 
91  for (i = 0; i < 4; i++) {
92  av_expr_free(s->comp_expr[i]);
93  s->comp_expr[i] = NULL;
94  av_freep(&s->comp_expr_str[i]);
95  av_freep(&s->lut[i]);
96  }
97 }
98 
100 {
101  static const enum AVPixelFormat pix_fmts[] = {
117  };
118 
119  return ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
120 }
121 
122 static int config_inputx(AVFilterLink *inlink)
123 {
124  AVFilterContext *ctx = inlink->dst;
125  LUT2Context *s = ctx->priv;
127  int hsub = desc->log2_chroma_w;
128  int vsub = desc->log2_chroma_h;
129 
131  s->height[1] = s->height[2] = AV_CEIL_RSHIFT(inlink->h, vsub);
132  s->height[0] = s->height[3] = inlink->h;
133  s->width[1] = s->width[2] = AV_CEIL_RSHIFT(inlink->w, hsub);
134  s->width[0] = s->width[3] = inlink->w;
135 
136  s->var_values[VAR_W] = inlink->w;
137  s->var_values[VAR_H] = inlink->h;
138  s->depthx = desc->comp[0].depth;
140 
141  if (s->tlut2) {
142  s->depthy = desc->comp[0].depth;
144  }
145 
146  return 0;
147 }
148 
149 static int config_inputy(AVFilterLink *inlink)
150 {
151  AVFilterContext *ctx = inlink->dst;
152  LUT2Context *s = ctx->priv;
154 
155  s->depthy = desc->comp[0].depth;
157 
158  return 0;
159 }
160 
161 static void lut2_8bit(struct LUT2Context *s, AVFrame *out, AVFrame *srcx, AVFrame *srcy)
162 {
163  int p, y, x;
164 
165  for (p = 0; p < s->nb_planes; p++) {
166  const uint16_t *lut = s->lut[p];
167  const uint8_t *srcxx, *srcyy;
168  uint8_t *dst;
169 
170  dst = out->data[p];
171  srcxx = srcx->data[p];
172  srcyy = srcy->data[p];
173 
174  for (y = 0; y < s->height[p]; y++) {
175  for (x = 0; x < s->width[p]; x++) {
176  dst[x] = lut[(srcyy[x] << s->depthx) | srcxx[x]];
177  }
178 
179  dst += out->linesize[p];
180  srcxx += srcx->linesize[p];
181  srcyy += srcy->linesize[p];
182  }
183  }
184 }
185 
186 static void lut2_16bit(struct LUT2Context *s, AVFrame *out, AVFrame *srcx, AVFrame *srcy)
187 {
188  int p, y, x;
189 
190  for (p = 0; p < s->nb_planes; p++) {
191  const uint16_t *lut = s->lut[p];
192  const uint16_t *srcxx, *srcyy;
193  uint16_t *dst;
194 
195  dst = (uint16_t *)out->data[p];
196  srcxx = (uint16_t *)srcx->data[p];
197  srcyy = (uint16_t *)srcy->data[p];
198 
199  for (y = 0; y < s->height[p]; y++) {
200  for (x = 0; x < s->width[p]; x++) {
201  dst[x] = lut[(srcyy[x] << s->depthx) | srcxx[x]];
202  }
203 
204  dst += out->linesize[p] / 2;
205  srcxx += srcx->linesize[p] / 2;
206  srcyy += srcy->linesize[p] / 2;
207  }
208  }
209 }
210 
212 {
213  AVFilterContext *ctx = fs->parent;
214  LUT2Context *s = fs->opaque;
215  AVFilterLink *outlink = ctx->outputs[0];
216  AVFrame *out, *srcx = NULL, *srcy = NULL;
217  int ret;
218 
219  if ((ret = ff_framesync_get_frame(&s->fs, 0, &srcx, 0)) < 0 ||
220  (ret = ff_framesync_get_frame(&s->fs, 1, &srcy, 0)) < 0)
221  return ret;
222 
223  if (ctx->is_disabled || !srcy) {
224  out = av_frame_clone(srcx);
225  if (!out)
226  return AVERROR(ENOMEM);
227  } else {
228  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
229  if (!out)
230  return AVERROR(ENOMEM);
231  av_frame_copy_props(out, srcx);
232 
233  s->lut2(s, out, srcx, srcy);
234  }
235 
236  out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
237 
238  return ff_filter_frame(outlink, out);
239 }
240 
241 static int config_output(AVFilterLink *outlink)
242 {
243  AVFilterContext *ctx = outlink->src;
244  LUT2Context *s = ctx->priv;
245  int p, ret;
246 
247  s->depth = s->depthx + s->depthy;
248 
249  s->lut2 = s->depth > 16 ? lut2_16bit : lut2_8bit;
250 
251  for (p = 0; p < s->nb_planes; p++) {
252  s->lut[p] = av_malloc_array(1 << s->depth, sizeof(uint16_t));
253  if (!s->lut[p])
254  return AVERROR(ENOMEM);
255  }
256 
257  for (p = 0; p < s->nb_planes; p++) {
258  double res;
259  int x, y;
260 
261  /* create the parsed expression */
262  av_expr_free(s->comp_expr[p]);
263  s->comp_expr[p] = NULL;
264  ret = av_expr_parse(&s->comp_expr[p], s->comp_expr_str[p],
265  var_names, NULL, NULL, NULL, NULL, 0, ctx);
266  if (ret < 0) {
267  av_log(ctx, AV_LOG_ERROR,
268  "Error when parsing the expression '%s' for the component %d.\n",
269  s->comp_expr_str[p], p);
270  return AVERROR(EINVAL);
271  }
272 
273  /* compute the lut */
274  for (y = 0; y < (1 << s->depthx); y++) {
275  s->var_values[VAR_Y] = y;
276  for (x = 0; x < (1 << s->depthx); x++) {
277  s->var_values[VAR_X] = x;
278  res = av_expr_eval(s->comp_expr[p], s->var_values, s);
279  if (isnan(res)) {
280  av_log(ctx, AV_LOG_ERROR,
281  "Error when evaluating the expression '%s' for the values %d and %d for the component %d.\n",
282  s->comp_expr_str[p], x, y, p);
283  return AVERROR(EINVAL);
284  }
285 
286  s->lut[p][(y << s->depthx) + x] = res;
287  }
288  }
289  }
290 
291  return 0;
292 }
293 
294 static int lut2_config_output(AVFilterLink *outlink)
295 {
296  AVFilterContext *ctx = outlink->src;
297  LUT2Context *s = ctx->priv;
298  AVFilterLink *srcx = ctx->inputs[0];
299  AVFilterLink *srcy = ctx->inputs[1];
300  FFFrameSyncIn *in;
301  int ret;
302 
303  if (srcx->format != srcy->format) {
304  av_log(ctx, AV_LOG_ERROR, "inputs must be of same pixel format\n");
305  return AVERROR(EINVAL);
306  }
307  if (srcx->w != srcy->w || srcx->h != srcy->h) {
308  av_log(ctx, AV_LOG_ERROR, "First input link %s parameters "
309  "(size %dx%d) do not match the corresponding "
310  "second input link %s parameters (size %dx%d)\n",
311  ctx->input_pads[0].name, srcx->w, srcx->h,
312  ctx->input_pads[1].name,
313  srcy->w, srcy->h);
314  return AVERROR(EINVAL);
315  }
316 
317  outlink->w = srcx->w;
318  outlink->h = srcx->h;
319  outlink->time_base = srcx->time_base;
320  outlink->sample_aspect_ratio = srcx->sample_aspect_ratio;
321  outlink->frame_rate = srcx->frame_rate;
322 
323  if ((ret = ff_framesync_init(&s->fs, ctx, 2)) < 0)
324  return ret;
325 
326  in = s->fs.in;
327  in[0].time_base = srcx->time_base;
328  in[1].time_base = srcy->time_base;
329  in[0].sync = 2;
330  in[0].before = EXT_STOP;
331  in[0].after = EXT_INFINITY;
332  in[1].sync = 1;
333  in[1].before = EXT_STOP;
334  in[1].after = EXT_INFINITY;
335  s->fs.opaque = s;
337 
338  if ((ret = config_output(outlink)) < 0)
339  return ret;
340 
341  return ff_framesync_configure(&s->fs);
342 }
343 
345 {
346  LUT2Context *s = ctx->priv;
347  return ff_framesync_activate(&s->fs);
348 }
349 
350 static const AVFilterPad inputs[] = {
351  {
352  .name = "srcx",
353  .type = AVMEDIA_TYPE_VIDEO,
354  .config_props = config_inputx,
355  },
356  {
357  .name = "srcy",
358  .type = AVMEDIA_TYPE_VIDEO,
359  .config_props = config_inputy,
360  },
361  { NULL }
362 };
363 
364 static const AVFilterPad outputs[] = {
365  {
366  .name = "default",
367  .type = AVMEDIA_TYPE_VIDEO,
368  .config_props = lut2_config_output,
369  },
370  { NULL }
371 };
372 
373 #define lut2_options options
374 
376 
378  .name = "lut2",
379  .description = NULL_IF_CONFIG_SMALL("Compute and apply a lookup table from two video inputs."),
380  .preinit = lut2_framesync_preinit,
381  .priv_size = sizeof(LUT2Context),
382  .priv_class = &lut2_class,
383  .uninit = uninit,
385  .activate = activate,
386  .inputs = inputs,
387  .outputs = outputs,
389 };
390 
391 #if CONFIG_TLUT2_FILTER
392 
393 static av_cold int init(AVFilterContext *ctx)
394 {
395  LUT2Context *s = ctx->priv;
396 
397  s->tlut2 = !strcmp(ctx->filter->name, "tlut2");
398 
399  return 0;
400 }
401 
402 static int tlut2_filter_frame(AVFilterLink *inlink, AVFrame *frame)
403 {
404  AVFilterContext *ctx = inlink->dst;
405  LUT2Context *s = ctx->priv;
406  AVFilterLink *outlink = ctx->outputs[0];
407 
408  if (s->prev_frame) {
409  AVFrame *out;
410 
411  if (ctx->is_disabled) {
412  out = av_frame_clone(frame);
413  } else {
414  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
415  if (!out) {
417  s->prev_frame = frame;
418  return AVERROR(ENOMEM);
419  }
420 
421  av_frame_copy_props(out, frame);
422  s->lut2(s, out, frame, s->prev_frame);
423  }
425  s->prev_frame = frame;
426  return ff_filter_frame(outlink, out);
427  }
428  s->prev_frame = frame;
429  return 0;
430 }
431 
432 #define tlut2_options options
433 
435 
436 static const AVFilterPad tlut2_inputs[] = {
437  {
438  .name = "default",
439  .type = AVMEDIA_TYPE_VIDEO,
440  .filter_frame = tlut2_filter_frame,
441  .config_props = config_inputx,
442  },
443  { NULL }
444 };
445 
446 static const AVFilterPad tlut2_outputs[] = {
447  {
448  .name = "default",
449  .type = AVMEDIA_TYPE_VIDEO,
450  .config_props = config_output,
451  },
452  { NULL }
453 };
454 
456  .name = "tlut2",
457  .description = NULL_IF_CONFIG_SMALL("Compute and apply a lookup table from two successive frames."),
458  .priv_size = sizeof(LUT2Context),
459  .priv_class = &tlut2_class,
461  .init = init,
462  .uninit = uninit,
463  .inputs = tlut2_inputs,
464  .outputs = tlut2_outputs,
466 };
467 
468 #endif
#define NULL
Definition: coverity.c:32
AVFilter ff_vf_tlut2
static int config_inputx(AVFilterLink *inlink)
Definition: vf_lut2.c:122
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:414
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
AVOption.
Definition: opt.h:246
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:416
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:399
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:417
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2486
Main libavfilter public API header.
static int config_output(AVFilterLink *outlink)
Definition: vf_lut2.c:241
const char * desc
Definition: nvenc.c:65
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
int(* on_event)(struct FFFrameSync *fs)
Callback called when a frame event is ready.
Definition: framesync.h:172
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:168
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:395
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:359
FRAMESYNC_DEFINE_CLASS(lut2, LUT2Context, fs)
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:383
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
Definition: framesync.c:117
int nb_planes
Definition: vf_lut2.c:63
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
int depth
Definition: vf_lut2.c:64
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 void lut2_8bit(struct LUT2Context *s, AVFrame *out, AVFrame *srcx, AVFrame *srcy)
Definition: vf_lut2.c:161
int is_disabled
the enabled state from the last expression evaluation
Definition: avfilter.h:385
int64_t pts
Timestamp of the current event.
Definition: framesync.h:167
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:92
Macro definitions for various function/variable attributes.
enum FFFrameSyncExtMode before
Extrapolation mode for timestamps before the first frame.
Definition: framesync.h:86
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:360
const char * name
Pad name.
Definition: internal.h:60
AVFilterContext * parent
Parent filter context.
Definition: framesync.h:152
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:361
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:346
static int query_formats(AVFilterContext *ctx)
Definition: vf_lut2.c:99
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
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:117
uint8_t
FFFrameSync fs
Definition: vf_lut2.c:55
#define av_cold
Definition: attributes.h:82
#define fs(width, name, subs,...)
Definition: cbs_vp9.c:259
AVOptions.
Definition: vf_lut2.c:47
double var_values[VAR_VARS_NB]
Definition: vf_lut2.c:60
#define FLAGS
Definition: vf_lut2.c:73
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
FFFrameSyncIn * in
Pointer to array of inputs.
Definition: framesync.h:203
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:413
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:394
static int process_frame(FFFrameSync *fs)
Definition: vf_lut2.c:211
static AVFrame * frame
Definition: vf_lut2.c:45
static const AVFilterPad outputs[]
Definition: vf_lut2.c:364
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
Definition: pixfmt.h:100
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:79
Definition: vf_lut2.c:46
AVFrame * prev_frame
Definition: vf_lut2.c:66
enum FFFrameSyncExtMode after
Extrapolation mode for timestamps after the last frame.
Definition: framesync.h:91
Input stream structure.
Definition: framesync.h:81
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:384
int depthy
Definition: vf_lut2.c:64
#define av_log(a,...)
A filter pad used for either input or output.
Definition: internal.h:54
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
AVFilterPad * input_pads
array of input pads
Definition: avfilter.h:345
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:176
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
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
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
Definition: framesync.c:293
int width[4]
Definition: vf_lut2.c:62
Frame sync structure.
Definition: framesync.h:146
#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
#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 depthx
Definition: vf_lut2.c:64
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:400
uint16_t * lut[4]
lookup table for each component
Definition: vf_lut2.c:61
AVRational time_base
Time base for the incoming frames.
Definition: framesync.h:96
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
Definition: framesync.c:344
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:382
AVFilter ff_vf_lut2
Definition: vf_lut2.c:377
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
var_name
Definition: aeval.c:46
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:377
static int activate(AVFilterContext *ctx)
Definition: vf_lut2.c:344
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:78
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
Definition: vf_lut2.c:44
AVFormatContext * ctx
Definition: movenc.c:48
AVRational time_base
Time base for the output events.
Definition: framesync.h:162
#define s(width, name)
Definition: cbs_vp9.c:257
int height[4]
Definition: vf_lut2.c:62
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:418
void * opaque
Opaque pointer, not used by the API.
Definition: framesync.h:177
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:378
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:540
static int lut2_config_output(AVFilterLink *outlink)
Definition: vf_lut2.c:294
static int config_inputy(AVFilterLink *inlink)
Definition: vf_lut2.c:149
Extend the frame to infinity.
Definition: framesync.h:75
misc drawing utilities
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
Definition: eval.c:334
static const AVFilterPad inputs[]
Definition: vf_lut2.c:350
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:257
int ff_framesync_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in)
Initialize a frame sync structure.
Definition: framesync.c:77
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
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
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:379
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
unsigned sync
Synchronization level: frames on input at the highest sync level will generate output frame events...
Definition: framesync.h:139
Describe the class of an AVClass context structure.
Definition: log.h:67
Filter definition.
Definition: avfilter.h:144
#define isnan(x)
Definition: libm.h:340
void(* lut2)(struct LUT2Context *s, AVFrame *dst, AVFrame *srcx, AVFrame *srcy)
Definition: vf_lut2.c:68
const char * name
Filter name.
Definition: avfilter.h:148
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:385
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:376
#define OFFSET(x)
Definition: vf_lut2.c:72
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
Definition: avfilter.h:133
static const AVOption options[]
Definition: vf_lut2.c:75
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:350
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:266
static void lut2_16bit(struct LUT2Context *s, AVFrame *out, AVFrame *srcx, AVFrame *srcy)
Definition: vf_lut2.c:186
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:396
#define flags(name, subs,...)
Definition: cbs_av1.c:596
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:380
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:386
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:240
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
Y , 8bpp.
Definition: pixfmt.h:74
common internal and external API header
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_lut2.c:83
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:215
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:415
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
Completely stop all streams with this one.
Definition: framesync.h:65
int tlut2
Definition: vf_lut2.c:65
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
Definition: eval.c:734
#define AVFILTER_DEFINE_CLASS(fname)
Definition: internal.h:334
static const char *const var_names[]
Definition: vf_lut2.c:33
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:258
AVExpr * comp_expr[4]
Definition: vf_lut2.c:59
An instance of a filter.
Definition: avfilter.h:338
char * comp_expr_str[4]
Definition: vf_lut2.c:57
FILE * out
Definition: movenc.c:54
#define av_freep(p)
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
#define av_malloc_array(a, b)
internal API functions
int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, unsigned get)
Get the current frame in an input.
Definition: framesync.c:256
int depth
Number of bits in the component.
Definition: pixdesc.h:58
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
const AVFilter * filter
the AVFilter of which this is an instance
Definition: avfilter.h:341
for(j=16;j >0;--j)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:654
simple arithmetic expression evaluator
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58