FFmpeg
vf_lenscorrection.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007 Richard Spindler (author of frei0r plugin from which this was derived)
3  * Copyright (C) 2014 Daniel Oberhoff
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file
24  * Lenscorrection filter, algorithm from the frei0r plugin with the same name
25 */
26 #include <stdlib.h>
27 #include <math.h>
28 
29 #include "libavutil/colorspace.h"
30 #include "libavutil/opt.h"
31 #include "libavutil/intreadwrite.h"
32 #include "libavutil/pixdesc.h"
33 
34 #include "avfilter.h"
35 #include "drawutils.h"
36 #include "internal.h"
37 #include "video.h"
38 
39 typedef struct LenscorrectionCtx {
40  const AVClass *av_class;
41  int planewidth[4];
42  int planeheight[4];
43  int depth;
44  int nb_planes;
45  double cx, cy, k1, k2;
47  uint8_t fill_rgba[4];
48  int fill_color[4];
49 
51 
52  int (*filter_slice)(AVFilterContext *ctx, void *arg, int job, int nb_jobs, int plane);
54 
55 #define OFFSET(x) offsetof(LenscorrectionCtx, x)
56 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
57 static const AVOption lenscorrection_options[] = {
58  { "cx", "set relative center x", OFFSET(cx), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS },
59  { "cy", "set relative center y", OFFSET(cy), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, .flags=FLAGS },
60  { "k1", "set quadratic distortion factor", OFFSET(k1), AV_OPT_TYPE_DOUBLE, {.dbl=0.0}, -1, 1, .flags=FLAGS },
61  { "k2", "set double quadratic distortion factor", OFFSET(k2), AV_OPT_TYPE_DOUBLE, {.dbl=0.0}, -1, 1, .flags=FLAGS },
62  { "i", "set interpolation type", OFFSET(interpolation), AV_OPT_TYPE_INT, {.i64=0}, 0, 64, .flags=FLAGS, "i" },
63  { "nearest", "nearest neighbour", 0, AV_OPT_TYPE_CONST, {.i64=0},0, 0, .flags=FLAGS, "i" },
64  { "bilinear", "bilinear", 0, AV_OPT_TYPE_CONST, {.i64=1},0, 0, .flags=FLAGS, "i" },
65  { "fc", "set the color of the unmapped pixels", OFFSET(fill_rgba), AV_OPT_TYPE_COLOR, {.str="black@0"}, .flags = FLAGS },
66  { NULL }
67 };
68 
69 AVFILTER_DEFINE_CLASS(lenscorrection);
70 
71 typedef struct ThreadData {
72  AVFrame *in, *out;
73 } ThreadData;
74 
75 #define NEAREST(type, name) \
76 static int filter##name##_slice(AVFilterContext *ctx, void *arg, int job, \
77  int nb_jobs, int plane) \
78 { \
79  LenscorrectionCtx *rect = ctx->priv; \
80  ThreadData *td = arg; \
81  AVFrame *in = td->in; \
82  AVFrame *out = td->out; \
83  \
84  const int32_t *correction = rect->correction[plane]; \
85  const int fill_color = rect->fill_color[plane]; \
86  const int w = rect->planewidth[plane], h = rect->planeheight[plane]; \
87  const int xcenter = rect->cx * w; \
88  const int ycenter = rect->cy * h; \
89  const int start = (h * job ) / nb_jobs; \
90  const int end = (h * (job+1)) / nb_jobs; \
91  const int inlinesize = in->linesize[plane] / sizeof(type); \
92  const int outlinesize = out->linesize[plane] / sizeof(type); \
93  const type *indata = (const type *)in->data[plane]; \
94  type *outrow = (type *)out->data[plane] + start * outlinesize; \
95  for (int i = start; i < end; i++, outrow += outlinesize) { \
96  const int off_y = i - ycenter; \
97  type *out = outrow; \
98  for (int j = 0; j < w; j++) { \
99  const int off_x = j - xcenter; \
100  const int64_t radius_mult = correction[j + i*w]; \
101  const int x = xcenter + ((radius_mult * off_x + (1<<23))>>24); \
102  const int y = ycenter + ((radius_mult * off_y + (1<<23))>>24); \
103  const char isvalid = x >= 0 && x < w && y >= 0 && y < h; \
104  *out++ = isvalid ? indata[y * inlinesize + x] : fill_color; \
105  } \
106  } \
107  return 0; \
108 }
109 
110 
111 NEAREST(uint8_t, 8)
112 NEAREST(uint16_t, 16)
113 
114 #define BILINEAR(type, name) \
115 static int filter##name##_slice_bilinear(AVFilterContext *ctx, void *arg, \
116  int job, int nb_jobs, int plane) \
117 { \
118  LenscorrectionCtx *rect = ctx->priv; \
119  ThreadData *td = arg; \
120  AVFrame *in = td->in; \
121  AVFrame *out = td->out; \
122  \
123  const int32_t *correction = rect->correction[plane]; \
124  const int fill_color = rect->fill_color[plane]; \
125  const int depth = rect->depth; \
126  const uint64_t max = (1 << 24) - 1; \
127  const uint64_t add = (1 << 23); \
128  const int w = rect->planewidth[plane], h = rect->planeheight[plane]; \
129  const int xcenter = rect->cx * w; \
130  const int ycenter = rect->cy * h; \
131  const int start = (h * job ) / nb_jobs; \
132  const int end = (h * (job+1)) / nb_jobs; \
133  const int inlinesize = in->linesize[plane] / sizeof(type); \
134  const int outlinesize = out->linesize[plane] / sizeof(type); \
135  const type *indata = (const type *)in->data[plane]; \
136  type *outrow = (type *)out->data[plane] + start * outlinesize; \
137  \
138  for (int i = start; i < end; i++, outrow += outlinesize) { \
139  const int off_y = i - ycenter; \
140  type *out = outrow; \
141  \
142  for (int j = 0; j < w; j++) { \
143  const int off_x = j - xcenter; \
144  const int64_t radius_mult = correction[j + i*w]; \
145  const int x = xcenter + ((radius_mult * off_x + (1<<23)) >> 24); \
146  const int y = ycenter + ((radius_mult * off_y + (1<<23)) >> 24); \
147  const char isvalid = x >= 0 && x <= w - 1 && y >= 0 && y <= h - 1; \
148  \
149  if (isvalid) { \
150  const int nx = FFMIN(x + 1, w - 1); \
151  const int ny = FFMIN(y + 1, h - 1); \
152  const uint64_t du = off_x >= 0 ? (radius_mult * off_x + add) & max : max - ((radius_mult * -off_x + add) & max); \
153  const uint64_t dv = off_y >= 0 ? (radius_mult * off_y + add) & max : max - ((radius_mult * -off_y + add) & max); \
154  const uint64_t p0 = indata[ y * inlinesize + x]; \
155  const uint64_t p1 = indata[ y * inlinesize + nx]; \
156  const uint64_t p2 = indata[ny * inlinesize + x]; \
157  const uint64_t p3 = indata[ny * inlinesize + nx]; \
158  uint64_t sum = 0; \
159  \
160  sum += (max - du) * (max - dv) * p0; \
161  sum += ( du) * (max - dv) * p1; \
162  sum += (max - du) * ( dv) * p2; \
163  sum += ( du) * ( dv) * p3; \
164  \
165  out[j] = av_clip_uintp2_c((sum + (1ULL << 47)) >> 48, depth); \
166  } else { \
167  out[j] = fill_color; \
168  } \
169  } \
170  } \
171  \
172  return 0; \
173 }
174 
175 BILINEAR(uint8_t, 8)
176 BILINEAR(uint16_t, 16)
177 
178 static const enum AVPixelFormat pix_fmts[] = {
203 };
204 
206 {
207  LenscorrectionCtx *rect = ctx->priv;
208  int i;
209 
210  for (i = 0; i < FF_ARRAY_ELEMS(rect->correction); i++) {
211  av_freep(&rect->correction[i]);
212  }
213 }
214 
215 static void calc_correction(AVFilterContext *ctx, int plane)
216 {
217  LenscorrectionCtx *rect = ctx->priv;
218  int w = rect->planewidth[plane];
219  int h = rect->planeheight[plane];
220  int xcenter = rect->cx * w;
221  int ycenter = rect->cy * h;
222  int k1 = rect->k1 * (1<<24);
223  int k2 = rect->k2 * (1<<24);
224  const int64_t r2inv = (4LL<<60) / (w * w + h * h);
225 
226  for (int j = 0; j < h; j++) {
227  const int off_y = j - ycenter;
228  const int off_y2 = off_y * off_y;
229  for (int i = 0; i < w; i++) {
230  const int off_x = i - xcenter;
231  const int64_t r2 = ((off_x * off_x + off_y2) * r2inv + (1LL<<31)) >> 32;
232  const int64_t r4 = (r2 * r2 + (1<<27)) >> 28;
233  const int radius_mult = (r2 * k1 + r4 * k2 + (1LL<<27) + (1LL<<52))>>28;
234  rect->correction[plane][j * w + i] = radius_mult;
235  }
236  }
237 }
238 
239 static int config_output(AVFilterLink *outlink)
240 {
241  AVFilterContext *ctx = outlink->src;
242  LenscorrectionCtx *rect = ctx->priv;
243  AVFilterLink *inlink = ctx->inputs[0];
244  const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(inlink->format);
245  int is_rgb = !!(pixdesc->flags & AV_PIX_FMT_FLAG_RGB);
246  uint8_t rgba_map[4];
247  int factor;
248 
249  ff_fill_rgba_map(rgba_map, inlink->format);
250  rect->depth = pixdesc->comp[0].depth;
251  factor = 1 << (rect->depth - 8);
252  rect->planeheight[1] = rect->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, pixdesc->log2_chroma_h);
253  rect->planeheight[0] = rect->planeheight[3] = inlink->h;
254  rect->planewidth[1] = rect->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, pixdesc->log2_chroma_w);
255  rect->planewidth[0] = rect->planewidth[3] = inlink->w;
256  rect->nb_planes = av_pix_fmt_count_planes(inlink->format);
257  rect->filter_slice = rect->depth <= 8 ? filter8_slice : filter16_slice;
258  if (rect->interpolation)
259  rect->filter_slice = rect->depth <= 8 ? filter8_slice_bilinear : filter16_slice_bilinear;
260 
261  if (is_rgb) {
262  rect->fill_color[rgba_map[0]] = rect->fill_rgba[0] * factor;
263  rect->fill_color[rgba_map[1]] = rect->fill_rgba[1] * factor;
264  rect->fill_color[rgba_map[2]] = rect->fill_rgba[2] * factor;
265  rect->fill_color[rgba_map[3]] = rect->fill_rgba[3] * factor;
266  } else {
267  rect->fill_color[0] = RGB_TO_Y_BT709(rect->fill_rgba[0], rect->fill_rgba[1], rect->fill_rgba[2]) * factor;
268  rect->fill_color[1] = RGB_TO_U_BT709(rect->fill_rgba[0], rect->fill_rgba[1], rect->fill_rgba[2], 0) * factor;
269  rect->fill_color[2] = RGB_TO_V_BT709(rect->fill_rgba[0], rect->fill_rgba[1], rect->fill_rgba[2], 0) * factor;
270  rect->fill_color[3] = rect->fill_rgba[3] * factor;
271  }
272 
273  for (int plane = 0; plane < rect->nb_planes; plane++) {
274  int w = rect->planewidth[plane];
275  int h = rect->planeheight[plane];
276 
277  if (!rect->correction[plane])
278  rect->correction[plane] = av_malloc_array(w, h * sizeof(**rect->correction));
279  if (!rect->correction[plane])
280  return AVERROR(ENOMEM);
281  calc_correction(ctx, plane);
282  }
283 
284  return 0;
285 }
286 
287 static int filter_slice(AVFilterContext *ctx, void *arg, int job,
288  int nb_jobs)
289 {
290  LenscorrectionCtx *rect = ctx->priv;
291 
292  for (int plane = 0; plane < rect->nb_planes; plane++)
293  rect->filter_slice(ctx, arg, job, nb_jobs, plane);
294 
295  return 0;
296 }
297 
299 {
300  AVFilterContext *ctx = inlink->dst;
301  AVFilterLink *outlink = ctx->outputs[0];
302  LenscorrectionCtx *rect = ctx->priv;
303  AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
304  ThreadData td;
305 
306  if (!out) {
307  av_frame_free(&in);
308  return AVERROR(ENOMEM);
309  }
310 
312 
313  td.in = in; td.out = out;
315  FFMIN(rect->planeheight[1], ff_filter_get_nb_threads(ctx)));
316 
317  av_frame_free(&in);
318  return ff_filter_frame(outlink, out);
319 }
320 
322  const char *cmd,
323  const char *arg,
324  char *res,
325  int res_len,
326  int flags)
327 {
328  int ret = ff_filter_process_command(ctx, cmd, arg, res, res_len, flags);
329 
330  if (ret < 0)
331  return ret;
332 
333  return config_output(ctx->outputs[0]);
334 }
335 
337  {
338  .name = "default",
339  .type = AVMEDIA_TYPE_VIDEO,
340  .filter_frame = filter_frame,
341  },
342 };
343 
345  {
346  .name = "default",
347  .type = AVMEDIA_TYPE_VIDEO,
348  .config_props = config_output,
349  },
350 };
351 
353  .name = "lenscorrection",
354  .description = NULL_IF_CONFIG_SMALL("Rectify the image by correcting for lens distortion."),
355  .priv_size = sizeof(LenscorrectionCtx),
359  .priv_class = &lenscorrection_class,
360  .uninit = uninit,
362  .process_command = process_command,
363 };
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:98
AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:447
LenscorrectionCtx::fill_color
int fill_color[4]
Definition: vf_lenscorrection.c:48
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:426
td
#define td
Definition: regdef.h:70
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_lenscorrection.c:205
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
out
FILE * out
Definition: movenc.c:54
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1018
LenscorrectionCtx::cy
double cy
Definition: vf_lenscorrection.c:45
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2660
calc_correction
static void calc_correction(AVFilterContext *ctx, int plane)
Definition: vf_lenscorrection.c:215
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:171
rect
Definition: f_ebur128.c:77
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:109
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:439
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:317
pixdesc.h
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:446
w
uint8_t w
Definition: llviddspenc.c:38
AVComponentDescriptor::depth
int depth
Number of bits in the component.
Definition: pixdesc.h:57
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:441
AVOption
AVOption.
Definition: opt.h:247
NEAREST
#define NEAREST(type, name)
Definition: vf_lenscorrection.c:75
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:404
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:169
ThreadData::out
AVFrame * out
Definition: af_adeclick.c:473
video.h
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:442
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:384
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(lenscorrection)
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2700
LenscorrectionCtx::correction
int32_t * correction[4]
Definition: vf_lenscorrection.c:50
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:438
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:422
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:205
LenscorrectionCtx::planewidth
int planewidth[4]
Definition: vf_lenscorrection.c:41
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:420
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:448
LenscorrectionCtx::nb_planes
int nb_planes
Definition: vf_lenscorrection.c:44
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:402
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:388
LenscorrectionCtx::depth
int depth
Definition: vf_lenscorrection.c:43
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:50
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:407
AV_PIX_FMT_YUVJ411P
@ 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:248
colorspace.h
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:90
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:416
LenscorrectionCtx::fill_rgba
uint8_t fill_rgba[4]
Definition: vf_lenscorrection.c:47
AV_PIX_FMT_YUVJ422P
@ 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:79
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:424
RGB_TO_Y_BT709
#define RGB_TO_Y_BT709(r, g, b)
Definition: vf_pseudocolor.c:553
intreadwrite.h
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:425
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:417
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:51
RGB_TO_U_BT709
#define RGB_TO_U_BT709(r1, g1, b1, max)
Definition: vf_pseudocolor.c:557
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:226
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:445
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:401
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:415
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:387
AVPixFmtDescriptor::log2_chroma_w
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:80
lenscorrection_options
static const AVOption lenscorrection_options[]
Definition: vf_lenscorrection.c:57
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
LenscorrectionCtx::cx
double cx
Definition: vf_lenscorrection.c:45
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
AV_PIX_FMT_YUVJ444P
@ 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:80
arg
const char * arg
Definition: jacosubdec.c:67
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:385
OFFSET
#define OFFSET(x)
Definition: vf_lenscorrection.c:55
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:423
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
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:537
AV_PIX_FMT_YUVJ420P
@ 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:78
AV_OPT_TYPE_COLOR
@ AV_OPT_TYPE_COLOR
Definition: opt.h:239
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_lenscorrection.c:178
LenscorrectionCtx::filter_slice
int(* filter_slice)(AVFilterContext *ctx, void *arg, int job, int nb_jobs, int plane)
Definition: vf_lenscorrection.c:52
AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_YUV440P10
Definition: pixfmt.h:406
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:405
LenscorrectionCtx::k1
double k1
Definition: vf_lenscorrection.c:45
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_lenscorrection.c:298
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:419
AVPixFmtDescriptor::flags
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:94
ff_vf_lenscorrection
const AVFilter ff_vf_lenscorrection
Definition: vf_lenscorrection.c:352
LenscorrectionCtx::k2
double k2
Definition: vf_lenscorrection.c:45
RGB_TO_V_BT709
#define RGB_TO_V_BT709(r1, g1, b1, max)
Definition: vf_pseudocolor.c:561
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:117
AV_PIX_FMT_FLAG_RGB
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
Definition: pixdesc.h:136
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:409
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:411
ff_filter_process_command
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
Definition: avfilter.c:882
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:167
LenscorrectionCtx::interpolation
int interpolation
Definition: vf_lenscorrection.c:46
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:443
interpolation
static int interpolation(DeclickChannel *c, const double *src, int ar_order, double *acoefficients, int *index, int nb_errors, double *auxiliary, double *interpolated)
Definition: af_adeclick.c:336
internal.h
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition: avfilter.h:146
lenscorrection_outputs
static const AVFilterPad lenscorrection_outputs[]
Definition: vf_lenscorrection.c:344
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
lenscorrection_inputs
static const AVFilterPad lenscorrection_inputs[]
Definition: vf_lenscorrection.c:336
FLAGS
#define FLAGS
Definition: vf_lenscorrection.c:56
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:32
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:421
ff_filter_get_nb_threads
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:803
ThreadData
Used for passing data between threads.
Definition: dsddec.c:67
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AV_PIX_FMT_YUVJ440P
@ 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:100
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:56
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:403
AVFilter
Filter definition.
Definition: avfilter.h:165
ret
ret
Definition: filter_design.txt:187
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:440
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:408
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:413
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:444
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
avfilter.h
AVPixFmtDescriptor::comp
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:105
LenscorrectionCtx::av_class
const AVClass * av_class
Definition: vf_lenscorrection.c:40
BILINEAR
#define BILINEAR(type, name)
Definition: vf_lenscorrection.c:114
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
AVFilterContext
An instance of a filter.
Definition: avfilter.h:402
factor
static const int factor[16]
Definition: vf_pp7.c:76
process_command
static int process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Definition: vf_lenscorrection.c:321
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:158
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:121
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_lenscorrection.c:239
ThreadData::in
AVFrame * in
Definition: af_adecorrelate.c:154
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
LenscorrectionCtx::planeheight
int planeheight[4]
Definition: vf_lenscorrection.c:42
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
ff_fill_rgba_map
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
Definition: drawutils.c:34
int32_t
int32_t
Definition: audioconvert.c:56
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:410
h
h
Definition: vp9dsp_template.c:2038
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:414
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:386
drawutils.h
ff_filter_execute
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition: internal.h:143
int
int
Definition: ffmpeg_filter.c:153
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233
LenscorrectionCtx
Definition: vf_lenscorrection.c:39
AVPixFmtDescriptor::log2_chroma_h
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:89
AV_PIX_FMT_YUVA422P
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:166
AV_PIX_FMT_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:412
filter_slice
static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
Definition: vf_lenscorrection.c:287