FFmpeg
vf_libopencv.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010 Stefano Sabatini
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 /**
22  * @file
23  * libopencv wrapper functions
24  */
25 
26 #include "config.h"
27 #if HAVE_OPENCV2_CORE_CORE_C_H
28 #include <opencv2/core/core_c.h>
29 #include <opencv2/imgproc/imgproc_c.h>
30 #else
31 #include <opencv/cv.h>
32 #include <opencv/cxcore.h>
33 #endif
34 #include "libavutil/avstring.h"
35 #include "libavutil/common.h"
36 #include "libavutil/file.h"
37 #include "libavutil/opt.h"
38 #include "avfilter.h"
39 #include "formats.h"
40 #include "internal.h"
41 #include "video.h"
42 
43 static void fill_iplimage_from_frame(IplImage *img, const AVFrame *frame, enum AVPixelFormat pixfmt)
44 {
45  IplImage *tmpimg;
46  int depth, channels_nb;
47 
48  if (pixfmt == AV_PIX_FMT_GRAY8) { depth = IPL_DEPTH_8U; channels_nb = 1; }
49  else if (pixfmt == AV_PIX_FMT_BGRA) { depth = IPL_DEPTH_8U; channels_nb = 4; }
50  else if (pixfmt == AV_PIX_FMT_BGR24) { depth = IPL_DEPTH_8U; channels_nb = 3; }
51  else return;
52 
53  tmpimg = cvCreateImageHeader((CvSize){frame->width, frame->height}, depth, channels_nb);
54  *img = *tmpimg;
55  img->imageData = img->imageDataOrigin = frame->data[0];
56  img->dataOrder = IPL_DATA_ORDER_PIXEL;
57  img->origin = IPL_ORIGIN_TL;
58  img->widthStep = frame->linesize[0];
59 }
60 
61 static void fill_frame_from_iplimage(AVFrame *frame, const IplImage *img, enum AVPixelFormat pixfmt)
62 {
63  frame->linesize[0] = img->widthStep;
64  frame->data[0] = img->imageData;
65 }
66 
68 {
69  static const enum AVPixelFormat pix_fmts[] = {
71  };
73 }
74 
75 typedef struct OCVContext {
76  const AVClass *class;
77  char *name;
78  char *params;
79  int (*init)(AVFilterContext *ctx, const char *args);
81  void (*end_frame_filter)(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg);
82  void *priv;
83 } OCVContext;
84 
85 typedef struct SmoothContext {
86  int type;
87  int param1, param2;
88  double param3, param4;
90 
91 static av_cold int smooth_init(AVFilterContext *ctx, const char *args)
92 {
93  OCVContext *s = ctx->priv;
94  SmoothContext *smooth = s->priv;
95  char type_str[128] = "gaussian";
96 
97  smooth->param1 = 3;
98  smooth->param2 = 0;
99  smooth->param3 = 0.0;
100  smooth->param4 = 0.0;
101 
102  if (args)
103  sscanf(args, "%127[^|]|%d|%d|%lf|%lf", type_str, &smooth->param1, &smooth->param2, &smooth->param3, &smooth->param4);
104 
105  if (!strcmp(type_str, "blur" )) smooth->type = CV_BLUR;
106  else if (!strcmp(type_str, "blur_no_scale")) smooth->type = CV_BLUR_NO_SCALE;
107  else if (!strcmp(type_str, "median" )) smooth->type = CV_MEDIAN;
108  else if (!strcmp(type_str, "gaussian" )) smooth->type = CV_GAUSSIAN;
109  else if (!strcmp(type_str, "bilateral" )) smooth->type = CV_BILATERAL;
110  else {
111  av_log(ctx, AV_LOG_ERROR, "Smoothing type '%s' unknown.\n", type_str);
112  return AVERROR(EINVAL);
113  }
114 
115  if (smooth->param1 < 0 || !(smooth->param1%2)) {
117  "Invalid value '%d' for param1, it has to be a positive odd number\n",
118  smooth->param1);
119  return AVERROR(EINVAL);
120  }
121  if ((smooth->type == CV_BLUR || smooth->type == CV_BLUR_NO_SCALE || smooth->type == CV_GAUSSIAN) &&
122  (smooth->param2 < 0 || (smooth->param2 && !(smooth->param2%2)))) {
124  "Invalid value '%d' for param2, it has to be zero or a positive odd number\n",
125  smooth->param2);
126  return AVERROR(EINVAL);
127  }
128 
129  av_log(ctx, AV_LOG_VERBOSE, "type:%s param1:%d param2:%d param3:%f param4:%f\n",
130  type_str, smooth->param1, smooth->param2, smooth->param3, smooth->param4);
131  return 0;
132 }
133 
134 static void smooth_end_frame_filter(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg)
135 {
136  OCVContext *s = ctx->priv;
137  SmoothContext *smooth = s->priv;
138  cvSmooth(inimg, outimg, smooth->type, smooth->param1, smooth->param2, smooth->param3, smooth->param4);
139 }
140 
141 static int read_shape_from_file(int *cols, int *rows, int **values, const char *filename,
142  void *log_ctx)
143 {
144  uint8_t *buf, *p, *pend;
145  size_t size;
146  int ret, i, j, w;
147 
148  if ((ret = av_file_map(filename, &buf, &size, 0, log_ctx)) < 0)
149  return ret;
150 
151  /* prescan file to get the number of lines and the maximum width */
152  w = 0;
153  for (i = 0; i < size; i++) {
154  if (buf[i] == '\n') {
155  if (*rows == INT_MAX) {
156  av_log(log_ctx, AV_LOG_ERROR, "Overflow on the number of rows in the file\n");
158  goto end;
159  }
160  ++(*rows);
161  *cols = FFMAX(*cols, w);
162  w = 0;
163  } else if (w == INT_MAX) {
164  av_log(log_ctx, AV_LOG_ERROR, "Overflow on the number of columns in the file\n");
165  return AVERROR_INVALIDDATA;
166  }
167  w++;
168  }
169  if (*rows > (SIZE_MAX / sizeof(int) / *cols)) {
170  av_log(log_ctx, AV_LOG_ERROR, "File with size %dx%d is too big\n",
171  *rows, *cols);
173  goto end;
174  }
175  if (!(*values = av_calloc(sizeof(int) * *rows, *cols))) {
176  ret = AVERROR(ENOMEM);
177  goto end;
178  }
179 
180  /* fill *values */
181  p = buf;
182  pend = buf + size-1;
183  for (i = 0; i < *rows; i++) {
184  for (j = 0;; j++) {
185  if (p > pend || *p == '\n') {
186  p++;
187  break;
188  } else
189  (*values)[*cols*i + j] = !!av_isgraph(*(p++));
190  }
191  }
192 
193 end:
194  av_file_unmap(buf, size);
195 
196 #ifdef DEBUG
197  {
198  char *line;
199  if (!(line = av_malloc(*cols + 1)))
200  return AVERROR(ENOMEM);
201  for (i = 0; i < *rows; i++) {
202  for (j = 0; j < *cols; j++)
203  line[j] = (*values)[i * *cols + j] ? '@' : ' ';
204  line[j] = 0;
205  av_log(log_ctx, AV_LOG_DEBUG, "%3d: %s\n", i, line);
206  }
207  av_free(line);
208  }
209 #endif
210 
211  return 0;
212 }
213 
214 static int parse_iplconvkernel(IplConvKernel **kernel, char *buf, void *log_ctx)
215 {
216  char shape_filename[128] = "", shape_str[32] = "rect";
217  int cols = 0, rows = 0, anchor_x = 0, anchor_y = 0, shape = CV_SHAPE_RECT;
218  int *values = NULL, ret = 0;
219 
220  sscanf(buf, "%dx%d+%dx%d/%32[^=]=%127s", &cols, &rows, &anchor_x, &anchor_y, shape_str, shape_filename);
221 
222  if (!strcmp(shape_str, "rect" )) shape = CV_SHAPE_RECT;
223  else if (!strcmp(shape_str, "cross" )) shape = CV_SHAPE_CROSS;
224  else if (!strcmp(shape_str, "ellipse")) shape = CV_SHAPE_ELLIPSE;
225  else if (!strcmp(shape_str, "custom" )) {
226  shape = CV_SHAPE_CUSTOM;
227  if ((ret = read_shape_from_file(&cols, &rows, &values, shape_filename, log_ctx)) < 0)
228  return ret;
229  } else {
230  av_log(log_ctx, AV_LOG_ERROR,
231  "Shape unspecified or type '%s' unknown.\n", shape_str);
232  ret = AVERROR(EINVAL);
233  goto out;
234  }
235 
236  if (rows <= 0 || cols <= 0) {
237  av_log(log_ctx, AV_LOG_ERROR,
238  "Invalid non-positive values for shape size %dx%d\n", cols, rows);
239  ret = AVERROR(EINVAL);
240  goto out;
241  }
242 
243  if (anchor_x < 0 || anchor_y < 0 || anchor_x >= cols || anchor_y >= rows) {
244  av_log(log_ctx, AV_LOG_ERROR,
245  "Shape anchor %dx%d is not inside the rectangle with size %dx%d.\n",
246  anchor_x, anchor_y, cols, rows);
247  ret = AVERROR(EINVAL);
248  goto out;
249  }
250 
251  *kernel = cvCreateStructuringElementEx(cols, rows, anchor_x, anchor_y, shape, values);
252  if (!*kernel) {
253  ret = AVERROR(ENOMEM);
254  goto out;
255  }
256 
257  av_log(log_ctx, AV_LOG_VERBOSE, "Structuring element: w:%d h:%d x:%d y:%d shape:%s\n",
258  rows, cols, anchor_x, anchor_y, shape_str);
259 out:
260  av_freep(&values);
261  return ret;
262 }
263 
264 typedef struct DilateContext {
266  IplConvKernel *kernel;
267 } DilateContext;
268 
269 static av_cold int dilate_init(AVFilterContext *ctx, const char *args)
270 {
271  OCVContext *s = ctx->priv;
272  DilateContext *dilate = s->priv;
273  char default_kernel_str[] = "3x3+0x0/rect";
274  char *kernel_str = NULL;
275  const char *buf = args;
276  int ret;
277 
278  if (args) {
279  kernel_str = av_get_token(&buf, "|");
280 
281  if (!kernel_str)
282  return AVERROR(ENOMEM);
283  }
284 
285  ret = parse_iplconvkernel(&dilate->kernel,
286  (!kernel_str || !*kernel_str) ? default_kernel_str
287  : kernel_str,
288  ctx);
289  av_free(kernel_str);
290  if (ret < 0)
291  return ret;
292 
293  if (!buf || sscanf(buf, "|%d", &dilate->nb_iterations) != 1)
294  dilate->nb_iterations = 1;
295  av_log(ctx, AV_LOG_VERBOSE, "iterations_nb:%d\n", dilate->nb_iterations);
296  if (dilate->nb_iterations <= 0) {
297  av_log(ctx, AV_LOG_ERROR, "Invalid non-positive value '%d' for nb_iterations\n",
298  dilate->nb_iterations);
299  return AVERROR(EINVAL);
300  }
301  return 0;
302 }
303 
305 {
306  OCVContext *s = ctx->priv;
307  DilateContext *dilate = s->priv;
308 
309  cvReleaseStructuringElement(&dilate->kernel);
310 }
311 
312 static void dilate_end_frame_filter(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg)
313 {
314  OCVContext *s = ctx->priv;
315  DilateContext *dilate = s->priv;
316  cvDilate(inimg, outimg, dilate->kernel, dilate->nb_iterations);
317 }
318 
319 static void erode_end_frame_filter(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg)
320 {
321  OCVContext *s = ctx->priv;
322  DilateContext *dilate = s->priv;
323  cvErode(inimg, outimg, dilate->kernel, dilate->nb_iterations);
324 }
325 
326 typedef struct OCVFilterEntry {
327  const char *name;
328  size_t priv_size;
329  int (*init)(AVFilterContext *ctx, const char *args);
331  void (*end_frame_filter)(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg);
333 
337  { "smooth", sizeof(SmoothContext), smooth_init, NULL, smooth_end_frame_filter },
338 };
339 
341 {
342  OCVContext *s = ctx->priv;
343  int i;
344 
345  if (!s->name) {
346  av_log(ctx, AV_LOG_ERROR, "No libopencv filter name specified\n");
347  return AVERROR(EINVAL);
348  }
349  for (i = 0; i < FF_ARRAY_ELEMS(ocv_filter_entries); i++) {
350  const OCVFilterEntry *entry = &ocv_filter_entries[i];
351  if (!strcmp(s->name, entry->name)) {
352  s->init = entry->init;
353  s->uninit = entry->uninit;
354  s->end_frame_filter = entry->end_frame_filter;
355 
356  if (!(s->priv = av_mallocz(entry->priv_size)))
357  return AVERROR(ENOMEM);
358  return s->init(ctx, s->params);
359  }
360  }
361 
362  av_log(ctx, AV_LOG_ERROR, "No libopencv filter named '%s'\n", s->name);
363  return AVERROR(EINVAL);
364 }
365 
367 {
368  OCVContext *s = ctx->priv;
369 
370  if (s->uninit)
371  s->uninit(ctx);
372  av_freep(&s->priv);
373 }
374 
376 {
377  AVFilterContext *ctx = inlink->dst;
378  OCVContext *s = ctx->priv;
379  AVFilterLink *outlink= inlink->dst->outputs[0];
380  AVFrame *out;
381  IplImage inimg, outimg;
382 
383  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
384  if (!out) {
385  av_frame_free(&in);
386  return AVERROR(ENOMEM);
387  }
389 
390  fill_iplimage_from_frame(&inimg , in , inlink->format);
391  fill_iplimage_from_frame(&outimg, out, inlink->format);
392  s->end_frame_filter(ctx, &inimg, &outimg);
393  fill_frame_from_iplimage(out, &outimg, inlink->format);
394 
395  av_frame_free(&in);
396 
397  return ff_filter_frame(outlink, out);
398 }
399 
400 #define OFFSET(x) offsetof(OCVContext, x)
401 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
402 static const AVOption ocv_options[] = {
403  { "filter_name", NULL, OFFSET(name), AV_OPT_TYPE_STRING, .flags = FLAGS },
404  { "filter_params", NULL, OFFSET(params), AV_OPT_TYPE_STRING, .flags = FLAGS },
405  { NULL }
406 };
407 
409 
411  {
412  .name = "default",
413  .type = AVMEDIA_TYPE_VIDEO,
414  .filter_frame = filter_frame,
415  },
416 };
417 
419  {
420  .name = "default",
421  .type = AVMEDIA_TYPE_VIDEO,
422  },
423 };
424 
426  .name = "ocv",
427  .description = NULL_IF_CONFIG_SMALL("Apply transform using libopencv."),
428  .priv_size = sizeof(OCVContext),
429  .priv_class = &ocv_class,
431  .init = init,
432  .uninit = uninit,
435 };
SmoothContext
Definition: vf_libopencv.c:85
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
OCVFilterEntry::priv_size
size_t priv_size
Definition: vf_libopencv.c:328
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
FLAGS
#define FLAGS
Definition: vf_libopencv.c:401
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
parse_iplconvkernel
static int parse_iplconvkernel(IplConvKernel **kernel, char *buf, void *log_ctx)
Definition: vf_libopencv.c:214
av_get_token
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
Definition: avstring.c:151
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1019
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:112
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:303
w
uint8_t w
Definition: llviddspenc.c:38
AVOption
AVOption.
Definition: opt.h:247
DilateContext
Definition: vf_libopencv.c:264
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:69
AV_PIX_FMT_BGRA
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:95
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:153
video.h
OCVFilterEntry
Definition: vf_libopencv.c:326
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
formats.h
OCVContext
Definition: vf_libopencv.c:75
OFFSET
#define OFFSET(x)
Definition: vf_libopencv.c:400
dilate_uninit
static av_cold void dilate_uninit(AVFilterContext *ctx)
Definition: vf_libopencv.c:304
av_file_map
int av_file_map(const char *filename, uint8_t **bufptr, size_t *size, int log_offset, void *log_ctx)
Read the file with name filename, and put its content in a newly allocated buffer or map it with mmap...
Definition: file.c:53
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(ocv)
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:50
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:90
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_libopencv.c:340
s
#define s(width, name)
Definition: cbs_vp9.c:257
SmoothContext::param4
double param4
Definition: vf_libopencv.c:88
OCVFilterEntry::init
int(* init)(AVFilterContext *ctx, const char *args)
Definition: vf_libopencv.c:329
smooth_end_frame_filter
static void smooth_end_frame_filter(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg)
Definition: vf_libopencv.c:134
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_libopencv.c:375
ff_set_common_formats_from_list
int ff_set_common_formats_from_list(AVFilterContext *ctx, const int *fmts)
Equivalent to ff_set_common_formats(ctx, ff_make_format_list(fmts))
Definition: formats.c:703
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:290
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
ctx
AVFormatContext * ctx
Definition: movenc.c:48
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:152
av_file_unmap
void av_file_unmap(uint8_t *bufptr, size_t size)
Unmap or free the buffer bufptr created by av_file_map().
Definition: file.c:144
SmoothContext::param3
double param3
Definition: vf_libopencv.c:88
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
avfilter_vf_ocv_outputs
static const AVFilterPad avfilter_vf_ocv_outputs[]
Definition: vf_libopencv.c:418
DilateContext::kernel
IplConvKernel * kernel
Definition: vf_libopencv.c:266
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
OCVContext::priv
void * priv
Definition: vf_libopencv.c:82
OCVFilterEntry::uninit
void(* uninit)(AVFilterContext *ctx)
Definition: vf_libopencv.c:330
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
OCVContext::init
int(* init)(AVFilterContext *ctx, const char *args)
Definition: vf_libopencv.c:79
dilate_init
static av_cold int dilate_init(AVFilterContext *ctx, const char *args)
Definition: vf_libopencv.c:269
size
int size
Definition: twinvq_data.h:10344
fill_iplimage_from_frame
static void fill_iplimage_from_frame(IplImage *img, const AVFrame *frame, enum AVPixelFormat pixfmt)
Definition: vf_libopencv.c:43
OCVContext::params
char * params
Definition: vf_libopencv.c:78
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_libopencv.c:366
av_isgraph
static av_const int av_isgraph(int c)
Locale-independent conversion of ASCII isgraph.
Definition: avstring.h:219
img
#define img
Definition: vf_colormatrix.c:116
erode_end_frame_filter
static void erode_end_frame_filter(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg)
Definition: vf_libopencv.c:319
line
Definition: graph2dot.c:48
SmoothContext::param2
int param2
Definition: vf_libopencv.c:87
dilate_end_frame_filter
static void dilate_end_frame_filter(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg)
Definition: vf_libopencv.c:312
internal.h
i
int i
Definition: input.c:406
common.h
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:263
OCVFilterEntry::name
const char * name
Definition: vf_libopencv.c:327
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:56
SmoothContext::param1
int param1
Definition: vf_libopencv.c:87
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:271
smooth
static float smooth(DeshakeOpenCLContext *deshake_ctx, float *gauss_kernel, int length, float max_val, AVFifoBuffer *values)
Definition: vf_deshake_opencl.c:903
AVFilter
Filter definition.
Definition: avfilter.h:149
ret
ret
Definition: filter_design.txt:187
pixfmt
enum AVPixelFormat pixfmt
Definition: kmsgrab.c:365
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_libopencv.c:67
fill_frame_from_iplimage
static void fill_frame_from_iplimage(AVFrame *frame, const IplImage *img, enum AVPixelFormat pixfmt)
Definition: vf_libopencv.c:61
DilateContext::nb_iterations
int nb_iterations
Definition: vf_libopencv.c:265
avfilter_vf_ocv_inputs
static const AVFilterPad avfilter_vf_ocv_inputs[]
Definition: vf_libopencv.c:410
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
avfilter.h
values
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return values
Definition: filter_design.txt:263
file.h
OCVContext::uninit
void(* uninit)(AVFilterContext *ctx)
Definition: vf_libopencv.c:80
AVFilterContext
An instance of a filter.
Definition: avfilter.h:346
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
OCVFilterEntry::end_frame_filter
void(* end_frame_filter)(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg)
Definition: vf_libopencv.c:331
read_shape_from_file
static int read_shape_from_file(int *cols, int *rows, int **values, const char *filename, void *log_ctx)
Definition: vf_libopencv.c:141
ff_vf_ocv
const AVFilter ff_vf_ocv
Definition: vf_libopencv.c:425
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:153
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
OCVContext::end_frame_filter
void(* end_frame_filter)(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg)
Definition: vf_libopencv.c:81
SmoothContext::type
int type
Definition: vf_libopencv.c:86
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
ocv_filter_entries
static const OCVFilterEntry ocv_filter_entries[]
Definition: vf_libopencv.c:334
avstring.h
smooth_init
static av_cold int smooth_init(AVFilterContext *ctx, const char *args)
Definition: vf_libopencv.c:91
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:228
OCVContext::name
char * name
Definition: vf_libopencv.c:77
int
int
Definition: ffmpeg_filter.c:156
ocv_options
static const AVOption ocv_options[]
Definition: vf_libopencv.c:402
line
The official guide to swscale for confused that consecutive non overlapping rectangles of slice_bottom special converter These generally are unscaled converters of common like for each output line the vertical scaler pulls lines from a ring buffer When the ring buffer does not contain the wanted line
Definition: swscale.txt:40