Go to the documentation of this file.
44 #define LUT_BITS (depth==16 ? 8 : 4)
45 #define LOAD(x) (((depth == 8 ? src[x] : AV_RN16A(src + (x) * 2)) << (16 - depth))\
46 + (((1 << (16 - depth)) - 1) >> 1))
47 #define STORE(x,val) (depth == 8 ? dst[x] = (val) >> (16 - depth) : \
48 AV_WN16A(dst + (x) * 2, (val) >> (16 - depth)))
51 static uint32_t
lowpass(
int prev,
int cur, int16_t *coef,
int depth)
60 int w,
int h,
int sstride,
int dstride,
61 int16_t *temporal,
int depth)
68 for (y = 0; y <
h; y++) {
69 for (x = 0; x <
w; x++) {
70 frame_ant[x] =
tmp =
lowpass(frame_ant[x],
LOAD(x), temporal, depth);
81 uint8_t *
src, uint8_t *dst,
82 uint16_t *line_ant, uint16_t *frame_ant,
83 int w,
int h,
int sstride,
int dstride,
84 int16_t *spatial, int16_t *temporal,
int depth)
96 for (x = 0; x <
w; x++) {
97 line_ant[x] =
tmp = pixel_ant =
lowpass(pixel_ant,
LOAD(x), spatial, depth);
98 frame_ant[x] =
tmp =
lowpass(frame_ant[x],
tmp, temporal, depth);
102 for (y = 1; y <
h; y++) {
106 if (
s->denoise_row[depth]) {
107 s->denoise_row[depth](
src, dst, line_ant, frame_ant,
w, spatial, temporal);
111 for (x = 0; x <
w-1; x++) {
112 line_ant[x] =
tmp =
lowpass(line_ant[x], pixel_ant, spatial, depth);
113 pixel_ant =
lowpass(pixel_ant,
LOAD(x+1), spatial, depth);
114 frame_ant[x] =
tmp =
lowpass(frame_ant[x],
tmp, temporal, depth);
117 line_ant[x] =
tmp =
lowpass(line_ant[x], pixel_ant, spatial, depth);
118 frame_ant[x] =
tmp =
lowpass(frame_ant[x],
tmp, temporal, depth);
125 uint8_t *
src, uint8_t *dst,
126 uint16_t *line_ant, uint16_t **frame_ant_ptr,
127 int w,
int h,
int sstride,
int dstride,
128 int16_t *spatial, int16_t *temporal,
int depth)
133 uint16_t *frame_ant = *frame_ant_ptr;
135 uint8_t *frame_src =
src;
139 for (y = 0; y <
h; y++,
src += sstride, frame_ant +=
w)
140 for (x = 0; x <
w; x++)
141 frame_ant[x] =
LOAD(x);
143 frame_ant = *frame_ant_ptr;
148 w,
h, sstride, dstride, spatial, temporal, depth);
151 w,
h, sstride, dstride, temporal, depth);
156 #define denoise(...) \
158 int ret = AVERROR_BUG; \
159 switch (s->depth) { \
160 case 8: ret = denoise_depth(__VA_ARGS__, 8); break; \
161 case 9: ret = denoise_depth(__VA_ARGS__, 9); break; \
162 case 10: ret = denoise_depth(__VA_ARGS__, 10); break; \
163 case 12: ret = denoise_depth(__VA_ARGS__, 12); break; \
164 case 14: ret = denoise_depth(__VA_ARGS__, 14); break; \
165 case 16: ret = denoise_depth(__VA_ARGS__, 16); break; \
168 av_frame_free(&out); \
170 av_frame_free(&in); \
178 double gamma, simil,
C;
180 gamma = log(0.25) / log(1.0 -
FFMIN(dist25,252.0)/255.0 - 0.00001);
185 C = pow(simil, gamma) * 256.0 *
f;
192 #define PARAM1_DEFAULT 4.0
193 #define PARAM2_DEFAULT 3.0
194 #define PARAM3_DEFAULT 6.0
250 for (
int i = 0;
i < 4;
i++)
263 s->hsub =
desc->log2_chroma_w;
264 s->vsub =
desc->log2_chroma_h;
265 s->depth = depth =
desc->comp[0].depth;
267 for (
i = 0;
i < 3;
i++) {
273 for (
i = 0;
i < 4;
i++) {
302 s->line[job_nr], &
s->frame_prev[job_nr],
339 if (
ctx->is_disabled) {
351 char *res,
int res_len,
int flags)
364 #define OFFSET(x) offsetof(HQDN3DContext, x)
365 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_PARAM
397 .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
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)
#define FILTER_PIXFMTS_ARRAY(array)
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.
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
@ 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)
static void fn() direct(const ftype *in, const ctype *ir, int len, ftype *out)
#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_INPUTS(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.
#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
static const AVFilterPad avfilter_vf_hqdn3d_outputs[]
int h
agreed upon image height
@ 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)
#define FILTER_OUTPUTS(array)
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 av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
#define AV_PIX_FMT_YUV420P14