Go to the documentation of this file.
33 #define OFFSET(x) offsetof(ConvolutionContext, x)
34 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
65 static const int same5x5[25] = {0, 0, 0, 0, 0,
71 static const int same7x7[49] = {0, 0, 0, 0, 0, 0, 0,
111 float scale,
float delta,
const int *
const matrix,
112 const uint8_t *
c[],
int peak,
int radius,
115 uint16_t *dst = (uint16_t *)dstp;
118 for (x = 0; x <
width; x++) {
124 dst[x] =
av_clip(sqrtf(suma*suma + sumb*sumb) * scale +
delta, 0, peak);
129 float scale,
float delta,
const int *
const matrix,
130 const uint8_t *
c[],
int peak,
int radius,
133 uint16_t *dst = (uint16_t *)dstp;
136 for (x = 0; x <
width; x++) {
140 dst[x] =
av_clip(sqrtf(suma*suma + sumb*sumb) * scale +
delta, 0, peak);
145 float scale,
float delta,
const int *
const matrix,
146 const uint8_t *
c[],
int peak,
int radius,
149 uint16_t *dst = (uint16_t *)dstp;
152 for (x = 0; x <
width; x++) {
158 dst[x] =
av_clip(sqrtf(suma*suma + sumb*sumb) * scale +
delta, 0, peak);
163 float scale,
float delta,
const int *
const matrix,
164 const uint8_t *
c[],
int peak,
int radius,
167 uint16_t *dst = (uint16_t *)dstp;
168 const uint16_t *c0 = (
const uint16_t *)
c[0], *
c1 = (
const uint16_t *)
c[1], *
c2 = (
const uint16_t *)
c[2];
169 const uint16_t *c3 = (
const uint16_t *)
c[3], *c5 = (
const uint16_t *)
c[5];
170 const uint16_t *c6 = (
const uint16_t *)
c[6], *c7 = (
const uint16_t *)
c[7], *c8 = (
const uint16_t *)
c[8];
173 for (x = 0; x <
width; x++) {
174 int sum0 = c0[x] * 5 +
c1[x] * 5 +
c2[x] * 5 +
175 c3[x] * -3 + c5[x] * -3 +
176 c6[x] * -3 + c7[x] * -3 + c8[x] * -3;
177 int sum1 = c0[x] * -3 +
c1[x] * 5 +
c2[x] * 5 +
178 c3[x] * 5 + c5[x] * -3 +
179 c6[x] * -3 + c7[x] * -3 + c8[x] * -3;
180 int sum2 = c0[x] * -3 +
c1[x] * -3 +
c2[x] * 5 +
181 c3[x] * 5 + c5[x] * 5 +
182 c6[x] * -3 + c7[x] * -3 + c8[x] * -3;
183 int sum3 = c0[x] * -3 +
c1[x] * -3 +
c2[x] * -3 +
184 c3[x] * 5 + c5[x] * 5 +
185 c6[x] * 5 + c7[x] * -3 + c8[x] * -3;
186 int sum4 = c0[x] * -3 +
c1[x] * -3 +
c2[x] * -3 +
187 c3[x] * -3 + c5[x] * 5 +
188 c6[x] * 5 + c7[x] * 5 + c8[x] * -3;
189 int sum5 = c0[x] * -3 +
c1[x] * -3 +
c2[x] * -3 +
190 c3[x] * -3 + c5[x] * -3 +
191 c6[x] * 5 + c7[x] * 5 + c8[x] * 5;
192 int sum6 = c0[x] * 5 +
c1[x] * -3 +
c2[x] * -3 +
193 c3[x] * -3 + c5[x] * -3 +
194 c6[x] * -3 + c7[x] * 5 + c8[x] * 5;
195 int sum7 = c0[x] * 5 +
c1[x] * 5 +
c2[x] * -3 +
196 c3[x] * -3 + c5[x] * -3 +
197 c6[x] * -3 + c7[x] * -3 + c8[x] * 5;
199 sum0 =
FFMAX(sum0, sum1);
200 sum2 =
FFMAX(sum2, sum3);
201 sum4 =
FFMAX(sum4, sum5);
202 sum6 =
FFMAX(sum6, sum7);
203 sum0 =
FFMAX(sum0, sum2);
204 sum4 =
FFMAX(sum4, sum6);
205 sum0 =
FFMAX(sum0, sum4);
212 float scale,
float delta,
const int *
const matrix,
213 const uint8_t *
c[],
int peak,
int radius,
218 const uint8_t *c6 =
c[6], *c7 =
c[7], *c8 =
c[8];
221 for (x = 0; x <
width; x++) {
222 float suma = c0[x] * -1 +
c1[x] * -1 +
c2[x] * -1 +
223 c6[x] * 1 + c7[x] * 1 + c8[x] * 1;
224 float sumb = c0[x] * -1 +
c2[x] * 1 + c3[x] * -1 +
225 c5[x] * 1 + c6[x] * -1 + c8[x] * 1;
232 float scale,
float delta,
const int *
const matrix,
233 const uint8_t *
c[],
int peak,
int radius,
238 for (x = 0; x <
width; x++) {
239 float suma =
c[0][x] * 1 +
c[1][x] * -1;
240 float sumb =
c[4][x] * 1 +
c[3][x] * -1;
247 float scale,
float delta,
const int *
const matrix,
248 const uint8_t *
c[],
int peak,
int radius,
253 const uint8_t *c6 =
c[6], *c7 =
c[7], *c8 =
c[8];
256 for (x = 0; x <
width; x++) {
257 float suma = c0[x] * -1 +
c1[x] * -2 +
c2[x] * -1 +
258 c6[x] * 1 + c7[x] * 2 + c8[x] * 1;
259 float sumb = c0[x] * -1 +
c2[x] * 1 + c3[x] * -2 +
260 c5[x] * 2 + c6[x] * -1 + c8[x] * 1;
267 float scale,
float delta,
const int *
const matrix,
268 const uint8_t *
c[],
int peak,
int radius,
273 const uint8_t *c6 =
c[6], *c7 =
c[7], *c8 =
c[8];
276 for (x = 0; x <
width; x++) {
277 int sum0 = c0[x] * 5 +
c1[x] * 5 +
c2[x] * 5 +
278 c3[x] * -3 + c5[x] * -3 +
279 c6[x] * -3 + c7[x] * -3 + c8[x] * -3;
280 int sum1 = c0[x] * -3 +
c1[x] * 5 +
c2[x] * 5 +
281 c3[x] * 5 + c5[x] * -3 +
282 c6[x] * -3 + c7[x] * -3 + c8[x] * -3;
283 int sum2 = c0[x] * -3 +
c1[x] * -3 +
c2[x] * 5 +
284 c3[x] * 5 + c5[x] * 5 +
285 c6[x] * -3 + c7[x] * -3 + c8[x] * -3;
286 int sum3 = c0[x] * -3 +
c1[x] * -3 +
c2[x] * -3 +
287 c3[x] * 5 + c5[x] * 5 +
288 c6[x] * 5 + c7[x] * -3 + c8[x] * -3;
289 int sum4 = c0[x] * -3 +
c1[x] * -3 +
c2[x] * -3 +
290 c3[x] * -3 + c5[x] * 5 +
291 c6[x] * 5 + c7[x] * 5 + c8[x] * -3;
292 int sum5 = c0[x] * -3 +
c1[x] * -3 +
c2[x] * -3 +
293 c3[x] * -3 + c5[x] * -3 +
294 c6[x] * 5 + c7[x] * 5 + c8[x] * 5;
295 int sum6 = c0[x] * 5 +
c1[x] * -3 +
c2[x] * -3 +
296 c3[x] * -3 + c5[x] * -3 +
297 c6[x] * -3 + c7[x] * 5 + c8[x] * 5;
298 int sum7 = c0[x] * 5 +
c1[x] * 5 +
c2[x] * -3 +
299 c3[x] * -3 + c5[x] * -3 +
300 c6[x] * -3 + c7[x] * -3 + c8[x] * 5;
302 sum0 =
FFMAX(sum0, sum1);
303 sum2 =
FFMAX(sum2, sum3);
304 sum4 =
FFMAX(sum4, sum5);
305 sum6 =
FFMAX(sum6, sum7);
306 sum0 =
FFMAX(sum0, sum2);
307 sum4 =
FFMAX(sum4, sum6);
308 sum0 =
FFMAX(sum0, sum4);
315 float rdiv,
float bias,
const int *
const matrix,
316 const uint8_t *
c[],
int peak,
int radius,
319 uint16_t *dst = (uint16_t *)dstp;
322 for (x = 0; x <
width; x++) {
323 int sum =
AV_RN16A(&
c[0][2 * x]) * matrix[0] +
332 sum = (
int)(sum * rdiv + bias + 0.5
f);
333 dst[x] =
av_clip(sum, 0, peak);
338 float rdiv,
float bias,
const int *
const matrix,
339 const uint8_t *
c[],
int peak,
int radius,
342 uint16_t *dst = (uint16_t *)dstp;
345 for (x = 0; x <
width; x++) {
348 for (
i = 0;
i < 25;
i++)
351 sum = (
int)(sum * rdiv + bias + 0.5
f);
352 dst[x] =
av_clip(sum, 0, peak);
357 float rdiv,
float bias,
const int *
const matrix,
358 const uint8_t *
c[],
int peak,
int radius,
361 uint16_t *dst = (uint16_t *)dstp;
364 for (x = 0; x <
width; x++) {
367 for (
i = 0;
i < 49;
i++)
370 sum = (
int)(sum * rdiv + bias + 0.5
f);
371 dst[x] =
av_clip(sum, 0, peak);
376 float rdiv,
float bias,
const int *
const matrix,
377 const uint8_t *
c[],
int peak,
int radius,
380 uint16_t *dst = (uint16_t *)dstp;
383 for (x = 0; x <
width; x++) {
386 for (
i = 0;
i < 2 * radius + 1;
i++)
389 sum = (
int)(sum * rdiv + bias + 0.5
f);
390 dst[x] =
av_clip(sum, 0, peak);
395 float rdiv,
float bias,
const int *
const matrix,
396 const uint8_t *
c[],
int peak,
int radius,
400 uint16_t *dst = (uint16_t *)dstp;
403 for (
int y = 0; y <
height; y++) {
405 memset(sum, 0,
sizeof(sum));
406 for (
int i = 0;
i < 2 * radius + 1;
i++) {
407 for (
int off16 = 0; off16 <
width; off16++)
411 for (
int off16 = 0; off16 <
width; off16++) {
412 sum[off16] = (
int)(sum[off16] * rdiv + bias + 0.5
f);
413 dst[off16] =
av_clip(sum[off16], 0, peak);
420 float rdiv,
float bias,
const int *
const matrix,
421 const uint8_t *
c[],
int peak,
int radius,
426 for (x = 0; x <
width; x++) {
429 for (
i = 0;
i < 49;
i++)
430 sum +=
c[
i][x] * matrix[
i];
432 sum = (
int)(sum * rdiv + bias + 0.5
f);
438 float rdiv,
float bias,
const int *
const matrix,
439 const uint8_t *
c[],
int peak,
int radius,
444 for (x = 0; x <
width; x++) {
447 for (
i = 0;
i < 25;
i++)
448 sum +=
c[
i][x] * matrix[
i];
450 sum = (
int)(sum * rdiv + bias + 0.5
f);
456 float rdiv,
float bias,
const int *
const matrix,
457 const uint8_t *
c[],
int peak,
int radius,
461 const uint8_t *c3 =
c[3], *c4 =
c[4], *c5 =
c[5];
462 const uint8_t *c6 =
c[6], *c7 =
c[7], *c8 =
c[8];
465 for (x = 0; x <
width; x++) {
466 int sum = c0[x] * matrix[0] +
c1[x] * matrix[1] +
c2[x] * matrix[2] +
467 c3[x] * matrix[3] + c4[x] * matrix[4] + c5[x] * matrix[5] +
468 c6[x] * matrix[6] + c7[x] * matrix[7] + c8[x] * matrix[8];
469 sum = (
int)(sum * rdiv + bias + 0.5
f);
475 float rdiv,
float bias,
const int *
const matrix,
476 const uint8_t *
c[],
int peak,
int radius,
481 for (x = 0; x <
width; x++) {
484 for (
i = 0;
i < 2 * radius + 1;
i++)
485 sum +=
c[
i][x] * matrix[
i];
487 sum = (
int)(sum * rdiv + bias + 0.5
f);
493 float rdiv,
float bias,
const int *
const matrix,
494 const uint8_t *
c[],
int peak,
int radius,
499 for (
int y = 0; y <
height; y++) {
500 memset(sum, 0,
sizeof(sum));
502 for (
int i = 0;
i < 2 * radius + 1;
i++) {
503 for (
int off16 = 0; off16 < 16; off16++)
504 sum[off16] +=
c[
i][0 + y *
stride + off16] * matrix[
i];
507 for (
int off16 = 0; off16 < 16; off16++) {
508 sum[off16] = (
int)(sum[off16] * rdiv + bias + 0.5
f);
516 int x,
int w,
int y,
int h,
int bpc)
520 for (
i = 0;
i < 9;
i++) {
521 int xoff =
FFABS(x + ((
i % 3) - 1));
522 int yoff =
FFABS(y + (
i / 3) - 1);
524 xoff = xoff >=
w ? 2 *
w - 1 - xoff : xoff;
525 yoff = yoff >=
h ? 2 *
h - 1 - yoff : yoff;
532 int x,
int w,
int y,
int h,
int bpc)
536 for (
i = 0;
i < 25;
i++) {
537 int xoff =
FFABS(x + ((
i % 5) - 2));
538 int yoff =
FFABS(y + (
i / 5) - 2);
540 xoff = xoff >=
w ? 2 *
w - 1 - xoff : xoff;
541 yoff = yoff >=
h ? 2 *
h - 1 - yoff : yoff;
548 int x,
int w,
int y,
int h,
int bpc)
552 for (
i = 0;
i < 49;
i++) {
553 int xoff =
FFABS(x + ((
i % 7) - 3));
554 int yoff =
FFABS(y + (
i / 7) - 3);
556 xoff = xoff >=
w ? 2 *
w - 1 - xoff : xoff;
557 yoff = yoff >=
h ? 2 *
h - 1 - yoff : yoff;
564 int x,
int w,
int y,
int h,
int bpc)
568 for (
i = 0;
i < radius * 2 + 1;
i++) {
569 int xoff =
FFABS(x +
i - radius);
571 xoff = xoff >=
w ? 2 *
w - 1 - xoff : xoff;
578 int x,
int w,
int y,
int h,
int bpc)
582 for (
i = 0;
i < radius * 2 + 1;
i++) {
583 int xoff =
FFABS(x +
i - radius);
585 xoff = xoff >=
h ? 2 *
h - 1 - xoff : xoff;
599 for (plane = 0; plane <
s->nb_planes; plane++) {
600 const int mode =
s->mode[plane];
601 const int bpc =
s->bpc;
602 const int radius =
s->size[plane] / 2;
603 const int height =
s->planeheight[plane];
604 const int width =
s->planewidth[plane];
605 const int stride =
in->linesize[plane];
606 const int dstride =
out->linesize[plane];
609 const int slice_start = (sizeh * jobnr) / nb_jobs;
610 const int slice_end = (sizeh * (jobnr+1)) / nb_jobs;
611 const float rdiv =
s->rdiv[plane];
612 const float bias =
s->bias[plane];
616 const int *matrix =
s->matrix[plane];
621 if (
s->copy[plane]) {
634 for (x = 0; x < radius; x++) {
639 s->filter[plane](dst + yoff + xoff, 1, rdiv,
640 bias, matrix,
c,
s->max, radius,
644 s->filter[plane](dst + yoff + xoff, sizew - 2 * radius,
645 rdiv, bias, matrix,
c,
s->max, radius,
647 for (x = sizew - radius; x < sizew; x++) {
652 s->filter[plane](dst + yoff + xoff, 1, rdiv,
653 bias, matrix,
c,
s->max, radius,
671 s->depth =
desc->comp[0].depth;
672 s->max = (1 <<
s->depth) - 1;
675 s->planewidth[0] =
s->planewidth[3] =
inlink->w;
677 s->planeheight[0] =
s->planeheight[3] =
inlink->h;
681 s->bpc = (
s->depth + 7) / 8;
683 if (!strcmp(
ctx->filter->name,
"convolution")) {
685 for (p = 0; p <
s->nb_planes; p++) {
690 else if (
s->size[p] == 3)
692 else if (
s->size[p] == 5)
694 else if (
s->size[p] == 7)
698 #if CONFIG_CONVOLUTION_FILTER && ARCH_X86_64
701 }
else if (!strcmp(
ctx->filter->name,
"prewitt")) {
703 for (p = 0; p <
s->nb_planes; p++)
705 }
else if (!strcmp(
ctx->filter->name,
"roberts")) {
707 for (p = 0; p <
s->nb_planes; p++)
709 }
else if (!strcmp(
ctx->filter->name,
"sobel")) {
711 for (p = 0; p <
s->nb_planes; p++)
713 }
else if (!strcmp(
ctx->filter->name,
"kirsch")) {
715 for (p = 0; p <
s->nb_planes; p++)
750 if (!strcmp(
ctx->filter->name,
"convolution")) {
751 for (
i = 0;
i < 4;
i++) {
752 int *matrix = (
int *)
s->matrix[
i];
753 char *p, *
arg, *saveptr =
NULL;
756 p =
s->matrix_str[
i];
758 s->matrix_length[
i] = 0;
760 while (
s->matrix_length[
i] < 49) {
765 sscanf(
arg,
"%d", &matrix[
s->matrix_length[
i]]);
766 sum += matrix[
s->matrix_length[
i]];
767 s->matrix_length[
i]++;
770 if (!(
s->matrix_length[
i] & 1)) {
779 s->size[
i] =
s->matrix_length[
i];
783 s->size[
i] =
s->matrix_length[
i];
784 }
else if (
s->matrix_length[
i] == 9) {
794 }
else if (
s->matrix_length[
i] == 25) {
803 }
else if (
s->matrix_length[
i] == 49) {
819 s->rdiv[
i] = 1. / sum;
821 if (
s->copy[
i] && (
s->rdiv[
i] != 1. ||
s->bias[
i] != 0.))
824 }
else if (!strcmp(
ctx->filter->name,
"prewitt")) {
825 for (
i = 0;
i < 4;
i++) {
826 if ((1 <<
i) &
s->planes)
832 s->rdiv[
i] =
s->scale;
833 s->bias[
i] =
s->delta;
835 }
else if (!strcmp(
ctx->filter->name,
"roberts")) {
836 for (
i = 0;
i < 4;
i++) {
837 if ((1 <<
i) &
s->planes)
843 s->rdiv[
i] =
s->scale;
844 s->bias[
i] =
s->delta;
846 }
else if (!strcmp(
ctx->filter->name,
"sobel")) {
847 for (
i = 0;
i < 4;
i++) {
848 if ((1 <<
i) &
s->planes)
854 s->rdiv[
i] =
s->scale;
855 s->bias[
i] =
s->delta;
857 }
else if (!strcmp(
ctx->filter->name,
"kirsch")) {
858 for (
i = 0;
i < 4;
i++) {
859 if ((1 <<
i) &
s->planes)
865 s->rdiv[
i] =
s->scale;
866 s->bias[
i] =
s->delta;
874 char *res,
int res_len,
int flags)
903 #if CONFIG_CONVOLUTION_FILTER
906 .
name =
"convolution",
909 .priv_class = &convolution_class,
920 #if CONFIG_PREWITT_FILTER || CONFIG_ROBERTS_FILTER || CONFIG_SOBEL_FILTER
922 static const AVOption prewitt_roberts_sobel_options[] = {
929 #if CONFIG_PREWITT_FILTER
931 #define prewitt_options prewitt_roberts_sobel_options
938 .priv_class = &prewitt_class,
949 #if CONFIG_SOBEL_FILTER
951 #define sobel_options prewitt_roberts_sobel_options
958 .priv_class = &sobel_class,
969 #if CONFIG_ROBERTS_FILTER
971 #define roberts_options prewitt_roberts_sobel_options
978 .priv_class = &roberts_class,
989 #if CONFIG_KIRSCH_FILTER
991 #define kirsch_options prewitt_roberts_sobel_options
998 .priv_class = &kirsch_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
#define AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_GBRAP16
AVPixelFormat
Pixel format.
static void filter16_row(uint8_t *dstp, int width, float rdiv, float bias, const int *const matrix, const uint8_t *c[], int peak, int radius, int dstride, int stride, int size)
static void setup_5x5(int radius, const uint8_t *c[], const uint8_t *src, int stride, int x, int w, int y, int h, int bpc)
static const int same5x5[25]
static void filter16_7x7(uint8_t *dstp, int width, float rdiv, float bias, const int *const matrix, const uint8_t *c[], int peak, int radius, int dstride, int stride, int size)
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
static void filter_3x3(uint8_t *dst, int width, float rdiv, float bias, const int *const matrix, const uint8_t *c[], int peak, int radius, int dstride, int stride, int size)
static void filter16_roberts(uint8_t *dstp, int width, float scale, float delta, const int *const matrix, const uint8_t *c[], int peak, int radius, int dstride, int stride, int size)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
static const AVFilterPad convolution_inputs[]
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
static int query_formats(AVFilterContext *ctx)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define AV_PIX_FMT_YUVA422P9
This structure describes decoded (raw) audio or video data.
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
#define AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P10
static void filter16_prewitt(uint8_t *dstp, int width, float scale, float delta, const int *const matrix, const uint8_t *c[], int peak, int radius, int dstride, int stride, int size)
#define AV_PIX_FMT_YUV420P10
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
const char * name
Filter name.
static void filter_column(uint8_t *dst, int height, float rdiv, float bias, const int *const matrix, const uint8_t *c[], int peak, int radius, int dstride, int stride, int size)
AVFormatInternal * internal
An opaque field for libavformat internal usage.
A link between two filters.
#define AV_PIX_FMT_YUVA422P10
static void filter_sobel(uint8_t *dst, int width, float scale, float delta, const int *const matrix, const uint8_t *c[], int peak, int radius, int dstride, int stride, int size)
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)
static void setup_row(int radius, const uint8_t *c[], const uint8_t *src, int stride, int x, int w, int y, int h, int bpc)
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.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_GBRP14
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
#define AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_YUVA444P16
static void setup_column(int radius, const uint8_t *c[], const uint8_t *src, int stride, int x, int w, int y, int h, int bpc)
#define AV_PIX_FMT_YUV422P9
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
#define AV_PIX_FMT_GRAY16
static void filter16_3x3(uint8_t *dstp, int width, float rdiv, float bias, const int *const matrix, const uint8_t *c[], int peak, int radius, int dstride, int stride, int size)
A filter pad used for either input or output.
#define AV_PIX_FMT_YUV444P10
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_PIX_FMT_YUV422P16
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
#define AV_PIX_FMT_GBRAP10
static void filter16_column(uint8_t *dstp, int height, float rdiv, float bias, const int *const matrix, const uint8_t *c[], int peak, int radius, int dstride, int stride, int size)
#define AV_PIX_FMT_GBRAP12
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
#define AV_PIX_FMT_YUV444P16
#define AV_CEIL_RSHIFT(a, b)
static void filter_prewitt(uint8_t *dst, int width, float scale, float delta, const int *const matrix, const uint8_t *c[], int peak, int radius, int dstride, int stride, int size)
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
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().
AVFILTER_DEFINE_CLASS(convolution)
static const AVFilterPad outputs[]
static enum AVPixelFormat pix_fmts[]
#define AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUV420P9
static void filter16_5x5(uint8_t *dstp, int width, float rdiv, float bias, const int *const matrix, const uint8_t *c[], int peak, int radius, int dstride, int stride, int size)
#define AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_GRAY14
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
#define AV_PIX_FMT_GRAY10
static av_cold int init(AVFilterContext *ctx)
#define AV_PIX_FMT_GBRP16
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
#define AV_PIX_FMT_YUV422P10
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 inputs
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static void filter_5x5(uint8_t *dst, int width, float rdiv, float bias, const int *const matrix, const uint8_t *c[], int peak, int radius, int dstride, int stride, int size)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static void filter_roberts(uint8_t *dst, int width, float scale, float delta, const int *const matrix, const uint8_t *c[], int peak, int radius, int dstride, int stride, int size)
#define AV_PIX_FMT_YUV422P12
AVFilter ff_vf_convolution
#define AV_PIX_FMT_YUV444P12
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.
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
#define AV_PIX_FMT_YUVA444P10
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
#define DECLARE_ALIGNED(n, t, v)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;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);return NULL;} return ac;} 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;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->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);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
int w
agreed upon image width
static void setup_7x7(int radius, const uint8_t *c[], const uint8_t *src, int stride, int x, int w, int y, int h, int bpc)
#define AV_PIX_FMT_GBRP12
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Used for passing data between threads.
static void filter_7x7(uint8_t *dst, int width, float rdiv, float bias, const int *const matrix, const uint8_t *c[], int peak, int radius, int dstride, int stride, int size)
static void setup_3x3(int radius, const uint8_t *c[], const uint8_t *src, int stride, int x, int w, int y, int h, int bpc)
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
const char * name
Pad name.
#define AV_PIX_FMT_YUV444P9
static const AVOption convolution_options[]
#define AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P14
static const AVFilterPad convolution_outputs[]
int h
agreed upon image height
#define AV_PIX_FMT_YUVA422P12
static void filter_kirsch(uint8_t *dst, int width, float scale, float delta, const int *const matrix, const uint8_t *c[], int peak, int radius, int dstride, int stride, int size)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
static const struct @322 planes[]
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
static void filter_row(uint8_t *dst, int width, float rdiv, float bias, const int *const matrix, const uint8_t *c[], int peak, int radius, int dstride, int stride, int size)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
void ff_convolution_init_x86(ConvolutionContext *s)
static void filter16_kirsch(uint8_t *dstp, int width, float scale, float delta, const int *const matrix, const uint8_t *c[], int peak, int radius, int dstride, int stride, int size)
static const int same3x3[9]
static int config_input(AVFilterLink *inlink)
static void filter16_sobel(uint8_t *dstp, int width, float scale, float delta, const int *const matrix, const uint8_t *c[], int peak, int radius, int dstride, int stride, int size)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
#define flags(name, subs,...)
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
static const int same7x7[49]
#define AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_GRAY12
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
#define AV_PIX_FMT_YUV420P14