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;
136 *frame_ant_ptr = frame_ant =
av_malloc(w*h*
sizeof(uint16_t));
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);
152 #define denoise(...) \
154 case 8: denoise_depth(__VA_ARGS__, 8); break;\
155 case 9: denoise_depth(__VA_ARGS__, 9); break;\
156 case 10: denoise_depth(__VA_ARGS__, 10); break;\
157 case 16: denoise_depth(__VA_ARGS__, 16); break;\
163 double gamma, simil,
C;
168 gamma = log(0.25) / log(1.0 -
FFMIN(dist25,252.0)/255.0 - 0.00001);
172 simil = 1.0 -
FFABS(f) / 255.0;
173 C = pow(simil, gamma) * 256.0 * f;
181 #define PARAM1_DEFAULT 4.0
182 #define PARAM2_DEFAULT 3.0
183 #define PARAM3_DEFAULT 6.0
265 for (i = 0; i < 4; i++) {
300 for (c = 0; c < 3; c++) {
321 #define OFFSET(x) offsetof(HQDN3DContext, x)
322 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
356 .priv_class = &hqdn3d_class,
360 .
inputs = avfilter_vf_hqdn3d_inputs,
361 .
outputs = avfilter_vf_hqdn3d_outputs,