56#define OFFSET(x) offsetof(OWDenoiseContext, x)
57#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
70 { 0, 48, 12, 60, 3, 51, 15, 63 },
71 { 32, 16, 44, 28, 35, 19, 47, 31 },
72 { 8, 56, 4, 52, 11, 59, 7, 55 },
73 { 40, 24, 36, 20, 43, 27, 39, 23 },
74 { 2, 50, 14, 62, 1, 49, 13, 61 },
75 { 34, 18, 46, 30, 33, 17, 45, 29 },
76 { 10, 58, 6, 54, 9, 57, 5, 53 },
77 { 42, 26, 38, 22, 41, 25, 37, 21 },
80static const double coeff[2][5] = {
100 -0.09127176311424948 /
M_SQRT2,
104 -0.07822326652898785 *
M_SQRT2,
111static inline void decompose(
float *dst_l,
float *dst_h,
const float *
src,
115 for (x = 0; x <
w; x++) {
116 double sum_l =
src[x * linesize] *
coeff[0][0];
117 double sum_h =
src[x * linesize] *
coeff[1][0];
118 for (
i = 1;
i <= 4;
i++) {
125 dst_l[x * linesize] = sum_l;
126 dst_h[x * linesize] = sum_h;
130static inline void compose(
float *
dst,
const float *src_l,
const float *src_h,
134 for (x = 0; x <
w; x++) {
135 double sum_l = src_l[x * linesize] *
icoeff[0][0];
136 double sum_h = src_h[x * linesize] *
icoeff[1][0];
137 for (
i = 1;
i <= 4;
i++) {
141 sum_l +=
icoeff[0][
i] * (src_l[x0] + src_l[x1]);
142 sum_h +=
icoeff[1][
i] * (src_h[x0] + src_h[x1]);
144 dst[x * linesize] = (sum_l + sum_h) * 0.5;
149 int xlinesize,
int ylinesize,
150 int step,
int w,
int h)
153 for (y = 0; y <
h; y++)
154 for (x = 0; x < step; x++)
155 decompose(dst_l + ylinesize*y + xlinesize*x,
156 dst_h + ylinesize*y + xlinesize*x,
157 src + ylinesize*y + xlinesize*x,
158 step * xlinesize, (
w - x + step - 1) / step);
161static inline void compose2D(
float *
dst,
const float *src_l,
const float *src_h,
162 int xlinesize,
int ylinesize,
163 int step,
int w,
int h)
166 for (y = 0; y <
h; y++)
167 for (x = 0; x < step; x++)
169 src_l + ylinesize*y + xlinesize*x,
170 src_h + ylinesize*y + xlinesize*x,
171 step * xlinesize, (
w - x + step - 1) / step);
175 int linesize,
int step,
int w,
int h)
183 int linesize,
int step,
int w,
int h)
191 uint8_t *
dst,
int dst_linesize,
192 const uint8_t *
src,
int src_linesize,
195 int x, y,
i, j, depth =
s->depth;
200 if (
s->pixel_depth <= 8) {
201 for (y = 0; y <
height; y++)
202 for(x = 0; x <
width; x++)
203 s->plane[0][0][y*
s->linesize + x] =
src[y*src_linesize + x];
205 const uint16_t *src16 = (
const uint16_t *)
src;
208 for (y = 0; y <
height; y++)
209 for(x = 0; x <
width; x++)
210 s->plane[0][0][y*
s->linesize + x] = src16[y*src_linesize + x];
213 for (
i = 0;
i < depth;
i++)
216 for (
i = 0;
i < depth;
i++) {
217 for (j = 1; j < 4; j++) {
218 for (y = 0; y <
height; y++) {
219 for (x = 0; x <
width; x++) {
220 double v =
s->plane[
i + 1][j][y*
s->linesize + x];
221 if (v > strength) v -= strength;
222 else if (v < -strength) v += strength;
224 s->plane[
i + 1][j][x + y*
s->linesize] = v;
229 for (
i = depth-1;
i >= 0;
i--)
232 if (
s->pixel_depth <= 8) {
233 for (y = 0; y <
height; y++) {
234 for (x = 0; x <
width; x++) {
235 i =
s->plane[0][0][y*
s->linesize + x] +
dither[x&7][y&7]*(1.0/64) + 1.0/128;
236 if ((
unsigned)
i > 255U)
i = ~(
i >> 31);
237 dst[y*dst_linesize + x] =
i;
241 uint16_t *dst16 = (uint16_t *)
dst;
244 for (y = 0; y <
height; y++) {
245 for (x = 0; x <
width; x++) {
246 i =
s->plane[0][0][y*
s->linesize + x];
247 dst16[y*dst_linesize + x] =
i;
265 if (
s->luma_strength > 0)
267 if (
s->chroma_strength > 0) {
279 if (
s->luma_strength > 0) {
284 if (
s->chroma_strength > 0) {
295 inlink->
w, inlink->
h);
325 s->hsub =
desc->log2_chroma_w;
326 s->vsub =
desc->log2_chroma_h;
327 s->pixel_depth =
desc->comp[0].depth;
330 for (j = 0; j < 4; j++) {
331 for (
i = 0;
i <=
s->depth;
i++) {
345 for (j = 0; j < 4; j++)
346 for (
i = 0;
i <=
s->depth;
i++)
360 .p.name =
"owdenoise",
362 .p.priv_class = &owdenoise_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static int config_input(AVFilterLink *inlink)
const FFFilter ff_vf_owdenoise
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)
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
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.
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.
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.
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P14
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
@ 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)
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
#define AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P10
Describe the class of an AVClass context structure.
void * priv
private data for use by the filter
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...
#define av_malloc_array(a, b)
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
static AVFormatContext * ctx
static const uint16_t dither[8][8]
static void decompose2D(float *dst_l, float *dst_h, const float *src, int xlinesize, int ylinesize, int step, int w, int h)
static void decompose2D2(float *dst[4], float *src, float *temp[2], int linesize, int step, int w, int h)
static void compose2D(float *dst, const float *src_l, const float *src_h, int xlinesize, int ylinesize, int step, int w, int h)
static const AVFilterPad owdenoise_inputs[]
static const double coeff[2][5]
static void compose2D2(float *dst, float *src[4], float *temp[2], int linesize, int step, int w, int h)
static void compose(float *dst, const float *src_l, const float *src_h, int linesize, int w)
static int config_input(AVFilterLink *inlink)
static const AVOption owdenoise_options[]
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static av_cold void uninit(AVFilterContext *ctx)
static const double icoeff[2][5]
static void decompose(float *dst_l, float *dst_h, const float *src, int linesize, int w)
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.