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.5f);
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.5f);
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.5f);
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.5f);
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.5f);
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.5f);
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.5f);
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.5f);
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.5f);
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.5f);
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]) {
630 for (y = slice_start; y <
slice_end; y += step) {
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,
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
AVFilter ff_vf_convolution
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
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
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.
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Main libavfilter public API header.
#define flags(name, subs,...)
#define AV_CEIL_RSHIFT(a, b)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
void ff_convolution_init_x86(ConvolutionContext *s)
mode
Use these values in ebur128_init (or'ed).
#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 AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
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.
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().
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static enum AVPixelFormat pix_fmts[]
static const struct @322 planes[]
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUV420P14
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
@ 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_YUVA422P12
#define AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P10
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
const char * name
Pad name.
const char * name
Filter name.
AVFormatInternal * internal
An opaque field for libavformat internal usage.
This structure describes decoded (raw) audio or video data.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Used for passing data between threads.
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)
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)
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 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)
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)
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static const AVOption convolution_options[]
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)
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)
static const int same5x5[25]
static int query_formats(AVFilterContext *ctx)
static const int same7x7[49]
static const AVFilterPad convolution_outputs[]
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)
static int config_input(AVFilterLink *inlink)
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)
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)
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)
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 int filter_frame(AVFilterLink *inlink, AVFrame *in)
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)
static const AVFilterPad convolution_inputs[]
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)
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 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)
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static av_cold int init(AVFilterContext *ctx)
AVFILTER_DEFINE_CLASS(convolution)
static const int same3x3[9]
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)
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 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 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)
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)
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 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 sobel(int w, int h, uint16_t *dst, int dst_linesize, int8_t *dir, int dir_linesize, const uint8_t *src, int src_linesize)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.