48 #define SHIFTUP(x,shift) (-((-(x))>>(shift)))
68 const uint8_t *src,
int src_stride,
71 uint32_t **sc = fp->
sc;
79 if (dst_stride == src_stride)
80 memcpy(dst, src, src_stride * height);
82 for (y = 0; y <
height; y++, dst += dst_stride, src += src_stride)
83 memcpy(dst, src, width);
87 for (y = 0; y < 2 * fp->
steps_y; y++)
88 memset(sc[y], 0,
sizeof(sc[y][0]) * (width + 2 * fp->
steps_x));
90 for (y = -fp->
steps_y; y < height + fp->steps_y; y++) {
94 memset(sr, 0,
sizeof(sr[0]) * (2 * fp->
steps_x - 1));
95 for (x = -fp->
steps_x; x < width + fp->steps_x; x++) {
96 tmp1 = x <= 0 ? src2[0] : x >= width ? src2[width-1] : src2[x];
97 for (z = 0; z < fp->
steps_x * 2; z += 2) {
98 tmp2 = sr[z + 0] + tmp1; sr[z + 0] = tmp1;
99 tmp1 = sr[z + 1] + tmp2; sr[z + 1] = tmp2;
101 for (z = 0; z < fp->
steps_y * 2; z += 2) {
102 tmp2 = sc[z + 0][x + fp->
steps_x] + tmp1; sc[z + 0][x + fp->
steps_x] = tmp1;
103 tmp1 = sc[z + 1][x + fp->
steps_x] + tmp2; sc[z + 1][x + fp->
steps_x] = tmp2;
109 res = (int32_t)*srx + ((((int32_t) * srx - (int32_t)((tmp1 + fp->
halfscale) >> fp->
scalebits)) * fp->
amount) >> 16);
110 *dsx = av_clip_uint8(res);
124 fp->
amount = amount * 65536.0;
135 int lmsize_x = 5, cmsize_x = 5;
136 int lmsize_y = 5, cmsize_y = 5;
137 double lamount = 1.0f, camount = 0.0f;
140 sscanf(args,
"%d:%d:%lf:%d:%d:%lf", &lmsize_x, &lmsize_y, &lamount,
141 &cmsize_x, &cmsize_y, &camount);
143 if ((lamount && (lmsize_x < 2 || lmsize_y < 2)) ||
144 (camount && (cmsize_x < 2 || cmsize_y < 2))) {
146 "Invalid value <2 for lmsize_x:%d or lmsize_y:%d or cmsize_x:%d or cmsize_y:%d\n",
147 lmsize_x, lmsize_y, cmsize_x, cmsize_y);
175 effect = fp->
amount == 0 ?
"none" : fp->
amount < 0 ?
"blur" :
"sharpen";
177 av_log(ctx,
AV_LOG_INFO,
"effect:%s type:%s msize_x:%d msize_y:%d amount:%0.2f\n",
180 for (z = 0; z < 2 * fp->
steps_y; z++)
201 for (z = 0; z < 2 * fp->
steps_y; z++)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
AVFilter avfilter_vf_unsharp
int linesize[8]
number of bytes per line
static void set_filter_param(FilterParam *fp, int msize_x, int msize_y, double amount)
memory handling functions
int h
agreed upon image height
AVFilterBufferRef * out_buf
uint32_t * sc[(MAX_SIZE *MAX_SIZE)-1]
finite state machine storage
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
static void apply_unsharp(uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int width, int height, FilterParam *fp)
#define AV_PERM_READ
can read from the buffer
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
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)
struct FilterParam FilterParam
void avfilter_end_frame(AVFilterLink *link)
Notifie the next filter that the current frame has finished.
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
static void end_frame(AVFilterLink *link)
FilterParam luma
luma parameters (width, height, amount)
A filter pad used for either input or output.
A link between two filters.
#define SHIFTUP(x, shift)
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
#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)
int w
agreed upon image width
int scalebits
bits to shift pixel
static av_cold void uninit(AVFilterContext *ctx)
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
Send a slice to the next filter.
static void free_filter_param(FilterParam *fp)
int format
agreed upon media format
static int config_props(AVFilterLink *link)
void avfilter_unref_buffer(AVFilterBufferRef *ref)
Remove a reference to a buffer.
int steps_x
horizontal step count
A reference to an AVFilterBuffer.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int32_t halfscale
amount to add to pixel
static int query_formats(AVFilterContext *ctx)
const char * name
filter name
AVFilterLink ** outputs
array of pointers to output links
int steps_y
vertical step count
common internal and external API header
AVFilterContext * dst
dest filter
uint8_t * data[8]
picture/audio data for each plane
AVFilterBufferRef * cur_buf
static void init_filter_param(AVFilterContext *ctx, FilterParam *fp, const char *effect_type, int width)
FilterParam chroma
chroma parameters (width, height, amount)