- if (prec <= 8) {
- unsigned char *inbuf, *outbuf, *in, *out;
-
- max = max_w * max_h;
- nr_samples = (size_t)(max * 3U * sizeof(unsigned char));
- in = inbuf = (unsigned char*)opj_image_data_alloc(nr_samples);
- out = outbuf = (unsigned char*)opj_image_data_alloc(nr_samples);
-
- if (inbuf == NULL || outbuf == NULL) {
- goto fails0;
- }
-
- r = image->comps[0].data;
- g = image->comps[1].data;
- b = image->comps[2].data;
-
- for (i = 0U; i < max; ++i) {
- *in++ = (unsigned char) * r++;
- *in++ = (unsigned char) * g++;
- *in++ = (unsigned char) * b++;
- }
-
- cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
-
- r = image->comps[0].data;
- g = image->comps[1].data;
- b = image->comps[2].data;
-
- for (i = 0U; i < max; ++i) {
- *r++ = (int) * out++;
- *g++ = (int) * out++;
- *b++ = (int) * out++;
- }
- ok = 1;
+ if ((image->comps[0].w == image->comps[1].w &&
+ image->comps[0].w == image->comps[2].w) &&
+ (image->comps[0].h == image->comps[1].h &&
+ image->comps[0].h == image->comps[2].h)) {
+ if (prec <= 8) {
+ unsigned char *inbuf, *outbuf, *in, *out;
+
+ max = max_w * max_h;
+ nr_samples = (size_t)(max * 3U * sizeof(unsigned char));
+ in = inbuf = (unsigned char*)opj_image_data_alloc(nr_samples);
+ out = outbuf = (unsigned char*)opj_image_data_alloc(nr_samples);
+
+ if (inbuf == NULL || outbuf == NULL) {
+ goto fails0;
+ }
+
+ r = image->comps[0].data;
+ g = image->comps[1].data;
+ b = image->comps[2].data;
+
+ for (i = 0U; i < max; ++i) {
+ *in++ = (unsigned char) * r++;
+ *in++ = (unsigned char) * g++;
+ *in++ = (unsigned char) * b++;
+ }
+
+ cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
+
+ r = image->comps[0].data;
+ g = image->comps[1].data;
+ b = image->comps[2].data;
+
+ for (i = 0U; i < max; ++i) {
+ *r++ = (int) * out++;
+ *g++ = (int) * out++;
+ *b++ = (int) * out++;
+ }
+ ok = 1;