]> granicus.if.org Git - openjpeg/commitdiff
fixed handling of "jp2->meth" value (Restricted ICC profile handling currently not...
authorAntonin Descampe <antonin@gmail.com>
Sun, 3 Jul 2011 17:56:49 +0000 (17:56 +0000)
committerAntonin Descampe <antonin@gmail.com>
Sun, 3 Jul 2011 17:56:49 +0000 (17:56 +0000)
CHANGES
applications/common/color.c
libopenjpeg/jp2.c

diff --git a/CHANGES b/CHANGES
index 252e7d355f2104cd7d83836afb3f567c28bb78ab..a2763aaba7e6917a780584880193c12f7be433cf 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,9 @@ What's New for OpenJPEG
 ! : changed
 + : added
 
+July 3, 2011
+* [antonin] fixed handling of "jp2->meth" value (Restricted ICC profile handling currently not implemented)
+
 June 30, 2011
 ! [antonin] fixed CTest configuration files
 
index ac0921a05ea3fb20969ad5b7497b1498ff885531..bda1f685d9b9f40d63c2ab19ba0c14261949240d 100644 (file)
@@ -289,6 +289,9 @@ void color_apply_icc_profile(opj_image_t *image)
 
        in_prof = 
         cmsOpenProfileFromMem(image->icc_profile_buf, image->icc_profile_len);
+
+       if(in_prof == NULL) return;
+
        in_space = cmsGetPCS(in_prof);
        out_space = cmsGetColorSpace(in_prof);
        intent = cmsGetHeaderRenderingIntent(in_prof);
index cea826bb6bc0b08638b26af8f073ffac237106d9..ffbf270fb6506b3e797567dcddb11555f8d02fc2 100644 (file)
@@ -281,11 +281,10 @@ static void jp2_write_colr(opj_jp2_t *jp2, opj_cio_t *cio) {
        cio_write(cio, jp2->precedence, 1);     /* PRECEDENCE */
        cio_write(cio, jp2->approx, 1);         /* APPROX */
 
-       if (jp2->meth == 1) {
-               cio_write(cio, jp2->enumcs, 4); /* EnumCS */
-       } else {
-               cio_write(cio, 0, 1);                   /* PROFILE (??) */
-       }
+       if(jp2->meth == 2)
+        jp2->enumcs = 0;
+
+       cio_write(cio, jp2->enumcs, 4); /* EnumCS */
 
        box.length = cio_tell(cio) - box.init_pos;
        cio_seek(cio, box.init_pos);
@@ -557,7 +556,8 @@ static opj_bool jp2_read_colr(opj_jp2_t *jp2, opj_cio_t *cio,
    {
        jp2->enumcs = cio_read(cio, 4); /* EnumCS */
    } 
-       else 
+       else
+       if (jp2->meth == 2) 
    {
 /* skip PROFILE */
        skip_len = box->init_pos + box->length - cio_tell(cio);
@@ -1042,24 +1042,13 @@ void jp2_setup_encoder(opj_jp2_t *jp2, opj_cparameters_t *parameters, opj_image_
        for (i = 0; i < image->numcomps; i++) {
                jp2->comps[i].bpcc = image->comps[i].prec - 1 + (image->comps[i].sgnd << 7);
        }
-
-       /* Colour Specification box */
-
-       if ((image->numcomps == 1 || image->numcomps == 3) && (jp2->bpc != 255)) {
-               jp2->meth = 1;  /* METH: Enumerated colourspace */
-       } else {
-               jp2->meth = 2;  /* METH: Restricted ICC profile */
-       }
-       if (jp2->meth == 1) {
-               if (image->color_space == 1)
-                       jp2->enumcs = 16;       /* sRGB as defined by IEC 61966-2.1 */
-               else if (image->color_space == 2)
-                       jp2->enumcs = 17;       /* greyscale */
-               else if (image->color_space == 3)
-                       jp2->enumcs = 18;       /* YUV */
-       } else {
-               jp2->enumcs = 0;                /* PROFILE (??) */
-       }
+       jp2->meth = 1;
+       if (image->color_space == 1)
+               jp2->enumcs = 16;       /* sRGB as defined by IEC 61966-2.1 */
+       else if (image->color_space == 2)
+               jp2->enumcs = 17;       /* greyscale */
+       else if (image->color_space == 3)
+               jp2->enumcs = 18;       /* YUV */
        jp2->precedence = 0;    /* PRECEDENCE */
        jp2->approx = 0;                /* APPROX */