OLD | NEW |
1 /* | 1 /* |
2 * The copyright in this software is being made available under the 2-clauses | 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 | 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 | 4 * party and contributor rights, including patent rights, and no such rights |
5 * are granted under this license. | 5 * are granted under this license. |
6 * | 6 * |
7 * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium | 7 * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium |
8 * Copyright (c) 2002-2014, Professor Benoit Macq | 8 * Copyright (c) 2002-2014, Professor Benoit Macq |
9 * Copyright (c) 2001-2003, David Janssens | 9 * Copyright (c) 2001-2003, David Janssens |
10 * Copyright (c) 2002-2003, Yannick Verschueren | 10 * Copyright (c) 2002-2003, Yannick Verschueren |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 } | 100 } |
101 fprintf(fd, " }\n"); | 101 fprintf(fd, " }\n"); |
102 } | 102 } |
103 fprintf(fd, "}\n"); | 103 fprintf(fd, "}\n"); |
104 } | 104 } |
105 #endif | 105 #endif |
106 | 106 |
107 /** | 107 /** |
108 * Initializes tile coding/decoding | 108 * Initializes tile coding/decoding |
109 */ | 109 */ |
110 static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
OPJ_BOOL isEncoder, OPJ_FLOAT32 fraction, OPJ_SIZE_T sizeof_block); | 110 static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
OPJ_BOOL isEncoder, OPJ_FLOAT32 fraction, OPJ_SIZE_T sizeof_block, opj_event_mg
r_t* manager); |
111 | 111 |
112 /** | 112 /** |
113 * Allocates memory for a decoding code block. | 113 * Allocates memory for a decoding code block. |
114 */ | 114 */ |
115 static OPJ_BOOL opj_tcd_code_block_dec_allocate (opj_tcd_cblk_dec_t * p_code_blo
ck); | 115 static OPJ_BOOL opj_tcd_code_block_dec_allocate (opj_tcd_cblk_dec_t * p_code_blo
ck); |
116 | 116 |
117 /** | 117 /** |
118 * Deallocates the decoding data of the given precinct. | 118 * Deallocates the decoding data of the given precinct. |
119 */ | 119 */ |
120 static void opj_tcd_code_block_dec_deallocate (opj_tcd_precinct_t * p_precinct); | 120 static void opj_tcd_code_block_dec_deallocate (opj_tcd_precinct_t * p_precinct); |
(...skipping 18 matching lines...) Expand all Loading... |
139 Free the memory allocated for encoding | 139 Free the memory allocated for encoding |
140 @param tcd TCD handle | 140 @param tcd TCD handle |
141 */ | 141 */ |
142 static void opj_tcd_free_tile(opj_tcd_t *tcd); | 142 static void opj_tcd_free_tile(opj_tcd_t *tcd); |
143 | 143 |
144 | 144 |
145 static OPJ_BOOL opj_tcd_t2_decode ( opj_tcd_t *p_tcd, | 145 static OPJ_BOOL opj_tcd_t2_decode ( opj_tcd_t *p_tcd, |
146 OPJ_BYTE * p_src_data, | 146 OPJ_BYTE * p_src_data, |
147 OPJ_UINT32 * p_data_read, | 147 OPJ_UINT32 * p_data_read, |
148 OPJ_UINT32 p_max_src_size, | 148 OPJ_UINT32 p_max_src_size, |
149 opj_codestream_index_t *p_cstr_index ); | 149 opj_codestream_index_t *p_cstr_index, |
| 150 opj_event_mgr_t *p_manager); |
150 | 151 |
151 static OPJ_BOOL opj_tcd_t1_decode (opj_tcd_t *p_tcd); | 152 static OPJ_BOOL opj_tcd_t1_decode (opj_tcd_t *p_tcd); |
152 | 153 |
153 static OPJ_BOOL opj_tcd_dwt_decode (opj_tcd_t *p_tcd); | 154 static OPJ_BOOL opj_tcd_dwt_decode (opj_tcd_t *p_tcd); |
154 | 155 |
155 static OPJ_BOOL opj_tcd_mct_decode (opj_tcd_t *p_tcd); | 156 static OPJ_BOOL opj_tcd_mct_decode (opj_tcd_t *p_tcd, opj_event_mgr_t *p_manager
); |
156 | 157 |
157 static OPJ_BOOL opj_tcd_dc_level_shift_decode (opj_tcd_t *p_tcd); | 158 static OPJ_BOOL opj_tcd_dc_level_shift_decode (opj_tcd_t *p_tcd); |
158 | 159 |
159 | 160 |
160 static OPJ_BOOL opj_tcd_dc_level_shift_encode ( opj_tcd_t *p_tcd ); | 161 static OPJ_BOOL opj_tcd_dc_level_shift_encode ( opj_tcd_t *p_tcd ); |
161 | 162 |
162 static OPJ_BOOL opj_tcd_mct_encode ( opj_tcd_t *p_tcd ); | 163 static OPJ_BOOL opj_tcd_mct_encode ( opj_tcd_t *p_tcd ); |
163 | 164 |
164 static OPJ_BOOL opj_tcd_dwt_encode ( opj_tcd_t *p_tcd ); | 165 static OPJ_BOOL opj_tcd_dwt_encode ( opj_tcd_t *p_tcd ); |
165 | 166 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 } else { | 261 } else { |
261 dr = pass->rate
- cblk->passes[n - 1].rate; | 262 dr = pass->rate
- cblk->passes[n - 1].rate; |
262 dd = pass->disto
rtiondec - cblk->passes[n - 1].distortiondec; | 263 dd = pass->disto
rtiondec - cblk->passes[n - 1].distortiondec; |
263 } | 264 } |
264 | 265 |
265 if (!dr) { | 266 if (!dr) { |
266 if (dd != 0) | 267 if (dd != 0) |
267 n = pass
no + 1; | 268 n = pass
no + 1; |
268 continue; | 269 continue; |
269 } | 270 } |
270 if (dd / dr >= thresh) | 271 if (thresh - (dd / dr) <
DBL_EPSILON) /* do not rely on float equality, check with DBL_EPSILON margin */ |
271 n = passno + 1; | 272 n = passno + 1; |
272 } | 273 } |
273 | 274 |
274 layer->numpasses = n - cblk->num
passesinlayers; | 275 layer->numpasses = n - cblk->num
passesinlayers; |
275 | 276 |
276 if (!layer->numpasses) { | 277 if (!layer->numpasses) { |
277 layer->disto = 0; | 278 layer->disto = 0; |
278 continue; | 279 continue; |
279 } | 280 } |
280 | 281 |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 l_tilec->data = new_data; | 649 l_tilec->data = new_data; |
649 /*fprintf(stderr, "tReallocate data of tilec (int): from %d to %
d x OPJ_UINT32n", l_tilec->data_size, l_data_size);*/ | 650 /*fprintf(stderr, "tReallocate data of tilec (int): from %d to %
d x OPJ_UINT32n", l_tilec->data_size, l_data_size);*/ |
650 l_tilec->data_size = l_tilec->data_size_needed; | 651 l_tilec->data_size = l_tilec->data_size_needed; |
651 l_tilec->ownsData = OPJ_TRUE; | 652 l_tilec->ownsData = OPJ_TRUE; |
652 } | 653 } |
653 return OPJ_TRUE; | 654 return OPJ_TRUE; |
654 } | 655 } |
655 | 656 |
656 /* ----------------------------------------------------------------------- */ | 657 /* ----------------------------------------------------------------------- */ |
657 | 658 |
658 static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
OPJ_BOOL isEncoder, OPJ_FLOAT32 fraction, OPJ_SIZE_T sizeof_block) | 659 static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
OPJ_BOOL isEncoder, OPJ_FLOAT32 fraction, OPJ_SIZE_T sizeof_block, opj_event_mg
r_t* manager) |
659 { | 660 { |
660 OPJ_UINT32 (*l_gain_ptr)(OPJ_UINT32) = 00; | 661 OPJ_UINT32 (*l_gain_ptr)(OPJ_UINT32) = 00; |
661 OPJ_UINT32 compno, resno, bandno, precno, cblkno; | 662 OPJ_UINT32 compno, resno, bandno, precno, cblkno; |
662 opj_tcp_t * l_tcp = 00; | 663 opj_tcp_t * l_tcp = 00; |
663 opj_cp_t * l_cp = 00; | 664 opj_cp_t * l_cp = 00; |
664 opj_tcd_tile_t * l_tile = 00; | 665 opj_tcd_tile_t * l_tile = 00; |
665 opj_tccp_t *l_tccp = 00; | 666 opj_tccp_t *l_tccp = 00; |
666 opj_tcd_tilecomp_t *l_tilec = 00; | 667 opj_tcd_tilecomp_t *l_tilec = 00; |
667 opj_image_comp_t * l_image_comp = 00; | 668 opj_image_comp_t * l_image_comp = 00; |
668 opj_tcd_resolution_t *l_res = 00; | 669 opj_tcd_resolution_t *l_res = 00; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 /* 4 borders of the tile rescale on the image if necessary */ | 705 /* 4 borders of the tile rescale on the image if necessary */ |
705 l_tx0 = l_cp->tx0 + p * l_cp->tdx; /* can't be greater than l_image->x1
so won't overflow */ | 706 l_tx0 = l_cp->tx0 + p * l_cp->tdx; /* can't be greater than l_image->x1
so won't overflow */ |
706 l_tile->x0 = (OPJ_INT32)opj_uint_max(l_tx0, l_image->x0); | 707 l_tile->x0 = (OPJ_INT32)opj_uint_max(l_tx0, l_image->x0); |
707 l_tile->x1 = (OPJ_INT32)opj_uint_min(opj_uint_adds(l_tx0, l_cp->tdx), l_
image->x1); | 708 l_tile->x1 = (OPJ_INT32)opj_uint_min(opj_uint_adds(l_tx0, l_cp->tdx), l_
image->x1); |
708 l_ty0 = l_cp->ty0 + q * l_cp->tdy; /* can't be greater than l_image->y1
so won't overflow */ | 709 l_ty0 = l_cp->ty0 + q * l_cp->tdy; /* can't be greater than l_image->y1
so won't overflow */ |
709 l_tile->y0 = (OPJ_INT32)opj_uint_max(l_ty0, l_image->y0); | 710 l_tile->y0 = (OPJ_INT32)opj_uint_max(l_ty0, l_image->y0); |
710 l_tile->y1 = (OPJ_INT32)opj_uint_min(opj_uint_adds(l_ty0, l_cp->tdy), l_
image->y1); | 711 l_tile->y1 = (OPJ_INT32)opj_uint_min(opj_uint_adds(l_ty0, l_cp->tdy), l_
image->y1); |
711 | 712 |
712 /* testcase 1888.pdf.asan.35.988 */ | 713 /* testcase 1888.pdf.asan.35.988 */ |
713 if (l_tccp->numresolutions == 0) { | 714 if (l_tccp->numresolutions == 0) { |
714 » » fprintf(stderr, "tiles require at least one resolution\n"); | 715 » » opj_event_msg(manager, EVT_ERROR, "tiles require at least one re
solution\n"); |
715 return OPJ_FALSE; | 716 return OPJ_FALSE; |
716 } | 717 } |
717 /*fprintf(stderr, "Tile border = %d,%d,%d,%d\n", l_tile->x0, l_tile->y0,
l_tile->x1,l_tile->y1);*/ | 718 /*fprintf(stderr, "Tile border = %d,%d,%d,%d\n", l_tile->x0, l_tile->y0,
l_tile->x1,l_tile->y1);*/ |
718 | 719 |
719 /*tile->numcomps = image->numcomps; */ | 720 /*tile->numcomps = image->numcomps; */ |
720 for (compno = 0; compno < l_tile->numcomps; ++compno) { | 721 for (compno = 0; compno < l_tile->numcomps; ++compno) { |
721 /*fprintf(stderr, "compno = %d/%d\n", compno, l_tile->numcomps);
*/ | 722 /*fprintf(stderr, "compno = %d/%d\n", compno, l_tile->numcomps);
*/ |
722 l_image_comp->resno_decoded = 0; | 723 l_image_comp->resno_decoded = 0; |
723 /* border of each l_tile component (global) */ | 724 /* border of each l_tile component (global) */ |
724 l_tilec->x0 = opj_int_ceildiv(l_tile->x0, (OPJ_INT32)l_image_com
p->dx); | 725 l_tilec->x0 = opj_int_ceildiv(l_tile->x0, (OPJ_INT32)l_image_com
p->dx); |
725 l_tilec->y0 = opj_int_ceildiv(l_tile->y0, (OPJ_INT32)l_image_com
p->dy); | 726 l_tilec->y0 = opj_int_ceildiv(l_tile->y0, (OPJ_INT32)l_image_com
p->dy); |
726 l_tilec->x1 = opj_int_ceildiv(l_tile->x1, (OPJ_INT32)l_image_com
p->dx); | 727 l_tilec->x1 = opj_int_ceildiv(l_tile->x1, (OPJ_INT32)l_image_com
p->dx); |
727 l_tilec->y1 = opj_int_ceildiv(l_tile->y1, (OPJ_INT32)l_image_com
p->dy); | 728 l_tilec->y1 = opj_int_ceildiv(l_tile->y1, (OPJ_INT32)l_image_com
p->dy); |
728 /*fprintf(stderr, "\tTile compo border = %d,%d,%d,%d\n", l_tilec
->x0, l_tilec->y0,l_tilec->x1,l_tilec->y1);*/ | 729 /*fprintf(stderr, "\tTile compo border = %d,%d,%d,%d\n", l_tilec
->x0, l_tilec->y0,l_tilec->x1,l_tilec->y1);*/ |
729 | 730 |
730 /* compute l_data_size with overflow check */ | 731 /* compute l_data_size with overflow check */ |
731 l_data_size = (OPJ_UINT32)(l_tilec->x1 - l_tilec->x0); | 732 l_data_size = (OPJ_UINT32)(l_tilec->x1 - l_tilec->x0); |
732 if ((((OPJ_UINT32)-1) / l_data_size) < (OPJ_UINT32)(l_tilec->y1
- l_tilec->y0)) { | 733 if ((((OPJ_UINT32)-1) / l_data_size) < (OPJ_UINT32)(l_tilec->y1
- l_tilec->y0)) { |
733 » » » /* TODO event */ | 734 » » » opj_event_msg(manager, EVT_ERROR, "Not enough memory for
tile data\n"); |
734 return OPJ_FALSE; | 735 return OPJ_FALSE; |
735 } | 736 } |
736 l_data_size = l_data_size * (OPJ_UINT32)(l_tilec->y1 - l_tilec->
y0); | 737 l_data_size = l_data_size * (OPJ_UINT32)(l_tilec->y1 - l_tilec->
y0); |
737 | 738 |
738 if ((((OPJ_UINT32)-1) / (OPJ_UINT32)sizeof(OPJ_UINT32)) < l_data
_size) { | 739 if ((((OPJ_UINT32)-1) / (OPJ_UINT32)sizeof(OPJ_UINT32)) < l_data
_size) { |
739 » » » /* TODO event */ | 740 » » » opj_event_msg(manager, EVT_ERROR, "Not enough memory for
tile data\n"); |
740 return OPJ_FALSE; | 741 return OPJ_FALSE; |
741 } | 742 } |
742 l_data_size = l_data_size * (OPJ_UINT32)sizeof(OPJ_UINT32); | 743 l_data_size = l_data_size * (OPJ_UINT32)sizeof(OPJ_UINT32); |
743 l_tilec->numresolutions = l_tccp->numresolutions; | 744 l_tilec->numresolutions = l_tccp->numresolutions; |
744 if (l_tccp->numresolutions < l_cp->m_specific_param.m_dec.m_redu
ce) { | 745 if (l_tccp->numresolutions < l_cp->m_specific_param.m_dec.m_redu
ce) { |
745 l_tilec->minimum_num_resolutions = 1; | 746 l_tilec->minimum_num_resolutions = 1; |
746 } | 747 } |
747 else { | 748 else { |
748 l_tilec->minimum_num_resolutions = l_tccp->numresolution
s - l_cp->m_specific_param.m_dec.m_reduce; | 749 l_tilec->minimum_num_resolutions = l_tccp->numresolution
s - l_cp->m_specific_param.m_dec.m_reduce; |
749 } | 750 } |
750 | 751 |
751 l_tilec->data_size_needed = l_data_size; | 752 l_tilec->data_size_needed = l_data_size; |
752 if (p_tcd->m_is_decoder && !opj_alloc_tile_component_data(l_tile
c)) { | 753 if (p_tcd->m_is_decoder && !opj_alloc_tile_component_data(l_tile
c)) { |
| 754 opj_event_msg(manager, EVT_ERROR, "Not enough memory for
tile data\n"); |
753 return OPJ_FALSE; | 755 return OPJ_FALSE; |
754 } | 756 } |
755 | 757 |
756 l_data_size = l_tilec->numresolutions * (OPJ_UINT32)sizeof(opj_t
cd_resolution_t); | 758 l_data_size = l_tilec->numresolutions * (OPJ_UINT32)sizeof(opj_t
cd_resolution_t); |
757 | 759 |
758 if (l_tilec->resolutions == 00) { | 760 if (l_tilec->resolutions == 00) { |
759 l_tilec->resolutions = (opj_tcd_resolution_t *) opj_mall
oc(l_data_size); | 761 l_tilec->resolutions = (opj_tcd_resolution_t *) opj_mall
oc(l_data_size); |
760 if (! l_tilec->resolutions ) { | 762 if (! l_tilec->resolutions ) { |
761 return OPJ_FALSE; | 763 return OPJ_FALSE; |
762 } | 764 } |
763 /*fprintf(stderr, "\tAllocate resolutions of tilec (opj_
tcd_resolution_t): %d\n",l_data_size);*/ | 765 /*fprintf(stderr, "\tAllocate resolutions of tilec (opj_
tcd_resolution_t): %d\n",l_data_size);*/ |
764 l_tilec->resolutions_size = l_data_size; | 766 l_tilec->resolutions_size = l_data_size; |
765 memset(l_tilec->resolutions,0,l_data_size); | 767 memset(l_tilec->resolutions,0,l_data_size); |
766 } | 768 } |
767 else if (l_data_size > l_tilec->resolutions_size) { | 769 else if (l_data_size > l_tilec->resolutions_size) { |
768 opj_tcd_resolution_t* new_resolutions = (opj_tcd_resolut
ion_t *) opj_realloc(l_tilec->resolutions, l_data_size); | 770 opj_tcd_resolution_t* new_resolutions = (opj_tcd_resolut
ion_t *) opj_realloc(l_tilec->resolutions, l_data_size); |
769 if (! new_resolutions) { | 771 if (! new_resolutions) { |
770 » » » » /* opj_event_msg(p_manager, EVT_ERROR, "Not enou
gh memory to tile resolutions\n");
*/ | 772 » » » » opj_event_msg(manager, EVT_ERROR, "Not enough me
mory for tile resolutions\n"); |
771 » » » » fprintf(stderr, "Not enough memory to tile resol
utions\n"); | |
772 opj_free(l_tilec->resolutions); | 773 opj_free(l_tilec->resolutions); |
773 l_tilec->resolutions = NULL; | 774 l_tilec->resolutions = NULL; |
774 l_tilec->resolutions_size = 0; | 775 l_tilec->resolutions_size = 0; |
775 return OPJ_FALSE; | 776 return OPJ_FALSE; |
776 } | 777 } |
777 l_tilec->resolutions = new_resolutions; | 778 l_tilec->resolutions = new_resolutions; |
778 /*fprintf(stderr, "\tReallocate data of tilec (int): fro
m %d to %d x OPJ_UINT32\n", l_tilec->resolutions_size, l_data_size);*/ | 779 /*fprintf(stderr, "\tReallocate data of tilec (int): fro
m %d to %d x OPJ_UINT32\n", l_tilec->resolutions_size, l_data_size);*/ |
779 memset(((OPJ_BYTE*) l_tilec->resolutions)+l_tilec->resol
utions_size,0,l_data_size - l_tilec->resolutions_size); | 780 memset(((OPJ_BYTE*) l_tilec->resolutions)+l_tilec->resol
utions_size,0,l_data_size - l_tilec->resolutions_size); |
780 l_tilec->resolutions_size = l_data_size; | 781 l_tilec->resolutions_size = l_data_size; |
781 } | 782 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 l_band->x1 = opj_int_ceildivpow2(l_tilec
->x1, (OPJ_INT32)l_level_no); | 855 l_band->x1 = opj_int_ceildivpow2(l_tilec
->x1, (OPJ_INT32)l_level_no); |
855 l_band->y1 = opj_int_ceildivpow2(l_tilec
->y1, (OPJ_INT32)l_level_no); | 856 l_band->y1 = opj_int_ceildivpow2(l_tilec
->y1, (OPJ_INT32)l_level_no); |
856 } | 857 } |
857 else { | 858 else { |
858 l_band->bandno = bandno + 1; | 859 l_band->bandno = bandno + 1; |
859 /* x0b = 1 if bandno = 1 or 3 */ | 860 /* x0b = 1 if bandno = 1 or 3 */ |
860 l_x0b = l_band->bandno&1; | 861 l_x0b = l_band->bandno&1; |
861 /* y0b = 1 if bandno = 2 or 3 */ | 862 /* y0b = 1 if bandno = 2 or 3 */ |
862 l_y0b = (OPJ_INT32)((l_band->bandno)>>1)
; | 863 l_y0b = (OPJ_INT32)((l_band->bandno)>>1)
; |
863 /* l_band border (global) */ | 864 /* l_band border (global) */ |
864 » » » » » l_band->x0 = opj_int_ceildivpow2(l_tilec
->x0 - (1 << l_level_no) * l_x0b, (OPJ_INT32)(l_level_no + 1)); | 865 » » » » » l_band->x0 = opj_int64_ceildivpow2(l_til
ec->x0 - ((OPJ_INT64)l_x0b << l_level_no), (OPJ_INT32)(l_level_no + 1)); |
865 » » » » » l_band->y0 = opj_int_ceildivpow2(l_tilec
->y0 - (1 << l_level_no) * l_y0b, (OPJ_INT32)(l_level_no + 1)); | 866 » » » » » l_band->y0 = opj_int64_ceildivpow2(l_til
ec->y0 - ((OPJ_INT64)l_y0b << l_level_no), (OPJ_INT32)(l_level_no + 1)); |
866 » » » » » l_band->x1 = opj_int_ceildivpow2(l_tilec
->x1 - (1 << l_level_no) * l_x0b, (OPJ_INT32)(l_level_no + 1)); | 867 » » » » » l_band->x1 = opj_int64_ceildivpow2(l_til
ec->x1 - ((OPJ_INT64)l_x0b << l_level_no), (OPJ_INT32)(l_level_no + 1)); |
867 » » » » » l_band->y1 = opj_int_ceildivpow2(l_tilec
->y1 - (1 << l_level_no) * l_y0b, (OPJ_INT32)(l_level_no + 1)); | 868 » » » » » l_band->y1 = opj_int64_ceildivpow2(l_til
ec->y1 - ((OPJ_INT64)l_y0b << l_level_no), (OPJ_INT32)(l_level_no + 1)); |
868 } | 869 } |
869 | 870 |
870 /** avoid an if with storing function pointer */ | 871 /** avoid an if with storing function pointer */ |
871 l_gain = (*l_gain_ptr) (l_band->bandno); | 872 l_gain = (*l_gain_ptr) (l_band->bandno); |
872 numbps = (OPJ_INT32)(l_image_comp->prec + l_gain
); | 873 numbps = (OPJ_INT32)(l_image_comp->prec + l_gain
); |
873 l_band->stepsize = (OPJ_FLOAT32)(((1.0 + l_step_
size->mant / 2048.0) * pow(2.0, (OPJ_INT32) (numbps - l_step_size->expn)))) * fr
action; | 874 l_band->stepsize = (OPJ_FLOAT32)(((1.0 + l_step_
size->mant / 2048.0) * pow(2.0, (OPJ_INT32) (numbps - l_step_size->expn)))) * fr
action; |
874 l_band->numbps = l_step_size->expn + (OPJ_INT32)
l_tccp->numgbits - 1; /* WHY -1 ? */ | 875 l_band->numbps = l_step_size->expn + (OPJ_INT32)
l_tccp->numgbits - 1; /* WHY -1 ? */ |
875 | 876 |
876 if (! l_band->precincts) { | 877 if (! l_band->precincts) { |
877 l_band->precincts = (opj_tcd_precinct_t
*) opj_malloc( /*3 * */ l_nb_precinct_size); | 878 l_band->precincts = (opj_tcd_precinct_t
*) opj_malloc( /*3 * */ l_nb_precinct_size); |
878 if (! l_band->precincts) { | 879 if (! l_band->precincts) { |
879 return OPJ_FALSE; | 880 return OPJ_FALSE; |
880 } | 881 } |
881 /*fprintf(stderr, "\t\t\t\tAllocate prec
incts of a band (opj_tcd_precinct_t): %d\n",l_nb_precinct_size); */ | 882 /*fprintf(stderr, "\t\t\t\tAllocate prec
incts of a band (opj_tcd_precinct_t): %d\n",l_nb_precinct_size); */ |
882 memset(l_band->precincts,0,l_nb_precinct
_size); | 883 memset(l_band->precincts,0,l_nb_precinct
_size); |
883 l_band->precincts_data_size = l_nb_preci
nct_size; | 884 l_band->precincts_data_size = l_nb_preci
nct_size; |
884 } | 885 } |
885 else if (l_band->precincts_data_size < l_nb_prec
inct_size) { | 886 else if (l_band->precincts_data_size < l_nb_prec
inct_size) { |
886 | 887 |
887 opj_tcd_precinct_t * new_precincts = (op
j_tcd_precinct_t *) opj_realloc(l_band->precincts,/*3 * */ l_nb_precinct_size); | 888 opj_tcd_precinct_t * new_precincts = (op
j_tcd_precinct_t *) opj_realloc(l_band->precincts,/*3 * */ l_nb_precinct_size); |
888 if (! new_precincts) { | 889 if (! new_precincts) { |
889 » » » » » » /* opj_event_msg(p_manager, EVT_
ERROR, "Not enough memory to handle band precints\n");
*/ | 890 » » » » » » opj_event_msg(manager, EVT_ERROR
, "Not enough memory to handle band precints\n"); |
890 » » » » » » fprintf(stderr, "Not enough memo
ry to handle band precints\n"); | |
891 opj_free(l_band->precincts); | 891 opj_free(l_band->precincts); |
892 l_band->precincts = NULL; | 892 l_band->precincts = NULL; |
893 l_band->precincts_data_size = 0; | 893 l_band->precincts_data_size = 0; |
894 return OPJ_FALSE; | 894 return OPJ_FALSE; |
895 } | 895 } |
896 l_band->precincts = new_precincts; | 896 l_band->precincts = new_precincts; |
897 /*fprintf(stderr, "\t\t\t\tReallocate pr
ecincts of a band (opj_tcd_precinct_t): from %d to %d\n",l_band->precincts_data_
size, l_nb_precinct_size);*/ | 897 /*fprintf(stderr, "\t\t\t\tReallocate pr
ecincts of a band (opj_tcd_precinct_t): from %d to %d\n",l_band->precincts_data_
size, l_nb_precinct_size);*/ |
898 memset(((OPJ_BYTE *) l_band->precincts)
+ l_band->precincts_data_size,0,l_nb_precinct_size - l_band->precincts_data_size
); | 898 memset(((OPJ_BYTE *) l_band->precincts)
+ l_band->precincts_data_size,0,l_nb_precinct_size - l_band->precincts_data_size
); |
899 l_band->precincts_data_size = l_nb_preci
nct_size; | 899 l_band->precincts_data_size = l_nb_preci
nct_size; |
900 } | 900 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 memset(l_current_precinct->cblks
.blocks,0,l_nb_code_blocks_size); | 943 memset(l_current_precinct->cblks
.blocks,0,l_nb_code_blocks_size); |
944 | 944 |
945 l_current_precinct->block_size =
l_nb_code_blocks_size; | 945 l_current_precinct->block_size =
l_nb_code_blocks_size; |
946 } | 946 } |
947 else if (l_nb_code_blocks_size > l_curre
nt_precinct->block_size) { | 947 else if (l_nb_code_blocks_size > l_curre
nt_precinct->block_size) { |
948 void *new_blocks = opj_realloc(l
_current_precinct->cblks.blocks, l_nb_code_blocks_size); | 948 void *new_blocks = opj_realloc(l
_current_precinct->cblks.blocks, l_nb_code_blocks_size); |
949 if (! new_blocks) { | 949 if (! new_blocks) { |
950 opj_free(l_current_preci
nct->cblks.blocks); | 950 opj_free(l_current_preci
nct->cblks.blocks); |
951 l_current_precinct->cblk
s.blocks = NULL; | 951 l_current_precinct->cblk
s.blocks = NULL; |
952 l_current_precinct->bloc
k_size = 0; | 952 l_current_precinct->bloc
k_size = 0; |
953 » » » » » » » /* opj_event_msg(p_manag
er, EVT_ERROR, "Not enough memory for current precinct codeblock element\n");
*/ | 953 » » » » » » » opj_event_msg(manager, E
VT_ERROR, "Not enough memory for current precinct codeblock element\n"); |
954 » » » » » » » fprintf(stderr, "Not eno
ugh memory for current precinct codeblock element\n"); | |
955 return OPJ_FALSE; | 954 return OPJ_FALSE; |
956 } | 955 } |
957 l_current_precinct->cblks.blocks
= new_blocks; | 956 l_current_precinct->cblks.blocks
= new_blocks; |
958 /*fprintf(stderr, "\t\t\t\tReall
ocate cblks of a precinct (opj_tcd_cblk_dec_t): from %d to %d\n",l_current_preci
nct->block_size, l_nb_code_blocks_size); */ | 957 /*fprintf(stderr, "\t\t\t\tReall
ocate cblks of a precinct (opj_tcd_cblk_dec_t): from %d to %d\n",l_current_preci
nct->block_size, l_nb_code_blocks_size); */ |
959 | 958 |
960 memset(((OPJ_BYTE *) l_current_p
recinct->cblks.blocks) + l_current_precinct->block_size | 959 memset(((OPJ_BYTE *) l_current_p
recinct->cblks.blocks) + l_current_precinct->block_size |
961 ,0 | 960 ,0 |
962 ,l_nb_c
ode_blocks_size - l_current_precinct->block_size); | 961 ,l_nb_c
ode_blocks_size - l_current_precinct->block_size); |
963 | 962 |
964 l_current_precinct->block_size =
l_nb_code_blocks_size; | 963 l_current_precinct->block_size =
l_nb_code_blocks_size; |
965 } | 964 } |
966 | 965 |
967 if (! l_current_precinct->incltree) { | 966 if (! l_current_precinct->incltree) { |
968 » » » » » » l_current_precinct->incltree = o
pj_tgt_create(l_current_precinct->cw, | 967 » » » » » » l_current_precinct->incltree = o
pj_tgt_create(l_current_precinct->cw, l_current_precinct->ch, manager); |
969 » » » » » » » » » »
» » » » » » » » » »
» » » » » » » » » l_curren
t_precinct->ch); | |
970 } | 968 } |
971 else{ | 969 else{ |
972 » » » » » » l_current_precinct->incltree = o
pj_tgt_init(l_current_precinct->incltree, | 970 » » » » » » l_current_precinct->incltree = o
pj_tgt_init(l_current_precinct->incltree, l_current_precinct->cw, l_current_prec
inct->ch, manager); |
973 » » » » » » » » » »
» » » » » » » » » »
» » » » » » » » l_current_precin
ct->cw, | |
974 » » » » » » » » » »
» » » » » » » » » »
» » » » » » » » l_current_precin
ct->ch); | |
975 } | 971 } |
976 | 972 |
977 if (! l_current_precinct->incltree)
{ | 973 if (! l_current_precinct->incltree)
{ |
978 » » » » » » fprintf(stderr, "WARNING: No inc
ltree created.\n"); | 974 » » » » » » opj_event_msg(manager, EVT_WARNI
NG, "No incltree created.\n"); |
979 /*return OPJ_FALSE;*/ | 975 /*return OPJ_FALSE;*/ |
980 } | 976 } |
981 | 977 |
982 if (! l_current_precinct->imsbtree) { | 978 if (! l_current_precinct->imsbtree) { |
983 » » » » » » l_current_precinct->imsbtree = o
pj_tgt_create( | 979 » » » » » » l_current_precinct->imsbtree = o
pj_tgt_create(l_current_precinct->cw, l_current_precinct->ch, manager); |
984 » » » » » » » » » »
» » » » » » » » » »
» » » » » » » » » l_curren
t_precinct->cw, | |
985 » » » » » » » » » »
» » » » » » » » » »
» » » » » » » » » l_curren
t_precinct->ch); | |
986 } | 980 } |
987 else { | 981 else { |
988 » » » » » » l_current_precinct->imsbtree = o
pj_tgt_init( | 982 » » » » » » l_current_precinct->imsbtree = o
pj_tgt_init(l_current_precinct->imsbtree, l_current_precinct->cw, l_current_prec
inct->ch, manager); |
989 » » » » » » » » » »
» » » » » » » » » »
» » » » » » » » l_current_precin
ct->imsbtree, | |
990 » » » » » » » » » »
» » » » » » » » » »
» » » » » » » » l_current_precin
ct->cw, | |
991 » » » » » » » » » »
» » » » » » » » » »
» » » » » » » » l_current_precin
ct->ch); | |
992 } | 983 } |
993 | 984 |
994 if (! l_current_precinct->imsbtree) { | 985 if (! l_current_precinct->imsbtree) { |
995 » » » » » » fprintf(stderr, "WARNING: No ims
btree created.\n"); | 986 » » » » » » opj_event_msg(manager, EVT_WARNI
NG, "No imsbtree created.\n"); |
996 /*return OPJ_FALSE;*/ | 987 /*return OPJ_FALSE;*/ |
997 } | 988 } |
998 | 989 |
999 for (cblkno = 0; cblkno < l_nb_code_bloc
ks; ++cblkno) { | 990 for (cblkno = 0; cblkno < l_nb_code_bloc
ks; ++cblkno) { |
1000 OPJ_INT32 cblkxstart = tlcblkxst
art + (OPJ_INT32)(cblkno % l_current_precinct->cw) * (1 << cblkwidthexpn); | 991 OPJ_INT32 cblkxstart = tlcblkxst
art + (OPJ_INT32)(cblkno % l_current_precinct->cw) * (1 << cblkwidthexpn); |
1001 OPJ_INT32 cblkystart = tlcblkyst
art + (OPJ_INT32)(cblkno / l_current_precinct->cw) * (1 << cblkheightexpn); | 992 OPJ_INT32 cblkystart = tlcblkyst
art + (OPJ_INT32)(cblkno / l_current_precinct->cw) * (1 << cblkheightexpn); |
1002 OPJ_INT32 cblkxend = cblkxstart
+ (1 << cblkwidthexpn); | 993 OPJ_INT32 cblkxend = cblkxstart
+ (1 << cblkwidthexpn); |
1003 OPJ_INT32 cblkyend = cblkystart
+ (1 << cblkheightexpn); | 994 OPJ_INT32 cblkyend = cblkystart
+ (1 << cblkheightexpn); |
1004 | 995 |
1005 if (isEncoder) { | 996 if (isEncoder) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 ++l_res; | 1029 ++l_res; |
1039 --l_level_no; | 1030 --l_level_no; |
1040 } /* resno */ | 1031 } /* resno */ |
1041 ++l_tccp; | 1032 ++l_tccp; |
1042 ++l_tilec; | 1033 ++l_tilec; |
1043 ++l_image_comp; | 1034 ++l_image_comp; |
1044 } /* compno */ | 1035 } /* compno */ |
1045 return OPJ_TRUE; | 1036 return OPJ_TRUE; |
1046 } | 1037 } |
1047 | 1038 |
1048 OPJ_BOOL opj_tcd_init_encode_tile (opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no) | 1039 OPJ_BOOL opj_tcd_init_encode_tile (opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no, opj_e
vent_mgr_t* p_manager) |
1049 { | 1040 { |
1050 » return opj_tcd_init_tile(p_tcd, p_tile_no, OPJ_TRUE, 1.0F, sizeof(opj_tc
d_cblk_enc_t)); | 1041 » return opj_tcd_init_tile(p_tcd, p_tile_no, OPJ_TRUE, 1.0F, sizeof(opj_tc
d_cblk_enc_t), p_manager); |
1051 } | 1042 } |
1052 | 1043 |
1053 OPJ_BOOL opj_tcd_init_decode_tile (opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no) | 1044 OPJ_BOOL opj_tcd_init_decode_tile (opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no, opj_e
vent_mgr_t* p_manager) |
1054 { | 1045 { |
1055 » return opj_tcd_init_tile(p_tcd, p_tile_no, OPJ_FALSE, 0.5F, sizeof(opj_t
cd_cblk_dec_t)); | 1046 » return opj_tcd_init_tile(p_tcd, p_tile_no, OPJ_FALSE, 0.5F, sizeof(opj_t
cd_cblk_dec_t), p_manager); |
1056 } | 1047 } |
1057 | 1048 |
1058 /** | 1049 /** |
1059 * Allocates memory for an encoding code block (but not data memory). | 1050 * Allocates memory for an encoding code block (but not data memory). |
1060 */ | 1051 */ |
1061 static OPJ_BOOL opj_tcd_code_block_enc_allocate (opj_tcd_cblk_enc_t * p_code_blo
ck) | 1052 static OPJ_BOOL opj_tcd_code_block_enc_allocate (opj_tcd_cblk_enc_t * p_code_blo
ck) |
1062 { | 1053 { |
1063 if (! p_code_block->layers) { | 1054 if (! p_code_block->layers) { |
1064 /* no memset since data */ | 1055 /* no memset since data */ |
1065 p_code_block->layers = (opj_tcd_layer_t*) opj_calloc(100, sizeof
(opj_tcd_layer_t)); | 1056 p_code_block->layers = (opj_tcd_layer_t*) opj_calloc(100, sizeof
(opj_tcd_layer_t)); |
(...skipping 16 matching lines...) Expand all Loading... |
1082 static OPJ_BOOL opj_tcd_code_block_enc_allocate_data (opj_tcd_cblk_enc_t * p_cod
e_block) | 1073 static OPJ_BOOL opj_tcd_code_block_enc_allocate_data (opj_tcd_cblk_enc_t * p_cod
e_block) |
1083 { | 1074 { |
1084 OPJ_UINT32 l_data_size; | 1075 OPJ_UINT32 l_data_size; |
1085 | 1076 |
1086 l_data_size = (OPJ_UINT32)((p_code_block->x1 - p_code_block->x0) * (p_co
de_block->y1 - p_code_block->y0) * (OPJ_INT32)sizeof(OPJ_UINT32)); | 1077 l_data_size = (OPJ_UINT32)((p_code_block->x1 - p_code_block->x0) * (p_co
de_block->y1 - p_code_block->y0) * (OPJ_INT32)sizeof(OPJ_UINT32)); |
1087 | 1078 |
1088 if (l_data_size > p_code_block->data_size) { | 1079 if (l_data_size > p_code_block->data_size) { |
1089 if (p_code_block->data) { | 1080 if (p_code_block->data) { |
1090 opj_free(p_code_block->data - 1); /* again, why -1 */ | 1081 opj_free(p_code_block->data - 1); /* again, why -1 */ |
1091 } | 1082 } |
1092 » » p_code_block->data = (OPJ_BYTE*) opj_malloc(l_data_size); | 1083 » » p_code_block->data = (OPJ_BYTE*) opj_malloc(l_data_size+1); |
1093 if(! p_code_block->data) { | 1084 if(! p_code_block->data) { |
1094 p_code_block->data_size = 0U; | 1085 p_code_block->data_size = 0U; |
1095 return OPJ_FALSE; | 1086 return OPJ_FALSE; |
1096 } | 1087 } |
1097 p_code_block->data_size = l_data_size; | 1088 p_code_block->data_size = l_data_size; |
1098 | 1089 |
1099 p_code_block->data[0] = 0; | 1090 p_code_block->data[0] = 0; |
1100 p_code_block->data+=1; /*why +1 ?*/ | 1091 p_code_block->data+=1; /*why +1 ?*/ |
1101 } | 1092 } |
1102 return OPJ_TRUE; | 1093 return OPJ_TRUE; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1259 | 1250 |
1260 /*---------------CLEAN-------------------*/ | 1251 /*---------------CLEAN-------------------*/ |
1261 | 1252 |
1262 return OPJ_TRUE; | 1253 return OPJ_TRUE; |
1263 } | 1254 } |
1264 | 1255 |
1265 OPJ_BOOL opj_tcd_decode_tile( opj_tcd_t *p_tcd, | 1256 OPJ_BOOL opj_tcd_decode_tile( opj_tcd_t *p_tcd, |
1266 OPJ_BYTE *p_src, | 1257 OPJ_BYTE *p_src, |
1267 OPJ_UINT32 p_max_length, | 1258 OPJ_UINT32 p_max_length, |
1268 OPJ_UINT32 p_tile_no, | 1259 OPJ_UINT32 p_tile_no, |
1269 opj_codestream_index_t *p_cstr_index | 1260 opj_codestream_index_t *p_cstr_index, |
| 1261 opj_event_mgr_t *p_manager |
1270 ) | 1262 ) |
1271 { | 1263 { |
1272 OPJ_UINT32 l_data_read; | 1264 OPJ_UINT32 l_data_read; |
1273 p_tcd->tcd_tileno = p_tile_no; | 1265 p_tcd->tcd_tileno = p_tile_no; |
1274 p_tcd->tcp = &(p_tcd->cp->tcps[p_tile_no]); | 1266 p_tcd->tcp = &(p_tcd->cp->tcps[p_tile_no]); |
1275 | 1267 |
1276 #ifdef TODO_MSD /* FIXME */ | 1268 #ifdef TODO_MSD /* FIXME */ |
1277 /* INDEX >> */ | 1269 /* INDEX >> */ |
1278 if(p_cstr_info) { | 1270 if(p_cstr_info) { |
1279 OPJ_UINT32 resno, compno, numprec = 0; | 1271 OPJ_UINT32 resno, compno, numprec = 0; |
(...skipping 12 matching lines...) Expand all Loading... |
1292 } | 1284 } |
1293 p_cstr_info->tile[p_tile_no].packet = (opj_packet_info_t *) opj_
malloc(p_cstr_info->numlayers * numprec * sizeof(opj_packet_info_t)); | 1285 p_cstr_info->tile[p_tile_no].packet = (opj_packet_info_t *) opj_
malloc(p_cstr_info->numlayers * numprec * sizeof(opj_packet_info_t)); |
1294 p_cstr_info->packno = 0; | 1286 p_cstr_info->packno = 0; |
1295 } | 1287 } |
1296 /* << INDEX */ | 1288 /* << INDEX */ |
1297 #endif | 1289 #endif |
1298 | 1290 |
1299 /*--------------TIER2------------------*/ | 1291 /*--------------TIER2------------------*/ |
1300 /* FIXME _ProfStart(PGROUP_T2); */ | 1292 /* FIXME _ProfStart(PGROUP_T2); */ |
1301 l_data_read = 0; | 1293 l_data_read = 0; |
1302 if (! opj_tcd_t2_decode(p_tcd, p_src, &l_data_read, p_max_length, p_cstr
_index)) | 1294 if (! opj_tcd_t2_decode(p_tcd, p_src, &l_data_read, p_max_length, p_cstr
_index, p_manager)) |
1303 { | 1295 { |
1304 return OPJ_FALSE; | 1296 return OPJ_FALSE; |
1305 } | 1297 } |
1306 /* FIXME _ProfStop(PGROUP_T2); */ | 1298 /* FIXME _ProfStop(PGROUP_T2); */ |
1307 | 1299 |
1308 /*------------------TIER1-----------------*/ | 1300 /*------------------TIER1-----------------*/ |
1309 | 1301 |
1310 /* FIXME _ProfStart(PGROUP_T1); */ | 1302 /* FIXME _ProfStart(PGROUP_T1); */ |
1311 if | 1303 if |
1312 (! opj_tcd_t1_decode(p_tcd)) | 1304 (! opj_tcd_t1_decode(p_tcd)) |
1313 { | 1305 { |
1314 return OPJ_FALSE; | 1306 return OPJ_FALSE; |
1315 } | 1307 } |
1316 /* FIXME _ProfStop(PGROUP_T1); */ | 1308 /* FIXME _ProfStop(PGROUP_T1); */ |
1317 | 1309 |
1318 /*----------------DWT---------------------*/ | 1310 /*----------------DWT---------------------*/ |
1319 | 1311 |
1320 /* FIXME _ProfStart(PGROUP_DWT); */ | 1312 /* FIXME _ProfStart(PGROUP_DWT); */ |
1321 if | 1313 if |
1322 (! opj_tcd_dwt_decode(p_tcd)) | 1314 (! opj_tcd_dwt_decode(p_tcd)) |
1323 { | 1315 { |
1324 return OPJ_FALSE; | 1316 return OPJ_FALSE; |
1325 } | 1317 } |
1326 /* FIXME _ProfStop(PGROUP_DWT); */ | 1318 /* FIXME _ProfStop(PGROUP_DWT); */ |
1327 | 1319 |
1328 /*----------------MCT-------------------*/ | 1320 /*----------------MCT-------------------*/ |
1329 /* FIXME _ProfStart(PGROUP_MCT); */ | 1321 /* FIXME _ProfStart(PGROUP_MCT); */ |
1330 if | 1322 if |
1331 (! opj_tcd_mct_decode(p_tcd)) | 1323 (! opj_tcd_mct_decode(p_tcd, p_manager)) |
1332 { | 1324 { |
1333 return OPJ_FALSE; | 1325 return OPJ_FALSE; |
1334 } | 1326 } |
1335 /* FIXME _ProfStop(PGROUP_MCT); */ | 1327 /* FIXME _ProfStop(PGROUP_MCT); */ |
1336 | 1328 |
1337 /* FIXME _ProfStart(PGROUP_DC_SHIFT); */ | 1329 /* FIXME _ProfStart(PGROUP_DC_SHIFT); */ |
1338 if | 1330 if |
1339 (! opj_tcd_dc_level_shift_decode(p_tcd)) | 1331 (! opj_tcd_dc_level_shift_decode(p_tcd)) |
1340 { | 1332 { |
1341 return OPJ_FALSE; | 1333 return OPJ_FALSE; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1455 ++l_img_comp; | 1447 ++l_img_comp; |
1456 ++l_tilec; | 1448 ++l_tilec; |
1457 } | 1449 } |
1458 | 1450 |
1459 return OPJ_TRUE; | 1451 return OPJ_TRUE; |
1460 } | 1452 } |
1461 | 1453 |
1462 | 1454 |
1463 | 1455 |
1464 | 1456 |
1465 void opj_tcd_free_tile(opj_tcd_t *p_tcd) | 1457 static void opj_tcd_free_tile(opj_tcd_t *p_tcd) |
1466 { | 1458 { |
1467 OPJ_UINT32 compno, resno, bandno, precno; | 1459 OPJ_UINT32 compno, resno, bandno, precno; |
1468 opj_tcd_tile_t *l_tile = 00; | 1460 opj_tcd_tile_t *l_tile = 00; |
1469 opj_tcd_tilecomp_t *l_tile_comp = 00; | 1461 opj_tcd_tilecomp_t *l_tile_comp = 00; |
1470 opj_tcd_resolution_t *l_res = 00; | 1462 opj_tcd_resolution_t *l_res = 00; |
1471 opj_tcd_band_t *l_band = 00; | 1463 opj_tcd_band_t *l_band = 00; |
1472 opj_tcd_precinct_t *l_precinct = 00; | 1464 opj_tcd_precinct_t *l_precinct = 00; |
1473 OPJ_UINT32 l_nb_resolutions, l_nb_precincts; | 1465 OPJ_UINT32 l_nb_resolutions, l_nb_precincts; |
1474 void (* l_tcd_code_block_deallocate) (opj_tcd_precinct_t *) = 00; | 1466 void (* l_tcd_code_block_deallocate) (opj_tcd_precinct_t *) = 00; |
1475 | 1467 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1538 ++l_tile_comp; | 1530 ++l_tile_comp; |
1539 } | 1531 } |
1540 | 1532 |
1541 opj_free(l_tile->comps); | 1533 opj_free(l_tile->comps); |
1542 l_tile->comps = 00; | 1534 l_tile->comps = 00; |
1543 opj_free(p_tcd->tcd_image->tiles); | 1535 opj_free(p_tcd->tcd_image->tiles); |
1544 p_tcd->tcd_image->tiles = 00; | 1536 p_tcd->tcd_image->tiles = 00; |
1545 } | 1537 } |
1546 | 1538 |
1547 | 1539 |
1548 OPJ_BOOL opj_tcd_t2_decode (opj_tcd_t *p_tcd, | 1540 static OPJ_BOOL opj_tcd_t2_decode (opj_tcd_t *p_tcd, |
1549 OPJ_BYTE * p_src_data, | 1541 OPJ_BYTE * p_src_data, |
1550 OPJ_UINT32 * p_data_read, | 1542 OPJ_UINT32 * p_data_read, |
1551 OPJ_UINT32 p_max_src_size, | 1543 OPJ_UINT32 p_max_src_size, |
1552 opj_codestream_index_t *p_cstr_index | 1544 opj_codestream_index_t *p_cstr_index, |
| 1545 opj_event_mgr_t *p_manager |
1553 ) | 1546 ) |
1554 { | 1547 { |
1555 opj_t2_t * l_t2; | 1548 opj_t2_t * l_t2; |
1556 | 1549 |
1557 l_t2 = opj_t2_create(p_tcd->image, p_tcd->cp); | 1550 l_t2 = opj_t2_create(p_tcd->image, p_tcd->cp); |
1558 if (l_t2 == 00) { | 1551 if (l_t2 == 00) { |
1559 return OPJ_FALSE; | 1552 return OPJ_FALSE; |
1560 } | 1553 } |
1561 | 1554 |
1562 if (! opj_t2_decode_packets( | 1555 if (! opj_t2_decode_packets( |
1563 l_t2, | 1556 l_t2, |
1564 p_tcd->tcd_tileno, | 1557 p_tcd->tcd_tileno, |
1565 p_tcd->tcd_image->tiles, | 1558 p_tcd->tcd_image->tiles, |
1566 p_src_data, | 1559 p_src_data, |
1567 p_data_read, | 1560 p_data_read, |
1568 p_max_src_size, | 1561 p_max_src_size, |
1569 p_cstr_index)) { | 1562 p_cstr_index, |
| 1563 p_manager)) { |
1570 opj_t2_destroy(l_t2); | 1564 opj_t2_destroy(l_t2); |
1571 return OPJ_FALSE; | 1565 return OPJ_FALSE; |
1572 } | 1566 } |
1573 | 1567 |
1574 opj_t2_destroy(l_t2); | 1568 opj_t2_destroy(l_t2); |
1575 | 1569 |
1576 /*---------------CLEAN-------------------*/ | 1570 /*---------------CLEAN-------------------*/ |
1577 return OPJ_TRUE; | 1571 return OPJ_TRUE; |
1578 } | 1572 } |
1579 | 1573 |
1580 OPJ_BOOL opj_tcd_t1_decode ( opj_tcd_t *p_tcd ) | 1574 static OPJ_BOOL opj_tcd_t1_decode ( opj_tcd_t *p_tcd ) |
1581 { | 1575 { |
1582 OPJ_UINT32 compno; | 1576 OPJ_UINT32 compno; |
1583 opj_t1_t * l_t1; | 1577 opj_t1_t * l_t1; |
1584 opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles; | 1578 opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles; |
1585 opj_tcd_tilecomp_t* l_tile_comp = l_tile->comps; | 1579 opj_tcd_tilecomp_t* l_tile_comp = l_tile->comps; |
1586 opj_tccp_t * l_tccp = p_tcd->tcp->tccps; | 1580 opj_tccp_t * l_tccp = p_tcd->tcp->tccps; |
1587 | 1581 |
1588 | 1582 |
1589 l_t1 = opj_t1_create(OPJ_FALSE); | 1583 l_t1 = opj_t1_create(OPJ_FALSE); |
1590 if (l_t1 == 00) { | 1584 if (l_t1 == 00) { |
1591 return OPJ_FALSE; | 1585 return OPJ_FALSE; |
1592 } | 1586 } |
1593 | 1587 |
1594 for (compno = 0; compno < l_tile->numcomps; ++compno) { | 1588 for (compno = 0; compno < l_tile->numcomps; ++compno) { |
1595 /* The +3 is headroom required by the vectorized DWT */ | 1589 /* The +3 is headroom required by the vectorized DWT */ |
1596 if (OPJ_FALSE == opj_t1_decode_cblks(l_t1, l_tile_comp, l_tccp))
{ | 1590 if (OPJ_FALSE == opj_t1_decode_cblks(l_t1, l_tile_comp, l_tccp))
{ |
1597 opj_t1_destroy(l_t1); | 1591 opj_t1_destroy(l_t1); |
1598 return OPJ_FALSE; | 1592 return OPJ_FALSE; |
1599 } | 1593 } |
1600 ++l_tile_comp; | 1594 ++l_tile_comp; |
1601 ++l_tccp; | 1595 ++l_tccp; |
1602 } | 1596 } |
1603 | 1597 |
1604 opj_t1_destroy(l_t1); | 1598 opj_t1_destroy(l_t1); |
1605 | 1599 |
1606 return OPJ_TRUE; | 1600 return OPJ_TRUE; |
1607 } | 1601 } |
1608 | 1602 |
1609 | 1603 |
1610 OPJ_BOOL opj_tcd_dwt_decode ( opj_tcd_t *p_tcd ) | 1604 static OPJ_BOOL opj_tcd_dwt_decode ( opj_tcd_t *p_tcd ) |
1611 { | 1605 { |
1612 OPJ_UINT32 compno; | 1606 OPJ_UINT32 compno; |
1613 opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles; | 1607 opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles; |
1614 opj_tcd_tilecomp_t * l_tile_comp = l_tile->comps; | 1608 opj_tcd_tilecomp_t * l_tile_comp = l_tile->comps; |
1615 opj_tccp_t * l_tccp = p_tcd->tcp->tccps; | 1609 opj_tccp_t * l_tccp = p_tcd->tcp->tccps; |
1616 opj_image_comp_t * l_img_comp = p_tcd->image->comps; | 1610 opj_image_comp_t * l_img_comp = p_tcd->image->comps; |
1617 | 1611 |
1618 for (compno = 0; compno < l_tile->numcomps; compno++) { | 1612 for (compno = 0; compno < l_tile->numcomps; compno++) { |
1619 /* | 1613 /* |
1620 if (tcd->cp->reduce != 0) { | 1614 if (tcd->cp->reduce != 0) { |
(...skipping 19 matching lines...) Expand all Loading... |
1640 } | 1634 } |
1641 } | 1635 } |
1642 | 1636 |
1643 ++l_tile_comp; | 1637 ++l_tile_comp; |
1644 ++l_img_comp; | 1638 ++l_img_comp; |
1645 ++l_tccp; | 1639 ++l_tccp; |
1646 } | 1640 } |
1647 | 1641 |
1648 return OPJ_TRUE; | 1642 return OPJ_TRUE; |
1649 } | 1643 } |
1650 OPJ_BOOL opj_tcd_mct_decode ( opj_tcd_t *p_tcd ) | 1644 static OPJ_BOOL opj_tcd_mct_decode ( opj_tcd_t *p_tcd, opj_event_mgr_t *p_manage
r) |
1651 { | 1645 { |
1652 opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles; | 1646 opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles; |
1653 opj_tcp_t * l_tcp = p_tcd->tcp; | 1647 opj_tcp_t * l_tcp = p_tcd->tcp; |
1654 opj_tcd_tilecomp_t * l_tile_comp = l_tile->comps; | 1648 opj_tcd_tilecomp_t * l_tile_comp = l_tile->comps; |
1655 OPJ_UINT32 l_samples,i; | 1649 OPJ_UINT32 l_samples,i; |
1656 | 1650 |
1657 if (! l_tcp->mct) { | 1651 if (! l_tcp->mct) { |
1658 return OPJ_TRUE; | 1652 return OPJ_TRUE; |
1659 } | 1653 } |
1660 | 1654 |
1661 l_samples = (OPJ_UINT32)((l_tile_comp->x1 - l_tile_comp->x0) * (l_tile_c
omp->y1 - l_tile_comp->y0)); | 1655 l_samples = (OPJ_UINT32)((l_tile_comp->x1 - l_tile_comp->x0) * (l_tile_c
omp->y1 - l_tile_comp->y0)); |
1662 | 1656 |
1663 if (l_tile->numcomps >= 3 ){ | 1657 if (l_tile->numcomps >= 3 ){ |
1664 /* testcase 1336.pdf.asan.47.376 */ | 1658 /* testcase 1336.pdf.asan.47.376 */ |
1665 if ((l_tile->comps[0].x1 - l_tile->comps[0].x0) * (l_tile->comps
[0].y1 - l_tile->comps[0].y0) < (OPJ_INT32)l_samples || | 1659 if ((l_tile->comps[0].x1 - l_tile->comps[0].x0) * (l_tile->comps
[0].y1 - l_tile->comps[0].y0) < (OPJ_INT32)l_samples || |
1666 (l_tile->comps[1].x1 - l_tile->comps[1].x0) * (l_tile->comps
[1].y1 - l_tile->comps[1].y0) < (OPJ_INT32)l_samples || | 1660 (l_tile->comps[1].x1 - l_tile->comps[1].x0) * (l_tile->comps
[1].y1 - l_tile->comps[1].y0) < (OPJ_INT32)l_samples || |
1667 (l_tile->comps[2].x1 - l_tile->comps[2].x0) * (l_tile->comps
[2].y1 - l_tile->comps[2].y0) < (OPJ_INT32)l_samples) { | 1661 (l_tile->comps[2].x1 - l_tile->comps[2].x0) * (l_tile->comps
[2].y1 - l_tile->comps[2].y0) < (OPJ_INT32)l_samples) { |
1668 fprintf(stderr, "Tiles don't all have the same dimension
. Skip the MCT step.\n"); | 1662 opj_event_msg(p_manager, EVT_ERROR, "Tiles don't all hav
e the same dimension. Skip the MCT step.\n"); |
1669 return OPJ_FALSE; | 1663 return OPJ_FALSE; |
1670 } | 1664 } |
1671 else if (l_tcp->mct == 2) { | 1665 else if (l_tcp->mct == 2) { |
1672 OPJ_BYTE ** l_data; | 1666 OPJ_BYTE ** l_data; |
1673 | 1667 |
1674 if (! l_tcp->m_mct_decoding_matrix) { | 1668 if (! l_tcp->m_mct_decoding_matrix) { |
1675 return OPJ_TRUE; | 1669 return OPJ_TRUE; |
1676 } | 1670 } |
1677 | 1671 |
1678 l_data = (OPJ_BYTE **) opj_malloc(l_tile->numcomps*sizeo
f(OPJ_BYTE*)); | 1672 l_data = (OPJ_BYTE **) opj_malloc(l_tile->numcomps*sizeo
f(OPJ_BYTE*)); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1710 } | 1704 } |
1711 else { | 1705 else { |
1712 opj_mct_decode_real((OPJ_FLOAT32*)l_tile->comps[0].d
ata, | 1706 opj_mct_decode_real((OPJ_FLOAT32*)l_tile->comps[0].d
ata, |
1713 (OPJ_FLOAT32*)l_tile->comps[1].d
ata, | 1707 (OPJ_FLOAT32*)l_tile->comps[1].d
ata, |
1714 (OPJ_FLOAT32*)l_tile->comps[2].d
ata, | 1708 (OPJ_FLOAT32*)l_tile->comps[2].d
ata, |
1715 l_samples); | 1709 l_samples); |
1716 } | 1710 } |
1717 } | 1711 } |
1718 } | 1712 } |
1719 else { | 1713 else { |
1720 /* FIXME need to use opj_event_msg function */ | 1714 opj_event_msg(p_manager, EVT_ERROR, "Number of components (%d) i
s inconsistent with a MCT. Skip the MCT step.\n",l_tile->numcomps); |
1721 fprintf(stderr,"Number of components (%d) is inconsistent with a
MCT. Skip the MCT step.\n",l_tile->numcomps); | |
1722 } | 1715 } |
1723 | 1716 |
1724 return OPJ_TRUE; | 1717 return OPJ_TRUE; |
1725 } | 1718 } |
1726 | 1719 |
1727 | 1720 |
1728 OPJ_BOOL opj_tcd_dc_level_shift_decode ( opj_tcd_t *p_tcd ) | 1721 static OPJ_BOOL opj_tcd_dc_level_shift_decode ( opj_tcd_t *p_tcd ) |
1729 { | 1722 { |
1730 OPJ_UINT32 compno; | 1723 OPJ_UINT32 compno; |
1731 opj_tcd_tilecomp_t * l_tile_comp = 00; | 1724 opj_tcd_tilecomp_t * l_tile_comp = 00; |
1732 opj_tccp_t * l_tccp = 00; | 1725 opj_tccp_t * l_tccp = 00; |
1733 opj_image_comp_t * l_img_comp = 00; | 1726 opj_image_comp_t * l_img_comp = 00; |
1734 opj_tcd_resolution_t* l_res = 00; | 1727 opj_tcd_resolution_t* l_res = 00; |
1735 opj_tcd_tile_t * l_tile; | 1728 opj_tcd_tile_t * l_tile; |
1736 OPJ_UINT32 l_width,l_height,i,j; | 1729 OPJ_UINT32 l_width,l_height,i,j; |
1737 OPJ_INT32 * l_current_ptr; | 1730 OPJ_INT32 * l_current_ptr; |
1738 OPJ_INT32 l_min, l_max; | 1731 OPJ_INT32 l_min, l_max; |
(...skipping 29 matching lines...) Expand all Loading... |
1768 *l_current_ptr = opj_int_clamp(*l_curren
t_ptr + l_tccp->m_dc_level_shift, l_min, l_max); | 1761 *l_current_ptr = opj_int_clamp(*l_curren
t_ptr + l_tccp->m_dc_level_shift, l_min, l_max); |
1769 ++l_current_ptr; | 1762 ++l_current_ptr; |
1770 } | 1763 } |
1771 l_current_ptr += l_stride; | 1764 l_current_ptr += l_stride; |
1772 } | 1765 } |
1773 } | 1766 } |
1774 else { | 1767 else { |
1775 for (j=0;j<l_height;++j) { | 1768 for (j=0;j<l_height;++j) { |
1776 for (i = 0; i < l_width; ++i) { | 1769 for (i = 0; i < l_width; ++i) { |
1777 OPJ_FLOAT32 l_value = *((OPJ_FLOAT32 *)
l_current_ptr); | 1770 OPJ_FLOAT32 l_value = *((OPJ_FLOAT32 *)
l_current_ptr); |
1778 *l_current_ptr = opj_int_clamp((OPJ_INT3
2)lrintf(l_value) + l_tccp->m_dc_level_shift, l_min, l_max); ; | 1771 *l_current_ptr = opj_int_clamp((OPJ_INT3
2)opj_lrintf(l_value) + l_tccp->m_dc_level_shift, l_min, l_max); ; |
1779 ++l_current_ptr; | 1772 ++l_current_ptr; |
1780 } | 1773 } |
1781 l_current_ptr += l_stride; | 1774 l_current_ptr += l_stride; |
1782 } | 1775 } |
1783 } | 1776 } |
1784 | 1777 |
1785 ++l_img_comp; | 1778 ++l_img_comp; |
1786 ++l_tccp; | 1779 ++l_tccp; |
1787 ++l_tile_comp; | 1780 ++l_tile_comp; |
1788 } | 1781 } |
1789 | 1782 |
1790 return OPJ_TRUE; | 1783 return OPJ_TRUE; |
1791 } | 1784 } |
1792 | 1785 |
1793 | 1786 |
1794 | 1787 |
1795 /** | 1788 /** |
1796 * Deallocates the encoding data of the given precinct. | 1789 * Deallocates the encoding data of the given precinct. |
1797 */ | 1790 */ |
1798 void opj_tcd_code_block_dec_deallocate (opj_tcd_precinct_t * p_precinct) | 1791 static void opj_tcd_code_block_dec_deallocate (opj_tcd_precinct_t * p_precinct) |
1799 { | 1792 { |
1800 OPJ_UINT32 cblkno , l_nb_code_blocks; | 1793 OPJ_UINT32 cblkno , l_nb_code_blocks; |
1801 | 1794 |
1802 opj_tcd_cblk_dec_t * l_code_block = p_precinct->cblks.dec; | 1795 opj_tcd_cblk_dec_t * l_code_block = p_precinct->cblks.dec; |
1803 if (l_code_block) { | 1796 if (l_code_block) { |
1804 /*fprintf(stderr,"deallocate codeblock:{\n");*/ | 1797 /*fprintf(stderr,"deallocate codeblock:{\n");*/ |
1805 /*fprintf(stderr,"\t x0=%d, y0=%d, x1=%d, y1=%d\n",l_code_block-
>x0, l_code_block->y0, l_code_block->x1, l_code_block->y1);*/ | 1798 /*fprintf(stderr,"\t x0=%d, y0=%d, x1=%d, y1=%d\n",l_code_block-
>x0, l_code_block->y0, l_code_block->x1, l_code_block->y1);*/ |
1806 /*fprintf(stderr,"\t numbps=%d, numlenbits=%d, len=%d, numnewpas
ses=%d, real_num_segs=%d, m_current_max_segs=%d\n ", | 1799 /*fprintf(stderr,"\t numbps=%d, numlenbits=%d, len=%d, numnewpas
ses=%d, real_num_segs=%d, m_current_max_segs=%d\n ", |
1807 l_code_block->numbps, l_code_block->numlenbits,
l_code_block->len, l_code_block->numnewpasses, l_code_block->real_num_segs, l_co
de_block->m_current_max_segs );*/ | 1800 l_code_block->numbps, l_code_block->numlenbits,
l_code_block->len, l_code_block->numnewpasses, l_code_block->real_num_segs, l_co
de_block->m_current_max_segs );*/ |
1808 | 1801 |
(...skipping 17 matching lines...) Expand all Loading... |
1826 } | 1819 } |
1827 | 1820 |
1828 opj_free(p_precinct->cblks.dec); | 1821 opj_free(p_precinct->cblks.dec); |
1829 p_precinct->cblks.dec = 00; | 1822 p_precinct->cblks.dec = 00; |
1830 } | 1823 } |
1831 } | 1824 } |
1832 | 1825 |
1833 /** | 1826 /** |
1834 * Deallocates the encoding data of the given precinct. | 1827 * Deallocates the encoding data of the given precinct. |
1835 */ | 1828 */ |
1836 void opj_tcd_code_block_enc_deallocate (opj_tcd_precinct_t * p_precinct) | 1829 static void opj_tcd_code_block_enc_deallocate (opj_tcd_precinct_t * p_precinct) |
1837 { | 1830 { |
1838 OPJ_UINT32 cblkno , l_nb_code_blocks; | 1831 OPJ_UINT32 cblkno , l_nb_code_blocks; |
1839 | 1832 |
1840 opj_tcd_cblk_enc_t * l_code_block = p_precinct->cblks.enc; | 1833 opj_tcd_cblk_enc_t * l_code_block = p_precinct->cblks.enc; |
1841 if (l_code_block) { | 1834 if (l_code_block) { |
1842 l_nb_code_blocks = p_precinct->block_size / sizeof(opj_tcd_cblk_
enc_t); | 1835 l_nb_code_blocks = p_precinct->block_size / sizeof(opj_tcd_cblk_
enc_t); |
1843 | 1836 |
1844 for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) { | 1837 for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) { |
1845 if (l_code_block->data) { | 1838 if (l_code_block->data) { |
1846 opj_free(l_code_block->data - 1); | 1839 opj_free(l_code_block->data - 1); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1887 } | 1880 } |
1888 | 1881 |
1889 l_data_size += l_size_comp * (OPJ_UINT32)((l_tilec->x1 - l_tilec
->x0) * (l_tilec->y1 - l_tilec->y0)); | 1882 l_data_size += l_size_comp * (OPJ_UINT32)((l_tilec->x1 - l_tilec
->x0) * (l_tilec->y1 - l_tilec->y0)); |
1890 ++l_img_comp; | 1883 ++l_img_comp; |
1891 ++l_tilec; | 1884 ++l_tilec; |
1892 } | 1885 } |
1893 | 1886 |
1894 return l_data_size; | 1887 return l_data_size; |
1895 } | 1888 } |
1896 | 1889 |
1897 OPJ_BOOL opj_tcd_dc_level_shift_encode ( opj_tcd_t *p_tcd ) | 1890 static OPJ_BOOL opj_tcd_dc_level_shift_encode ( opj_tcd_t *p_tcd ) |
1898 { | 1891 { |
1899 OPJ_UINT32 compno; | 1892 OPJ_UINT32 compno; |
1900 opj_tcd_tilecomp_t * l_tile_comp = 00; | 1893 opj_tcd_tilecomp_t * l_tile_comp = 00; |
1901 opj_tccp_t * l_tccp = 00; | 1894 opj_tccp_t * l_tccp = 00; |
1902 opj_image_comp_t * l_img_comp = 00; | 1895 opj_image_comp_t * l_img_comp = 00; |
1903 opj_tcd_tile_t * l_tile; | 1896 opj_tcd_tile_t * l_tile; |
1904 OPJ_UINT32 l_nb_elem,i; | 1897 OPJ_UINT32 l_nb_elem,i; |
1905 OPJ_INT32 * l_current_ptr; | 1898 OPJ_INT32 * l_current_ptr; |
1906 | 1899 |
1907 l_tile = p_tcd->tcd_image->tiles; | 1900 l_tile = p_tcd->tcd_image->tiles; |
(...skipping 19 matching lines...) Expand all Loading... |
1927 } | 1920 } |
1928 | 1921 |
1929 ++l_img_comp; | 1922 ++l_img_comp; |
1930 ++l_tccp; | 1923 ++l_tccp; |
1931 ++l_tile_comp; | 1924 ++l_tile_comp; |
1932 } | 1925 } |
1933 | 1926 |
1934 return OPJ_TRUE; | 1927 return OPJ_TRUE; |
1935 } | 1928 } |
1936 | 1929 |
1937 OPJ_BOOL opj_tcd_mct_encode ( opj_tcd_t *p_tcd ) | 1930 static OPJ_BOOL opj_tcd_mct_encode ( opj_tcd_t *p_tcd ) |
1938 { | 1931 { |
1939 opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles; | 1932 opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles; |
1940 opj_tcd_tilecomp_t * l_tile_comp = p_tcd->tcd_image->tiles->comps; | 1933 opj_tcd_tilecomp_t * l_tile_comp = p_tcd->tcd_image->tiles->comps; |
1941 OPJ_UINT32 samples = (OPJ_UINT32)((l_tile_comp->x1 - l_tile_comp->x0) *
(l_tile_comp->y1 - l_tile_comp->y0)); | 1934 OPJ_UINT32 samples = (OPJ_UINT32)((l_tile_comp->x1 - l_tile_comp->x0) *
(l_tile_comp->y1 - l_tile_comp->y0)); |
1942 OPJ_UINT32 i; | 1935 OPJ_UINT32 i; |
1943 OPJ_BYTE ** l_data = 00; | 1936 OPJ_BYTE ** l_data = 00; |
1944 opj_tcp_t * l_tcp = p_tcd->tcp; | 1937 opj_tcp_t * l_tcp = p_tcd->tcp; |
1945 | 1938 |
1946 if(!p_tcd->tcp->mct) { | 1939 if(!p_tcd->tcp->mct) { |
1947 return OPJ_TRUE; | 1940 return OPJ_TRUE; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1982 else if (l_tcp->tccps->qmfbid == 0) { | 1975 else if (l_tcp->tccps->qmfbid == 0) { |
1983 opj_mct_encode_real(l_tile->comps[0].data, l_tile->comps[1].data
, l_tile->comps[2].data, samples); | 1976 opj_mct_encode_real(l_tile->comps[0].data, l_tile->comps[1].data
, l_tile->comps[2].data, samples); |
1984 } | 1977 } |
1985 else { | 1978 else { |
1986 opj_mct_encode(l_tile->comps[0].data, l_tile->comps[1].data, l_t
ile->comps[2].data, samples); | 1979 opj_mct_encode(l_tile->comps[0].data, l_tile->comps[1].data, l_t
ile->comps[2].data, samples); |
1987 } | 1980 } |
1988 | 1981 |
1989 return OPJ_TRUE; | 1982 return OPJ_TRUE; |
1990 } | 1983 } |
1991 | 1984 |
1992 OPJ_BOOL opj_tcd_dwt_encode ( opj_tcd_t *p_tcd ) | 1985 static OPJ_BOOL opj_tcd_dwt_encode ( opj_tcd_t *p_tcd ) |
1993 { | 1986 { |
1994 opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles; | 1987 opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles; |
1995 opj_tcd_tilecomp_t * l_tile_comp = p_tcd->tcd_image->tiles->comps; | 1988 opj_tcd_tilecomp_t * l_tile_comp = p_tcd->tcd_image->tiles->comps; |
1996 opj_tccp_t * l_tccp = p_tcd->tcp->tccps; | 1989 opj_tccp_t * l_tccp = p_tcd->tcp->tccps; |
1997 OPJ_UINT32 compno; | 1990 OPJ_UINT32 compno; |
1998 | 1991 |
1999 for (compno = 0; compno < l_tile->numcomps; ++compno) { | 1992 for (compno = 0; compno < l_tile->numcomps; ++compno) { |
2000 if (l_tccp->qmfbid == 1) { | 1993 if (l_tccp->qmfbid == 1) { |
2001 if (! opj_dwt_encode(l_tile_comp)) { | 1994 if (! opj_dwt_encode(l_tile_comp)) { |
2002 return OPJ_FALSE; | 1995 return OPJ_FALSE; |
2003 } | 1996 } |
2004 } | 1997 } |
2005 else if (l_tccp->qmfbid == 0) { | 1998 else if (l_tccp->qmfbid == 0) { |
2006 if (! opj_dwt_encode_real(l_tile_comp)) { | 1999 if (! opj_dwt_encode_real(l_tile_comp)) { |
2007 return OPJ_FALSE; | 2000 return OPJ_FALSE; |
2008 } | 2001 } |
2009 } | 2002 } |
2010 | 2003 |
2011 ++l_tile_comp; | 2004 ++l_tile_comp; |
2012 ++l_tccp; | 2005 ++l_tccp; |
2013 } | 2006 } |
2014 | 2007 |
2015 return OPJ_TRUE; | 2008 return OPJ_TRUE; |
2016 } | 2009 } |
2017 | 2010 |
2018 OPJ_BOOL opj_tcd_t1_encode ( opj_tcd_t *p_tcd ) | 2011 static OPJ_BOOL opj_tcd_t1_encode ( opj_tcd_t *p_tcd ) |
2019 { | 2012 { |
2020 opj_t1_t * l_t1; | 2013 opj_t1_t * l_t1; |
2021 const OPJ_FLOAT64 * l_mct_norms; | 2014 const OPJ_FLOAT64 * l_mct_norms; |
2022 OPJ_UINT32 l_mct_numcomps = 0U; | 2015 OPJ_UINT32 l_mct_numcomps = 0U; |
2023 opj_tcp_t * l_tcp = p_tcd->tcp; | 2016 opj_tcp_t * l_tcp = p_tcd->tcp; |
2024 | 2017 |
2025 l_t1 = opj_t1_create(OPJ_TRUE); | 2018 l_t1 = opj_t1_create(OPJ_TRUE); |
2026 if (l_t1 == 00) { | 2019 if (l_t1 == 00) { |
2027 return OPJ_FALSE; | 2020 return OPJ_FALSE; |
2028 } | 2021 } |
(...skipping 16 matching lines...) Expand all Loading... |
2045 if (! opj_t1_encode_cblks(l_t1, p_tcd->tcd_image->tiles , l_tcp, l_mct_n
orms, l_mct_numcomps)) { | 2038 if (! opj_t1_encode_cblks(l_t1, p_tcd->tcd_image->tiles , l_tcp, l_mct_n
orms, l_mct_numcomps)) { |
2046 opj_t1_destroy(l_t1); | 2039 opj_t1_destroy(l_t1); |
2047 return OPJ_FALSE; | 2040 return OPJ_FALSE; |
2048 } | 2041 } |
2049 | 2042 |
2050 opj_t1_destroy(l_t1); | 2043 opj_t1_destroy(l_t1); |
2051 | 2044 |
2052 return OPJ_TRUE; | 2045 return OPJ_TRUE; |
2053 } | 2046 } |
2054 | 2047 |
2055 OPJ_BOOL opj_tcd_t2_encode (opj_tcd_t *p_tcd, | 2048 static OPJ_BOOL opj_tcd_t2_encode (opj_tcd_t *p_tcd, |
2056 OPJ_BYTE * p_dest_data, | 2049 OPJ_BYTE * p_dest_data, |
2057 OPJ_UINT32 * p_data_written, | 2050 OPJ_UINT32 * p_data_written, |
2058 OPJ_UINT32 p_max_dest_size, | 2051 OPJ_UINT32 p_max_dest_size, |
2059 opj_codestream_info_t *p_cstr_in
fo ) | 2052 opj_codestream_info_t *p_cstr_in
fo ) |
2060 { | 2053 { |
2061 opj_t2_t * l_t2; | 2054 opj_t2_t * l_t2; |
2062 | 2055 |
2063 l_t2 = opj_t2_create(p_tcd->image, p_tcd->cp); | 2056 l_t2 = opj_t2_create(p_tcd->image, p_tcd->cp); |
2064 if (l_t2 == 00) { | 2057 if (l_t2 == 00) { |
2065 return OPJ_FALSE; | 2058 return OPJ_FALSE; |
(...skipping 17 matching lines...) Expand all Loading... |
2083 return OPJ_FALSE; | 2076 return OPJ_FALSE; |
2084 } | 2077 } |
2085 | 2078 |
2086 opj_t2_destroy(l_t2); | 2079 opj_t2_destroy(l_t2); |
2087 | 2080 |
2088 /*---------------CLEAN-------------------*/ | 2081 /*---------------CLEAN-------------------*/ |
2089 return OPJ_TRUE; | 2082 return OPJ_TRUE; |
2090 } | 2083 } |
2091 | 2084 |
2092 | 2085 |
2093 OPJ_BOOL opj_tcd_rate_allocate_encode( opj_tcd_t *p_tcd, | 2086 static OPJ_BOOL opj_tcd_rate_allocate_encode( opj_tcd_t *p_tcd, |
2094 OPJ_
BYTE * p_dest_data, | 2087 OPJ_
BYTE * p_dest_data, |
2095 OPJ_
UINT32 p_max_dest_size, | 2088 OPJ_
UINT32 p_max_dest_size, |
2096 opj_
codestream_info_t *p_cstr_info ) | 2089 opj_
codestream_info_t *p_cstr_info ) |
2097 { | 2090 { |
2098 opj_cp_t * l_cp = p_tcd->cp; | 2091 opj_cp_t * l_cp = p_tcd->cp; |
2099 OPJ_UINT32 l_nb_written = 0; | 2092 OPJ_UINT32 l_nb_written = 0; |
2100 | 2093 |
2101 if (p_cstr_info) { | 2094 if (p_cstr_info) { |
2102 p_cstr_info->index_write = 0; | 2095 p_cstr_info->index_write = 0; |
2103 } | 2096 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2200 } | 2193 } |
2201 break; | 2194 break; |
2202 } | 2195 } |
2203 | 2196 |
2204 ++l_img_comp; | 2197 ++l_img_comp; |
2205 ++l_tilec; | 2198 ++l_tilec; |
2206 } | 2199 } |
2207 | 2200 |
2208 return OPJ_TRUE; | 2201 return OPJ_TRUE; |
2209 } | 2202 } |
OLD | NEW |