42 {0x00,0x60,0x18,0x78,0x06,0x66,0x1E,0x7E},
43 {0x40,0x20,0x58,0x38,0x46,0x26,0x5E,0x3E},
44 {0x10,0x70,0x08,0x68,0x16,0x76,0x0E,0x6E},
45 {0x50,0x30,0x48,0x28,0x56,0x36,0x4E,0x2E},
46 {0x04,0x64,0x1C,0x7C,0x02,0x62,0x1A,0x7A},
47 {0x44,0x24,0x5C,0x3C,0x42,0x22,0x5A,0x3A},
48 {0x14,0x74,0x0C,0x6C,0x12,0x72,0x0A,0x6A},
49 {0x54,0x34,0x4C,0x2C,0x52,0x32,0x4A,0x2A},
55 for (x = 0; x <
width; x++, dc += x & 1) {
56 int pix = src[x] << 7;
57 int delta = dc[0] - pix;
58 int m = abs(delta) * thresh >> 16;
59 m =
FFMAX(0, 127 - m);
60 m = m * m * delta >> 14;
61 pix += m + dithers[x & 7];
62 dst[x] = av_clip_uint8(pix >> 7);
69 for (x = 0; x <
width; x++) {
70 v = buf1[x] + src[2 * x] + src[2 * x + 1] + src[2 * x + src_linesize] + src[2 * x + 1 + src_linesize];
79 int bstride =
FFALIGN(width, 16) / 2;
81 uint32_t dc_factor = (1 << 21) / (r * r);
82 uint16_t *dc = ctx->
buf + 16;
83 uint16_t *buf = ctx->
buf + bstride + 32;
86 memset(dc, 0, (bstride + 16) *
sizeof(*buf));
87 for (y = 0; y <
r; y++)
88 ctx->
blur_line(dc, buf + y * bstride, buf + (y - 1) * bstride, src + 2 * y * src_linesize, src_linesize, width / 2);
91 int mod = ((y +
r) / 2) %
r;
92 uint16_t *buf0 = buf + mod * bstride;
93 uint16_t *buf1 = buf + (mod ? mod - 1 : r - 1) * bstride;
95 ctx->
blur_line(dc, buf0, buf1, src + (y + r) * src_linesize, src_linesize, width / 2);
96 for (x = v = 0; x <
r; x++)
98 for (; x < width / 2; x++) {
100 dc[x-
r] = v * dc_factor >> 16;
102 for (; x < (width + r + 1) / 2; x++)
103 dc[x-r] = v * dc_factor >> 16;
104 for (x = -r / 2; x < 0; x++)
108 for (y = 0; y <
r; y++)
109 ctx->
filter_line(dst + y * dst_linesize, src + y * src_linesize, dc - r / 2, width, thresh,
dither[y & 7]);
111 ctx->
filter_line(dst + y * dst_linesize, src + y * src_linesize, dc - r / 2, width, thresh,
dither[y & 7]);
112 if (++y >= height)
break;
113 ctx->
filter_line(dst + y * dst_linesize, src + y * src_linesize, dc - r / 2, width, thresh,
dither[y & 7]);
114 if (++y >= height)
break;
127 sscanf(args,
"%f:%d", &thresh, &radius);
129 thresh = av_clipf(thresh, 0.51, 255);
130 gf->
thresh = (1 << 15) / thresh;
131 gf->
radius = av_clip((radius + 1) & ~1, 4, 32);
194 outpicref->
video->
w = outlink->
w;
195 outpicref->
video->
h = outlink->
h;
197 outpicref = inpicref;
213 for (p = 0; p < 4 && inpic->
data[p]; p++) {
223 if (
FFMIN(w, h) > 2 * r)
225 else if (outpic->
data[p] != inpic->
data[p])
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
AVFilterBufferRef * avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
Request a picture buffer with a specific set of permissions.
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
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
static void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src)
Copy properties of src to dst, without copying the actual data.
int h
agreed upon image height
AVFilterBufferRef * out_buf
#define AV_CPU_FLAG_MMX2
SSE integer functions or AMD MMX ext.
#define DECLARE_ALIGNED(n, t, v)
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
void ff_gradfun_filter_line_mmx2(uint8_t *dst, uint8_t *src, uint16_t *dc, int width, int thresh, const uint16_t *dithers)
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
int chroma_h
weight of the chroma planes
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
void(* filter_line)(uint8_t *dst, uint8_t *src, uint16_t *dc, int width, int thresh, const uint16_t *dithers)
DSP functions.
void avfilter_end_frame(AVFilterLink *link)
Notifie the next filter that the current frame has finished.
AVFilter avfilter_vf_gradfun
static int config_input(AVFilterLink *inlink)
static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
A filter pad used for either input or output.
A link between two filters.
static av_cold void uninit(AVFilterContext *ctx)
void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
#define AV_CPU_FLAG_SSSE3
Conroe SSSE3 functions.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
void ff_gradfun_filter_line_ssse3(uint8_t *dst, uint8_t *src, uint16_t *dc, int width, int thresh, const uint16_t *dithers)
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
void av_log(void *avcl, int level, const char *fmt,...)
AVFilterFormats * avfilter_make_format_list(const int *fmts)
Create a list of supported formats.
const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB]
The array of all the pixel format descriptors.
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static av_always_inline void emms_c(void)
Empty mmx state.
int w
agreed upon image width
void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
Send a slice to the next filter.
as above, but U and V bytes are swapped
int format
agreed upon media format
static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
uint16_t * buf
holds image data for blur algorithm passed into filter.
void avfilter_unref_buffer(AVFilterBufferRef *ref)
Remove a reference to a buffer.
A reference to an AVFilterBuffer.
static const uint16_t dither[8][8]
int perms
permissions, see the AV_PERM_* flags
AVFilterBufferRef * avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask)
Add a new reference to a buffer.
void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
Notify the next filter of the start of a frame.
const char * name
filter name
static void end_frame(AVFilterLink *inlink)
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
static void filter(GradFunContext *ctx, uint8_t *dst, uint8_t *src, int width, int height, int dst_linesize, int src_linesize, int r)
AVFilterLink ** outputs
array of pointers to output links
#define AV_PERM_PRESERVE
nobody else can overwrite the buffer
static int query_formats(AVFilterContext *ctx)
static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
int chroma_w
width of the chroma planes
#define AV_PERM_WRITE
can write to the buffer
void ff_gradfun_blur_line_sse2(uint16_t *dc, uint16_t *buf, uint16_t *buf1, uint8_t *src, int src_linesize, int width)
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
AVFilterBufferRef * cur_buf
#define AV_CPU_FLAG_SSE2
PIV SSE2 functions.
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.