Go to the documentation of this file.
45 #define LUT_BITS (depth==16 ? 8 : 4)
46 #define LOAD(x) (((depth == 8 ? src[x] : AV_RN16A(src + (x) * 2)) << (16 - depth))\
47 + (((1 << (16 - depth)) - 1) >> 1))
48 #define STORE(x,val) (depth == 8 ? dst[x] = (val) >> (16 - depth) : \
49 AV_WN16A(dst + (x) * 2, (val) >> (16 - depth)))
52 static uint32_t
lowpass(
int prev,
int cur, int16_t *coef,
int depth)
54 int d = (prev - cur) >> (8 -
LUT_BITS);
61 int w,
int h,
int sstride,
int dstride,
62 int16_t *temporal,
int depth)
69 for (y = 0; y <
h; y++) {
70 for (x = 0; x <
w; x++) {
71 frame_ant[x] =
tmp =
lowpass(frame_ant[x],
LOAD(x), temporal, depth);
82 uint8_t *
src, uint8_t *
dst,
83 uint16_t *line_ant, uint16_t *frame_ant,
84 int w,
int h,
int sstride,
int dstride,
85 int16_t *spatial, int16_t *temporal,
int depth)
97 for (x = 0; x <
w; x++) {
98 line_ant[x] =
tmp = pixel_ant =
lowpass(pixel_ant,
LOAD(x), spatial, depth);
99 frame_ant[x] =
tmp =
lowpass(frame_ant[x],
tmp, temporal, depth);
103 for (y = 1; y <
h; y++) {
107 if (
s->denoise_row[depth]) {
108 s->denoise_row[depth](
src,
dst, line_ant, frame_ant,
w, spatial, temporal);
112 for (x = 0; x <
w-1; x++) {
113 line_ant[x] =
tmp =
lowpass(line_ant[x], pixel_ant, spatial, depth);
114 pixel_ant =
lowpass(pixel_ant,
LOAD(x+1), spatial, depth);
115 frame_ant[x] =
tmp =
lowpass(frame_ant[x],
tmp, temporal, depth);
118 line_ant[x] =
tmp =
lowpass(line_ant[x], pixel_ant, spatial, depth);
119 frame_ant[x] =
tmp =
lowpass(frame_ant[x],
tmp, temporal, depth);
126 uint8_t *
src, uint8_t *
dst,
127 uint16_t *line_ant, uint16_t **frame_ant_ptr,
128 int w,
int h,
int sstride,
int dstride,
129 int16_t *spatial, int16_t *temporal,
int depth)
134 uint16_t *frame_ant = *frame_ant_ptr;
136 uint8_t *frame_src =
src;
140 for (y = 0; y <
h; y++,
src += sstride, frame_ant +=
w)
141 for (x = 0; x <
w; x++)
142 frame_ant[x] =
LOAD(x);
144 frame_ant = *frame_ant_ptr;
149 w,
h, sstride, dstride, spatial, temporal, depth);
152 w,
h, sstride, dstride, temporal, depth);
157 #define denoise(...) \
159 int ret = AVERROR_BUG; \
160 switch (s->depth) { \
161 case 8: ret = denoise_depth(__VA_ARGS__, 8); break; \
162 case 9: ret = denoise_depth(__VA_ARGS__, 9); break; \
163 case 10: ret = denoise_depth(__VA_ARGS__, 10); break; \
164 case 12: ret = denoise_depth(__VA_ARGS__, 12); break; \
165 case 14: ret = denoise_depth(__VA_ARGS__, 14); break; \
166 case 16: ret = denoise_depth(__VA_ARGS__, 16); break; \
169 av_frame_free(&out); \
171 av_frame_free(&in); \
179 double gamma, simil,
C;
181 gamma =
log(0.25) /
log(1.0 -
FFMIN(dist25,252.0)/255.0 - 0.00001);
186 C = pow(simil, gamma) * 256.0 *
f;
193 #define PARAM1_DEFAULT 4.0
194 #define PARAM2_DEFAULT 3.0
195 #define PARAM3_DEFAULT 6.0
251 for (
int i = 0;
i < 4;
i++)
264 s->hsub =
desc->log2_chroma_w;
265 s->vsub =
desc->log2_chroma_h;
266 s->depth = depth =
desc->comp[0].depth;
268 for (
i = 0;
i < 3;
i++) {
274 for (
i = 0;
i < 4;
i++) {
303 s->line[job_nr], &
s->frame_prev[job_nr],
340 if (
ctx->is_disabled) {
352 char *res,
int res_len,
int flags)
365 #define OFFSET(x) offsetof(HQDN3DContext, x)
366 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_PARAM
391 .priv_class = &hqdn3d_class,
static av_cold int init(AVFilterContext *ctx)
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
#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 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.
#define AV_PIX_FMT_YUV420P10
#define AV_LOG_VERBOSE
Detailed information.
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
const char * name
Filter name.
static av_always_inline uint32_t lowpass(int prev, int cur, int16_t *coef, int depth)
A link between two filters.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int config_input(AVFilterLink *inlink)
void ff_hqdn3d_init_x86(HQDN3DContext *hqdn3d)
#define AV_PIX_FMT_YUV422P9
A filter pad used for either input or output.
#define AV_PIX_FMT_YUV444P10
s EdgeDetect Foobar g libavfilter vf_edgedetect c libavfilter vf_foobar c edit libavfilter and add an entry for foobar following the pattern of the other filters edit libavfilter allfilters and add an entry for foobar following the pattern of the other filters configure make j< whatever > ffmpeg ffmpeg i you should get a foobar png with Lena edge detected That s your new playground is ready Some little details about what s going which in turn will define variables for the build system and the C
#define AV_PIX_FMT_YUV422P16
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
#define AV_PIX_FMT_YUV444P16
#define AV_CEIL_RSHIFT(a, b)
static av_cold void uninit(AVFilterContext *ctx)
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P16
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FILTER_OUTPUTS(array)
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
static __device__ float fabs(float a)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
static const AVFilterPad avfilter_vf_hqdn3d_inputs[]
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
#define AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_YUV422P10
#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
#define AV_PIX_FMT_YUV422P12
AVFILTER_DEFINE_CLASS(hqdn3d)
#define AV_PIX_FMT_YUV444P12
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
static av_always_inline void denoise_temporal(uint8_t *src, uint8_t *dst, uint16_t *frame_ant, int w, int h, int sstride, int dstride, int16_t *temporal, int depth)
static const AVOption hqdn3d_options[]
static int do_denoise(AVFilterContext *ctx, void *data, int job_nr, int n_jobs)
static void precalc_coefs(double dist25, int depth, int16_t *ct)
#define i(width, name, range_min, range_max)
int w
agreed upon image width
#define av_malloc_array(a, b)
Used for passing data between threads.
static enum AVPixelFormat pix_fmts[]
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
static av_always_inline void denoise_spatial(HQDN3DContext *s, uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, int w, int h, int sstride, int dstride, int16_t *spatial, int16_t *temporal, int depth)
const char * name
Pad name.
#define AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P14
const AVFilter ff_vf_hqdn3d
int h
agreed upon image height
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static av_always_inline int denoise_depth(HQDN3DContext *s, uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t **frame_ant_ptr, int w, int h, int sstride, int dstride, int16_t *spatial, int16_t *temporal, int depth)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
#define flags(name, subs,...)
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)
#define AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV444P14
static void calc_coefs(AVFilterContext *ctx)
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
#define AV_PIX_FMT_YUV420P14