FFmpeg: libavfilter/vf_lut2.c Source File

FFmpeg
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 {
44   VAR_W,
45   VAR_H,
46   VAR_X,
47   VAR_Y,
48   VAR_BITDEPTHX,
49   VAR_BITDEPTHY,
50   VAR_VARS_NB
51 };
52 
53  typedef struct LUT2Context {
54   const AVClass *class;
55   FFFrameSync fs;
56 
57   char *comp_expr_str[4];
58 
59   AVExpr *comp_expr[4];
60   double var_values[VAR_VARS_NB];
61   uint16_t *lut[4]; ///< lookup table for each component
62   int width[4], height[4];
63   int nb_planes;
64   int depth, depthx, depthy;
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 
83  static av_cold void uninit(AVFilterContext *ctx)
84 {
85  LUT2Context *s = ctx->priv;
86  int i;
87 
88  ff_framesync_uninit(&s->fs);
89  av_frame_free(&s->prev_frame);
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 
99  static int query_formats(AVFilterContext *ctx)
100 {
101  static const enum AVPixelFormat pix_fmts[] = {
102  AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV440P,
103  AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P,
104  AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUV420P,
105  AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ420P,
106  AV_PIX_FMT_YUVJ411P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P,
107  AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9,
108  AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10,
109  AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV440P12,
110  AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA444P9,
111  AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA444P10,
112  AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10,
113  AV_PIX_FMT_GBRP12,
114  AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12,
115  AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9, AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12,
116  AV_PIX_FMT_NONE
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;
126  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
127  int hsub = desc->log2_chroma_w;
128  int vsub = desc->log2_chroma_h;
129 
130  s->nb_planes = av_pix_fmt_count_planes(inlink->format);
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;
139  s->var_values[VAR_BITDEPTHX] = s->depthx;
140 
141  if (s->tlut2) {
142  s->depthy = desc->comp[0].depth;
143  s->var_values[VAR_BITDEPTHY] = s->depthy;
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;
153  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
154 
155  s->depthy = desc->comp[0].depth;
156  s->var_values[VAR_BITDEPTHY] = s->depthy;
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 
211  static int process_frame(FFFrameSync *fs)
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;
336  s->fs.on_event = process_frame;
337 
338  if ((ret = config_output(outlink)) < 0)
339  return ret;
340 
341  return ff_framesync_configure(&s->fs);
342 }
343 
344  static int activate(AVFilterContext *ctx)
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 
375 FRAMESYNC_DEFINE_CLASS(lut2, LUT2Context, fs);
376 
377  AVFilter ff_vf_lut2 = {
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,
384  .query_formats = query_formats,
385  .activate = activate,
386  .inputs = inputs,
387  .outputs = outputs,
388  .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
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  LUT2Context *s = inlink->dst->priv;
405  AVFilterLink *outlink = inlink->dst->outputs[0];
406 
407  if (s->prev_frame) {
408  AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
409  if (!out) {
410  av_frame_free(&s->prev_frame);
411  s->prev_frame = frame;
412  return AVERROR(ENOMEM);
413  }
414  av_frame_copy_props(out, frame);
415  s->lut2(s, out, frame, s->prev_frame);
416  av_frame_free(&s->prev_frame);
417  s->prev_frame = frame;
418  return ff_filter_frame(outlink, out);
419  }
420  s->prev_frame = frame;
421  return 0;
422 }
423 
424 #define tlut2_options options
425 
426 AVFILTER_DEFINE_CLASS(tlut2);
427 
428 static const AVFilterPad tlut2_inputs[] = {
429  {
430  .name = "default",
431  .type = AVMEDIA_TYPE_VIDEO,
432  .filter_frame = tlut2_filter_frame,
433  .config_props = config_inputx,
434  },
435  { NULL }
436 };
437 
438 static const AVFilterPad tlut2_outputs[] = {
439  {
440  .name = "default",
441  .type = AVMEDIA_TYPE_VIDEO,
442  .config_props = config_output,
443  },
444  { NULL }
445 };
446 
447 AVFilter ff_vf_tlut2 = {
448  .name = "tlut2",
449  .description = NULL_IF_CONFIG_SMALL("Compute and apply a lookup table from two successive frames."),
450  .priv_size = sizeof(LUT2Context),
451  .priv_class = &tlut2_class,
452  .query_formats = query_formats,
453  .init = init,
454  .uninit = uninit,
455  .inputs = tlut2_inputs,
456  .outputs = tlut2_outputs,
457 };
458 
459 #endif
NULL
#define NULL
Definition: coverity.c:32
ff_vf_tlut2
AVFilter ff_vf_tlut2
s
const char * s
Definition: avisynth_c.h:768
config_inputx
static int config_inputx(AVFilterLink *inlink)
Definition: vf_lut2.c:122
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:401
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2363
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:218
AVOption
AVOption.
Definition: opt.h:246
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:403
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:388
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:404
AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:67
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2403
avfilter.h
Main libavfilter public API header.
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_lut2.c:241
desc
const char * desc
Definition: nvenc.c:65
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
FFFrameSync::on_event
int(* on_event)(struct FFFrameSync *fs)
Callback called when a frame event is ready.
Definition: framesync.h:172
AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:164
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:384
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:349
FRAMESYNC_DEFINE_CLASS
FRAMESYNC_DEFINE_CLASS(lut2, LUT2Context, fs)
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:372
ff_framesync_configure
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
Definition: framesync.c:117
LUT2Context::nb_planes
int nb_planes
Definition: vf_lut2.c:63
av_expr_parse
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
LUT2Context::depth
int depth
Definition: vf_lut2.c:64
ff_get_video_buffer
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
lut2_8bit
static void lut2_8bit(struct LUT2Context *s, AVFrame *out, AVFrame *srcx, AVFrame *srcy)
Definition: vf_lut2.c:161
AVFilterContext::is_disabled
int is_disabled
the enabled state from the last expression evaluation
Definition: avfilter.h:385
FFFrameSync::pts
int64_t pts
Timestamp of the current event.
Definition: framesync.h:167
AVPixFmtDescriptor::log2_chroma_w
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:92
attributes.h
Macro definitions for various function/variable attributes.
FFFrameSyncIn::before
enum FFFrameSyncExtMode before
Extrapolation mode for timestamps before the first frame.
Definition: framesync.h:86
ff_make_format_list
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:350
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:60
FFFrameSync::parent
AVFilterContext * parent
Parent filter context.
Definition: framesync.h:152
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:351
AVFilterContext::inputs
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:346
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_lut2.c:99
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1080
AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:97
AVPixFmtDescriptor::comp
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:117
uint8_t
uint8_t
Definition: audio_convert.c:194
LUT2Context::fs
FFFrameSync fs
Definition: vf_lut2.c:55
av_cold
#define av_cold
Definition: attributes.h:82
opt.h
AVOptions.
VAR_Y
Definition: vf_lut2.c:47
LUT2Context::var_values
double var_values[VAR_VARS_NB]
Definition: vf_lut2.c:60
FLAGS
#define FLAGS
Definition: vf_lut2.c:73
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:311
AVExpr
Definition: eval.c:157
FFFrameSync::in
FFFrameSyncIn * in
Pointer to array of inputs.
Definition: framesync.h:203
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:400
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:383
process_frame
static int process_frame(FFFrameSync *fs)
Definition: vf_lut2.c:211
frame
static AVFrame * frame
Definition: demuxing_decoding.c:53
VAR_H
Definition: vf_lut2.c:45
outputs
static const AVFilterPad outputs[]
Definition: vf_lut2.c:364
AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
Definition: pixfmt.h:96
flags
static int flags
Definition: log.c:55
AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:75
VAR_X
Definition: vf_lut2.c:46
LUT2Context::prev_frame
AVFrame * prev_frame
Definition: vf_lut2.c:66
FFFrameSyncIn::after
enum FFFrameSyncExtMode after
Extrapolation mode for timestamps after the last frame.
Definition: framesync.h:91
FFFrameSyncIn
Input stream structure.
Definition: framesync.h:81
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:373
LUT2Context::depthy
int depthy
Definition: vf_lut2.c:64
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:54
av_rescale_q
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
AVFilterContext::input_pads
AVFilterPad * input_pads
array of input pads
Definition: avfilter.h:345
AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:172
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
ff_set_common_formats
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
AVPixFmtDescriptor::log2_chroma_h
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:101
ff_framesync_uninit
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
Definition: framesync.c:293
LUT2Context::width
int width[4]
Definition: vf_lut2.c:62
FFFrameSync
Frame sync structure.
Definition: framesync.h:146
AVERROR
#define AVERROR(e)
Definition: error.h:43
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:202
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:353
LUT2Context::depthx
int depthx
Definition: vf_lut2.c:64
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:389
LUT2Context::lut
uint16_t * lut[4]
lookup table for each component
Definition: vf_lut2.c:61
FFFrameSyncIn::time_base
AVRational time_base
Time base for the incoming frames.
Definition: framesync.h:96
ff_framesync_activate
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
Definition: framesync.c:344
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:371
ff_vf_lut2
AVFilter ff_vf_lut2
Definition: vf_lut2.c:377
AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:66
var_name
var_name
Definition: aeval.c:46
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:366
activate
static int activate(AVFilterContext *ctx)
Definition: vf_lut2.c:344
AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:74
void
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
VAR_W
Definition: vf_lut2.c:44
ctx
AVFormatContext * ctx
Definition: movenc.c:48
FFFrameSync::time_base
AVRational time_base
Time base for the output events.
Definition: framesync.h:162
LUT2Context::height
int height[4]
Definition: vf_lut2.c:62
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:405
FFFrameSync::opaque
void * opaque
Opaque pointer, not used by the API.
Definition: framesync.h:177
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:367
av_frame_clone
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:538
lut2_config_output
static int lut2_config_output(AVFilterLink *outlink)
Definition: vf_lut2.c:294
config_inputy
static int config_inputy(AVFilterLink *inlink)
Definition: vf_lut2.c:149
EXT_INFINITY
Extend the frame to infinity.
Definition: framesync.h:75
drawutils.h
misc drawing utilities
av_expr_free
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
Definition: eval.c:334
inputs
static const AVFilterPad inputs[]
Definition: vf_lut2.c:350
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:249
ff_framesync_init
int ff_framesync_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in)
Initialize a frame sync structure.
Definition: framesync.c:77
AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:173
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
in
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
Definition: audio_convert.c:194
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:368
AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:68
FFFrameSyncIn::sync
unsigned sync
Synchronization level: frames on input at the highest sync level will generate output frame events...
Definition: framesync.h:139
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
AVFilter
Filter definition.
Definition: avfilter.h:144
isnan
#define isnan(x)
Definition: libm.h:340
LUT2Context::lut2
void(* lut2)(struct LUT2Context *s, AVFrame *dst, AVFrame *srcx, AVFrame *srcy)
Definition: vf_lut2.c:68
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:148
AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:374
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:365
OFFSET
#define OFFSET(x)
Definition: vf_lut2.c:72
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
#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
options
static const AVOption options[]
Definition: vf_lut2.c:75
AVFilterContext::outputs
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:350
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:266
lut2_16bit
static void lut2_16bit(struct LUT2Context *s, AVFrame *out, AVFrame *srcx, AVFrame *srcy)
Definition: vf_lut2.c:186
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:385
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:369
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:375
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:232
AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62
AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:70
common.h
common internal and external API header
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_lut2.c:83
AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:211
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:402
AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:76
AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:69
EXT_STOP
Completely stop all streams with this one.
Definition: framesync.h:65
LUT2Context::tlut2
int tlut2
Definition: vf_lut2.c:65
av_expr_eval
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
Definition: eval.c:734
AVFILTER_DEFINE_CLASS
#define AVFILTER_DEFINE_CLASS(fname)
Definition: internal.h:334
var_names
static const char *const var_names[]
Definition: vf_lut2.c:33
AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:254
LUT2Context::comp_expr
AVExpr * comp_expr[4]
Definition: vf_lut2.c:59
AVFilterContext
An instance of a filter.
Definition: avfilter.h:338
LUT2Context::comp_expr_str
char * comp_expr_str[4]
Definition: vf_lut2.c:57
out
FILE * out
Definition: movenc.c:54
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:95
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:32
internal.h
internal API functions
ff_framesync_get_frame
int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, unsigned get)
Get the current frame in an input.
Definition: framesync.c:256
AVComponentDescriptor::depth
int depth
Number of bits in the component.
Definition: pixdesc.h:58
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
AVFilterContext::filter
const AVFilter * filter
the AVFilter of which this is an instance
Definition: avfilter.h:341
for
for(j=16;j >0;--j)
Definition: h264pred_template.c:469
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:652
eval.h
simple arithmetic expression evaluator
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58

Generated on Sun May 13 2018 02:04:02 for FFmpeg by   doxygen 1.8.6

AltStyle によって変換されたページ (->オリジナル) /