51 #define SHIFTUP(x,shift) (-((-(x))>>(shift)))
71 const uint8_t *src,
int src_stride,
74 uint32_t **sc = fp->
sc;
82 if (dst_stride == src_stride)
83 memcpy(dst, src, src_stride * height);
85 for (y = 0; y <
height; y++, dst += dst_stride, src += src_stride)
86 memcpy(dst, src, width);
90 for (y = 0; y < 2 * fp->
steps_y; y++)
91 memset(sc[y], 0,
sizeof(sc[y][0]) * (width + 2 * fp->
steps_x));
93 for (y = -fp->
steps_y; y < height + fp->steps_y; y++) {
97 memset(sr, 0,
sizeof(sr[0]) * (2 * fp->
steps_x - 1));
98 for (x = -fp->
steps_x; x < width + fp->steps_x; x++) {
99 tmp1 = x <= 0 ? src2[0] : x >= width ? src2[width-1] : src2[x];
100 for (z = 0; z < fp->
steps_x * 2; z += 2) {
101 tmp2 = sr[z + 0] + tmp1; sr[z + 0] = tmp1;
102 tmp1 = sr[z + 1] + tmp2; sr[z + 1] = tmp2;
104 for (z = 0; z < fp->
steps_y * 2; z += 2) {
105 tmp2 = sc[z + 0][x + fp->
steps_x] + tmp1; sc[z + 0][x + fp->
steps_x] = tmp1;
106 tmp1 = sc[z + 1][x + fp->
steps_x] + tmp2; sc[z + 1][x + fp->
steps_x] = tmp2;
113 *dsx = av_clip_uint8(res);
127 fp->
amount = amount * 65536.0;
138 int lmsize_x = 5, cmsize_x = 5;
139 int lmsize_y = 5, cmsize_y = 5;
140 double lamount = 1.0f, camount = 0.0f;
143 sscanf(args,
"%d:%d:%lf:%d:%d:%lf", &lmsize_x, &lmsize_y, &lamount,
144 &cmsize_x, &cmsize_y, &camount);
146 if ((lamount && (lmsize_x < 2 || lmsize_y < 2)) ||
147 (camount && (cmsize_x < 2 || cmsize_y < 2))) {
149 "Invalid value <2 for lmsize_x:%d or lmsize_y:%d or cmsize_x:%d or cmsize_y:%d\n",
150 lmsize_x, lmsize_y, cmsize_x, cmsize_y);
178 effect = fp->
amount == 0 ?
"none" : fp->
amount < 0 ?
"blur" :
"sharpen";
183 for (z = 0; z < 2 * fp->
steps_y; z++)
205 for (z = 0; z < 2 * fp->
steps_y; z++)
269 .
inputs = avfilter_vf_unsharp_inputs,
271 .
outputs = avfilter_vf_unsharp_outputs,
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
static const AVFilterPad avfilter_vf_unsharp_inputs[]
AVFilter avfilter_vf_unsharp
int linesize[8]
number of bytes per line
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static void set_filter_param(FilterParam *fp, int msize_x, int msize_y, double amount)
static const AVFilterPad outputs[]
memory handling functions
int h
agreed upon image height
int ff_filter_frame(AVFilterLink *link, AVFilterBufferRef *frame)
Send a frame of data to the next filter.
uint32_t * sc[(MAX_SIZE *MAX_SIZE)-1]
finite state machine storage
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
const char * name
Pad name.
struct FilterParam FilterParam
void avfilter_unref_bufferp(AVFilterBufferRef **ref)
Remove a reference to a buffer and set the pointer to NULL.
static const AVFilterPad avfilter_vf_unsharp_outputs[]
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
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)
AVFilterBufferRef * ff_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
Request a picture buffer with a specific set of permissions.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
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,...)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int w
agreed upon image width
int scalebits
bits to shift pixel
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
static av_cold void uninit(AVFilterContext *ctx)
static void free_filter_param(FilterParam *fp)
int format
agreed upon media format
static int config_props(AVFilterLink *link)
int steps_x
horizontal step count
A reference to an AVFilterBuffer.
static int filter_frame(AVFilterLink *link, AVFilterBufferRef *in)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
int32_t halfscale
amount to add to pixel
static const AVFilterPad inputs[]
static av_cold int init(AVFilterContext *ctx, const char *args)
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
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
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:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
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
uint8_t * data[8]
picture/audio data for each plane
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
static void init_filter_param(AVFilterContext *ctx, FilterParam *fp, const char *effect_type, int width)
AVPixelFormat
Pixel format.
FilterParam chroma
chroma parameters (width, height, amount)