[trunk] As per T.809 code block are not shifted in JP3D
authorMathieu Malaterre <mathieu.malaterre@gmail.com>
Wed, 28 Nov 2012 13:06:02 +0000 (13:06 +0000)
committerMathieu Malaterre <mathieu.malaterre@gmail.com>
Wed, 28 Nov 2012 13:06:02 +0000 (13:06 +0000)
Table A.7
3D code-block width, height and depth exponent values xcb = value, ycb = value
or zcb = value.
NOTE – This redefines Rec. ITU-T T.800 | ISO/IEC 15444-1 significantly! The 3D
code-block width, height and depth are limited to powers of two with the minimum
size being 20 and the maximum being 210.
Further, the 3D code-block size is restricted so that 4 ≤ xcb+ycb+zcb ≤ 18.

src/lib/openjp3d/jp3d.c

index c21d74420d1ea59c5e9ca4e22eb116227a03963c..de4b226685db49826fc8116c29a25b417037bc3e 100755 (executable)
@@ -809,6 +809,7 @@ static void j3d_read_com(opj_j3d_t *j3d) {
 \r
 static void j3d_write_cox(opj_j3d_t *j3d, int compno) {\r
        int i;\r
+  int shift = 2;\r
 \r
        opj_cp_t *cp = j3d->cp;\r
        opj_tcp_t *tcp = &cp->tcps[j3d->curtileno];\r
@@ -820,11 +821,15 @@ static void j3d_write_cox(opj_j3d_t *j3d, int compno) {
                cio_write(cio, tccp->numresolution[1] - 1, 1);  /* SPcox (E) No of decomposition levels in y-axis*/\r
                cio_write(cio, tccp->numresolution[2] - 1, 1);  /* SPcox (F) No of decomposition levels in z-axis*/\r
        }\r
+       if (j3d->cinfo->codec_format == CODEC_J3D) {\r
+    /* Table A.7 */\r
+    shift = 0;\r
+  }\r
        /* (cblkw - 2) + (cblkh - 2) + (cblkl - 2) <= 18*/\r
-       cio_write(cio, tccp->cblk[0] - 2, 1);                           /* SPcox (G) Cblk width entre 10 y 2 (8 y 0)*/\r
-       cio_write(cio, tccp->cblk[1] - 2, 1);                           /* SPcox (H) Cblk height*/\r
+       cio_write(cio, tccp->cblk[0] - shift, 1);                               /* SPcox (G) Cblk width entre 10 y 2 (8 y 0)*/\r
+       cio_write(cio, tccp->cblk[1] - shift, 1);                               /* SPcox (H) Cblk height*/\r
        if (j3d->cinfo->codec_format == CODEC_J3D) {\r
-               cio_write(cio, tccp->cblk[2] - 2, 1);                   /* SPcox (I) Cblk depth*/\r
+               cio_write(cio, tccp->cblk[2] - shift, 1);                       /* SPcox (I) Cblk depth*/\r
        }\r
        cio_write(cio, tccp->cblksty, 1);                               /* SPcox (J) Cblk style*/\r
        cio_write(cio, tccp->dwtid[0], 1);                              /* SPcox (K) WT in x-axis 15444-2 Table A10*/\r
@@ -847,6 +852,7 @@ static void j3d_write_cox(opj_j3d_t *j3d, int compno) {
 \r
 static void j3d_read_cox(opj_j3d_t *j3d, int compno) {\r
        int i;\r
+  int shift = 2;\r
 \r
        opj_cp_t *cp = j3d->cp;\r
        opj_tcp_t *tcp = j3d->state == J3D_STATE_TPH ? &cp->tcps[j3d->curtileno] : j3d->default_tcp;\r
@@ -866,10 +872,14 @@ static void j3d_read_cox(opj_j3d_t *j3d, int compno) {
        cp->reduce[1] = int_min((tccp->numresolution[1])-1, cp->reduce[1]);\r
        cp->reduce[2] = int_min((tccp->numresolution[2])-1, cp->reduce[2]);\r
        \r
-       tccp->cblk[0] = cio_read(cio, 1) + 2;   /* SPcox (G) */\r
-       tccp->cblk[1] = cio_read(cio, 1) + 2;   /* SPcox (H) */\r
+  if (j3d->cinfo->codec_format == CODEC_J3D) {\r
+    /* Table A.7 */\r
+    shift = 0;\r
+  }\r
+       tccp->cblk[0] = cio_read(cio, 1) + shift;       /* SPcox (G) */\r
+       tccp->cblk[1] = cio_read(cio, 1) + shift;       /* SPcox (H) */\r
        if (j3d->cinfo->codec_format == CODEC_J3D)\r
-               tccp->cblk[2] = cio_read(cio, 1) + 2;   /* SPcox (I) */\r
+               tccp->cblk[2] = cio_read(cio, 1) + shift;       /* SPcox (I) */\r
        else\r
                tccp->cblk[2] = tccp->cblk[0];\r
 \r