Lines Matching refs:dec

87 static void jp2_dec_destroy(jp2_dec_t *dec);
101 jp2_dec_t *dec;
119 dec = 0;
123 if (!(dec = jp2_dec_create())) {
165 if (!dec->ihdr) {
166 dec->ihdr = box;
171 if (!dec->bpcc) {
172 dec->bpcc = box;
177 if (!dec->cdef) {
178 dec->cdef = box;
183 if (!dec->pclr) {
184 dec->pclr = box;
189 if (!dec->cmap) {
190 dec->cmap = box;
195 if (!dec->colr) {
196 dec->colr = box;
215 if (!(dec->image = jpc_decode(in, optstr))) {
221 if (!dec->ihdr) {
228 if (dec->ihdr->data.ihdr.numcmpts != JAS_CAST(uint, jas_image_numcmpts(dec->image))) {
233 if (!jas_image_numcmpts(dec->image)) {
240 dtype = jas_image_cmptdtype(dec->image, 0);
241 for (i = 1; i < JAS_CAST(uint, jas_image_numcmpts(dec->image)); ++i) {
242 if (jas_image_cmptdtype(dec->image, i) != dtype) {
250 if ((samedtype && dec->ihdr->data.ihdr.bpc != JP2_DTYPETOBPC(dtype)) ||
251 (!samedtype && dec->ihdr->data.ihdr.bpc != JP2_IHDR_BPCNULL)) {
256 if (dec->ihdr->data.ihdr.comptype != JP2_IHDR_COMPTYPE) {
261 if (dec->bpcc) {
264 if (dec->bpcc->data.bpcc.numcmpts != JAS_CAST(uint, jas_image_numcmpts(
265 dec->image))) {
271 for (i = 0; i < JAS_CAST(uint, jas_image_numcmpts(dec->image)); ++i) {
272 if (jas_image_cmptdtype(dec->image, i) != JP2_BPCTODTYPE(dec->bpcc->data.bpcc.bpcs[i])) {
282 if (!dec->colr) {
287 switch (dec->colr->data.colr.method) {
289 jas_image_setclrspc(dec->image, jp2_getcs(&dec->colr->data.colr));
292 iccprof = jas_iccprof_createfrombuf(dec->colr->data.colr.iccp,
293 dec->colr->data.colr.iccplen);
297 jas_image_setclrspc(dec->image, fromiccpcs(icchdr.colorspc));
298 dec->image->cmprof_ = jas_cmprof_createfromiccprof(iccprof);
299 assert(dec->image->cmprof_);
305 if (dec->cmap && !dec->pclr) {
307 jp2_box_destroy(dec->cmap);
308 dec->cmap = 0;
312 if (!dec->cmap && dec->pclr) {
314 jp2_box_destroy(dec->pclr);
315 dec->pclr = 0;
320 dec->numchans = dec->cmap ? dec->cmap->data.cmap.numchans : JAS_CAST(uint, jas_image_numcmpts(dec->image));
323 if (dec->cmap) {
324 for (i = 0; i < dec->numchans; ++i) {
326 if (dec->cmap->data.cmap.ents[i].cmptno >= JAS_CAST(uint, jas_image_numcmpts(dec->image))) {
331 if (dec->cmap->data.cmap.ents[i].pcol >= dec->pclr->data.pclr.numchans) {
339 if (!(dec->chantocmptlut = jas_alloc2(dec->numchans, sizeof(uint_fast16_t)))) {
344 if (!dec->cmap) {
345 for (i = 0; i < dec->numchans; ++i) {
346 dec->chantocmptlut[i] = i;
349 cmapd = &dec->cmap->data.cmap;
350 pclrd = &dec->pclr->data.pclr;
351 cdefd = &dec->cdef->data.cdef;
355 dec->chantocmptlut[channo] = channo;
361 newcmptno = jas_image_numcmpts(dec->image);
362 jas_image_depalettize(dec->image, cmapent->cmptno, pclrd->numlutents, lutents, JP2_BPCTODTYPE(pclrd->bpc[cmapent->pcol]), newcmptno);
363 dec->chantocmptlut[channo] = newcmptno;
366 if (dec->cdef) {
371 jas_image_setcmpttype(dec->image, newcmptno, jp2_getct(jas_image_clrspc(dec->image), cdefent->type, cdefent->assoc));
373 jas_image_setcmpttype(dec->image, newcmptno, jp2_getct(jas_image_clrspc(dec->image), 0, channo + 1));
382 for (i = 0; i < JAS_CAST(uint, jas_image_numcmpts(dec->image)); ++i) {
383 jas_image_setcmpttype(dec->image, i, JAS_IMAGE_CT_UNKNOWN);
387 if (dec->cdef) {
388 for (i = 0; i < dec->numchans; ++i) {
389 jas_image_setcmpttype(dec->image,
390 dec->chantocmptlut[dec->cdef->data.cdef.ents[i].channo],
391 jp2_getct(jas_image_clrspc(dec->image),
392 dec->cdef->data.cdef.ents[i].type, dec->cdef->data.cdef.ents[i].assoc));
395 for (i = 0; i < dec->numchans; ++i) {
396 jas_image_setcmpttype(dec->image, dec->chantocmptlut[i],
397 jp2_getct(jas_image_clrspc(dec->image), 0, i + 1));
402 for (i = jas_image_numcmpts(dec->image); i > 0; --i) {
403 if (jas_image_cmpttype(dec->image, i - 1) == JAS_IMAGE_CT_UNKNOWN) {
404 jas_image_delcmpt(dec->image, i - 1);
409 if (!jas_image_numcmpts(dec->image)) {
414 jas_eprintf("no of components is %d\n", jas_image_numcmpts(dec->image));
418 image = dec->image;
419 dec->image = 0;
421 jp2_dec_destroy(dec);
429 if (dec) {
430 jp2_dec_destroy(dec);
478 jp2_dec_t *dec;
480 if (!(dec = jas_malloc(sizeof(jp2_dec_t)))) {
483 dec->ihdr = 0;
484 dec->bpcc = 0;
485 dec->cdef = 0;
486 dec->pclr = 0;
487 dec->image = 0;
488 dec->chantocmptlut = 0;
489 dec->cmap = 0;
490 dec->colr = 0;
491 return dec;
494 static void jp2_dec_destroy(jp2_dec_t *dec)
496 if (dec->ihdr) {
497 jp2_box_destroy(dec->ihdr);
499 if (dec->bpcc) {
500 jp2_box_destroy(dec->bpcc);
502 if (dec->cdef) {
503 jp2_box_destroy(dec->cdef);
505 if (dec->pclr) {
506 jp2_box_destroy(dec->pclr);
508 if (dec->image) {
509 jas_image_destroy(dec->image);
511 if (dec->cmap) {
512 jp2_box_destroy(dec->cmap);
514 if (dec->colr) {
515 jp2_box_destroy(dec->colr);
517 if (dec->chantocmptlut) {
518 jas_free(dec->chantocmptlut);
520 jas_free(dec);