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)
53 int d = (prev - cur) >> (8 -
LUT_BITS);
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);
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++) {
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);
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;
137 for (y = 0; y < h; y++, src += sstride, frame_ant += w)
138 for (x = 0; x < w; x++)
139 frame_ant[x] =
LOAD(x);
141 frame_ant = *frame_ant_ptr;
146 w, h, sstride, dstride, spatial, temporal, depth);
149 w, h, sstride, dstride, temporal, depth);
153 #define denoise(...) \
155 case 8: denoise_depth(__VA_ARGS__, 8); break;\
156 case 9: denoise_depth(__VA_ARGS__, 9); break;\
157 case 10: denoise_depth(__VA_ARGS__, 10); break;\
158 case 16: denoise_depth(__VA_ARGS__, 16); break;\
164 double gamma, simil,
C;
169 gamma = log(0.25) / log(1.0 -
FFMIN(dist25,252.0)/255.0 - 0.00001);
173 simil = 1.0 -
FFABS(f) / 255.0;
174 C = pow(simil, gamma) * 256.0 * f;
182 #define PARAM1_DEFAULT 4.0
183 #define PARAM2_DEFAULT 3.0
184 #define PARAM3_DEFAULT 6.0
266 for (i = 0; i < 4; i++) {
301 for (c = 0; c < 3; c++) {
322 #define OFFSET(x) offsetof(HQDN3DContext, x)
323 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
357 .priv_class = &hqdn3d_class,
361 .
inputs = avfilter_vf_hqdn3d_inputs,
362 .
outputs = avfilter_vf_hqdn3d_outputs,