46#define COLOR_DIFF_COEFF_SIZE 512
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;
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;
218static 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;
290 inlink->
w, inlink->
h, &
s->luma);
291 if (
inpic->data[2]) {
314 .p.priv_class = &sab_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static AVFormatContext * ctx
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
#define AV_CEIL_RSHIFT(a, b)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
int(* init)(AVBSFContext *ctx)
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
#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.
void sws_freeVec(SwsVector *a)
SwsVector * sws_getGaussianVec(double variance, double quality)
Return a normalized Gaussian curve used to filter stuff quality = 3 is high quality,...
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.
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.
void sws_freeContext(SwsContext *swsContext)
Free the swscaler context swsContext.
@ SWS_POINT
nearest neighbor
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FILTER_PIXFMTS_ARRAY(array)
#define AVFILTER_DEFINE_CLASS(fname)
#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[]
Memory handling functions.
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)
static int config_props(AVBitStreamFilterLink *link)
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.
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, a positive or negative value, which is typically indicating the size in bytes of each pict...
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]
Main external API structure.
double * coeff
pointer to the list of coefficients
int length
number of coefficients in the vector
#define av_malloc_array(a, b)
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
#define COLOR_DIFF_COEFF_SIZE
static void close_filter_param(FilterParam *f)
static int config_props(AVFilterLink *inlink)
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[]
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.