45 #define COLOR_DIFF_COEFF_SIZE 512
74 #define RADIUS_MIN 0.1
75 #define RADIUS_MAX 4.0
77 #define PRE_FILTER_RADIUS_MIN 0.1
78 #define PRE_FILTER_RADIUS_MAX 2.0
80 #define STRENGTH_MIN 0.1
81 #define STRENGTH_MAX 100.0
83 #define OFFSET(x) offsetof(SabContext, x)
84 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
114 s->chroma.radius =
s->luma.radius;
116 s->chroma.pre_filter_radius =
s->luma.pre_filter_radius;
118 s->chroma.strength =
s->luma.strength;
120 s->luma.quality =
s->chroma.quality = 3.0;
124 "luma_radius:%f luma_pre_filter_radius::%f luma_strength:%f "
125 "chroma_radius:%f chroma_pre_filter_radius:%f chroma_strength:%f\n",
126 s->luma .radius,
s->luma .pre_filter_radius,
s->luma .strength,
127 s->chroma.radius,
s->chroma.pre_filter_radius,
s->chroma.strength);
133 if (
f->pre_filter_context) {
135 f->pre_filter_context =
NULL;
157 if (!
f->pre_filter_buf)
160 f->pre_filter_linesize = linesize;
174 if (index < 0 || index >= vec->
length) d = 0.0;
185 if (!
f->dist_coeff) {
190 for (y = 0; y < vec->
length; y++) {
191 for (x = 0; x < vec->
length; x++) {
193 f->dist_coeff[x + y*
f->dist_linesize] = (
int)(d*(1<<10) + 0.5);
207 s->hsub =
desc->log2_chroma_w;
208 s->vsub =
desc->log2_chroma_h;
230 const int radius =
f.dist_width/2;
233 int src2_linesize[
NB_PLANES] = { src_linesize };
235 int dst2_linesize[
NB_PLANES] = {
f.pre_filter_linesize };
237 sws_scale(
f.pre_filter_context, src2, src2_linesize, 0,
h, dst2, dst2_linesize);
239 #define UPDATE_FACTOR do { \
241 factor = f.color_diff_coeff[COLOR_DIFF_COEFF_SIZE/2 + pre_val - \
242 f.pre_filter_buf[ix + iy*f.pre_filter_linesize]] * f.dist_coeff[dx + dy*f.dist_linesize]; \
243 sum += src[ix + iy*src_linesize] * factor; \
247 for (y = 0; y <
h; y++) {
248 for (x = 0; x <
w; x++) {
252 const int pre_val =
f.pre_filter_buf[x + y*
f.pre_filter_linesize];
253 if (x >= radius && x <
w - radius) {
254 for (dy = 0; dy < radius*2 + 1; dy++) {
256 int iy = y+dy - radius;
259 for (dx = 0; dx < radius*2 + 1; dx++) {
260 const int ix = x+dx - radius;
265 for (dy = 0; dy < radius*2+1; dy++) {
267 int iy = y+dy - radius;
270 for (dx = 0; dx < radius*2 + 1; dx++) {
271 int ix = x+dx - radius;
277 dst[x + y*dst_linesize] = (sum + div/2) / div;
296 inlink->
w, inlink->
h, &
s->luma);
297 if (
inpic->data[2]) {
335 .priv_class = &sab_class,
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
#define flags(name, subs,...)
#define AV_CEIL_RSHIFT(a, b)
static unsigned sws_flags
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_LOG_VERBOSE
Detailed information.
SwsVector * sws_getGaussianVec(double variance, double quality)
Return a normalized Gaussian curve used to filter stuff quality = 3 is high quality,...
void sws_freeVec(SwsVector *a)
void sws_freeContext(struct SwsContext *swsContext)
Free the swscaler context swsContext.
int attribute_align_arg sws_scale(struct SwsContext *c, const uint8_t *const srcSlice[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
swscale wrapper, so we don't need to export the SwsContext.
struct SwsContext * sws_getContext(int srcW, int srcH, enum AVPixelFormat srcFormat, int dstW, int dstH, enum AVPixelFormat dstFormat, int flags, SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param)
Allocate and return an SwsContext.
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static av_always_inline av_const int avpriv_mirror(int x, int w)
static enum AVPixelFormat pix_fmts[]
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Describe the class of an AVClass context structure.
void * priv
private data for use by the filter
AVFilterLink ** outputs
array of pointers to output links
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
const char * name
Pad name.
const char * name
Filter name.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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...
struct SwsContext * pre_filter_context
int color_diff_coeff[COLOR_DIFF_COEFF_SIZE]
double * coeff
pointer to the list of coefficients
int length
number of coefficients in the vector
#define av_malloc_array(a, b)
static const AVFilterPad sab_outputs[]
static void blur(uint8_t *dst, const int dst_linesize, const uint8_t *src, const int src_linesize, const int w, const int h, FilterParam *fp)
static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
#define PRE_FILTER_RADIUS_MAX
#define PRE_FILTER_RADIUS_MIN
static int query_formats(AVFilterContext *ctx)
#define COLOR_DIFF_COEFF_SIZE
AVFILTER_DEFINE_CLASS(sab)
static void close_filter_param(FilterParam *f)
static int config_props(AVFilterLink *inlink)
static av_cold int init(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx)
static int open_filter_param(FilterParam *f, int width, int height, unsigned int sws_flags)
static const AVOption sab_options[]
static const AVFilterPad sab_inputs[]
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.