Go to the documentation of this file.
66 const uint8_t *
c[],
int peak,
int radius,
70 #define OFFSET(x) offsetof(ConvolutionContext, x)
71 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
102 static const int same5x5[25] = {0, 0, 0, 0, 0,
108 static const int same7x7[49] = {0, 0, 0, 0, 0, 0, 0,
114 0, 0, 0, 0, 0, 0, 0};
147 float scale,
float delta,
const int *
const matrix,
148 const uint8_t *
c[],
int peak,
int radius,
151 uint16_t *dst = (uint16_t *)
dstp;
154 for (x = 0; x <
width; x++) {
160 dst[x] = av_clip(sqrtf(suma*suma + sumb*sumb) * scale +
delta, 0, peak);
165 float scale,
float delta,
const int *
const matrix,
166 const uint8_t *
c[],
int peak,
int radius,
169 uint16_t *dst = (uint16_t *)
dstp;
172 for (x = 0; x <
width; x++) {
176 dst[x] = av_clip(sqrtf(suma*suma + sumb*sumb) * scale +
delta, 0, peak);
181 float scale,
float delta,
const int *
const matrix,
182 const uint8_t *
c[],
int peak,
int radius,
185 uint16_t *dst = (uint16_t *)
dstp;
188 for (x = 0; x <
width; x++) {
194 dst[x] = av_clip(sqrtf(suma*suma + sumb*sumb) * scale +
delta, 0, peak);
199 float scale,
float delta,
const int *
const matrix,
200 const uint8_t *
c[],
int peak,
int radius,
205 const uint8_t *c6 =
c[6], *c7 =
c[7], *c8 =
c[8];
208 for (x = 0; x <
width; x++) {
209 int suma = c0[x] * -1 +
c1[x] * -1 +
c2[x] * -1 +
210 c6[x] * 1 + c7[x] * 1 + c8[x] * 1;
211 int sumb = c0[x] * -1 +
c2[x] * 1 + c3[x] * -1 +
212 c5[x] * 1 + c6[x] * -1 + c8[x] * 1;
214 dst[x] = av_clip_uint8(sqrtf(suma*suma + sumb*sumb) * scale +
delta);
219 float scale,
float delta,
const int *
const matrix,
220 const uint8_t *
c[],
int peak,
int radius,
225 for (x = 0; x <
width; x++) {
226 int suma =
c[0][x] * 1 +
c[1][x] * -1;
227 int sumb =
c[4][x] * 1 +
c[3][x] * -1;
229 dst[x] = av_clip_uint8(sqrtf(suma*suma + sumb*sumb) * scale +
delta);
234 float scale,
float delta,
const int *
const matrix,
235 const uint8_t *
c[],
int peak,
int radius,
240 const uint8_t *c6 =
c[6], *c7 =
c[7], *c8 =
c[8];
243 for (x = 0; x <
width; x++) {
244 int suma = c0[x] * -1 +
c1[x] * -2 +
c2[x] * -1 +
245 c6[x] * 1 + c7[x] * 2 + c8[x] * 1;
246 int sumb = c0[x] * -1 +
c2[x] * 1 + c3[x] * -2 +
247 c5[x] * 2 + c6[x] * -1 + c8[x] * 1;
249 dst[x] = av_clip_uint8(sqrtf(suma*suma + sumb*sumb) * scale +
delta);
254 float rdiv,
float bias,
const int *
const matrix,
255 const uint8_t *
c[],
int peak,
int radius,
258 uint16_t *dst = (uint16_t *)
dstp;
261 for (x = 0; x <
width; x++) {
262 int sum =
AV_RN16A(&
c[0][2 * x]) * matrix[0] +
271 sum = (
int)(sum * rdiv + bias + 0.5
f);
272 dst[x] = av_clip(sum, 0, peak);
277 float rdiv,
float bias,
const int *
const matrix,
278 const uint8_t *
c[],
int peak,
int radius,
281 uint16_t *dst = (uint16_t *)
dstp;
284 for (x = 0; x <
width; x++) {
287 for (
i = 0;
i < 25;
i++)
290 sum = (
int)(sum * rdiv + bias + 0.5
f);
291 dst[x] = av_clip(sum, 0, peak);
296 float rdiv,
float bias,
const int *
const matrix,
297 const uint8_t *
c[],
int peak,
int radius,
300 uint16_t *dst = (uint16_t *)
dstp;
303 for (x = 0; x <
width; x++) {
306 for (
i = 0;
i < 49;
i++)
309 sum = (
int)(sum * rdiv + bias + 0.5
f);
310 dst[x] = av_clip(sum, 0, peak);
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++) {
325 for (
i = 0;
i < 2 * radius + 1;
i++)
328 sum = (
int)(sum * rdiv + bias + 0.5
f);
329 dst[x] = av_clip(sum, 0, peak);
334 float rdiv,
float bias,
const int *
const matrix,
335 const uint8_t *
c[],
int peak,
int radius,
338 uint16_t *dst = (uint16_t *)
dstp;
341 for (y = 0; y <
height; y++) {
344 for (
i = 0;
i < 2 * radius + 1;
i++)
347 sum = (
int)(sum * rdiv + bias + 0.5
f);
348 dst[0] = av_clip(sum, 0, peak);
354 float rdiv,
float bias,
const int *
const matrix,
355 const uint8_t *
c[],
int peak,
int radius,
360 for (x = 0; x <
width; x++) {
363 for (
i = 0;
i < 49;
i++)
364 sum +=
c[
i][x] * matrix[
i];
366 sum = (
int)(sum * rdiv + bias + 0.5
f);
367 dst[x] = av_clip_uint8(sum);
372 float rdiv,
float bias,
const int *
const matrix,
373 const uint8_t *
c[],
int peak,
int radius,
378 for (x = 0; x <
width; x++) {
381 for (
i = 0;
i < 25;
i++)
382 sum +=
c[
i][x] * matrix[
i];
384 sum = (
int)(sum * rdiv + bias + 0.5
f);
385 dst[x] = av_clip_uint8(sum);
390 float rdiv,
float bias,
const int *
const matrix,
391 const uint8_t *
c[],
int peak,
int radius,
395 const uint8_t *c3 =
c[3], *c4 =
c[4], *c5 =
c[5];
396 const uint8_t *c6 =
c[6], *c7 =
c[7], *c8 =
c[8];
399 for (x = 0; x <
width; x++) {
400 int sum = c0[x] * matrix[0] +
c1[x] * matrix[1] +
c2[x] * matrix[2] +
401 c3[x] * matrix[3] + c4[x] * matrix[4] + c5[x] * matrix[5] +
402 c6[x] * matrix[6] + c7[x] * matrix[7] + c8[x] * matrix[8];
403 sum = (
int)(sum * rdiv + bias + 0.5
f);
404 dst[x] = av_clip_uint8(sum);
409 float rdiv,
float bias,
const int *
const matrix,
410 const uint8_t *
c[],
int peak,
int radius,
415 for (x = 0; x <
width; x++) {
418 for (
i = 0;
i < 2 * radius + 1;
i++)
419 sum +=
c[
i][x] * matrix[
i];
421 sum = (
int)(sum * rdiv + bias + 0.5
f);
422 dst[x] = av_clip_uint8(sum);
427 float rdiv,
float bias,
const int *
const matrix,
428 const uint8_t *
c[],
int peak,
int radius,
433 for (y = 0; y <
height; y++) {
436 for (
i = 0;
i < 2 * radius + 1;
i++)
439 sum = (
int)(sum * rdiv + bias + 0.5
f);
440 dst[0] = av_clip_uint8(sum);
446 int x,
int w,
int y,
int h,
int bpc)
450 for (
i = 0;
i < 9;
i++) {
451 int xoff =
FFABS(x + ((
i % 3) - 1));
452 int yoff =
FFABS(y + (
i / 3) - 1);
454 xoff = xoff >=
w ? 2 *
w - 1 - xoff : xoff;
455 yoff = yoff >=
h ? 2 *
h - 1 - yoff : yoff;
462 int x,
int w,
int y,
int h,
int bpc)
466 for (
i = 0;
i < 25;
i++) {
467 int xoff =
FFABS(x + ((
i % 5) - 2));
468 int yoff =
FFABS(y + (
i / 5) - 2);
470 xoff = xoff >=
w ? 2 *
w - 1 - xoff : xoff;
471 yoff = yoff >=
h ? 2 *
h - 1 - yoff : yoff;
478 int x,
int w,
int y,
int h,
int bpc)
482 for (
i = 0;
i < 49;
i++) {
483 int xoff =
FFABS(x + ((
i % 7) - 3));
484 int yoff =
FFABS(y + (
i / 7) - 3);
486 xoff = xoff >=
w ? 2 *
w - 1 - xoff : xoff;
487 yoff = yoff >=
h ? 2 *
h - 1 - yoff : yoff;
494 int x,
int w,
int y,
int h,
int bpc)
498 for (
i = 0;
i < radius * 2 + 1;
i++) {
499 int xoff =
FFABS(x +
i - radius);
501 xoff = xoff >=
w ? 2 *
w - 1 - xoff : xoff;
508 int x,
int w,
int y,
int h,
int bpc)
512 for (
i = 0;
i < radius * 2 + 1;
i++) {
513 int xoff =
FFABS(x +
i - radius);
515 xoff = xoff >=
h ? 2 *
h - 1 - xoff : xoff;
531 const int bpc =
s->bpc;
532 const int radius =
s->size[
plane] / 2;
536 const int dstride =
out->linesize[
plane];
539 const int slice_start = (sizeh * jobnr) / nb_jobs;
540 const int slice_end = (sizeh * (jobnr+1)) / nb_jobs;
541 const float rdiv =
s->rdiv[
plane];
542 const float bias =
s->bias[
plane];
546 const int *matrix =
s->matrix[
plane];
560 for (y = slice_start; y <
slice_end; y++) {
564 for (x = 0; x < radius; x++) {
569 s->filter[
plane](dst + yoff + xoff, 1, rdiv,
570 bias, matrix,
c,
s->max, radius,
574 s->filter[
plane](dst + yoff + xoff, sizew - 2 * radius,
575 rdiv, bias, matrix,
c,
s->max, radius,
577 for (x = sizew - radius; x < sizew; x++) {
582 s->filter[
plane](dst + yoff + xoff, 1, rdiv,
583 bias, matrix,
c,
s->max, radius,
601 s->depth =
desc->comp[0].depth;
602 s->max = (1 <<
s->depth) - 1;
605 s->planewidth[0] =
s->planewidth[3] =
inlink->w;
607 s->planeheight[0] =
s->planeheight[3] =
inlink->h;
611 s->bpc = (
s->depth + 7) / 8;
613 if (!strcmp(
ctx->filter->name,
"convolution")) {
615 for (p = 0; p <
s->nb_planes; p++) {
620 else if (
s->size[p] == 3)
622 else if (
s->size[p] == 5)
624 else if (
s->size[p] == 7)
628 }
else if (!strcmp(
ctx->filter->name,
"prewitt")) {
630 for (p = 0; p <
s->nb_planes; p++)
632 }
else if (!strcmp(
ctx->filter->name,
"roberts")) {
634 for (p = 0; p <
s->nb_planes; p++)
636 }
else if (!strcmp(
ctx->filter->name,
"sobel")) {
638 for (p = 0; p <
s->nb_planes; p++)
673 if (!strcmp(
ctx->filter->name,
"convolution")) {
674 for (
i = 0;
i < 4;
i++) {
675 int *matrix = (
int *)
s->matrix[
i];
676 char *p, *
arg, *saveptr =
NULL;
679 p =
s->matrix_str[
i];
680 while (
s->matrix_length[
i] < 49) {
685 sscanf(
arg,
"%d", &matrix[
s->matrix_length[
i]]);
686 sum += matrix[
s->matrix_length[
i]];
687 s->matrix_length[
i]++;
690 if (!(
s->matrix_length[
i] & 1)) {
697 s->size[
i] =
s->matrix_length[
i];
701 s->size[
i] =
s->matrix_length[
i];
702 }
else if (
s->matrix_length[
i] == 9) {
709 }
else if (
s->matrix_length[
i] == 25) {
716 }
else if (
s->matrix_length[
i] == 49) {
730 s->rdiv[
i] = 1. / sum;
732 if (
s->copy[
i] && (
s->rdiv[
i] != 1. ||
s->bias[
i] != 0.))
735 }
else if (!strcmp(
ctx->filter->name,
"prewitt")) {
736 for (
i = 0;
i < 4;
i++) {
737 if ((1 <<
i) &
s->planes)
743 s->rdiv[
i] =
s->scale;
744 s->bias[
i] =
s->delta;
746 }
else if (!strcmp(
ctx->filter->name,
"roberts")) {
747 for (
i = 0;
i < 4;
i++) {
748 if ((1 <<
i) &
s->planes)
754 s->rdiv[
i] =
s->scale;
755 s->bias[
i] =
s->delta;
757 }
else if (!strcmp(
ctx->filter->name,
"sobel")) {
758 for (
i = 0;
i < 4;
i++) {
759 if ((1 <<
i) &
s->planes)
765 s->rdiv[
i] =
s->scale;
766 s->bias[
i] =
s->delta;
791 #if CONFIG_CONVOLUTION_FILTER
794 .
name =
"convolution",
797 .priv_class = &convolution_class,
807 #if CONFIG_PREWITT_FILTER
809 static const AVOption prewitt_options[] = {
822 .priv_class = &prewitt_class,
832 #if CONFIG_SOBEL_FILTER
834 static const AVOption sobel_options[] = {
847 .priv_class = &sobel_class,
857 #if CONFIG_ROBERTS_FILTER
859 static const AVOption roberts_options[] = {
872 .priv_class = &roberts_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 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]
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_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 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 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)
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.
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)
#define AV_PIX_FMT_YUVA422P9
This structure describes decoded (raw) audio or video data.
#define AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P10
#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.
AVFormatInternal * internal
An opaque field for libavformat internal usage.
A link between two filters.
#define AV_PIX_FMT_YUVA422P10
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
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)
#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 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)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
#define AV_PIX_FMT_GRAY16
A filter pad used for either input or output.
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)
#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 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)
#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
#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 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_YUV420P9
#define AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_GRAY14
void(* filter[4])(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)
@ 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
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)
Describe the class of an AVClass context structure.
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 const struct @314 planes[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define AV_PIX_FMT_YUV422P12
AVFilter ff_vf_convolution
#define AV_PIX_FMT_YUV444P12
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
#define AV_PIX_FMT_YUVA444P10
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)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
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)
#define i(width, name, range_min, range_max)
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 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
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)
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
void(* setup[4])(int radius, const uint8_t *c[], const uint8_t *src, int stride, int x, int width, int y, int height, int bpc)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
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)
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
#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_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)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
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)
static const int same3x3[9]
static int config_input(AVFilterLink *inlink)
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)
@ 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
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)
#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
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)