summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonin Descampe <antonin@gmail.com>2011-07-03 17:56:49 +0000
committerAntonin Descampe <antonin@gmail.com>2011-07-03 17:56:49 +0000
commitfa6aea80f5b8fa6a21557f4e6696a1d320a538bf (patch)
treedae5da0c2b8a7a0fa67a0c1725e4bcc532783e79
parentb09051fd79da1101185a73198aac2d65cf2b2450 (diff)
fixed handling of "jp2->meth" value (Restricted ICC profile handling currently not implemented)
-rw-r--r--CHANGES3
-rw-r--r--applications/common/color.c3
-rw-r--r--libopenjpeg/jp2.c37
3 files changed, 19 insertions, 24 deletions
diff --git a/CHANGES b/CHANGES
index 252e7d35..a2763aab 100644
--- 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
diff --git a/applications/common/color.c b/applications/common/color.c
index ac0921a0..bda1f685 100644
--- a/applications/common/color.c
+++ b/applications/common/color.c
@@ -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);
diff --git a/libopenjpeg/jp2.c b/libopenjpeg/jp2.c
index cea826bb..ffbf270f 100644
--- a/libopenjpeg/jp2.c
+++ b/libopenjpeg/jp2.c
@@ -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 */