aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-06-22 02:46:35 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-06-22 03:01:24 +0200
commit4e926fb969acbb27415c2109d7339259875b6909 (patch)
tree3c5d53ef58d42b7161d9c2f1dd27626e6b6e565b
parentb1fdf81c6eed786742c08037a9aa662ef7967ab2 (diff)
downloadffmpeg-4e926fb969acbb27415c2109d7339259875b6909.tar.gz
avcodec/jpeg2000: Move L band scaling from the 9/7f wavelet to quantization stage
This reduces the number of operations Its not done for 9/7i as that would overflow thanks to JPEG2000 allowing 32 decomposition levels Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/jpeg2000.c5
-rw-r--r--libavcodec/jpeg2000dwt.c8
2 files changed, 9 insertions, 4 deletions
diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index b61e8fec33..b333aad568 100644
--- a/libavcodec/jpeg2000.c
+++ b/libavcodec/jpeg2000.c
@@ -315,15 +315,20 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
break;
}
if (codsty->transform != FF_DWT53) {
+ int lband = 0;
switch (bandno + (reslevelno > 0)) {
case 1:
case 2:
band->f_stepsize *= F_LFTG_X * 2;
+ lband = 1;
break;
case 3:
band->f_stepsize *= F_LFTG_X * F_LFTG_X * 4;
break;
}
+ if (codsty->transform == FF_DWT97) {
+ band->f_stepsize *= pow(F_LFTG_K, 2*(codsty->nreslevels2decode - reslevelno) + lband - 2);
+ }
}
/* FIXME: In openjepg code stespize = stepsize * 0.5. Why?
* If not set output of entropic decoder is not correct. */
diff --git a/libavcodec/jpeg2000dwt.c b/libavcodec/jpeg2000dwt.c
index dff2516d11..4201fc6e8d 100644
--- a/libavcodec/jpeg2000dwt.c
+++ b/libavcodec/jpeg2000dwt.c
@@ -196,7 +196,7 @@ static void dwt_encode97_float(DWTContext *s, float *t)
// copy back and deinterleave
for (i = mh; i < lh; i+=2, j++)
- t[w*lp + j] = F_LFTG_X * l[i];
+ t[w*lp + j] = l[i];
for (i = 1-mh; i < lh; i+=2, j++)
t[w*lp + j] = l[i];
}
@@ -213,7 +213,7 @@ static void dwt_encode97_float(DWTContext *s, float *t)
// copy back and deinterleave
for (i = mv; i < lv; i+=2, j++)
- t[w*j + lp] = F_LFTG_X * l[i];
+ t[w*j + lp] = l[i];
for (i = 1-mv; i < lv; i+=2, j++)
t[w*j + lp] = l[i];
}
@@ -421,7 +421,7 @@ static void dwt_decode97_float(DWTContext *s, float *t)
int i, j = 0;
// copy with interleaving
for (i = mh; i < lh; i += 2, j++)
- l[i] = data[w * lp + j] * F_LFTG_K;
+ l[i] = data[w * lp + j];
for (i = 1 - mh; i < lh; i += 2, j++)
l[i] = data[w * lp + j];
@@ -437,7 +437,7 @@ static void dwt_decode97_float(DWTContext *s, float *t)
int i, j = 0;
// copy with interleaving
for (i = mv; i < lv; i += 2, j++)
- l[i] = data[w * j + lp] * F_LFTG_K;
+ l[i] = data[w * j + lp];
for (i = 1 - mv; i < lv; i += 2, j++)
l[i] = data[w * j + lp];