Go to the documentation of this file.
46 #define COLOR_DIFF_COEFF_SIZE 512
68 #define RADIUS_MIN 0.1
69 #define RADIUS_MAX 4.0
71 #define PRE_FILTER_RADIUS_MIN 0.1
72 #define PRE_FILTER_RADIUS_MAX 2.0
74 #define STRENGTH_MIN 0.1
75 #define STRENGTH_MAX 100.0
77 #define OFFSET(x) offsetof(SabContext, x)
78 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
108 s->chroma.radius =
s->luma.radius;
110 s->chroma.pre_filter_radius =
s->luma.pre_filter_radius;
112 s->chroma.strength =
s->luma.strength;
114 s->luma.quality =
s->chroma.quality = 3.0;
118 "luma_radius:%f luma_pre_filter_radius::%f luma_strength:%f "
119 "chroma_radius:%f chroma_pre_filter_radius:%f chroma_strength:%f\n",
120 s->luma .radius,
s->luma .pre_filter_radius,
s->luma .strength,
121 s->chroma.radius,
s->chroma.pre_filter_radius,
s->chroma.strength);
127 if (
f->pre_filter_context) {
129 f->pre_filter_context =
NULL;
151 if (!
f->pre_filter_buf)
154 f->pre_filter_linesize = linesize;
168 if (index < 0 || index >= vec->
length) d = 0.0;
171 f->color_diff_coeff[
i] = (int)(d/vec->
coeff[vec->
length/2]*(1<<12) + 0.5);
179 if (!
f->dist_coeff) {
184 for (y = 0; y < vec->
length; y++) {
185 for (x = 0; x < vec->
length; x++) {
187 f->dist_coeff[x + y*
f->dist_linesize] = (int)(d*(1<<10) + 0.5);
201 s->hsub =
desc->log2_chroma_w;
202 s->vsub =
desc->log2_chroma_h;
218 static void blur(uint8_t *
dst,
const int dst_linesize,
219 const uint8_t *
src,
const int src_linesize,
224 const int radius =
f.dist_width/2;
227 int src2_linesize[
NB_PLANES] = { src_linesize };
228 uint8_t *dst2[
NB_PLANES] = {
f.pre_filter_buf };
229 int dst2_linesize[
NB_PLANES] = {
f.pre_filter_linesize };
231 sws_scale(
f.pre_filter_context,
src2, src2_linesize, 0,
h, dst2, dst2_linesize);
233 #define UPDATE_FACTOR do { \
235 factor = f.color_diff_coeff[COLOR_DIFF_COEFF_SIZE/2 + pre_val - \
236 f.pre_filter_buf[ix + iy*f.pre_filter_linesize]] * f.dist_coeff[dx + dy*f.dist_linesize]; \
237 sum += src[ix + iy*src_linesize] * factor; \
241 for (y = 0; y <
h; y++) {
242 for (x = 0; x <
w; x++) {
246 const int pre_val =
f.pre_filter_buf[x + y*
f.pre_filter_linesize];
247 if (x >= radius && x <
w - radius) {
248 for (dy = 0; dy < radius*2 + 1; dy++) {
250 int iy = y+dy - radius;
253 for (dx = 0; dx < radius*2 + 1; dx++) {
254 const int ix = x+dx - radius;
259 for (dy = 0; dy < radius*2+1; dy++) {
261 int iy = y+dy - radius;
264 for (dx = 0; dx < radius*2 + 1; dx++) {
265 int ix = x+dx - radius;
271 dst[x + y*dst_linesize] = (sum + div/2) / div;
291 if (
inpic->data[2]) {
320 .priv_class = &sab_class,
#define PRE_FILTER_RADIUS_MAX
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
AVPixelFormat
Pixel format.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static enum AVPixelFormat pix_fmts[]
#define FILTER_PIXFMTS_ARRAY(array)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
void sws_freeContext(SwsContext *swsContext)
Free the swscaler context swsContext.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define FILTER_INPUTS(array)
This structure describes decoded (raw) audio or video data.
AVFILTER_DEFINE_CLASS(sab)
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)
#define AV_LOG_VERBOSE
Detailed information.
static const AVOption sab_options[]
const char * name
Filter name.
A link between two filters.
#define PRE_FILTER_RADIUS_MIN
void sws_freeVec(SwsVector *a)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
A filter pad used for either input or output.
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
#define COLOR_DIFF_COEFF_SIZE
#define AV_CEIL_RSHIFT(a, b)
int length
number of coefficients in the vector
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
SwsVector * sws_getGaussianVec(double variance, double quality)
Return a normalized Gaussian curve used to filter stuff quality = 3 is high quality,...
#define FILTER_OUTPUTS(array)
Describe the class of an AVClass context structure.
static const AVFilterPad sab_inputs[]
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
static void close_filter_param(FilterParam *f)
static av_always_inline av_const int avpriv_mirror(int x, int w)
double * coeff
pointer to the list of coefficients
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
int color_diff_coeff[COLOR_DIFF_COEFF_SIZE]
@ SWS_POINT
nearest neighbor
static int config_props(AVFilterLink *inlink)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
#define i(width, name, range_min, range_max)
int w
agreed upon image width
#define av_malloc_array(a, b)
const char * name
Pad name.
struct SwsContext * pre_filter_context
static int open_filter_param(FilterParam *f, int width, int height, unsigned int sws_flags)
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.
int h
agreed upon image height
int attribute_align_arg sws_scale(SwsContext *sws, 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.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
static av_cold int init(AVFilterContext *ctx)
Main external API structure.
static av_cold void uninit(AVFilterContext *ctx)