55 uint32_t **sc = fp->
sc;
61 const int amount = fp->
amount;
62 const int steps_x = fp->
steps_x;
63 const int steps_y = fp->
steps_y;
72 for (y = 0; y < 2 * steps_y; y++)
73 memset(sc[y], 0,
sizeof(sc[y][0]) * (width + 2 * steps_x));
75 for (y = -steps_y; y < height + steps_y; y++) {
79 memset(sr, 0,
sizeof(sr[0]) * (2 * steps_x - 1));
80 for (x = -steps_x; x < width + steps_x; x++) {
81 tmp1 = x <= 0 ? src2[0] : x >= width ? src2[width-1] : src2[x];
82 for (z = 0; z < steps_x * 2; z += 2) {
83 tmp2 = sr[z + 0] + tmp1; sr[z + 0] = tmp1;
84 tmp1 = sr[z + 1] + tmp2; sr[z + 1] = tmp2;
86 for (z = 0; z < steps_y * 2; z += 2) {
87 tmp2 = sc[z + 0][x + steps_x] + tmp1; sc[z + 0][x + steps_x] = tmp1;
88 tmp1 = sc[z + 1][x + steps_x] + tmp2; sc[z + 1][x + steps_x] = tmp2;
90 if (x >= steps_x && y >= steps_y) {
91 const uint8_t *srx = src - steps_y * src_stride + x - steps_x;
92 uint8_t *dsx = dst - steps_y * dst_stride + x - steps_x;
94 res = (
int32_t)*srx + ((((
int32_t) * srx - (
int32_t)((tmp1 + halfscale) >> scalebits)) * amount) >> 16);
95 *dsx = av_clip_uint8(res);
109 int i, plane_w[3], plane_h[3];
111 plane_w[0] = inlink->
w;
113 plane_h[0] = inlink->
h;
116 fp[1] = fp[2] = &s->
chroma;
117 for (i = 0; i < 3; i++) {
127 fp->
amount = amount * 65536.0;
149 if (!CONFIG_OPENCL && s->
opencl) {
150 av_log(ctx,
AV_LOG_ERROR,
"OpenCL support was not enabled in this build, cannot be selected\n");
153 if (CONFIG_OPENCL && s->
opencl) {
179 const char *effect = fp->
amount == 0 ?
"none" : fp->
amount < 0 ?
"blur" :
"sharpen";
183 "Invalid even size for %s matrix size %dx%d\n",
191 for (z = 0; z < 2 * fp->
steps_y; z++)
193 sizeof(*(fp->
sc[z])))))
222 for (z = 0; z < 2 * fp->
steps_y; z++)
230 if (CONFIG_OPENCL && s->
opencl) {
251 if (CONFIG_OPENCL && s->
opencl) {
268 #define OFFSET(x) offsetof(UnsharpContext, x)
269 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
313 .priv_class = &unsharp_class,
317 .
inputs = avfilter_vf_unsharp_inputs,
318 .
outputs = avfilter_vf_unsharp_outputs,
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
static const AVFilterPad avfilter_vf_unsharp_inputs[]
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Main libavfilter public API header.
Memory handling functions.
static av_cold int init(AVFilterContext *ctx)
int h
agreed upon image height
UnsharpFilterParam luma
luma parameters (width, height, amount)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
int steps_x
horizontal step count
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
void ff_opencl_unsharp_uninit(AVFilterContext *ctx)
static av_cold int end(AVCodecContext *avctx)
static const AVFilterPad avfilter_vf_unsharp_outputs[]
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
#define AV_LOG_VERBOSE
Detailed information.
A filter pad used for either input or output.
int ff_opencl_unsharp_init(AVFilterContext *ctx)
A link between two filters.
int scalebits
bits to shift pixel
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
int32_t halfscale
amount to add to pixel
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#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:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int w
agreed upon image width
uint32_t * sc[MAX_MATRIX_SIZE-1]
finite state machine storage
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
static void apply_unsharp(uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int width, int height, UnsharpFilterParam *fp)
static av_cold void uninit(AVFilterContext *ctx)
static const AVFilterPad outputs[]
static int apply_unsharp_c(AVFilterContext *ctx, AVFrame *in, AVFrame *out)
static int filter_frame(AVFilterLink *link, AVFrame *in)
static const AVOption unsharp_options[]
int ff_opencl_unsharp_process_inout_buf(AVFilterContext *ctx, AVFrame *in, AVFrame *out)
int format
agreed upon media format
AVFILTER_DEFINE_CLASS(unsharp)
static int config_props(AVFilterLink *link)
static const AVFilterPad inputs[]
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
int steps_y
vertical step count
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
static void set_filter_param(UnsharpFilterParam *fp, int msize_x, int msize_y, float amount)
static int init_filter_param(AVFilterContext *ctx, UnsharpFilterParam *fp, const char *effect_type, int width)
UnsharpFilterParam chroma
chroma parameters (width, height, amount)
static int query_formats(AVFilterContext *ctx)
const char * name
Filter name.
AVFilterLink ** outputs
array of pointers to output links
static enum AVPixelFormat pix_fmts[]
int(* apply_unsharp)(AVFilterContext *ctx, AVFrame *in, AVFrame *out)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal and external API header
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
AVFilterContext * dst
dest filter
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
#define av_malloc_array(a, b)
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.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
int ff_opencl_apply_unsharp(AVFilterContext *ctx, AVFrame *in, AVFrame *out)
#define AV_CEIL_RSHIFT(a, b)
static void free_filter_param(UnsharpFilterParam *fp)