summaryrefslogtreecommitdiff
path: root/libavfilter
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2016-09-11 23:19:57 +0200
committerPaul B Mahol <onemda@gmail.com>2016-09-12 14:38:45 +0200
commitb791d0e4e0d148e399a21b3521d4b4a9ed5e8ae1 (patch)
tree3a29a95947da7a30bfbdcf5a0eec19b1216347d5 /libavfilter
parentdc669d5fbed20c2ceb68b45e3aafaefbf3c8871e (diff)
avfilter/vf_vaguedenoiser: calculate dimensions at init
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/vf_vaguedenoiser.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/libavfilter/vf_vaguedenoiser.c b/libavfilter/vf_vaguedenoiser.c
index 5b3c6da827..2b93e70e57 100644
--- a/libavfilter/vf_vaguedenoiser.c
+++ b/libavfilter/vf_vaguedenoiser.c
@@ -52,10 +52,10 @@ typedef struct VagueDenoiserContext {
float *out;
float *tmp;
- int hlowsize[32];
- int hhighsize[32];
- int vlowsize[32];
- int vhighsize[32];
+ int hlowsize[4][32];
+ int hhighsize[4][32];
+ int vlowsize[4][32];
+ int vhighsize[4][32];
void (*thresholding)(float *block, const int width, const int height,
const int stride, const float threshold,
@@ -132,7 +132,7 @@ static int config_input(AVFilterLink *inlink)
{
VagueDenoiserContext *s = inlink->dst->priv;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
- int nsteps_width, nsteps_height, nsteps_max;
+ int p, i, nsteps_width, nsteps_height, nsteps_max;
s->depth = desc->comp[0].depth;
s->nb_planes = desc->nb_components;
@@ -163,6 +163,20 @@ static int config_input(AVFilterLink *inlink)
s->nsteps = FFMIN(s->nsteps, nsteps_max - 2);
+ for (p = 0; p < 4; p++) {
+ s->hlowsize[p][0] = (s->planewidth[p] + 1) >> 1;
+ s->hhighsize[p][0] = s->planewidth[p] >> 1;
+ s->vlowsize[p][0] = (s->planeheight[p] + 1) >> 1;
+ s->vhighsize[p][0] = s->planeheight[p] >> 1;
+
+ for (i = 1; i < s->nsteps; i++) {
+ s->hlowsize[p][i] = (s->hlowsize[p][i - 1] + 1) >> 1;
+ s->hhighsize[p][i] = s->hlowsize[p][i - 1] >> 1;
+ s->vlowsize[p][i] = (s->vlowsize[p][i - 1] + 1) >> 1;
+ s->vhighsize[p][i] = s->vlowsize[p][i - 1] >> 1;
+ }
+ }
+
return 0;
}
@@ -441,21 +455,9 @@ static void filter(VagueDenoiserContext *s, AVFrame *in, AVFrame *out)
s->thresholding(s->block, width, height, width, s->threshold, s->percent, s->nsteps);
- s->hlowsize[0] = (width + 1) >> 1;
- s->hhighsize[0] = width >> 1;
- s->vlowsize[0] = (height + 1) >> 1;
- s->vhighsize[0] = height >> 1;
-
- for (i = 1; i < s->nsteps; i++) {
- s->hlowsize[i] = (s->hlowsize[i - 1] + 1) >> 1;
- s->hhighsize[i] = s->hlowsize[i - 1] >> 1;
- s->vlowsize[i] = (s->vlowsize[i - 1] + 1) >> 1;
- s->vhighsize[i] = s->vlowsize[i - 1] >> 1;
- }
-
while (nsteps_invert--) {
- const int idx = s->vlowsize[nsteps_invert] + s->vhighsize[nsteps_invert];
- const int idx2 = s->hlowsize[nsteps_invert] + s->hhighsize[nsteps_invert];
+ const int idx = s->vlowsize[p][nsteps_invert] + s->vhighsize[p][nsteps_invert];
+ const int idx2 = s->hlowsize[p][nsteps_invert] + s->hhighsize[p][nsteps_invert];
float * idx3 = s->block;
for (i = 0; i < idx2; i++) {
copyv(idx3, width, s->in + NPAD, idx);