2 * The copyright in this software is being made available under the 2-clauses
3 * BSD License, included below. This software may be subject to other third
4 * party and contributor rights, including patent rights, and no such rights
5 * are granted under this license.
7 * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
8 * Copyright (c) 2002-2014, Professor Benoit Macq
9 * Copyright (c) 2001-2003, David Janssens
10 * Copyright (c) 2002-2003, Yannick Verschueren
11 * Copyright (c) 2003-2007, Francois-Olivier Devaux
12 * Copyright (c) 2003-2014, Antonin Descampe
13 * Copyright (c) 2005, Herve Drolon, FreeImage Team
14 * All rights reserved.
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
38 #include "opj_includes.h"
40 /** @defgroup T2 T2 - Implementation of a tier-2 coding */
43 /** @name Local static functions */
46 static void t2_putcommacode(opj_bio_t *bio, int n);
47 static int t2_getcommacode(opj_bio_t *bio);
49 Variable length code for signalling delta Zil (truncation point)
50 @param bio Bit Input/Output component
53 static void t2_putnumpasses(opj_bio_t *bio, int n);
54 static int t2_getnumpasses(opj_bio_t *bio);
56 Encode a packet of a tile to a destination buffer
57 @param tile Tile for which to write the packets
58 @param tcp Tile coding parameters
59 @param pi Packet identity
60 @param dest Destination buffer
61 @param len Length of the destination buffer
62 @param cstr_info Codestream information structure
63 @param tileno Number of the tile encoded
66 static int t2_encode_packet(opj_tcd_tile_t *tile, opj_tcp_t *tcp,
67 opj_pi_iterator_t *pi, unsigned char *dest, int len,
68 opj_codestream_info_t *cstr_info, int tileno);
75 static opj_bool t2_init_seg(opj_tcd_cblk_dec_t* cblk, int index, int cblksty,
78 Decode a packet of a tile from a source buffer
80 @param src Source buffer
81 @param len Length of the source buffer
82 @param tile Tile for which to write the packets
83 @param tcp Tile coding parameters
84 @param pi Packet identity
85 @param pack_info Packet information
88 static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len,
90 opj_tcp_t *tcp, opj_pi_iterator_t *pi, opj_packet_info_t *pack_info);
96 /* ----------------------------------------------------------------------- */
98 /* #define RESTART 0x04 */
100 static void t2_putcommacode(opj_bio_t *bio, int n)
103 bio_write(bio, 1, 1);
105 bio_write(bio, 0, 1);
108 static int t2_getcommacode(opj_bio_t *bio)
111 for (n = 0; bio_read(bio, 1); n++) {
117 static void t2_putnumpasses(opj_bio_t *bio, int n)
120 bio_write(bio, 0, 1);
122 bio_write(bio, 2, 2);
124 bio_write(bio, 0xc | (n - 3), 4);
125 } else if (n <= 36) {
126 bio_write(bio, 0x1e0 | (n - 6), 9);
127 } else if (n <= 164) {
128 bio_write(bio, 0xff80 | (n - 37), 16);
132 static int t2_getnumpasses(opj_bio_t *bio)
135 if (!bio_read(bio, 1)) {
138 if (!bio_read(bio, 1)) {
141 if ((n = bio_read(bio, 2)) != 3) {
144 if ((n = bio_read(bio, 5)) != 31) {
147 return (37 + bio_read(bio, 7));
150 static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp,
151 opj_pi_iterator_t *pi, unsigned char *dest, int length,
152 opj_codestream_info_t *cstr_info, int tileno)
155 unsigned char *c = dest;
157 int compno = pi->compno; /* component value */
158 int resno = pi->resno; /* resolution level value */
159 int precno = pi->precno; /* precinct value */
160 int layno = pi->layno; /* quality layer value */
162 opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
163 opj_tcd_resolution_t *res = &tilec->resolutions[resno];
165 opj_bio_t *bio = NULL; /* BIO component */
168 if (tcp->csty & J2K_CP_CSTY_SOP) {
173 c[4] = (unsigned char)((tile->packno % 65536) / 256);
174 c[5] = (unsigned char)((tile->packno % 65536) % 256);
180 for (bandno = 0; bandno < res->numbands; bandno++) {
181 opj_tcd_band_t *band = &res->bands[bandno];
182 opj_tcd_precinct_t *prc = &band->precincts[precno];
183 tgt_reset(prc->incltree);
184 tgt_reset(prc->imsbtree);
185 for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
186 opj_tcd_cblk_enc_t* cblk = &prc->cblks.enc[cblkno];
188 tgt_setvalue(prc->imsbtree, cblkno, band->numbps - cblk->numbps);
194 bio_init_enc(bio, c, length);
195 bio_write(bio, 1, 1); /* Empty header bit */
197 /* Writing Packet header */
198 for (bandno = 0; bandno < res->numbands; bandno++) {
199 opj_tcd_band_t *band = &res->bands[bandno];
200 opj_tcd_precinct_t *prc = &band->precincts[precno];
201 for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
202 opj_tcd_cblk_enc_t* cblk = &prc->cblks.enc[cblkno];
203 opj_tcd_layer_t *layer = &cblk->layers[layno];
204 if (!cblk->numpasses && layer->numpasses) {
205 tgt_setvalue(prc->incltree, cblkno, layno);
208 for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
209 opj_tcd_cblk_enc_t* cblk = &prc->cblks.enc[cblkno];
210 opj_tcd_layer_t *layer = &cblk->layers[layno];
214 /* cblk inclusion bits */
215 if (!cblk->numpasses) {
216 tgt_encode(bio, prc->incltree, cblkno, layno + 1);
218 bio_write(bio, layer->numpasses != 0, 1);
220 /* if cblk not included, go to the next cblk */
221 if (!layer->numpasses) {
224 /* if first instance of cblk --> zero bit-planes information */
225 if (!cblk->numpasses) {
226 cblk->numlenbits = 3;
227 tgt_encode(bio, prc->imsbtree, cblkno, 999);
229 /* number of coding passes included */
230 t2_putnumpasses(bio, layer->numpasses);
232 /* computation of the increase of the length indicator and insertion in the header */
233 for (passno = cblk->numpasses; passno < cblk->numpasses + layer->numpasses;
235 opj_tcd_pass_t *pass = &cblk->passes[passno];
238 if (pass->term || passno == (cblk->numpasses + layer->numpasses) - 1) {
239 increment = int_max(increment,
240 int_floorlog2(len) + 1 - (cblk->numlenbits + int_floorlog2(nump)));
245 t2_putcommacode(bio, increment);
247 /* computation of the new Length indicator */
248 cblk->numlenbits += increment;
250 /* insertion of the codeword segment length */
251 for (passno = cblk->numpasses; passno < cblk->numpasses + layer->numpasses;
253 opj_tcd_pass_t *pass = &cblk->passes[passno];
256 if (pass->term || passno == (cblk->numpasses + layer->numpasses) - 1) {
257 bio_write(bio, len, cblk->numlenbits + int_floorlog2(nump));
265 if (bio_flush(bio)) {
267 return -999; /* modified to eliminate longjmp !! */
270 c += bio_numbytes(bio);
274 if (tcp->csty & J2K_CP_CSTY_EPH) {
282 /* End of packet header position. Currently only represents the distance to start of packet
283 // Will be updated later by incrementing with packet start value */
284 if (cstr_info && cstr_info->index_write) {
285 opj_packet_info_t *info_PK = &cstr_info->tile[tileno].packet[cstr_info->packno];
286 info_PK->end_ph_pos = (int)(c - dest);
290 /* Writing the packet body */
292 for (bandno = 0; bandno < res->numbands; bandno++) {
293 opj_tcd_band_t *band = &res->bands[bandno];
294 opj_tcd_precinct_t *prc = &band->precincts[precno];
295 for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
296 opj_tcd_cblk_enc_t* cblk = &prc->cblks.enc[cblkno];
297 opj_tcd_layer_t *layer = &cblk->layers[layno];
298 if (!layer->numpasses) {
301 if (c + layer->len > dest + length) {
305 memcpy(c, layer->data, layer->len);
306 cblk->numpasses += layer->numpasses;
309 if (cstr_info && cstr_info->index_write) {
310 opj_packet_info_t *info_PK = &cstr_info->tile[tileno].packet[cstr_info->packno];
311 info_PK->disto += layer->disto;
312 if (cstr_info->D_max < info_PK->disto) {
313 cstr_info->D_max = info_PK->disto;
323 static opj_bool t2_init_seg(opj_tcd_cblk_dec_t* cblk, int index, int cblksty,
328 segs = (opj_tcd_seg_t*) opj_realloc(cblk->segs,
329 (index + 1) * sizeof(opj_tcd_seg_t));
336 seg = &cblk->segs[index];
341 if (cblksty & J2K_CCP_CBLKSTY_TERMALL) {
343 } else if (cblksty & J2K_CCP_CBLKSTY_LAZY) {
347 seg->maxpasses = (((seg - 1)->maxpasses == 1) ||
348 ((seg - 1)->maxpasses == 10)) ? 2 : 1;
351 seg->maxpasses = 109;
357 static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len,
358 opj_tcd_tile_t *tile,
359 opj_tcp_t *tcp, opj_pi_iterator_t *pi, opj_packet_info_t *pack_info)
362 unsigned char *c = src;
364 opj_cp_t *cp = t2->cp;
366 int compno = pi->compno; /* component value */
367 int resno = pi->resno; /* resolution level value */
368 int precno = pi->precno; /* precinct value */
369 int layno = pi->layno; /* quality layer value */
371 opj_tcd_resolution_t* res = &tile->comps[compno].resolutions[resno];
373 unsigned char *hd = NULL;
376 opj_bio_t *bio = NULL; /* BIO component */
379 for (bandno = 0; bandno < res->numbands; bandno++) {
380 opj_tcd_band_t *band = &res->bands[bandno];
381 opj_tcd_precinct_t *prc = &band->precincts[precno];
383 if ((band->x1 - band->x0 == 0) || (band->y1 - band->y0 == 0)) {
387 tgt_reset(prc->incltree);
388 tgt_reset(prc->imsbtree);
389 for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
390 opj_tcd_cblk_dec_t* cblk = &prc->cblks.dec[cblkno];
398 if (tcp->csty & J2K_CP_CSTY_SOP) {
399 if ((*c) != 0xff || (*(c + 1) != 0x91)) {
400 opj_event_msg(t2->cinfo, EVT_WARNING, "Expected SOP marker\n");
405 /** TODO : check the Nsop value */
409 When the marker PPT/PPM is used the packet header are store in PPT/PPM marker
410 This part deal with this caracteristic
411 step 1: Read packet header in the saved structure
412 step 2: Return to codestream for decoding
417 if (cp->ppm == 1) { /* PPM */
419 bio_init_dec(bio, hd, cp->ppm_len);
420 } else if (tcp->ppt == 1) { /* PPT */
422 bio_init_dec(bio, hd, tcp->ppt_len);
423 } else { /* Normal Case */
425 bio_init_dec(bio, hd, src + len - hd);
428 present = bio_read(bio, 1);
432 hd += bio_numbytes(bio);
437 if (tcp->csty & J2K_CP_CSTY_EPH) {
438 if ((*hd) != 0xff || (*(hd + 1) != 0x92)) {
439 printf("Error : expected EPH marker\n");
446 /* End of packet header position. Currently only represents the distance to start of packet
447 // Will be updated later by incrementing with packet start value*/
449 pack_info->end_ph_pos = (int)(c - src);
453 if (cp->ppm == 1) { /* PPM case */
454 cp->ppm_len += cp->ppm_data - hd;
458 if (tcp->ppt == 1) { /* PPT case */
459 tcp->ppt_len += tcp->ppt_data - hd;
467 for (bandno = 0; bandno < res->numbands; bandno++) {
468 opj_tcd_band_t *band = &res->bands[bandno];
469 opj_tcd_precinct_t *prc = &band->precincts[precno];
471 if ((band->x1 - band->x0 == 0) || (band->y1 - band->y0 == 0)) {
475 for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
476 int included, increment, n, segno;
477 opj_tcd_cblk_dec_t* cblk = &prc->cblks.dec[cblkno];
478 /* if cblk not yet included before --> inclusion tagtree */
479 if (!cblk->numsegs) {
480 included = tgt_decode(bio, prc->incltree, cblkno, layno + 1);
483 included = bio_read(bio, 1);
485 /* if cblk not included */
487 cblk->numnewpasses = 0;
490 /* if cblk not yet included --> zero-bitplane tagtree */
491 if (!cblk->numsegs) {
493 for (i = 0; !tgt_decode(bio, prc->imsbtree, cblkno, i); i++) {
497 cblk->numbps = band->numbps - numimsbs;
498 cblk->numlenbits = 3;
500 /* number of coding passes */
501 cblk->numnewpasses = t2_getnumpasses(bio);
502 increment = t2_getcommacode(bio);
503 /* length indicator increment */
504 cblk->numlenbits += increment;
506 if (!cblk->numsegs) {
507 if (!t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 1)) {
508 opj_event_msg(t2->cinfo, EVT_ERROR, "Out of memory\n");
513 segno = cblk->numsegs - 1;
514 if (cblk->segs[segno].numpasses == cblk->segs[segno].maxpasses) {
516 if (!t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 0)) {
517 opj_event_msg(t2->cinfo, EVT_ERROR, "Out of memory\n");
523 n = cblk->numnewpasses;
526 cblk->segs[segno].numnewpasses = int_min(cblk->segs[segno].maxpasses -
527 cblk->segs[segno].numpasses, n);
528 cblk->segs[segno].newlen = bio_read(bio,
529 cblk->numlenbits + int_floorlog2(cblk->segs[segno].numnewpasses));
530 n -= cblk->segs[segno].numnewpasses;
533 if (!t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 0)) {
534 opj_event_msg(t2->cinfo, EVT_ERROR, "Out of memory\n");
543 if (bio_inalign(bio)) {
548 hd += bio_numbytes(bio);
552 if (tcp->csty & J2K_CP_CSTY_EPH) {
553 if ((*hd) != 0xff || (*(hd + 1) != 0x92)) {
554 opj_event_msg(t2->cinfo, EVT_ERROR, "Expected EPH marker\n");
562 /* End of packet header position. Currently only represents the distance to start of packet
563 // Will be updated later by incrementing with packet start value*/
565 pack_info->end_ph_pos = (int)(hd - src);
570 cp->ppm_len += cp->ppm_data - hd;
572 } else if (tcp->ppt == 1) {
573 tcp->ppt_len += tcp->ppt_data - hd;
579 for (bandno = 0; bandno < res->numbands; bandno++) {
580 opj_tcd_band_t *band = &res->bands[bandno];
581 opj_tcd_precinct_t *prc = &band->precincts[precno];
583 if ((band->x1 - band->x0 == 0) || (band->y1 - band->y0 == 0)) {
587 for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
588 opj_tcd_cblk_dec_t* cblk = &prc->cblks.dec[cblkno];
589 opj_tcd_seg_t *seg = NULL;
590 if (!cblk->numnewpasses) {
593 if (!cblk->numsegs) {
594 seg = &cblk->segs[0];
598 seg = &cblk->segs[cblk->numsegs - 1];
599 if (seg->numpasses == seg->maxpasses) {
606 if (c + seg->newlen > src + len) {
611 /* we need here a j2k handle to verify if making a check to
612 the validity of cblocks parameters is selected from user (-W) */
614 /* let's check that we are not exceeding */
615 if ((cblk->len + seg->newlen) > 8192) {
616 opj_event_msg(t2->cinfo, EVT_WARNING,
617 "JPWL: segment too long (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
618 seg->newlen, cblkno, precno, bandno, resno, compno);
620 opj_event_msg(t2->cinfo, EVT_ERROR, "JPWL: giving up\n");
623 seg->newlen = 8192 - cblk->len;
624 opj_event_msg(t2->cinfo, EVT_WARNING, " - truncating segment to %d\n",
629 #endif /* USE_JPWL */
631 cblk->data = (unsigned char*) opj_realloc(cblk->data,
632 (cblk->len + seg->newlen) * sizeof(unsigned char));
633 memcpy(cblk->data + cblk->len, c, seg->newlen);
634 if (seg->numpasses == 0) {
635 seg->data = &cblk->data;
636 seg->dataindex = cblk->len;
639 cblk->len += seg->newlen;
640 seg->len += seg->newlen;
641 seg->numpasses += seg->numnewpasses;
642 cblk->numnewpasses -= seg->numnewpasses;
643 if (cblk->numnewpasses > 0) {
647 } while (cblk->numnewpasses > 0);
654 /* ----------------------------------------------------------------------- */
656 int t2_encode_packets(opj_t2_t* t2, int tileno, opj_tcd_tile_t *tile,
657 int maxlayers, unsigned char *dest, int len, opj_codestream_info_t *cstr_info,
658 int tpnum, int tppos, int pino, J2K_T2_MODE t2_mode, int cur_totnum_tp)
660 unsigned char *c = dest;
663 opj_pi_iterator_t *pi = NULL;
665 opj_image_t *image = t2->image;
666 opj_cp_t *cp = t2->cp;
667 opj_tcp_t *tcp = &cp->tcps[tileno];
668 int pocno = cp->cinema == CINEMA4K_24 ? 2 : 1;
669 int maxcomp = cp->max_comp_size > 0 ? image->numcomps : 1;
671 pi = pi_initialise_encode(image, cp, tileno, t2_mode);
673 /* TODO: throw an error */
677 if (t2_mode == THRESH_CALC) { /* Calculating threshold */
678 for (compno = 0; compno < maxcomp; compno++) {
679 for (poc = 0; poc < pocno ; poc++) {
682 if (pi_create_encode(pi, cp, tileno, poc, tpnum, tppos, t2_mode,
684 opj_event_msg(t2->cinfo, EVT_ERROR, "Error initializing Packet Iterator\n");
685 pi_destroy(pi, cp, tileno);
688 while (pi_next(&pi[poc])) {
689 if (pi[poc].layno < maxlayers) {
690 e = t2_encode_packet(tile, &cp->tcps[tileno], &pi[poc], c, dest + len - c,
692 comp_len = comp_len + e;
703 if (cp->max_comp_size) {
704 if (comp_len > cp->max_comp_size) {
714 } else { /* t2_mode == FINAL_PASS */
715 pi_create_encode(pi, cp, tileno, pino, tpnum, tppos, t2_mode, cur_totnum_tp);
716 while (pi_next(&pi[pino])) {
717 if (pi[pino].layno < maxlayers) {
718 e = t2_encode_packet(tile, &cp->tcps[tileno], &pi[pino], c, dest + len - c,
727 if (cstr_info->index_write) {
728 opj_tile_info_t *info_TL = &cstr_info->tile[tileno];
729 opj_packet_info_t *info_PK = &info_TL->packet[cstr_info->packno];
730 if (!cstr_info->packno) {
731 info_PK->start_pos = info_TL->end_header + 1;
733 info_PK->start_pos = ((cp->tp_on | tcp->POC) &&
734 info_PK->start_pos) ? info_PK->start_pos : info_TL->packet[cstr_info->packno -
737 info_PK->end_pos = info_PK->start_pos + e - 1;
738 info_PK->end_ph_pos += info_PK->start_pos -
739 1; /* End of packet header which now only represents the distance
740 // to start of packet is incremented by value of start of packet*/
751 pi_destroy(pi, cp, tileno);
760 int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno,
761 opj_tcd_tile_t *tile, opj_codestream_info_t *cstr_info)
763 unsigned char *c = src;
764 opj_pi_iterator_t *pi;
766 int n = 0, curtp = 0;
769 opj_image_t *image = t2->image;
770 opj_cp_t *cp = t2->cp;
772 /* create a packet iterator */
773 pi = pi_create_decode(image, cp, tileno);
775 /* TODO: throw an error */
781 for (pino = 0; pino <= cp->tcps[tileno].numpocs; pino++) {
782 while (pi_next(&pi[pino])) {
783 if ((cp->layer == 0) || (cp->layer >= ((pi[pino].layno) + 1))) {
784 opj_packet_info_t *pack_info;
786 pack_info = &cstr_info->tile[tileno].packet[cstr_info->packno];
790 e = t2_decode_packet(t2, c, src + len - c, tile, &cp->tcps[tileno], &pi[pino],
796 pi_destroy(pi, cp, tileno);
799 /* progression in resolution */
800 image->comps[pi[pino].compno].resno_decoded =
802 int_max(pi[pino].resno, image->comps[pi[pino].compno].resno_decoded)
803 : image->comps[pi[pino].compno].resno_decoded;
808 opj_tile_info_t *info_TL = &cstr_info->tile[tileno];
809 opj_packet_info_t *info_PK = &info_TL->packet[cstr_info->packno];
810 if (!cstr_info->packno) {
811 info_PK->start_pos = info_TL->end_header + 1;
812 } else if (info_TL->packet[cstr_info->packno - 1].end_pos >=
813 (int)cstr_info->tile[tileno].tp[curtp].tp_end_pos) { /* New tile part*/
814 info_TL->tp[curtp].tp_numpacks = cstr_info->packno -
815 tp_start_packno; /* Number of packets in previous tile-part*/
816 info_TL->tp[curtp].tp_start_pack = tp_start_packno;
817 tp_start_packno = cstr_info->packno;
819 info_PK->start_pos = cstr_info->tile[tileno].tp[curtp].tp_end_header + 1;
821 info_PK->start_pos = (cp->tp_on &&
822 info_PK->start_pos) ? info_PK->start_pos : info_TL->packet[cstr_info->packno -
825 info_PK->end_pos = info_PK->start_pos + e - 1;
826 info_PK->end_ph_pos += info_PK->start_pos -
827 1; /* End of packet header which now only represents the distance
828 // to start of packet is incremented by value of start of packet*/
833 if (e == -999) { /* ADD */
842 cstr_info->tile[tileno].tp[curtp].tp_numpacks = cstr_info->packno -
843 tp_start_packno; /* Number of packets in last tile-part*/
844 cstr_info->tile[tileno].tp[curtp].tp_start_pack = tp_start_packno;
848 /* don't forget to release pi */
849 pi_destroy(pi, cp, tileno);
858 /* ----------------------------------------------------------------------- */
860 opj_t2_t* t2_create(opj_common_ptr cinfo, opj_image_t *image, opj_cp_t *cp)
862 /* create the tcd structure */
863 opj_t2_t *t2 = (opj_t2_t*)opj_malloc(sizeof(opj_t2_t));
874 void t2_destroy(opj_t2_t *t2)