Go to the documentation of this file.
22 #include "config_components.h"
36 #define OFFSET(x) offsetof(ConvolutionContext, x)
37 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
68 static const int same5x5[25] = {0, 0, 0, 0, 0,
74 static const int same7x7[49] = {0, 0, 0, 0, 0, 0, 0,
110 const uint8_t *
c[],
int peak,
int radius,
113 uint16_t *
dst = (uint16_t *)dstp;
116 for (x = 0; x <
width; x++) {
128 const uint8_t *
c[],
int peak,
int radius,
131 uint16_t *
dst = (uint16_t *)dstp;
134 for (x = 0; x <
width; x++) {
144 const uint8_t *
c[],
int peak,
int radius,
147 uint16_t *
dst = (uint16_t *)dstp;
150 for (x = 0; x <
width; x++) {
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);
213 const uint8_t *
c[],
int peak,
int radius,
216 const uint8_t *c0 =
c[0], *
c1 =
c[1], *
c2 =
c[2];
217 const uint8_t *c3 =
c[3], *c5 =
c[5];
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;
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;
248 const uint8_t *
c[],
int peak,
int radius,
251 const uint8_t *c0 =
c[0], *
c1 =
c[1], *
c2 =
c[2];
252 const uint8_t *c3 =
c[3], *c5 =
c[5];
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] * -47 +
c1[x] * -162 +
c2[x] * -47 +
258 c6[x] * 47 + c7[x] * 162 + c8[x] * 47;
259 float sumb = c0[x] * -47 +
c2[x] * 47 + c3[x] * -162 +
260 c5[x] * 162 + c6[x] * -47 + c8[x] * 47;
270 const uint8_t *
c[],
int peak,
int radius,
273 const uint8_t *c0 =
c[0], *
c1 =
c[1], *
c2 =
c[2];
274 const uint8_t *c3 =
c[3], *c5 =
c[5];
275 const uint8_t *c6 =
c[6], *c7 =
c[7], *c8 =
c[8];
278 for (x = 0; x <
width; x++) {
279 int sum0 = c0[x] * 5 +
c1[x] * 5 +
c2[x] * 5 +
280 c3[x] * -3 + c5[x] * -3 +
281 c6[x] * -3 + c7[x] * -3 + c8[x] * -3;
282 int sum1 = c0[x] * -3 +
c1[x] * 5 +
c2[x] * 5 +
283 c3[x] * 5 + c5[x] * -3 +
284 c6[x] * -3 + c7[x] * -3 + c8[x] * -3;
285 int sum2 = c0[x] * -3 +
c1[x] * -3 +
c2[x] * 5 +
286 c3[x] * 5 + c5[x] * 5 +
287 c6[x] * -3 + c7[x] * -3 + c8[x] * -3;
288 int sum3 = c0[x] * -3 +
c1[x] * -3 +
c2[x] * -3 +
289 c3[x] * 5 + c5[x] * 5 +
290 c6[x] * 5 + c7[x] * -3 + c8[x] * -3;
291 int sum4 = c0[x] * -3 +
c1[x] * -3 +
c2[x] * -3 +
292 c3[x] * -3 + c5[x] * 5 +
293 c6[x] * 5 + c7[x] * 5 + c8[x] * -3;
294 int sum5 = c0[x] * -3 +
c1[x] * -3 +
c2[x] * -3 +
295 c3[x] * -3 + c5[x] * -3 +
296 c6[x] * 5 + c7[x] * 5 + c8[x] * 5;
297 int sum6 = c0[x] * 5 +
c1[x] * -3 +
c2[x] * -3 +
298 c3[x] * -3 + c5[x] * -3 +
299 c6[x] * -3 + c7[x] * 5 + c8[x] * 5;
300 int sum7 = c0[x] * 5 +
c1[x] * 5 +
c2[x] * -3 +
301 c3[x] * -3 + c5[x] * -3 +
302 c6[x] * -3 + c7[x] * -3 + c8[x] * 5;
304 sum0 =
FFMAX(sum0, sum1);
305 sum2 =
FFMAX(sum2, sum3);
306 sum4 =
FFMAX(sum4, sum5);
307 sum6 =
FFMAX(sum6, sum7);
308 sum0 =
FFMAX(sum0, sum2);
309 sum4 =
FFMAX(sum4, sum6);
310 sum0 =
FFMAX(sum0, sum4);
317 float rdiv,
float bias,
const int *
const matrix,
318 const uint8_t *
c[],
int peak,
int radius,
321 uint16_t *
dst = (uint16_t *)dstp;
324 for (x = 0; x <
width; x++) {
339 float rdiv,
float bias,
const int *
const matrix,
340 const uint8_t *
c[],
int peak,
int radius,
343 uint16_t *
dst = (uint16_t *)dstp;
346 for (x = 0; x <
width; x++) {
350 for (
i = 0;
i < 25;
i++)
358 float rdiv,
float bias,
const int *
const matrix,
359 const uint8_t *
c[],
int peak,
int radius,
362 uint16_t *
dst = (uint16_t *)dstp;
365 for (x = 0; x <
width; x++) {
369 for (
i = 0;
i < 49;
i++)
377 float rdiv,
float bias,
const int *
const matrix,
378 const uint8_t *
c[],
int peak,
int radius,
381 uint16_t *
dst = (uint16_t *)dstp;
384 for (x = 0; x <
width; x++) {
388 for (
i = 0;
i < 2 * radius + 1;
i++)
396 float rdiv,
float bias,
const int *
const matrix,
397 const uint8_t *
c[],
int peak,
int radius,
401 uint16_t *
dst = (uint16_t *)dstp;
404 for (
int y = 0; y <
height; y++) {
406 memset(sum, 0,
sizeof(sum));
407 for (
int i = 0;
i < 2 * radius + 1;
i++) {
408 for (
int off16 = 0; off16 <
width; off16++)
412 for (
int off16 = 0; off16 <
width; off16++) {
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++) {
430 for (
i = 0;
i < 49;
i++)
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++) {
448 for (
i = 0;
i < 25;
i++)
456 float rdiv,
float bias,
const int *
const matrix,
457 const uint8_t *
c[],
int peak,
int radius,
460 const uint8_t *c0 =
c[0], *
c1 =
c[1], *
c2 =
c[2];
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++) {
467 (
unsigned)c3[x] *
matrix[3] + (unsigned)c4[x] *
matrix[4] + (
unsigned)c5[x] *
matrix[5] +
468 (unsigned)c6[x] *
matrix[6] + (
unsigned)c7[x] *
matrix[7] + (unsigned)c8[x] *
matrix[8];
474 float rdiv,
float bias,
const int *
const matrix,
475 const uint8_t *
c[],
int peak,
int radius,
480 for (x = 0; x <
width; x++) {
484 for (
i = 0;
i < 2 * radius + 1;
i++)
492 float rdiv,
float bias,
const int *
const matrix,
493 const uint8_t *
c[],
int peak,
int radius,
498 for (
int y = 0; y <
height; y++) {
499 memset(sum, 0,
sizeof(sum));
501 for (
int i = 0;
i < 2 * radius + 1;
i++) {
502 for (
int off16 = 0; off16 < 16; off16++)
506 for (
int off16 = 0; off16 < 16; off16++) {
514 int x,
int w,
int y,
int h,
int bpc)
518 for (
i = 0;
i < 25;
i++) {
527 int x,
int w,
int y,
int h,
int bpc)
531 for (
i = 0;
i < 49;
i++) {
540 int x,
int w,
int y,
int h,
int bpc)
544 for (
i = 0;
i < radius * 2 + 1;
i++) {
552 int x,
int w,
int y,
int h,
int bpc)
556 for (
i = 0;
i < radius * 2 + 1;
i++) {
571 for (plane = 0; plane <
s->nb_planes; plane++) {
572 const int mode =
s->mode[plane];
573 const int bpc =
s->bpc;
574 const int radius =
s->size[plane] / 2;
575 const int height =
s->planeheight[plane];
576 const int width =
s->planewidth[plane];
578 const int dstride =
out->linesize[plane];
583 const float rdiv =
s->rdiv[plane];
584 const float bias =
s->bias[plane];
585 const uint8_t *
src = in->
data[plane];
587 uint8_t *
dst =
out->data[plane] + dst_pos;
588 const int *
matrix =
s->matrix[plane];
590 const uint8_t *
c[49];
593 if (
s->copy[plane]) {
604 const int right =
FFMAX(
left, sizew - radius);
608 for (x = 0; x <
left; x++) {
613 s->filter[plane](
dst + yoff + xoff, 1, rdiv,
618 s->filter[plane](
dst + yoff + xoff, right -
left,
621 for (x = right; x < sizew; x++) {
626 s->filter[plane](
dst + yoff + xoff, 1, rdiv,
645 s->depth =
desc->comp[0].depth;
646 s->max = (1 <<
s->depth) - 1;
649 s->planewidth[0] =
s->planewidth[3] =
inlink->w;
651 s->planeheight[0] =
s->planeheight[3] =
inlink->h;
655 s->bpc = (
s->depth + 7) / 8;
657 if (!strcmp(
ctx->filter->
name,
"convolution")) {
658 for (
i = 0;
i < 4;
i++) {
660 char *orig, *
p, *
arg, *saveptr =
NULL;
665 s->matrix_length[
i] = 0;
666 s->rdiv[
i] =
s->user_rdiv[
i];
669 while (
s->matrix_length[
i] < 49) {
676 s->matrix_length[
i]++;
680 if (!(
s->matrix_length[
i] & 1)) {
689 s->size[
i] =
s->matrix_length[
i];
693 s->size[
i] =
s->matrix_length[
i];
694 }
else if (
s->matrix_length[
i] == 9) {
704 }
else if (
s->matrix_length[
i] == 25) {
713 }
else if (
s->matrix_length[
i] == 49) {
729 s->rdiv[
i] = 1. / sum;
731 if (
s->copy[
i] && (
s->rdiv[
i] != 1. ||
s->bias[
i] != 0.))
734 }
else if (!strcmp(
ctx->filter->
name,
"prewitt")) {
735 for (
i = 0;
i < 4;
i++) {
737 s->copy[
i] = !((1 <<
i) &
s->planes);
740 s->rdiv[
i] =
s->scale;
741 s->bias[
i] =
s->delta;
743 }
else if (!strcmp(
ctx->filter->
name,
"roberts")) {
744 for (
i = 0;
i < 4;
i++) {
746 s->copy[
i] = !((1 <<
i) &
s->planes);
749 s->rdiv[
i] =
s->scale;
750 s->bias[
i] =
s->delta;
752 #if CONFIG_SOBEL_FILTER
753 }
else if (!strcmp(
ctx->filter->
name,
"sobel")) {
756 }
else if (!strcmp(
ctx->filter->
name,
"kirsch")) {
757 for (
i = 0;
i < 4;
i++) {
759 s->copy[
i] = !((1 <<
i) &
s->planes);
762 s->rdiv[
i] =
s->scale;
763 s->bias[
i] =
s->delta;
765 }
else if (!strcmp(
ctx->filter->
name,
"scharr")) {
766 for (
i = 0;
i < 4;
i++) {
768 s->copy[
i] = !((1 <<
i) &
s->planes);
771 s->rdiv[
i] =
s->scale;
772 s->bias[
i] =
s->delta;
776 if (!strcmp(
ctx->filter->
name,
"convolution")) {
778 for (
p = 0;
p <
s->nb_planes;
p++) {
783 else if (
s->size[
p] == 3)
785 else if (
s->size[
p] == 5)
787 else if (
s->size[
p] == 7)
791 #if CONFIG_CONVOLUTION_FILTER && ARCH_X86_64 && HAVE_X86ASM
794 }
else if (!strcmp(
ctx->filter->
name,
"prewitt")) {
796 for (
p = 0;
p <
s->nb_planes;
p++)
798 }
else if (!strcmp(
ctx->filter->
name,
"roberts")) {
800 for (
p = 0;
p <
s->nb_planes;
p++)
802 }
else if (!strcmp(
ctx->filter->
name,
"kirsch")) {
804 for (
p = 0;
p <
s->nb_planes;
p++)
806 }
else if (!strcmp(
ctx->filter->
name,
"scharr")) {
808 for (
p = 0;
p <
s->nb_planes;
p++)
839 FFMIN3(
s->planeheight[1],
s->planewidth[1],
s->nb_threads));
846 char *res,
int res_len,
int flags)
866 #if CONFIG_CONVOLUTION_FILTER
869 .
p.
name =
"convolution",
871 .p.priv_class = &convolution_class,
892 #if CONFIG_PREWITT_FILTER
897 .p.priv_class = &common_class,
908 #if CONFIG_SOBEL_FILTER
913 .p.priv_class = &common_class,
924 #if CONFIG_ROBERTS_FILTER
929 .p.priv_class = &common_class,
940 #if CONFIG_KIRSCH_FILTER
945 .p.priv_class = &common_class,
956 #if CONFIG_SCHARR_FILTER
961 .p.priv_class = &common_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
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)
AVPixelFormat
Pixel format.
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
const FFFilter ff_vf_kirsch
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)
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)
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
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
#define AV_PIX_FMT_YUV420P10
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
const char * name
Filter name.
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 filter16_scharr(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)
A link between two filters.
#define AV_PIX_FMT_YUVA422P10
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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.
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
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 const int same3x3[9]
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_GBRP14
static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output)
Handle slice ends.
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
#define AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_YUVA444P16
#define FILTER_PIXFMTS_ARRAY(array)
#define AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_GRAY16
A filter pad used for either input or output.
AVFILTER_DEFINE_CLASS(convolution)
static const AVFilterPad convolution_inputs[]
#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 ...
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const struct @594 planes[]
#define AV_PIX_FMT_YUV422P16
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
@ 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 FILTER_OUTPUTS(array)
#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)
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().
#define AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P16
static AVFormatContext * ctx
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
#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
#define AV_PIX_FMT_GBRP16
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
static int bias(int x, int c)
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
static __device__ float sqrtf(float a)
static enum AVPixelFormat pix_fmts[]
#define AV_PIX_FMT_YUV422P10
static av_always_inline av_const int avpriv_mirror(int x, int w)
static const AVOption common_options[]
@ 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 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)
const FFFilter ff_vf_scharr
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define DECLARE_ALIGNED(n, t, v)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static const AVOption convolution_options[]
#define i(width, name, range_min, range_max)
#define AV_PIX_FMT_YUV422P12
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_YUV444P12
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 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_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)
const FFFilter ff_vf_prewitt
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.
static int config_input(AVFilterLink *inlink)
@ 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 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 const int same5x5[25]
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
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 int param_init(AVFilterContext *ctx)
int w
agreed upon image width
#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 const int same7x7[49]
@ 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.
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_YUV444P9
static void filter_scharr(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 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 slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)
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_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)
#define AV_PIX_FMT_YUVA444P9
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)
#define FILTER_INPUTS(array)
#define AV_PIX_FMT_YUV420P12
Tag MUST be and< 10hcoeff half pel interpolation filter coefficients, hcoeff[0] are the 2 middle coefficients[1] are the next outer ones and so on, resulting in a filter like:...eff[2], hcoeff[1], hcoeff[0], hcoeff[0], hcoeff[1], hcoeff[2] ... the sign of the coefficients is not explicitly stored but alternates after each coeff and coeff[0] is positive, so ...,+,-,+,-,+,+,-,+,-,+,... hcoeff[0] is not explicitly stored but found by subtracting the sum of all stored coefficients with signs from 32 hcoeff[0]=32 - hcoeff[1] - hcoeff[2] - ... a good choice for hcoeff and htaps is htaps=6 hcoeff={40,-10, 2} an alternative which requires more computations at both encoder and decoder side and may or may not be better is htaps=8 hcoeff={42,-14, 6,-2}ref_frames minimum of the number of available reference frames and max_ref_frames for example the first frame after a key frame always has ref_frames=1spatial_decomposition_type wavelet type 0 is a 9/7 symmetric compact integer wavelet 1 is a 5/3 symmetric compact integer wavelet others are reserved stored as delta from last, last is reset to 0 if always_reset||keyframeqlog quality(logarithmic quantizer scale) stored as delta from last, last is reset to 0 if always_reset||keyframemv_scale stored as delta from last, last is reset to 0 if always_reset||keyframe FIXME check that everything works fine if this changes between framesqbias dequantization bias stored as delta from last, last is reset to 0 if always_reset||keyframeblock_max_depth maximum depth of the block tree stored as delta from last, last is reset to 0 if always_reset||keyframequant_table quantization tableHighlevel bitstream structure:==============================--------------------------------------------|Header|--------------------------------------------|------------------------------------|||Block0||||split?||||yes no||||......... intra?||||:Block01 :yes no||||:Block02 :....... ..........||||:Block03 ::y DC ::ref index:||||:Block04 ::cb DC ::motion x :||||......... :cr DC ::motion y :||||....... ..........|||------------------------------------||------------------------------------|||Block1|||...|--------------------------------------------|------------ ------------ ------------|||Y subbands||Cb subbands||Cr subbands||||--- ---||--- ---||--- ---|||||LL0||HL0||||LL0||HL0||||LL0||HL0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||LH0||HH0||||LH0||HH0||||LH0||HH0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HL1||LH1||||HL1||LH1||||HL1||LH1|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HH1||HL2||||HH1||HL2||||HH1||HL2|||||...||...||...|||------------ ------------ ------------|--------------------------------------------Decoding process:=================------------|||Subbands|------------||||------------|Intra DC||||LL0 subband prediction ------------|\ Dequantization ------------------- \||Reference frames|\ IDWT|------- -------|Motion \|||Frame 0||Frame 1||Compensation . OBMC v -------|------- -------|--------------. \------> Frame n output Frame Frame<----------------------------------/|...|------------------- Range Coder:============Binary Range Coder:------------------- The implemented range coder is an adapted version based upon "Range encoding: an algorithm for removing redundancy from a digitised message." by G. N. N. Martin. The symbols encoded by the Snow range coder are bits(0|1). The associated probabilities are not fix but change depending on the symbol mix seen so far. bit seen|new state ---------+----------------------------------------------- 0|256 - state_transition_table[256 - old_state];1|state_transition_table[old_state];state_transition_table={ 0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 194, 194, 195, 196, 197, 198, 199, 200, 201, 202, 202, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 215, 215, 216, 217, 218, 219, 220, 220, 222, 223, 224, 225, 226, 227, 227, 229, 229, 230, 231, 232, 234, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 0, 0, 0, 0, 0, 0, 0};FIXME Range Coding of integers:------------------------- FIXME Neighboring Blocks:===================left and top are set to the respective blocks unless they are outside of the image in which case they are set to the Null block top-left is set to the top left block unless it is outside of the image in which case it is set to the left block if this block has no larger parent block or it is at the left side of its parent block and the top right block is not outside of the image then the top right block is used for top-right else the top-left block is used Null block y, cb, cr are 128 level, ref, mx and my are 0 Motion Vector Prediction:=========================1. the motion vectors of all the neighboring blocks are scaled to compensate for the difference of reference frames scaled_mv=(mv *(256 *(current_reference+1)/(mv.reference+1))+128)> the median of the scaled left
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_YUV422P14
int h
agreed upon image height
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
AVFILTER_DEFINE_CLASS_EXT(common, "kirsch/prewitt/roberts/scharr/sobel", common_options)
#define AV_PIX_FMT_YUVA422P12
@ AV_OPT_TYPE_INT
Underlying C type is int.
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_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)
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
const FFFilter ff_vf_sobel
@ 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
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
AVFilter p
The public AVFilter.
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
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 ff_sobel_init(ConvolutionContext *s, int depth, int nb_planes)
static void scale(int *out, const int *in, const int w, const int h, const int shift)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
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)
char * name
Name of this format context, only used for logging purposes.
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.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
#define AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV444P14
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
#define AV_PIX_FMT_GRAY12
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
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)
const FFFilter ff_vf_convolution
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
#define AV_PIX_FMT_YUV420P14
const FFFilter ff_vf_roberts