summaryrefslogtreecommitdiff
path: root/libavfilter
diff options
context:
space:
mode:
authorClément Bœsch <ubitux@gmail.com>2013-05-26 22:32:24 +0200
committerClément Bœsch <ubitux@gmail.com>2013-05-26 22:41:02 +0200
commitb439ece51cbf4d27bcd05826ed1adc86b9a6ef9b (patch)
tree9950fbf1e05217bee18a6fe3432df531040a9420 /libavfilter
parentbd89b2b22ac71aae4ec5c6a27adb88d877b7b76e (diff)
lavfi/dctdnoiz: move DC normalization out of loops.
Make code slightly faster, simpler, clearer. The filter is still slow as hell, and that change won't cause any visible performance improvement (it still takes more than one minute to process a single 1080p frame on a Core 2 here).
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/vf_dctdnoiz.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/libavfilter/vf_dctdnoiz.c b/libavfilter/vf_dctdnoiz.c
index 8de203c042..92129adafb 100644
--- a/libavfilter/vf_dctdnoiz.c
+++ b/libavfilter/vf_dctdnoiz.c
@@ -82,9 +82,10 @@ static float *dct_block(DCTdnoizContext *ctx, const float *src, int src_linesize
av_dct_calc(ctx->dct, line);
column = ctx->tmp_block + y;
- for (x = 0; x < BSIZE; x++) {
- *line *= x == 0 ? 1. / sqrt(BSIZE) : sqrt(2. / BSIZE);
- *column = *line++;
+ column[0] = line[0] * (1. / sqrt(BSIZE));
+ column += BSIZE;
+ for (x = 1; x < BSIZE; x++) {
+ *column = line[x] * sqrt(2. / BSIZE);
column += BSIZE;
}
}
@@ -92,8 +93,9 @@ static float *dct_block(DCTdnoizContext *ctx, const float *src, int src_linesize
column = ctx->tmp_block;
for (x = 0; x < BSIZE; x++) {
av_dct_calc(ctx->dct, column);
- for (y = 0; y < BSIZE; y++)
- column[y] *= y == 0 ? 1. / sqrt(BSIZE) : sqrt(2. / BSIZE);
+ column[0] *= 1. / sqrt(BSIZE);
+ for (y = 1; y < BSIZE; y++)
+ column[y] *= sqrt(2. / BSIZE);
column += BSIZE;
}
@@ -111,18 +113,18 @@ static void idct_block(DCTdnoizContext *ctx, float *dst, int dst_linesize)
float *tmp = ctx->tmp_block;
for (y = 0; y < BSIZE; y++) {
- for (x = 0; x < BSIZE; x++)
- block[x] *= x == 0 ? sqrt(BSIZE) : 1./sqrt(2. / BSIZE);
+ block[0] *= sqrt(BSIZE);
+ for (x = 1; x < BSIZE; x++)
+ block[x] *= 1./sqrt(2. / BSIZE);
av_dct_calc(ctx->idct, block);
block += BSIZE;
}
block = ctx->block;
for (y = 0; y < BSIZE; y++) {
- for (x = 0; x < BSIZE; x++) {
- tmp[x] = block[x*BSIZE + y];
- tmp[x] *= x == 0 ? sqrt(BSIZE) : 1./sqrt(2. / BSIZE);
- }
+ tmp[0] = block[y] * sqrt(BSIZE);
+ for (x = 1; x < BSIZE; x++)
+ tmp[x] = block[x*BSIZE + y] * (1./sqrt(2. / BSIZE));
av_dct_calc(ctx->idct, tmp);
for (x = 0; x < BSIZE; x++)
dst[x*dst_linesize + y] += tmp[x];