33 #define BSIZE (1<<(NBITS))
35 static const char *
const var_names[] = {
"c", NULL };
49 float color_dct[3][3];
59 #define OFFSET(x) offsetof(DCTdnoizContext, x)
60 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
77 for (y = 0; y <
BSIZE; y++) {
80 memcpy(line, src, BSIZE *
sizeof(*line));
85 column[0] = line[0] * (1. / sqrt(BSIZE));
87 for (x = 1; x <
BSIZE; x++) {
88 *column = line[x] * sqrt(2. / BSIZE);
94 for (x = 0; x <
BSIZE; x++) {
96 column[0] *= 1. / sqrt(BSIZE);
97 for (y = 1; y <
BSIZE; y++)
98 column[y] *= sqrt(2. / BSIZE);
102 for (y = 0; y <
BSIZE; y++)
103 for (x = 0; x <
BSIZE; x++)
115 for (y = 0; y <
BSIZE; y++) {
116 block[0] *= sqrt(BSIZE);
117 for (x = 1; x <
BSIZE; x++)
118 block[x] *= 1./sqrt(2. / BSIZE);
124 for (y = 0; y <
BSIZE; y++) {
125 tmp[0] = block[
y] * sqrt(BSIZE);
126 for (x = 1; x <
BSIZE; x++)
127 tmp[x] = block[x*BSIZE + y] * (1./sqrt(2. / BSIZE));
129 for (x = 0; x <
BSIZE; x++)
130 dst[x*dst_linesize + y] += tmp[x];
138 int i, x,
y, bx, by, linesize, *iweights;
139 const float dct_3x3[3][3] = {
140 { 1./sqrt(3), 1./sqrt(3), 1./sqrt(3) },
141 { 1./sqrt(2), 0, -1./sqrt(2) },
142 { 1./sqrt(6), -2./sqrt(6), 1./sqrt(6) },
147 for (y = 0; y < 3; y++)
148 for (x = 0; x < 3; x++)
149 s->
color_dct[y][x] = dct_3x3[rgba_map[y]][rgba_map[x]];
161 for (i = 0; i < 2; i++) {
177 for (by = 0; by <
BSIZE; by++)
178 for (bx = 0; bx <
BSIZE; bx++)
179 iweights[(y + by)*linesize + x + bx]++;
182 s->
weights[y*linesize + x] = 1. / iweights[y*linesize + x];
194 NULL, NULL, NULL, NULL, 0, ctx);
223 const uint8_t *
src,
int src_linesize,
int w,
int h)
226 float *dstp_r = dst[0];
227 float *dstp_g = dst[1];
228 float *dstp_b = dst[2];
230 for (y = 0; y < h; y++) {
233 for (x = 0; x < w; x++) {
234 dstp_r[x] = srcp[0] * dct3ch[0][0] + srcp[1] * dct3ch[0][1] + srcp[2] * dct3ch[0][2];
235 dstp_g[x] = srcp[0] * dct3ch[1][0] + srcp[1] * dct3ch[1][1] + srcp[2] * dct3ch[1][2];
236 dstp_b[x] = srcp[0] * dct3ch[2][0] + srcp[1] * dct3ch[2][1] + srcp[2] * dct3ch[2][2];
240 dstp_r += dst_linesize;
241 dstp_g += dst_linesize;
242 dstp_b += dst_linesize;
247 float **
src,
int src_linesize,
int w,
int h)
250 const float *src_r = src[0];
251 const float *src_g = src[1];
252 const float *src_b = src[2];
254 for (y = 0; y < h; y++) {
257 for (x = 0; x < w; x++) {
258 dstp[0] = av_clip_uint8(src_r[x] * dct3ch[0][0] + src_g[x] * dct3ch[1][0] + src_b[x] * dct3ch[2][0]);
259 dstp[1] = av_clip_uint8(src_r[x] * dct3ch[0][1] + src_g[x] * dct3ch[1][1] + src_b[x] * dct3ch[2][1]);
260 dstp[2] = av_clip_uint8(src_r[x] * dct3ch[0][2] + src_g[x] * dct3ch[1][2] + src_b[x] * dct3ch[2][2]);
264 src_r += src_linesize;
265 src_g += src_linesize;
266 src_b += src_linesize;
271 float *dst,
int dst_linesize,
272 const float *
src,
int src_linesize,
278 const float *weights = s->
weights;
281 memset(dst, 0, h * dst_linesize *
sizeof(*dst));
284 for (y = 0; y < h -
BSIZE + 1; y += s->
step) {
285 for (x = 0; x < w - BSIZE + 1; x += s->
step) {
286 float *ftb =
dct_block(s, src + x, src_linesize);
289 for (by = 0; by <
BSIZE; by++) {
290 for (bx = 0; bx <
BSIZE; bx++) {
296 for (by = 0; by <
BSIZE; by++) {
297 for (bx = 0; bx <
BSIZE; bx++) {
306 src += s->
step * src_linesize;
307 dst += s->
step * dst_linesize;
312 for (y = 0; y < h; y++) {
313 for (x = 0; x < w; x++)
314 dst[x] *= weights[x];
316 weights += dst_linesize;
343 for (plane = 0; plane < 3; plane++)
354 const int dst_linesize = out->
linesize[0];
355 const int src_linesize = in->
linesize[0];
356 const int hpad = (inlink->
w - s->
pr_width) * 3;
364 memcpy(dstp, srcp, hpad);
365 dstp += dst_linesize;
366 srcp += src_linesize;
373 for (y = 0; y < vpad; y++) {
374 memcpy(dstp, srcp, inlink->
w * 3);
375 dstp += dst_linesize;
376 srcp += src_linesize;
396 for (i = 0; i < 2; i++) {
429 .
inputs = dctdnoiz_inputs,
431 .priv_class = &dctdnoiz_class,