[FFmpeg-cvslog] avcodec/jpeg2000: Move L band scaling from the 9/ 7f wavelet to quantization stage

Michael Niedermayer git at videolan.org
Mon Jun 22 03:17:20 CEST 2015


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Mon Jun 22 02:46:35 2015 +0200| [4e926fb969acbb27415c2109d7339259875b6909] | committer: Michael Niedermayer

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 at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4e926fb969acbb27415c2109d7339259875b6909
---

 libavcodec/jpeg2000.c    |    5 +++++
 libavcodec/jpeg2000dwt.c |    8 ++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index b61e8fe..b333aad 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 dff2516..4201fc6 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];
 



More information about the ffmpeg-cvslog mailing list