[FFmpeg-soc] [soc]: r812 - in jpeg2000: j2k.c j2k.h j2kdec.c j2kenc.c

k.nowosad subversion at mplayerhq.hu
Wed Aug 15 14:08:39 CEST 2007


Author: k.nowosad
Date: Wed Aug 15 14:08:39 2007
New Revision: 812

Log:
added look-up tables for tier-1 functions in j2k.c


Modified:
   jpeg2000/j2k.c
   jpeg2000/j2k.h
   jpeg2000/j2kdec.c
   jpeg2000/j2kenc.c

Modified: jpeg2000/j2k.c
==============================================================================
--- jpeg2000/j2k.c	(original)
+++ jpeg2000/j2k.c	Wed Aug 15 14:08:39 2007
@@ -80,8 +80,15 @@ J2kTgtNode *ff_j2k_tag_tree_init(int w, 
     return res;
 }
 
+static uint8_t nbctxno_lut[256][4];
+
 int ff_j2k_getnbctxno(int flag, int bandno)
 {
+    return nbctxno_lut[flag&255][bandno];
+}
+
+static int getnbctxno(int flag, int bandno)
+{
     int h, v, d;
 
     h = ((flag & J2K_T1_SIG_E) ? 1:0)+
@@ -138,16 +145,20 @@ int ff_j2k_getnbctxno(int flag, int band
 
 int ff_j2k_getrefctxno(int flag)
 {
-    if (!(flag & J2K_T1_REF)){
-        if (flag & J2K_T1_SIG_NB)
-            return 15;
-        return 14;
-    }
-    return 16;
+    const uint8_t refctxno_lut[2][2] = {{14, 15}, {16, 16}};
+    return refctxno_lut[flag>>14][(flag & 255) != 0];
 }
 
+static uint8_t sgnctxno_lut[16][16], xorbit_lut[16][16];
+
 int ff_j2k_getsgnctxno(int flag, int *xorbit)
 {
+    *xorbit = xorbit_lut[flag&15][(flag>>8)&15];
+    return  sgnctxno_lut[flag&15][(flag>>8)&15];
+}
+
+static int getsgnctxno(int flag, uint8_t *xorbit)
+{
     int vcontrib, hcontrib;
     const int contribtab[3][3] = {{0, -1, 1}, {-1, -1, 0}, {1, 0, 1}};
     const int ctxlbltab[3][3] = {{13, 12, 11}, {10, 9, 10}, {11, 12, 13}};
@@ -161,6 +172,17 @@ int ff_j2k_getsgnctxno(int flag, int *xo
     return ctxlbltab[hcontrib][vcontrib];
 }
 
+void ff_j2k_init_tier1_luts()
+{
+    int i, j;
+    for (i = 0; i < 256; i++)
+        for (j = 0; j < 4; j++)
+            nbctxno_lut[i][j] = getnbctxno(i, j);
+    for (i = 0; i < 16; i++)
+        for (j = 0; j < 16; j++)
+            sgnctxno_lut[i][j] = getsgnctxno(i + (j << 8), &xorbit_lut[i][j]);
+}
+
 void ff_j2k_set_significant(J2kT1Context *t1, int x, int y)
 {
     x++; y++;

Modified: jpeg2000/j2k.h
==============================================================================
--- jpeg2000/j2k.h	(original)
+++ jpeg2000/j2k.h	Wed Aug 15 14:08:39 2007
@@ -121,6 +121,7 @@ J2kTgtNode *ff_j2k_tag_tree_init(int w, 
 int ff_j2k_getnbctxno(int flag, int bandno);
 int ff_j2k_getrefctxno(int flag);
 int ff_j2k_getsgnctxno(int flag, int *xorbit);
+void ff_j2k_init_tier1_luts();
 
 void ff_j2k_set_significant(J2kT1Context *t1, int x, int y);
 

Modified: jpeg2000/j2kdec.c
==============================================================================
--- jpeg2000/j2kdec.c	(original)
+++ jpeg2000/j2kdec.c	Wed Aug 15 14:08:39 2007
@@ -1109,6 +1109,8 @@ static int decode_frame(AVCodecContext *
 
     s->ppx = s->ppy = 15;
 
+    ff_j2k_init_tier1_luts();
+
     if (bytestream_get_be16(&s->buf) != J2K_SOC){
         av_log(avctx, AV_LOG_ERROR, "SOC marker not present\n");
         return -1;

Modified: jpeg2000/j2kenc.c
==============================================================================
--- jpeg2000/j2kenc.c	(original)
+++ jpeg2000/j2kenc.c	Wed Aug 15 14:08:39 2007
@@ -1065,6 +1065,8 @@ static int encode_frame(AVCodecContext *
     s->nguardbits = 1;
     s->lambda = s->picture->quality * LAMBDA_SCALE;
 
+    ff_j2k_init_tier1_luts();
+
     // TODO: other pixel formats
     for (i = 0; i < 3; i++)
         s->cbps[i] = 8;



More information about the FFmpeg-soc mailing list