46 {0x00,0x60,0x18,0x78,0x06,0x66,0x1E,0x7E},
47 {0x40,0x20,0x58,0x38,0x46,0x26,0x5E,0x3E},
48 {0x10,0x70,0x08,0x68,0x16,0x76,0x0E,0x6E},
49 {0x50,0x30,0x48,0x28,0x56,0x36,0x4E,0x2E},
50 {0x04,0x64,0x1C,0x7C,0x02,0x62,0x1A,0x7A},
51 {0x44,0x24,0x5C,0x3C,0x42,0x22,0x5A,0x3A},
52 {0x14,0x74,0x0C,0x6C,0x12,0x72,0x0A,0x6A},
53 {0x54,0x34,0x4C,0x2C,0x52,0x32,0x4A,0x2A},
59 for (x = 0; x <
width; x++, dc += x & 1) {
60 int pix = src[x] << 7;
61 int delta = dc[0] - pix;
62 int m = abs(delta) * thresh >> 16;
63 m =
FFMAX(0, 127 - m);
64 m = m * m * delta >> 14;
65 pix += m + dithers[x & 7];
66 dst[x] = av_clip_uint8(pix >> 7);
73 for (x = 0; x <
width; x++) {
74 v = buf1[x] + src[2 * x] + src[2 * x + 1] + src[2 * x + src_linesize] + src[2 * x + 1 + src_linesize];
83 int bstride =
FFALIGN(width, 16) / 2;
85 uint32_t dc_factor = (1 << 21) / (r * r);
86 uint16_t *dc = ctx->
buf + 16;
87 uint16_t *buf = ctx->
buf + bstride + 32;
90 memset(dc, 0, (bstride + 16) *
sizeof(*buf));
91 for (y = 0; y <
r; y++)
92 ctx->
blur_line(dc, buf + y * bstride, buf + (y - 1) * bstride, src + 2 * y * src_linesize, src_linesize, width / 2);
95 int mod = ((y +
r) / 2) %
r;
96 uint16_t *buf0 = buf + mod * bstride;
97 uint16_t *buf1 = buf + (mod ? mod - 1 : r - 1) * bstride;
99 ctx->
blur_line(dc, buf0, buf1, src + (y + r) * src_linesize, src_linesize, width / 2);
100 for (x = v = 0; x <
r; x++)
102 for (; x < width / 2; x++) {
103 v += dc[x] - dc[x-
r];
104 dc[x-
r] = v * dc_factor >> 16;
106 for (; x < (width + r + 1) / 2; x++)
107 dc[x-r] = v * dc_factor >> 16;
108 for (x = -r / 2; x < 0; x++)
112 for (y = 0; y <
r; y++)
113 ctx->
filter_line(dst + y * dst_linesize, src + y * src_linesize, dc - r / 2, width, thresh,
dither[y & 7]);
115 ctx->
filter_line(dst + y * dst_linesize, src + y * src_linesize, dc - r / 2, width, thresh,
dither[y & 7]);
116 if (++y >= height)
break;
117 ctx->
filter_line(dst + y * dst_linesize, src + y * src_linesize, dc - r / 2, width, thresh,
dither[y & 7]);
118 if (++y >= height)
break;
130 sscanf(args,
"%f:%d", &thresh, &radius);
132 thresh = av_clipf(thresh, 0.51, 255);
133 gf->
thresh = (1 << 15) / thresh;
134 gf->
radius = av_clip((radius + 1) & ~1, 4, 32);
209 for (p = 0; p < 4 && in->
data[p]; p++) {
219 if (
FFMIN(w, h) > 2 * r)
221 else if (out->
data[p] != in->
data[p])
258 .
inputs = avfilter_vf_gradfun_inputs,
259 .
outputs = avfilter_vf_gradfun_outputs,
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
AVFilterBufferRefVideoProps * video
video buffer specific properties
void ff_gradfun_filter_line_c(uint8_t *dst, uint8_t *src, uint16_t *dc, int width, int thresh, const uint16_t *dithers)
int linesize[8]
number of bytes per line
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static const AVFilterPad outputs[]
int h
agreed upon image height
int ff_filter_frame(AVFilterLink *link, AVFilterBufferRef *frame)
Send a frame of data to the next filter.
Holds instance-specific information for gradfun.
void ff_gradfun_blur_line_c(uint16_t *dc, uint16_t *buf, uint16_t *buf1, uint8_t *src, int src_linesize, int width)
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
#define AV_PERM_READ
can read from the buffer
const char * name
Pad name.
int chroma_h
weight of the chroma planes
void(* filter_line)(uint8_t *dst, uint8_t *src, uint16_t *dc, int width, int thresh, const uint16_t *dithers)
DSP functions.
void avfilter_unref_bufferp(AVFilterBufferRef **ref)
Remove a reference to a buffer and set the pointer to NULL.
AVFilter avfilter_vf_gradfun
static int config_input(AVFilterLink *inlink)
static const AVFilterPad avfilter_vf_gradfun_outputs[]
A filter pad used for either input or output.
A link between two filters.
AVFilterBufferRef * ff_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
Request a picture buffer with a specific set of permissions.
static av_cold void uninit(AVFilterContext *ctx)
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
void(* blur_line)(uint16_t *dc, uint16_t *buf, uint16_t *buf1, uint8_t *src, int src_linesize, int width)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
void av_log(void *avcl, int level, const char *fmt,...)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int w
agreed upon image width
as above, but U and V bytes are swapped
static av_cold int init(AVFilterContext *ctx, const char *args)
void ff_gradfun_init_x86(GradFunContext *gf)
int format
agreed upon media format
uint16_t * buf
holds image data for blur algorithm passed into filter.
A reference to an AVFilterBuffer.
static const uint16_t dither[8][8]
int perms
permissions, see the AV_PERM_* flags
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *in)
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
static const AVFilterPad inputs[]
struct GradFunContext GradFunContext
Holds instance-specific information for gradfun.
const char * name
filter name
static void filter(GradFunContext *ctx, uint8_t *dst, uint8_t *src, int width, int height, int dst_linesize, int src_linesize, int r)
static const AVFilterPad avfilter_vf_gradfun_inputs[]
AVFilterLink ** outputs
array of pointers to output links
#define AV_PERM_PRESERVE
nobody else can overwrite the buffer
#define DECLARE_ALIGNED(n, t, v)
static int query_formats(AVFilterContext *ctx)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
int chroma_w
width of the chroma planes
common internal and external API header
void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src)
Copy properties of src to dst, without copying the actual data.
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
#define AV_PERM_WRITE
can write to the buffer
AVFilterContext * dst
dest filter
int thresh
threshold for gradient algorithm
uint8_t * data[8]
picture/audio data for each plane
int chroma_r
blur radius for the chroma 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.
AVPixelFormat
Pixel format.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...