Backport of upstream commit: From dee11ec440d7908d1daf69f40a3324b27cf213ba Mon Sep 17 00:00:00 2001 From: Michael Adams Date: Mon, 24 Oct 2016 07:26:40 -0700 Subject: [PATCH] The component domains must be the same for the ICT/RCT in the JPC codec. This was previously enforced with an assertion. Now, it is handled in a more graceful manner. diff -pruN jasper-1.900.1.orig/src/libjasper/jpc/jpc_dec.c jasper-1.900.1/src/libjasper/jpc/jpc_dec.c --- jasper-1.900.1.orig/src/libjasper/jpc/jpc_dec.c 2017-03-31 22:20:39.000000000 +0200 +++ jasper-1.900.1/src/libjasper/jpc/jpc_dec.c 2017-03-31 22:48:55.368931732 +0200 @@ -1014,6 +1014,24 @@ if (!prc->cblks) { return 0; } +static int jas_image_cmpt_domains_same(jas_image_t *image) +{ + int cmptno; + jas_image_cmpt_t *cmpt; + jas_image_cmpt_t *cmpt0; + + cmpt0 = image->cmpts_[0]; + for (cmptno = 1; cmptno < image->numcmpts_; ++cmptno) { + cmpt = image->cmpts_[cmptno]; + if (cmpt->tlx_ != cmpt0->tlx_ || cmpt->tly_ != cmpt0->tly_ || + cmpt->hstep_ != cmpt0->hstep_ || cmpt->vstep_ != cmpt0->vstep_ || + cmpt->width_ != cmpt0->width_ || cmpt->height_ != cmpt0->height_) { + return 0; + } + } + return 1; +} + static int jpc_dec_tiledecode(jpc_dec_t *dec, jpc_dec_tile_t *tile) { int i; @@ -1074,6 +1092,10 @@ static int jpc_dec_tiledecode(jpc_dec_t jas_eprintf("RCT requires at least three components\n"); return -1; } + if (!jas_image_cmpt_domains_same(dec->image)) { + jas_eprintf("RCT requires all components have the same domain\n"); + return -1; + } jpc_irct(tile->tcomps[0].data, tile->tcomps[1].data, tile->tcomps[2].data); break; @@ -1082,6 +1104,10 @@ static int jpc_dec_tiledecode(jpc_dec_t jas_eprintf("ICT requires at least three components\n"); return -1; } + if (!jas_image_cmpt_domains_same(dec->image)) { + jas_eprintf("RCT requires all components have the same domain\n"); + return -1; + } jpc_iict(tile->tcomps[0].data, tile->tcomps[1].data, tile->tcomps[2].data); break;