FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vf_convolution.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2013 Oka Motofumi (chikuzen.mo at gmail dot com)
3  * Copyright (c) 2015 Paul B Mahol
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 #include "libavutil/avstring.h"
23 #include "libavutil/imgutils.h"
24 #include "libavutil/opt.h"
25 #include "libavutil/pixdesc.h"
26 #include "avfilter.h"
27 #include "formats.h"
28 #include "internal.h"
29 #include "video.h"
30 
31 typedef struct ConvolutionContext {
32  const AVClass *class;
33 
34  char *matrix_str[4];
35  float rdiv[4];
36  float bias[4];
37  float scale;
38  float delta;
39  int planes;
40 
41  int size[4];
42  int depth;
43  int bpc;
44  int bstride;
47  int nb_planes;
49  int planewidth[4];
50  int planeheight[4];
51  int matrix[4][25];
52  int matrix_length[4];
53  int copy[4];
54 
55  int (*filter[4])(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
57 
58 #define OFFSET(x) offsetof(ConvolutionContext, x)
59 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
60 
61 static const AVOption convolution_options[] = {
62  { "0m", "set matrix for 1st plane", OFFSET(matrix_str[0]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS },
63  { "1m", "set matrix for 2nd plane", OFFSET(matrix_str[1]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS },
64  { "2m", "set matrix for 3rd plane", OFFSET(matrix_str[2]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS },
65  { "3m", "set matrix for 4th plane", OFFSET(matrix_str[3]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS },
66  { "0rdiv", "set rdiv for 1st plane", OFFSET(rdiv[0]), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, INT_MAX, FLAGS},
67  { "1rdiv", "set rdiv for 2nd plane", OFFSET(rdiv[1]), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, INT_MAX, FLAGS},
68  { "2rdiv", "set rdiv for 3rd plane", OFFSET(rdiv[2]), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, INT_MAX, FLAGS},
69  { "3rdiv", "set rdiv for 4th plane", OFFSET(rdiv[3]), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, INT_MAX, FLAGS},
70  { "0bias", "set bias for 1st plane", OFFSET(bias[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS},
71  { "1bias", "set bias for 2nd plane", OFFSET(bias[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS},
72  { "2bias", "set bias for 3rd plane", OFFSET(bias[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS},
73  { "3bias", "set bias for 4th plane", OFFSET(bias[3]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS},
74  { NULL }
75 };
76 
77 AVFILTER_DEFINE_CLASS(convolution);
78 
79 static const int same3x3[9] = {0, 0, 0,
80  0, 1, 0,
81  0, 0, 0};
82 
83 static const int same5x5[25] = {0, 0, 0, 0, 0,
84  0, 0, 0, 0, 0,
85  0, 0, 1, 0, 0,
86  0, 0, 0, 0, 0,
87  0, 0, 0, 0, 0};
88 
90 {
91  static const enum AVPixelFormat pix_fmts[] = {
110  };
111 
112  return ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
113 }
114 
115 static inline void line_copy8(uint8_t *line, const uint8_t *srcp, int width, int mergin)
116 {
117  int i;
118 
119  memcpy(line, srcp, width);
120 
121  for (i = mergin; i > 0; i--) {
122  line[-i] = line[i];
123  line[width - 1 + i] = line[width - 1 - i];
124  }
125 }
126 
127 static inline void line_copy16(uint16_t *line, const uint16_t *srcp, int width, int mergin)
128 {
129  int i;
130 
131  memcpy(line, srcp, width * 2);
132 
133  for (i = mergin; i > 0; i--) {
134  line[-i] = line[i];
135  line[width - 1 + i] = line[width - 1 - i];
136  }
137 }
138 
139 typedef struct ThreadData {
140  AVFrame *in, *out;
141  int plane;
142 } ThreadData;
143 
144 static int filter16_prewitt(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
145 {
146  ConvolutionContext *s = ctx->priv;
147  ThreadData *td = arg;
148  AVFrame *in = td->in;
149  AVFrame *out = td->out;
150  const int plane = td->plane;
151  const int peak = (1 << s->depth) - 1;
152  const int stride = in->linesize[plane] / 2;
153  const int bstride = s->bstride;
154  const int height = s->planeheight[plane];
155  const int width = s->planewidth[plane];
156  const int slice_start = (height * jobnr) / nb_jobs;
157  const int slice_end = (height * (jobnr+1)) / nb_jobs;
158  const uint16_t *src = (const uint16_t *)in->data[plane] + slice_start * stride;
159  uint16_t *dst = (uint16_t *)out->data[plane] + slice_start * (out->linesize[plane] / 2);
160  const float scale = s->scale;
161  const float delta = s->delta;
162  uint16_t *p0 = (uint16_t *)s->bptrs[jobnr] + 16;
163  uint16_t *p1 = p0 + bstride;
164  uint16_t *p2 = p1 + bstride;
165  uint16_t *orig = p0, *end = p2;
166  int y, x;
167 
168  line_copy16(p0, src + stride * (slice_start == 0 ? 1 : -1), width, 1);
169  line_copy16(p1, src, width, 1);
170 
171  for (y = slice_start; y < slice_end; y++) {
172  src += stride * (y < height - 1 ? 1 : -1);
173  line_copy16(p2, src, width, 1);
174 
175  for (x = 0; x < width; x++) {
176  int suma = p0[x - 1] * -1 +
177  p0[x] * -1 +
178  p0[x + 1] * -1 +
179  p2[x - 1] * 1 +
180  p2[x] * 1 +
181  p2[x + 1] * 1;
182  int sumb = p0[x - 1] * -1 +
183  p0[x + 1] * 1 +
184  p1[x - 1] * -1 +
185  p1[x + 1] * 1 +
186  p2[x - 1] * -1 +
187  p2[x + 1] * 1;
188 
189  dst[x] = av_clip(sqrt(suma*suma + sumb*sumb) * scale + delta, 0, peak);
190  }
191 
192  p0 = p1;
193  p1 = p2;
194  p2 = (p2 == end) ? orig: p2 + bstride;
195  dst += out->linesize[plane] / 2;
196  }
197 
198  return 0;
199 }
200 
201 static int filter16_sobel(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
202 {
203  ConvolutionContext *s = ctx->priv;
204  ThreadData *td = arg;
205  AVFrame *in = td->in;
206  AVFrame *out = td->out;
207  const int plane = td->plane;
208  const int peak = (1 << s->depth) - 1;
209  const int stride = in->linesize[plane] / 2;
210  const int bstride = s->bstride;
211  const int height = s->planeheight[plane];
212  const int width = s->planewidth[plane];
213  const int slice_start = (height * jobnr) / nb_jobs;
214  const int slice_end = (height * (jobnr+1)) / nb_jobs;
215  const uint16_t *src = (const uint16_t *)in->data[plane] + slice_start * stride;
216  uint16_t *dst = (uint16_t *)out->data[plane] + slice_start * (out->linesize[plane] / 2);
217  const float scale = s->scale;
218  const float delta = s->delta;
219  uint16_t *p0 = (uint16_t *)s->bptrs[jobnr] + 16;
220  uint16_t *p1 = p0 + bstride;
221  uint16_t *p2 = p1 + bstride;
222  uint16_t *orig = p0, *end = p2;
223  int y, x;
224 
225  line_copy16(p0, src + stride * (slice_start == 0 ? 1 : -1), width, 1);
226  line_copy16(p1, src, width, 1);
227 
228  for (y = slice_start; y < slice_end; y++) {
229  src += stride * (y < height - 1 ? 1 : -1);
230  line_copy16(p2, src, width, 1);
231 
232  for (x = 0; x < width; x++) {
233  int suma = p0[x - 1] * -1 +
234  p0[x] * -2 +
235  p0[x + 1] * -1 +
236  p2[x - 1] * 1 +
237  p2[x] * 2 +
238  p2[x + 1] * 1;
239  int sumb = p0[x - 1] * -1 +
240  p0[x + 1] * 1 +
241  p1[x - 1] * -2 +
242  p1[x + 1] * 2 +
243  p2[x - 1] * -1 +
244  p2[x + 1] * 1;
245 
246  dst[x] = av_clip(sqrt(suma*suma + sumb*sumb) * scale + delta, 0, peak);
247  }
248 
249  p0 = p1;
250  p1 = p2;
251  p2 = (p2 == end) ? orig: p2 + bstride;
252  dst += out->linesize[plane] / 2;
253  }
254 
255  return 0;
256 }
257 
258 static int filter_prewitt(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
259 {
260  ConvolutionContext *s = ctx->priv;
261  ThreadData *td = arg;
262  AVFrame *in = td->in;
263  AVFrame *out = td->out;
264  const int plane = td->plane;
265  const int stride = in->linesize[plane];
266  const int bstride = s->bstride;
267  const int height = s->planeheight[plane];
268  const int width = s->planewidth[plane];
269  const int slice_start = (height * jobnr) / nb_jobs;
270  const int slice_end = (height * (jobnr+1)) / nb_jobs;
271  const uint8_t *src = in->data[plane] + slice_start * stride;
272  uint8_t *dst = out->data[plane] + slice_start * out->linesize[plane];
273  const float scale = s->scale;
274  const float delta = s->delta;
275  uint8_t *p0 = s->bptrs[jobnr] + 16;
276  uint8_t *p1 = p0 + bstride;
277  uint8_t *p2 = p1 + bstride;
278  uint8_t *orig = p0, *end = p2;
279  int y, x;
280 
281  line_copy8(p0, src + stride * (slice_start == 0 ? 1 : -1), width, 1);
282  line_copy8(p1, src, width, 1);
283 
284  for (y = slice_start; y < slice_end; y++) {
285  src += stride * (y < height - 1 ? 1 : -1);
286  line_copy8(p2, src, width, 1);
287 
288  for (x = 0; x < width; x++) {
289  int suma = p0[x - 1] * -1 +
290  p0[x] * -1 +
291  p0[x + 1] * -1 +
292  p2[x - 1] * 1 +
293  p2[x] * 1 +
294  p2[x + 1] * 1;
295  int sumb = p0[x - 1] * -1 +
296  p0[x + 1] * 1 +
297  p1[x - 1] * -1 +
298  p1[x + 1] * 1 +
299  p2[x - 1] * -1 +
300  p2[x + 1] * 1;
301 
302  dst[x] = av_clip_uint8(sqrt(suma*suma + sumb*sumb) * scale + delta);
303  }
304 
305  p0 = p1;
306  p1 = p2;
307  p2 = (p2 == end) ? orig: p2 + bstride;
308  dst += out->linesize[plane];
309  }
310 
311  return 0;
312 }
313 
314 static int filter_sobel(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
315 {
316  ConvolutionContext *s = ctx->priv;
317  ThreadData *td = arg;
318  AVFrame *in = td->in;
319  AVFrame *out = td->out;
320  const int plane = td->plane;
321  const int stride = in->linesize[plane];
322  const int bstride = s->bstride;
323  const int height = s->planeheight[plane];
324  const int width = s->planewidth[plane];
325  const int slice_start = (height * jobnr) / nb_jobs;
326  const int slice_end = (height * (jobnr+1)) / nb_jobs;
327  const uint8_t *src = in->data[plane] + slice_start * stride;
328  uint8_t *dst = out->data[plane] + slice_start * out->linesize[plane];
329  const float scale = s->scale;
330  const float delta = s->delta;
331  uint8_t *p0 = s->bptrs[jobnr] + 16;
332  uint8_t *p1 = p0 + bstride;
333  uint8_t *p2 = p1 + bstride;
334  uint8_t *orig = p0, *end = p2;
335  int y, x;
336 
337  line_copy8(p0, src + stride * (slice_start == 0 ? 1 : -1), width, 1);
338  line_copy8(p1, src, width, 1);
339 
340  for (y = slice_start; y < slice_end; y++) {
341  src += stride * (y < height - 1 ? 1 : -1);
342  line_copy8(p2, src, width, 1);
343 
344  for (x = 0; x < width; x++) {
345  int suma = p0[x - 1] * -1 +
346  p0[x] * -2 +
347  p0[x + 1] * -1 +
348  p2[x - 1] * 1 +
349  p2[x] * 2 +
350  p2[x + 1] * 1;
351  int sumb = p0[x - 1] * -1 +
352  p0[x + 1] * 1 +
353  p1[x - 1] * -2 +
354  p1[x + 1] * 2 +
355  p2[x - 1] * -1 +
356  p2[x + 1] * 1;
357 
358  dst[x] = av_clip_uint8(sqrt(suma*suma + sumb*sumb) * scale + delta);
359  }
360 
361  p0 = p1;
362  p1 = p2;
363  p2 = (p2 == end) ? orig: p2 + bstride;
364  dst += out->linesize[plane];
365  }
366 
367  return 0;
368 }
369 
370 static int filter16_3x3(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
371 {
372  ConvolutionContext *s = ctx->priv;
373  ThreadData *td = arg;
374  AVFrame *in = td->in;
375  AVFrame *out = td->out;
376  const int plane = td->plane;
377  const int peak = (1 << s->depth) - 1;
378  const int stride = in->linesize[plane] / 2;
379  const int bstride = s->bstride;
380  const int height = s->planeheight[plane];
381  const int width = s->planewidth[plane];
382  const int slice_start = (height * jobnr) / nb_jobs;
383  const int slice_end = (height * (jobnr+1)) / nb_jobs;
384  const uint16_t *src = (const uint16_t *)in->data[plane] + slice_start * stride;
385  uint16_t *dst = (uint16_t *)out->data[plane] + slice_start * (out->linesize[plane] / 2);
386  uint16_t *p0 = (uint16_t *)s->bptrs[jobnr] + 16;
387  uint16_t *p1 = p0 + bstride;
388  uint16_t *p2 = p1 + bstride;
389  uint16_t *orig = p0, *end = p2;
390  const int *matrix = s->matrix[plane];
391  const float rdiv = s->rdiv[plane];
392  const float bias = s->bias[plane];
393  int y, x;
394 
395  line_copy16(p0, src + stride * (slice_start == 0 ? 1 : -1), width, 1);
396  line_copy16(p1, src, width, 1);
397 
398  for (y = slice_start; y < slice_end; y++) {
399  src += stride * (y < height - 1 ? 1 : -1);
400  line_copy16(p2, src, width, 1);
401 
402  for (x = 0; x < width; x++) {
403  int sum = p0[x - 1] * matrix[0] +
404  p0[x] * matrix[1] +
405  p0[x + 1] * matrix[2] +
406  p1[x - 1] * matrix[3] +
407  p1[x] * matrix[4] +
408  p1[x + 1] * matrix[5] +
409  p2[x - 1] * matrix[6] +
410  p2[x] * matrix[7] +
411  p2[x + 1] * matrix[8];
412  sum = (int)(sum * rdiv + bias + 0.5f);
413  dst[x] = av_clip(sum, 0, peak);
414  }
415 
416  p0 = p1;
417  p1 = p2;
418  p2 = (p2 == end) ? orig: p2 + bstride;
419  dst += out->linesize[plane] / 2;
420  }
421 
422  return 0;
423 }
424 
425 static int filter16_5x5(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
426 {
427  ConvolutionContext *s = ctx->priv;
428  ThreadData *td = arg;
429  AVFrame *in = td->in;
430  AVFrame *out = td->out;
431  const int plane = td->plane;
432  const int peak = (1 << s->depth) - 1;
433  const int stride = in->linesize[plane] / 2;
434  const int bstride = s->bstride;
435  const int height = s->planeheight[plane];
436  const int width = s->planewidth[plane];
437  const int slice_start = (height * jobnr) / nb_jobs;
438  const int slice_end = (height * (jobnr+1)) / nb_jobs;
439  const uint16_t *src = (const uint16_t *)in->data[plane] + slice_start * stride;
440  uint16_t *dst = (uint16_t *)out->data[plane] + slice_start * (out->linesize[plane] / 2);
441  uint16_t *p0 = (uint16_t *)s->bptrs[jobnr] + 16;
442  uint16_t *p1 = p0 + bstride;
443  uint16_t *p2 = p1 + bstride;
444  uint16_t *p3 = p2 + bstride;
445  uint16_t *p4 = p3 + bstride;
446  uint16_t *orig = p0, *end = p4;
447  const int *matrix = s->matrix[plane];
448  float rdiv = s->rdiv[plane];
449  float bias = s->bias[plane];
450  int y, x, i;
451 
452  line_copy16(p0, src + 2 * stride * (slice_start < 2 ? 1 : -1), width, 2);
453  line_copy16(p1, src + stride * (slice_start == 0 ? 1 : -1), width, 2);
454  line_copy16(p2, src, width, 2);
455  src += stride;
456  line_copy16(p3, src, width, 2);
457 
458  for (y = slice_start; y < slice_end; y++) {
459  uint16_t *array[] = {
460  p0 - 2, p0 - 1, p0, p0 + 1, p0 + 2,
461  p1 - 2, p1 - 1, p1, p1 + 1, p1 + 2,
462  p2 - 2, p2 - 1, p2, p2 + 1, p2 + 2,
463  p3 - 2, p3 - 1, p3, p3 + 1, p3 + 2,
464  p4 - 2, p4 - 1, p4, p4 + 1, p4 + 2
465  };
466 
467  src += stride * (y < height - 2 ? 1 : -1);
468  line_copy16(p4, src, width, 2);
469 
470  for (x = 0; x < width; x++) {
471  int sum = 0;
472 
473  for (i = 0; i < 25; i++) {
474  sum += *(array[i] + x) * matrix[i];
475  }
476  sum = (int)(sum * rdiv + bias + 0.5f);
477  dst[x] = av_clip(sum, 0, peak);
478  }
479 
480  p0 = p1;
481  p1 = p2;
482  p2 = p3;
483  p3 = p4;
484  p4 = (p4 == end) ? orig: p4 + bstride;
485  dst += out->linesize[plane] / 2;
486  }
487 
488  return 0;
489 }
490 
491 static int filter_3x3(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
492 {
493  ConvolutionContext *s = ctx->priv;
494  ThreadData *td = arg;
495  AVFrame *in = td->in;
496  AVFrame *out = td->out;
497  const int plane = td->plane;
498  const int stride = in->linesize[plane];
499  const int bstride = s->bstride;
500  const int height = s->planeheight[plane];
501  const int width = s->planewidth[plane];
502  const int slice_start = (height * jobnr) / nb_jobs;
503  const int slice_end = (height * (jobnr+1)) / nb_jobs;
504  const uint8_t *src = in->data[plane] + slice_start * stride;
505  uint8_t *dst = out->data[plane] + slice_start * out->linesize[plane];
506  uint8_t *p0 = s->bptrs[jobnr] + 16;
507  uint8_t *p1 = p0 + bstride;
508  uint8_t *p2 = p1 + bstride;
509  uint8_t *orig = p0, *end = p2;
510  const int *matrix = s->matrix[plane];
511  const float rdiv = s->rdiv[plane];
512  const float bias = s->bias[plane];
513  int y, x;
514 
515  line_copy8(p0, src + stride * (slice_start == 0 ? 1 : -1), width, 1);
516  line_copy8(p1, src, width, 1);
517 
518  for (y = slice_start; y < slice_end; y++) {
519  src += stride * (y < height - 1 ? 1 : -1);
520  line_copy8(p2, src, width, 1);
521 
522  for (x = 0; x < width; x++) {
523  int sum = p0[x - 1] * matrix[0] +
524  p0[x] * matrix[1] +
525  p0[x + 1] * matrix[2] +
526  p1[x - 1] * matrix[3] +
527  p1[x] * matrix[4] +
528  p1[x + 1] * matrix[5] +
529  p2[x - 1] * matrix[6] +
530  p2[x] * matrix[7] +
531  p2[x + 1] * matrix[8];
532  sum = (int)(sum * rdiv + bias + 0.5f);
533  dst[x] = av_clip_uint8(sum);
534  }
535 
536  p0 = p1;
537  p1 = p2;
538  p2 = (p2 == end) ? orig: p2 + bstride;
539  dst += out->linesize[plane];
540  }
541 
542  return 0;
543 }
544 
545 static int filter_5x5(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
546 {
547  ConvolutionContext *s = ctx->priv;
548  ThreadData *td = arg;
549  AVFrame *in = td->in;
550  AVFrame *out = td->out;
551  const int plane = td->plane;
552  const int stride = in->linesize[plane];
553  const int bstride = s->bstride;
554  const int height = s->planeheight[plane];
555  const int width = s->planewidth[plane];
556  const int slice_start = (height * jobnr) / nb_jobs;
557  const int slice_end = (height * (jobnr+1)) / nb_jobs;
558  const uint8_t *src = in->data[plane] + slice_start * stride;
559  uint8_t *dst = out->data[plane] + slice_start * out->linesize[plane];
560  uint8_t *p0 = s->bptrs[jobnr] + 16;
561  uint8_t *p1 = p0 + bstride;
562  uint8_t *p2 = p1 + bstride;
563  uint8_t *p3 = p2 + bstride;
564  uint8_t *p4 = p3 + bstride;
565  uint8_t *orig = p0, *end = p4;
566  const int *matrix = s->matrix[plane];
567  float rdiv = s->rdiv[plane];
568  float bias = s->bias[plane];
569  int y, x, i;
570 
571  line_copy8(p0, src + 2 * stride * (slice_start < 2 ? 1 : -1), width, 2);
572  line_copy8(p1, src + stride * (slice_start == 0 ? 1 : -1), width, 2);
573  line_copy8(p2, src, width, 2);
574  src += stride;
575  line_copy8(p3, src, width, 2);
576 
577 
578  for (y = slice_start; y < slice_end; y++) {
579  uint8_t *array[] = {
580  p0 - 2, p0 - 1, p0, p0 + 1, p0 + 2,
581  p1 - 2, p1 - 1, p1, p1 + 1, p1 + 2,
582  p2 - 2, p2 - 1, p2, p2 + 1, p2 + 2,
583  p3 - 2, p3 - 1, p3, p3 + 1, p3 + 2,
584  p4 - 2, p4 - 1, p4, p4 + 1, p4 + 2
585  };
586 
587  src += stride * (y < height - 2 ? 1 : -1);
588  line_copy8(p4, src, width, 2);
589 
590  for (x = 0; x < width; x++) {
591  int sum = 0;
592 
593  for (i = 0; i < 25; i++) {
594  sum += *(array[i] + x) * matrix[i];
595  }
596  sum = (int)(sum * rdiv + bias + 0.5f);
597  dst[x] = av_clip_uint8(sum);
598  }
599 
600  p0 = p1;
601  p1 = p2;
602  p2 = p3;
603  p3 = p4;
604  p4 = (p4 == end) ? orig: p4 + bstride;
605  dst += out->linesize[plane];
606  }
607 
608  return 0;
609 }
610 
611 static int config_input(AVFilterLink *inlink)
612 {
613  AVFilterContext *ctx = inlink->dst;
614  ConvolutionContext *s = ctx->priv;
616  int p;
617 
618  s->depth = desc->comp[0].depth;
619 
620  s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
621  s->planewidth[0] = s->planewidth[3] = inlink->w;
622  s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
623  s->planeheight[0] = s->planeheight[3] = inlink->h;
624 
627  s->bptrs = av_calloc(s->nb_threads, sizeof(*s->bptrs));
628  if (!s->bptrs)
629  return AVERROR(ENOMEM);
630 
631  s->bstride = s->planewidth[0] + 32;
632  s->bpc = (s->depth + 7) / 8;
633  s->buffer = av_malloc_array(5 * s->bstride * s->nb_threads, s->bpc);
634  if (!s->buffer)
635  return AVERROR(ENOMEM);
636 
637  for (p = 0; p < s->nb_threads; p++) {
638  s->bptrs[p] = s->buffer + 5 * s->bstride * s->bpc * p;
639  }
640 
641  if (!strcmp(ctx->filter->name, "convolution")) {
642  if (s->depth > 8) {
643  for (p = 0; p < s->nb_planes; p++) {
644  if (s->size[p] == 3)
645  s->filter[p] = filter16_3x3;
646  else if (s->size[p] == 5)
647  s->filter[p] = filter16_5x5;
648  }
649  }
650  } else if (!strcmp(ctx->filter->name, "prewitt")) {
651  if (s->depth > 8)
652  for (p = 0; p < s->nb_planes; p++)
653  s->filter[p] = filter16_prewitt;
654  } else if (!strcmp(ctx->filter->name, "sobel")) {
655  if (s->depth > 8)
656  for (p = 0; p < s->nb_planes; p++)
657  s->filter[p] = filter16_sobel;
658  }
659 
660  return 0;
661 }
662 
663 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
664 {
665  AVFilterContext *ctx = inlink->dst;
666  ConvolutionContext *s = ctx->priv;
667  AVFilterLink *outlink = ctx->outputs[0];
668  AVFrame *out;
669  int plane;
670 
671  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
672  if (!out) {
673  av_frame_free(&in);
674  return AVERROR(ENOMEM);
675  }
676  av_frame_copy_props(out, in);
677 
678  for (plane = 0; plane < s->nb_planes; plane++) {
679  ThreadData td;
680 
681  if (s->copy[plane]) {
682  av_image_copy_plane(out->data[plane], out->linesize[plane],
683  in->data[plane], in->linesize[plane],
684  s->planewidth[plane] * s->bpc,
685  s->planeheight[plane]);
686  continue;
687  }
688 
689  td.in = in;
690  td.out = out;
691  td.plane = plane;
692  ctx->internal->execute(ctx, s->filter[plane], &td, NULL, FFMIN(s->planeheight[plane], s->nb_threads));
693  }
694 
695  av_frame_free(&in);
696  return ff_filter_frame(outlink, out);
697 }
698 
700 {
701  ConvolutionContext *s = ctx->priv;
702  int i;
703 
704  if (!strcmp(ctx->filter->name, "convolution")) {
705  for (i = 0; i < 4; i++) {
706  int *matrix = (int *)s->matrix[i];
707  char *p, *arg, *saveptr = NULL;
708 
709  p = s->matrix_str[i];
710  while (s->matrix_length[i] < 25) {
711  if (!(arg = av_strtok(p, " ", &saveptr)))
712  break;
713 
714  p = NULL;
715  sscanf(arg, "%d", &matrix[s->matrix_length[i]]);
716  s->matrix_length[i]++;
717  }
718 
719  if (s->matrix_length[i] == 9) {
720  s->size[i] = 3;
721  if (!memcmp(matrix, same3x3, sizeof(same3x3)))
722  s->copy[i] = 1;
723  else
724  s->filter[i] = filter_3x3;
725  } else if (s->matrix_length[i] == 25) {
726  s->size[i] = 5;
727  if (!memcmp(matrix, same5x5, sizeof(same5x5)))
728  s->copy[i] = 1;
729  else
730  s->filter[i] = filter_5x5;
731  } else {
732  return AVERROR(EINVAL);
733  }
734  }
735  } else if (!strcmp(ctx->filter->name, "prewitt")) {
736  for (i = 0; i < 4; i++) {
737  if ((1 << i) & s->planes)
738  s->filter[i] = filter_prewitt;
739  else
740  s->copy[i] = 1;
741  }
742  } else if (!strcmp(ctx->filter->name, "sobel")) {
743  for (i = 0; i < 4; i++) {
744  if ((1 << i) & s->planes)
745  s->filter[i] = filter_sobel;
746  else
747  s->copy[i] = 1;
748  }
749  }
750 
751  return 0;
752 }
753 
755 {
756  ConvolutionContext *s = ctx->priv;
757 
758  av_freep(&s->bptrs);
759  av_freep(&s->buffer);
760 }
761 
762 static const AVFilterPad convolution_inputs[] = {
763  {
764  .name = "default",
765  .type = AVMEDIA_TYPE_VIDEO,
766  .config_props = config_input,
767  .filter_frame = filter_frame,
768  },
769  { NULL }
770 };
771 
773  {
774  .name = "default",
775  .type = AVMEDIA_TYPE_VIDEO,
776  },
777  { NULL }
778 };
779 
780 #if CONFIG_CONVOLUTION_FILTER
781 
782 AVFilter ff_vf_convolution = {
783  .name = "convolution",
784  .description = NULL_IF_CONFIG_SMALL("Apply convolution filter."),
785  .priv_size = sizeof(ConvolutionContext),
786  .priv_class = &convolution_class,
787  .init = init,
788  .uninit = uninit,
790  .inputs = convolution_inputs,
791  .outputs = convolution_outputs,
793 };
794 
795 #endif /* CONFIG_CONVOLUTION_FILTER */
796 
797 #if CONFIG_PREWITT_FILTER
798 
799 static const AVOption prewitt_options[] = {
800  { "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=15}, 0, 15, FLAGS},
801  { "scale", "set scale", OFFSET(scale), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, 65535, FLAGS},
802  { "delta", "set delta", OFFSET(delta), AV_OPT_TYPE_FLOAT, {.dbl=0}, -65535, 65535, FLAGS},
803  { NULL }
804 };
805 
806 AVFILTER_DEFINE_CLASS(prewitt);
807 
808 AVFilter ff_vf_prewitt = {
809  .name = "prewitt",
810  .description = NULL_IF_CONFIG_SMALL("Apply prewitt operator."),
811  .priv_size = sizeof(ConvolutionContext),
812  .priv_class = &prewitt_class,
813  .init = init,
814  .uninit = uninit,
816  .inputs = convolution_inputs,
817  .outputs = convolution_outputs,
819 };
820 
821 #endif /* CONFIG_PREWITT_FILTER */
822 
823 #if CONFIG_SOBEL_FILTER
824 
825 static const AVOption sobel_options[] = {
826  { "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=15}, 0, 15, FLAGS},
827  { "scale", "set scale", OFFSET(scale), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, 65535, FLAGS},
828  { "delta", "set delta", OFFSET(delta), AV_OPT_TYPE_FLOAT, {.dbl=0}, -65535, 65535, FLAGS},
829  { NULL }
830 };
831 
833 
834 AVFilter ff_vf_sobel = {
835  .name = "sobel",
836  .description = NULL_IF_CONFIG_SMALL("Apply sobel operator."),
837  .priv_size = sizeof(ConvolutionContext),
838  .priv_class = &sobel_class,
839  .init = init,
840  .uninit = uninit,
842  .inputs = convolution_inputs,
843  .outputs = convolution_outputs,
845 };
846 
847 #endif /* CONFIG_SOBEL_FILTER */
int plane
Definition: avisynth_c.h:422
static int filter16_prewitt(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#define NULL
Definition: coverity.c:32
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:388
const char * s
Definition: avisynth_c.h:768
AVFrame * out
Definition: af_sofalizer.c:587
static int filter16_3x3(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:382
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2333
This structure describes decoded (raw) audio or video data.
Definition: frame.h:187
AVOption.
Definition: opt.h:246
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:384
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:361
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:385
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:67
misc image utilities
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2373
Main libavfilter public API header.
static void sobel(int w, int h, uint16_t *dst, int dst_linesize, int8_t *dir, int dir_linesize, const uint8_t *src, int src_linesize)
const char * desc
Definition: nvenc.c:60
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:180
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:367
static int filter16_5x5(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:355
static int filter_sobel(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:92
#define src
Definition: vp8dsp.c:254
int(* filter[4])(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:92
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
Definition: mem.c:230
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
#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:125
BYTE int const BYTE * srcp
Definition: avisynth_c.h:813
const char * name
Pad name.
Definition: internal.h:60
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1125
AVFrame * in
Definition: af_sofalizer.c:587
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:102
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:117
uint8_t
#define av_cold
Definition: attributes.h:82
float delta
AVOptions.
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:381
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:366
#define height
int plane
Definition: vf_blend.c:57
static av_cold void uninit(AVFilterContext *ctx)
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
Definition: pixfmt.h:101
static int flags
Definition: log.c:57
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:75
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:364
ptrdiff_t size
Definition: opengl_enc.c:101
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:356
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:387
static void line_copy16(uint16_t *line, const uint16_t *srcp, int width, int mergin)
A filter pad used for either input or output.
Definition: internal.h:54
static void line_copy8(uint8_t *line, const uint8_t *srcp, int width, int mergin)
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:188
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:568
#define td
Definition: regdef.h:70
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:101
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:163
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:179
static const AVFilterPad convolution_inputs[]
void * priv
private data for use by the filter
Definition: avfilter.h:338
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:116
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:389
const char * arg
Definition: jacosubdec.c:66
Definition: graph2dot.c:48
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:372
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:354
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:373
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:66
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:349
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:370
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:831
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:335
static const AVFilterPad convolution_outputs[]
#define FFMIN(a, b)
Definition: common.h:96
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:74
#define width
static const AVOption convolution_options[]
AVFormatContext * ctx
Definition: movenc.c:48
static int query_formats(AVFilterContext *ctx)
static av_cold int init(AVFilterContext *ctx)
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:386
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:386
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:350
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:369
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:362
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:376
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:359
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:218
static int filter16_sobel(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:189
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:351
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:68
Describe the class of an AVClass context structure.
Definition: log.h:67
Filter definition.
Definition: avfilter.h:144
AVFILTER_DEFINE_CLASS(convolution)
static const int same3x3[9]
const char * name
Filter name.
Definition: avfilter.h:148
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:357
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:348
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:335
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:262
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:360
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:368
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
Definition: avfilter.h:363
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:352
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:358
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:201
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok()...
Definition: avstring.c:184
GLint GLenum GLboolean GLsizei stride
Definition: opengl_enc.c:105
int
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62
Y , 8bpp.
Definition: pixfmt.h:70
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:229
static const int same5x5[25]
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:383
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:76
static int filter_5x5(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:69
avfilter_execute_func * execute
Definition: internal.h:155
static int filter_prewitt(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:2051
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:272
static int config_input(AVFilterLink *inlink)
#define FLAGS
An instance of a filter.
Definition: avfilter.h:323
#define OFFSET(x)
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:100
static int array[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:106
#define av_malloc_array(a, b)
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
Definition: imgutils.c:337
static int filter_3x3(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#define stride
internal API functions
int depth
Number of bits in the component.
Definition: pixdesc.h:58
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
const AVFilter * filter
the AVFilter of which this is an instance
Definition: avfilter.h:326
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:363
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:596
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58