34 #define OFFSET(x) offsetof(ConvolutionContext, x)
35 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
66 static const int same5x5[25] = {0, 0, 0, 0, 0,
72 static const int same7x7[49] = {0, 0, 0, 0, 0, 0, 0,
112 float scale,
float delta,
const int *
const matrix,
113 const uint8_t *
c[],
int peak,
int radius,
116 uint16_t *dst = (uint16_t *)dstp;
119 for (x = 0; x <
width; x++) {
125 dst[x] =
av_clip(sqrtf(suma*suma + sumb*sumb) * scale +
delta, 0, peak);
130 float scale,
float delta,
const int *
const matrix,
131 const uint8_t *
c[],
int peak,
int radius,
134 uint16_t *dst = (uint16_t *)dstp;
137 for (x = 0; x <
width; x++) {
141 dst[x] =
av_clip(sqrtf(suma*suma + sumb*sumb) * scale +
delta, 0, peak);
146 float scale,
float delta,
const int *
const matrix,
147 const uint8_t *
c[],
int peak,
int radius,
150 uint16_t *dst = (uint16_t *)dstp;
153 for (x = 0; x <
width; x++) {
159 dst[x] =
av_clip(sqrtf(suma*suma + sumb*sumb) * scale +
delta, 0, peak);
164 float scale,
float delta,
const int *
const matrix,
165 const uint8_t *
c[],
int peak,
int radius,
168 uint16_t *dst = (uint16_t *)dstp;
169 const uint16_t *c0 = (
const uint16_t *)
c[0], *
c1 = (
const uint16_t *)
c[1], *
c2 = (
const uint16_t *)
c[2];
170 const uint16_t *c3 = (
const uint16_t *)
c[3], *c5 = (
const uint16_t *)
c[5];
171 const uint16_t *c6 = (
const uint16_t *)
c[6], *c7 = (
const uint16_t *)
c[7], *c8 = (
const uint16_t *)
c[8];
174 for (x = 0; x <
width; x++) {
175 int sum0 = c0[x] * 5 +
c1[x] * 5 +
c2[x] * 5 +
176 c3[x] * -3 + c5[x] * -3 +
177 c6[x] * -3 + c7[x] * -3 + c8[x] * -3;
178 int sum1 = c0[x] * -3 +
c1[x] * 5 +
c2[x] * 5 +
179 c3[x] * 5 + c5[x] * -3 +
180 c6[x] * -3 + c7[x] * -3 + c8[x] * -3;
181 int sum2 = c0[x] * -3 +
c1[x] * -3 +
c2[x] * 5 +
182 c3[x] * 5 + c5[x] * 5 +
183 c6[x] * -3 + c7[x] * -3 + c8[x] * -3;
184 int sum3 = c0[x] * -3 +
c1[x] * -3 +
c2[x] * -3 +
185 c3[x] * 5 + c5[x] * 5 +
186 c6[x] * 5 + c7[x] * -3 + c8[x] * -3;
187 int sum4 = c0[x] * -3 +
c1[x] * -3 +
c2[x] * -3 +
188 c3[x] * -3 + c5[x] * 5 +
189 c6[x] * 5 + c7[x] * 5 + c8[x] * -3;
190 int sum5 = c0[x] * -3 +
c1[x] * -3 +
c2[x] * -3 +
191 c3[x] * -3 + c5[x] * -3 +
192 c6[x] * 5 + c7[x] * 5 + c8[x] * 5;
193 int sum6 = c0[x] * 5 +
c1[x] * -3 +
c2[x] * -3 +
194 c3[x] * -3 + c5[x] * -3 +
195 c6[x] * -3 + c7[x] * 5 + c8[x] * 5;
196 int sum7 = c0[x] * 5 +
c1[x] * 5 +
c2[x] * -3 +
197 c3[x] * -3 + c5[x] * -3 +
198 c6[x] * -3 + c7[x] * -3 + c8[x] * 5;
200 sum0 =
FFMAX(sum0, sum1);
201 sum2 =
FFMAX(sum2, sum3);
202 sum4 =
FFMAX(sum4, sum5);
203 sum6 =
FFMAX(sum6, sum7);
204 sum0 =
FFMAX(sum0, sum2);
205 sum4 =
FFMAX(sum4, sum6);
206 sum0 =
FFMAX(sum0, sum4);
213 float scale,
float delta,
const int *
const matrix,
214 const uint8_t *
c[],
int peak,
int radius,
219 const uint8_t *c6 =
c[6], *c7 =
c[7], *c8 =
c[8];
222 for (x = 0; x <
width; x++) {
223 float suma = c0[x] * -1 +
c1[x] * -1 +
c2[x] * -1 +
224 c6[x] * 1 + c7[x] * 1 + c8[x] * 1;
225 float sumb = c0[x] * -1 +
c2[x] * 1 + c3[x] * -1 +
226 c5[x] * 1 + c6[x] * -1 + c8[x] * 1;
233 float scale,
float delta,
const int *
const matrix,
234 const uint8_t *
c[],
int peak,
int radius,
239 for (x = 0; x <
width; x++) {
240 float suma =
c[0][x] * 1 +
c[1][x] * -1;
241 float sumb =
c[4][x] * 1 +
c[3][x] * -1;
248 float scale,
float delta,
const int *
const matrix,
249 const uint8_t *
c[],
int peak,
int radius,
254 const uint8_t *c6 =
c[6], *c7 =
c[7], *c8 =
c[8];
257 for (x = 0; x <
width; x++) {
258 float suma = c0[x] * -1 +
c1[x] * -2 +
c2[x] * -1 +
259 c6[x] * 1 + c7[x] * 2 + c8[x] * 1;
260 float sumb = c0[x] * -1 +
c2[x] * 1 + c3[x] * -2 +
261 c5[x] * 2 + c6[x] * -1 + c8[x] * 1;
268 float scale,
float delta,
const int *
const matrix,
269 const uint8_t *
c[],
int peak,
int radius,
274 const uint8_t *c6 =
c[6], *c7 =
c[7], *c8 =
c[8];
277 for (x = 0; x <
width; x++) {
278 int sum0 = c0[x] * 5 +
c1[x] * 5 +
c2[x] * 5 +
279 c3[x] * -3 + c5[x] * -3 +
280 c6[x] * -3 + c7[x] * -3 + c8[x] * -3;
281 int sum1 = c0[x] * -3 +
c1[x] * 5 +
c2[x] * 5 +
282 c3[x] * 5 + c5[x] * -3 +
283 c6[x] * -3 + c7[x] * -3 + c8[x] * -3;
284 int sum2 = c0[x] * -3 +
c1[x] * -3 +
c2[x] * 5 +
285 c3[x] * 5 + c5[x] * 5 +
286 c6[x] * -3 + c7[x] * -3 + c8[x] * -3;
287 int sum3 = c0[x] * -3 +
c1[x] * -3 +
c2[x] * -3 +
288 c3[x] * 5 + c5[x] * 5 +
289 c6[x] * 5 + c7[x] * -3 + c8[x] * -3;
290 int sum4 = c0[x] * -3 +
c1[x] * -3 +
c2[x] * -3 +
291 c3[x] * -3 + c5[x] * 5 +
292 c6[x] * 5 + c7[x] * 5 + c8[x] * -3;
293 int sum5 = c0[x] * -3 +
c1[x] * -3 +
c2[x] * -3 +
294 c3[x] * -3 + c5[x] * -3 +
295 c6[x] * 5 + c7[x] * 5 + c8[x] * 5;
296 int sum6 = c0[x] * 5 +
c1[x] * -3 +
c2[x] * -3 +
297 c3[x] * -3 + c5[x] * -3 +
298 c6[x] * -3 + c7[x] * 5 + c8[x] * 5;
299 int sum7 = c0[x] * 5 +
c1[x] * 5 +
c2[x] * -3 +
300 c3[x] * -3 + c5[x] * -3 +
301 c6[x] * -3 + c7[x] * -3 + c8[x] * 5;
303 sum0 =
FFMAX(sum0, sum1);
304 sum2 =
FFMAX(sum2, sum3);
305 sum4 =
FFMAX(sum4, sum5);
306 sum6 =
FFMAX(sum6, sum7);
307 sum0 =
FFMAX(sum0, sum2);
308 sum4 =
FFMAX(sum4, sum6);
309 sum0 =
FFMAX(sum0, sum4);
316 float rdiv,
float bias,
const int *
const matrix,
317 const uint8_t *
c[],
int peak,
int radius,
320 uint16_t *dst = (uint16_t *)dstp;
323 for (x = 0; x <
width; x++) {
324 unsigned sum = (unsigned)
AV_RN16A(&
c[0][2 * x]) * matrix[0] +
325 (unsigned)
AV_RN16A(&
c[1][2 * x]) * matrix[1] +
326 (unsigned)
AV_RN16A(&
c[2][2 * x]) * matrix[2] +
327 (unsigned)
AV_RN16A(&
c[3][2 * x]) * matrix[3] +
328 (unsigned)
AV_RN16A(&
c[4][2 * x]) * matrix[4] +
329 (unsigned)
AV_RN16A(&
c[5][2 * x]) * matrix[5] +
330 (unsigned)
AV_RN16A(&
c[6][2 * x]) * matrix[6] +
331 (unsigned)
AV_RN16A(&
c[7][2 * x]) * matrix[7] +
332 (unsigned)
AV_RN16A(&
c[8][2 * x]) * matrix[8];
333 dst[x] =
av_clip((
int)sum * rdiv + bias + 0.5f, 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++) {
349 for (
i = 0;
i < 25;
i++)
350 sum += (
unsigned)
AV_RN16A(&
c[
i][2 * x]) * matrix[
i];
352 dst[x] =
av_clip((
int)sum * rdiv + bias + 0.5f, 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++) {
368 for (
i = 0;
i < 49;
i++)
369 sum += (
unsigned)
AV_RN16A(&
c[
i][2 * x]) * matrix[
i];
371 dst[x] =
av_clip((
int)sum * rdiv + bias + 0.5f, 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++) {
387 for (
i = 0;
i < 2 * radius + 1;
i++)
388 sum += (
unsigned)
AV_RN16A(&
c[
i][2 * x]) * matrix[
i];
390 dst[x] =
av_clip((
int)sum * rdiv + bias + 0.5f, 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 dst[off16] =
av_clip((
int)sum[off16] * rdiv + bias + 0.5f, 0, peak);
419 float rdiv,
float bias,
const int *
const matrix,
420 const uint8_t *
c[],
int peak,
int radius,
425 for (x = 0; x <
width; x++) {
429 for (
i = 0;
i < 49;
i++)
430 sum += (
unsigned)
c[
i][x] * matrix[
i];
437 float rdiv,
float bias,
const int *
const matrix,
438 const uint8_t *
c[],
int peak,
int radius,
443 for (x = 0; x <
width; x++) {
447 for (
i = 0;
i < 25;
i++)
448 sum += (
unsigned)
c[
i][x] * matrix[
i];
455 float rdiv,
float bias,
const int *
const matrix,
456 const uint8_t *
c[],
int peak,
int radius,
460 const uint8_t *c3 =
c[3], *c4 =
c[4], *c5 =
c[5];
461 const uint8_t *c6 =
c[6], *c7 =
c[7], *c8 =
c[8];
464 for (x = 0; x <
width; x++) {
465 unsigned sum = (unsigned)c0[x] * matrix[0] + (
unsigned)
c1[x] * matrix[1] + (unsigned)
c2[x] * matrix[2] +
466 (
unsigned)c3[x] * matrix[3] + (unsigned)c4[x] * matrix[4] + (
unsigned)c5[x] * matrix[5] +
467 (unsigned)c6[x] * matrix[6] + (
unsigned)c7[x] * matrix[7] + (unsigned)c8[x] * matrix[8];
473 float rdiv,
float bias,
const int *
const matrix,
474 const uint8_t *
c[],
int peak,
int radius,
479 for (x = 0; x <
width; x++) {
483 for (
i = 0;
i < 2 * radius + 1;
i++)
484 sum += (
unsigned)
c[
i][x] * matrix[
i];
491 float rdiv,
float bias,
const int *
const matrix,
492 const uint8_t *
c[],
int peak,
int radius,
497 for (
int y = 0; y <
height; y++) {
498 memset(sum, 0,
sizeof(sum));
500 for (
int i = 0;
i < 2 * radius + 1;
i++) {
501 for (
int off16 = 0; off16 < 16; off16++)
502 sum[off16] += (
unsigned)
c[
i][0 + y *
stride + off16] * matrix[
i];
505 for (
int off16 = 0; off16 < 16; off16++) {
506 dst[off16] =
av_clip_uint8((
int)sum[off16] * rdiv + bias + 0.5f);
513 int x,
int w,
int y,
int h,
int bpc)
517 for (
i = 0;
i < 9;
i++) {
518 int xoff =
FFABS(x + ((
i % 3) - 1));
519 int yoff =
FFABS(y + (
i / 3) - 1);
521 xoff = xoff >=
w ? 2 *
w - 1 - xoff : xoff;
522 yoff = yoff >=
h ? 2 *
h - 1 - yoff : yoff;
529 int x,
int w,
int y,
int h,
int bpc)
533 for (
i = 0;
i < 25;
i++) {
542 int x,
int w,
int y,
int h,
int bpc)
546 for (
i = 0;
i < 49;
i++) {
555 int x,
int w,
int y,
int h,
int bpc)
559 for (
i = 0;
i < radius * 2 + 1;
i++) {
567 int x,
int w,
int y,
int h,
int bpc)
571 for (
i = 0;
i < radius * 2 + 1;
i++) {
586 for (plane = 0; plane <
s->nb_planes; plane++) {
587 const int mode =
s->mode[plane];
588 const int bpc =
s->bpc;
589 const int radius =
s->size[plane] / 2;
590 const int height =
s->planeheight[plane];
591 const int width =
s->planewidth[plane];
592 const int stride =
in->linesize[plane];
593 const int dstride =
out->linesize[plane];
596 const int slice_start =
ff_slice_pos(sizeh, jobnr, nb_jobs);
598 const float rdiv =
s->rdiv[plane];
599 const float bias =
s->bias[plane];
603 const int *matrix =
s->matrix[plane];
608 if (
s->copy[plane]) {
617 for (y = slice_start; y <
slice_end; y += step) {
618 const int left =
FFMIN(radius, sizew);
619 const int right =
FFMAX(left, sizew - radius);
623 for (x = 0; x < left; x++) {
628 s->filter[plane](dst + yoff + xoff, 1, rdiv,
629 bias, matrix,
c,
s->max, radius,
633 s->filter[plane](dst + yoff + xoff, right - left,
634 rdiv, bias, matrix,
c,
s->max, radius,
636 for (x = right; x < sizew; x++) {
641 s->filter[plane](dst + yoff + xoff, 1, rdiv,
642 bias, matrix,
c,
s->max, radius,
660 s->depth =
desc->comp[0].depth;
661 s->max = (1 <<
s->depth) - 1;
664 s->planewidth[0] =
s->planewidth[3] = inlink->
w;
666 s->planeheight[0] =
s->planeheight[3] = inlink->
h;
670 s->bpc = (
s->depth + 7) / 8;
672 if (!strcmp(
ctx->filter->name,
"convolution")) {
674 for (p = 0; p <
s->nb_planes; p++) {
679 else if (
s->size[p] == 3)
681 else if (
s->size[p] == 5)
683 else if (
s->size[p] == 7)
687 #if CONFIG_CONVOLUTION_FILTER && ARCH_X86_64
690 }
else if (!strcmp(
ctx->filter->name,
"prewitt")) {
692 for (p = 0; p <
s->nb_planes; p++)
694 }
else if (!strcmp(
ctx->filter->name,
"roberts")) {
696 for (p = 0; p <
s->nb_planes; p++)
698 }
else if (!strcmp(
ctx->filter->name,
"sobel")) {
700 for (p = 0; p <
s->nb_planes; p++)
702 }
else if (!strcmp(
ctx->filter->name,
"kirsch")) {
704 for (p = 0; p <
s->nb_planes; p++)
739 if (!strcmp(
ctx->filter->name,
"convolution")) {
740 for (
i = 0;
i < 4;
i++) {
741 int *matrix = (
int *)
s->matrix[
i];
742 char *p, *
arg, *saveptr =
NULL;
745 p =
s->matrix_str[
i];
747 s->matrix_length[
i] = 0;
749 while (
s->matrix_length[
i] < 49) {
754 sscanf(
arg,
"%d", &matrix[
s->matrix_length[
i]]);
755 sum += matrix[
s->matrix_length[
i]];
756 s->matrix_length[
i]++;
759 if (!(
s->matrix_length[
i] & 1)) {
768 s->size[
i] =
s->matrix_length[
i];
772 s->size[
i] =
s->matrix_length[
i];
773 }
else if (
s->matrix_length[
i] == 9) {
783 }
else if (
s->matrix_length[
i] == 25) {
792 }
else if (
s->matrix_length[
i] == 49) {
808 s->rdiv[
i] = 1. / sum;
810 if (
s->copy[
i] && (
s->rdiv[
i] != 1. ||
s->bias[
i] != 0.))
813 }
else if (!strcmp(
ctx->filter->name,
"prewitt")) {
814 for (
i = 0;
i < 4;
i++) {
815 if ((1 <<
i) &
s->planes)
821 s->rdiv[
i] =
s->scale;
822 s->bias[
i] =
s->delta;
824 }
else if (!strcmp(
ctx->filter->name,
"roberts")) {
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,
"sobel")) {
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,
"kirsch")) {
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;
863 char *res,
int res_len,
int flags)
892 #if CONFIG_CONVOLUTION_FILTER
895 .
name =
"convolution",
898 .priv_class = &convolution_class,
909 #if CONFIG_PREWITT_FILTER || CONFIG_ROBERTS_FILTER || CONFIG_SOBEL_FILTER
911 static const AVOption prewitt_roberts_sobel_options[] = {
918 #if CONFIG_PREWITT_FILTER
920 #define prewitt_options prewitt_roberts_sobel_options
927 .priv_class = &prewitt_class,
938 #if CONFIG_SOBEL_FILTER
940 #define sobel_options prewitt_roberts_sobel_options
947 .priv_class = &sobel_class,
958 #if CONFIG_ROBERTS_FILTER
960 #define roberts_options prewitt_roberts_sobel_options
967 .priv_class = &roberts_class,
978 #if CONFIG_KIRSCH_FILTER
980 #define kirsch_options prewitt_roberts_sobel_options
987 .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).
static int ff_slice_pos(int total, int jobnr, int nb_jobs)
Compute the boundary index for a slice when work of size total is split into nb_jobs slices.
#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 av_always_inline av_const int avpriv_mirror(int x, int w)
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.