| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 /* ----------------------------------------------------------------------- */ | 168 /* ----------------------------------------------------------------------- */ |
| 169 | 169 |
| 170 /** | 170 /** |
| 171 Create a new TCD handle | 171 Create a new TCD handle |
| 172 */ | 172 */ |
| 173 opj_tcd_t* opj_tcd_create(OPJ_BOOL p_is_decoder) | 173 opj_tcd_t* opj_tcd_create(OPJ_BOOL p_is_decoder) |
| 174 { | 174 { |
| 175 opj_tcd_t *l_tcd = 00; | 175 opj_tcd_t *l_tcd = 00; |
| 176 | 176 |
| 177 /* create the tcd structure */ | 177 /* create the tcd structure */ |
| 178 l_tcd = (opj_tcd_t*) opj_malloc(sizeof(opj_tcd_t)); | 178 l_tcd = (opj_tcd_t*) opj_calloc(1,sizeof(opj_tcd_t)); |
| 179 if (!l_tcd) { | 179 if (!l_tcd) { |
| 180 return 00; | 180 return 00; |
| 181 } | 181 } |
| 182 memset(l_tcd,0,sizeof(opj_tcd_t)); | |
| 183 | 182 |
| 184 l_tcd->m_is_decoder = p_is_decoder ? 1 : 0; | 183 l_tcd->m_is_decoder = p_is_decoder ? 1 : 0; |
| 185 | 184 |
| 186 l_tcd->tcd_image = (opj_tcd_image_t*)opj_malloc(sizeof(opj_tcd_image_t))
; | 185 l_tcd->tcd_image = (opj_tcd_image_t*)opj_calloc(1,sizeof(opj_tcd_image_t
)); |
| 187 if (!l_tcd->tcd_image) { | 186 if (!l_tcd->tcd_image) { |
| 188 opj_free(l_tcd); | 187 opj_free(l_tcd); |
| 189 return 00; | 188 return 00; |
| 190 } | 189 } |
| 191 memset(l_tcd->tcd_image,0,sizeof(opj_tcd_image_t)); | |
| 192 | 190 |
| 193 return l_tcd; | 191 return l_tcd; |
| 194 } | 192 } |
| 195 | 193 |
| 196 | 194 |
| 197 /* ----------------------------------------------------------------------- */ | 195 /* ----------------------------------------------------------------------- */ |
| 198 | 196 |
| 199 void opj_tcd_rateallocate_fixed(opj_tcd_t *tcd) { | 197 void opj_tcd_rateallocate_fixed(opj_tcd_t *tcd) { |
| 200 OPJ_UINT32 layno; | 198 OPJ_UINT32 layno; |
| 201 | 199 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 * ((OPJ_FLOAT64)(1 << tcd->image->comps[compno].prec) -1
.0)) | 458 * ((OPJ_FLOAT64)(1 << tcd->image->comps[compno].prec) -1
.0)) |
| 461 * ((OPJ_FLOAT64)(tilec->numpix)); | 459 * ((OPJ_FLOAT64)(tilec->numpix)); |
| 462 } /* compno */ | 460 } /* compno */ |
| 463 | 461 |
| 464 /* index file */ | 462 /* index file */ |
| 465 if(cstr_info) { | 463 if(cstr_info) { |
| 466 opj_tile_info_t *tile_info = &cstr_info->tile[tcd->tcd_tileno]; | 464 opj_tile_info_t *tile_info = &cstr_info->tile[tcd->tcd_tileno]; |
| 467 tile_info->numpix = tcd_tile->numpix; | 465 tile_info->numpix = tcd_tile->numpix; |
| 468 tile_info->distotile = tcd_tile->distotile; | 466 tile_info->distotile = tcd_tile->distotile; |
| 469 tile_info->thresh = (OPJ_FLOAT64 *) opj_malloc(tcd_tcp->numlayer
s * sizeof(OPJ_FLOAT64)); | 467 tile_info->thresh = (OPJ_FLOAT64 *) opj_malloc(tcd_tcp->numlayer
s * sizeof(OPJ_FLOAT64)); |
| 468 if (!tile_info->thresh) { |
| 469 /* FIXME event manager error callback */ |
| 470 return OPJ_FALSE; |
| 471 } |
| 470 } | 472 } |
| 471 | 473 |
| 472 for (layno = 0; layno < tcd_tcp->numlayers; layno++) { | 474 for (layno = 0; layno < tcd_tcp->numlayers; layno++) { |
| 473 OPJ_FLOAT64 lo = min; | 475 OPJ_FLOAT64 lo = min; |
| 474 OPJ_FLOAT64 hi = max; | 476 OPJ_FLOAT64 hi = max; |
| 475 OPJ_BOOL success = OPJ_FALSE; | 477 OPJ_BOOL success = OPJ_FALSE; |
| 476 OPJ_UINT32 maxlen = tcd_tcp->rates[layno] ? opj_uint_min(((OPJ_U
INT32) ceil(tcd_tcp->rates[layno])), len) : len; | 478 OPJ_UINT32 maxlen = tcd_tcp->rates[layno] ? opj_uint_min(((OPJ_U
INT32) ceil(tcd_tcp->rates[layno])), len) : len; |
| 477 OPJ_FLOAT64 goodthresh = 0; | 479 OPJ_FLOAT64 goodthresh = 0; |
| 478 OPJ_FLOAT64 stable_thresh = 0; | 480 OPJ_FLOAT64 stable_thresh = 0; |
| 479 OPJ_UINT32 i; | 481 OPJ_UINT32 i; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 495 } | 497 } |
| 496 | 498 |
| 497 for (i = 0; i < 128; ++i) { | 499 for (i = 0; i < 128; ++i) { |
| 498 OPJ_FLOAT64 distoachieved = 0; /* fixed_quality
*/ | 500 OPJ_FLOAT64 distoachieved = 0; /* fixed_quality
*/ |
| 499 | 501 |
| 500 thresh = (lo + hi) / 2; | 502 thresh = (lo + hi) / 2; |
| 501 | 503 |
| 502 opj_tcd_makelayer(tcd, layno, thresh, 0); | 504 opj_tcd_makelayer(tcd, layno, thresh, 0); |
| 503 | 505 |
| 504 if (cp->m_specific_param.m_enc.m_fixed_quality)
{ /* fixed_quality */ | 506 if (cp->m_specific_param.m_enc.m_fixed_quality)
{ /* fixed_quality */ |
| 505 if(cp->m_specific_param.m_enc.m_cinema){ | 507 if(OPJ_IS_CINEMA(cp->rsiz)){ |
| 506 if (! opj_t2_encode_packets(t2,t
cd->tcd_tileno, tcd_tile, layno + 1, dest, p_data_written, maxlen, cstr_info,tcd
->cur_tp_num,tcd->tp_pos,tcd->cur_pino,THRESH_CALC)) { | 508 if (! opj_t2_encode_packets(t2,t
cd->tcd_tileno, tcd_tile, layno + 1, dest, p_data_written, maxlen, cstr_info,tcd
->cur_tp_num,tcd->tp_pos,tcd->cur_pino,THRESH_CALC)) { |
| 507 | 509 |
| 508 lo = thresh; | 510 lo = thresh; |
| 509 continue; | 511 continue; |
| 510 } | 512 } |
| 511 else { | 513 else { |
| 512 distoachieved = layno ==
0 ? | 514 distoachieved = layno ==
0 ? |
| 513 tcd_tile
->distolayer[0] : cumdisto[layno - 1] + tcd_tile->distolayer[layno]; | 515 tcd_tile
->distolayer[0] : cumdisto[layno - 1] + tcd_tile->distolayer[layno]; |
| 514 | 516 |
| 515 if (distoachieved < dist
otarget) { | 517 if (distoachieved < dist
otarget) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 cumdisto[layno] = (layno == 0) ? tcd_tile->distolayer[0] : (cumd
isto[layno - 1] + tcd_tile->distolayer[layno]); | 570 cumdisto[layno] = (layno == 0) ? tcd_tile->distolayer[0] : (cumd
isto[layno - 1] + tcd_tile->distolayer[layno]); |
| 569 } | 571 } |
| 570 | 572 |
| 571 return OPJ_TRUE; | 573 return OPJ_TRUE; |
| 572 } | 574 } |
| 573 | 575 |
| 574 OPJ_BOOL opj_tcd_init( opj_tcd_t *p_tcd, | 576 OPJ_BOOL opj_tcd_init( opj_tcd_t *p_tcd, |
| 575 opj_image_t * p_image, | 577 opj_image_t * p_image, |
| 576 opj_cp_t * p_cp ) | 578 opj_cp_t * p_cp ) |
| 577 { | 579 { |
| 578 OPJ_UINT32 l_tile_comp_size; | |
| 579 | |
| 580 p_tcd->image = p_image; | 580 p_tcd->image = p_image; |
| 581 p_tcd->cp = p_cp; | 581 p_tcd->cp = p_cp; |
| 582 | 582 |
| 583 p_tcd->tcd_image->tiles = (opj_tcd_tile_t *) opj_malloc(sizeof(opj_tcd_t
ile_t)); | 583 p_tcd->tcd_image->tiles = (opj_tcd_tile_t *) opj_calloc(1,sizeof(opj_tcd
_tile_t)); |
| 584 if (! p_tcd->tcd_image->tiles) { | 584 if (! p_tcd->tcd_image->tiles) { |
| 585 return OPJ_FALSE; | 585 return OPJ_FALSE; |
| 586 } | 586 } |
| 587 memset(p_tcd->tcd_image->tiles,0, sizeof(opj_tcd_tile_t)); | |
| 588 | 587 |
| 589 l_tile_comp_size = p_image->numcomps * (OPJ_UINT32)sizeof(opj_tcd_tileco
mp_t); | 588 p_tcd->tcd_image->tiles->comps = (opj_tcd_tilecomp_t *) opj_calloc(p_ima
ge->numcomps,sizeof(opj_tcd_tilecomp_t)); |
| 590 p_tcd->tcd_image->tiles->comps = (opj_tcd_tilecomp_t *) opj_malloc(l_til
e_comp_size); | |
| 591 if (! p_tcd->tcd_image->tiles->comps ) { | 589 if (! p_tcd->tcd_image->tiles->comps ) { |
| 592 return OPJ_FALSE; | 590 return OPJ_FALSE; |
| 593 } | 591 } |
| 594 memset( p_tcd->tcd_image->tiles->comps , 0 , l_tile_comp_size); | |
| 595 | 592 |
| 596 p_tcd->tcd_image->tiles->numcomps = p_image->numcomps; | 593 p_tcd->tcd_image->tiles->numcomps = p_image->numcomps; |
| 597 p_tcd->tp_pos = p_cp->m_specific_param.m_enc.m_tp_pos; | 594 p_tcd->tp_pos = p_cp->m_specific_param.m_enc.m_tp_pos; |
| 598 | 595 |
| 599 return OPJ_TRUE; | 596 return OPJ_TRUE; |
| 600 } | 597 } |
| 601 | 598 |
| 602 /** | 599 /** |
| 603 Destroy a previously created TCD handle | 600 Destroy a previously created TCD handle |
| 604 */ | 601 */ |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 /*tile->numcomps = image->numcomps; */ \ | 676 /*tile->numcomps = image->numcomps; */ \ |
| 680 for(compno = 0; compno < l_tile->numcomps; ++compno) { \ | 677 for(compno = 0; compno < l_tile->numcomps; ++compno) { \ |
| 681 /*fprintf(stderr, "compno = %d/%d\n", compno, l_tile->numcomps);
*/
\ | 678 /*fprintf(stderr, "compno = %d/%d\n", compno, l_tile->numcomps);
*/
\ |
| 682 \ | 679 \ |
| 683 /* border of each l_tile component (global) */ \ | 680 /* border of each l_tile component (global) */ \ |
| 684 l_tilec->x0 = opj_int_ceildiv(l_tile->x0, (OPJ_INT32)l_image_com
p->dx);
\ | 681 l_tilec->x0 = opj_int_ceildiv(l_tile->x0, (OPJ_INT32)l_image_com
p->dx);
\ |
| 685 l_tilec->y0 = opj_int_ceildiv(l_tile->y0, (OPJ_INT32)l_image_com
p->dy);
\ | 682 l_tilec->y0 = opj_int_ceildiv(l_tile->y0, (OPJ_INT32)l_image_com
p->dy);
\ |
| 686 l_tilec->x1 = opj_int_ceildiv(l_tile->x1, (OPJ_INT32)l_image_com
p->dx);
\ | 683 l_tilec->x1 = opj_int_ceildiv(l_tile->x1, (OPJ_INT32)l_image_com
p->dx);
\ |
| 687 l_tilec->y1 = opj_int_ceildiv(l_tile->y1, (OPJ_INT32)l_image_com
p->dy);
\ | 684 l_tilec->y1 = opj_int_ceildiv(l_tile->y1, (OPJ_INT32)l_image_com
p->dy);
\ |
| 688 /*fprintf(stderr, "\tTile compo border = %d,%d,%d,%d\n", l_tilec
->x0, l_tilec->y0,l_tilec->x1,l_tilec->y1);*/
\ | 685 /*fprintf(stderr, "\tTile compo border = %d,%d,%d,%d\n", l_tilec
->x0, l_tilec->y0,l_tilec->x1,l_tilec->y1);*/
\ |
| 689 if (l_tilec->x1 < 0 || l_tilec->x0 < 0 || l_tilec->y1 < 0 || l_t
ilec->y0 < 0) return OPJ_FALSE;\ | 686 \ |
| 690 l_data_size = (OPJ_UINT32)(l_tilec->x1 - l_tilec->x0)
\ | 687 l_data_size = (OPJ_UINT32)(l_tilec->x1 - l_tilec->x0)
\ |
| 691 * (OPJ_UINT32)(l_tilec->y1 - l_tilec->y0) * (OPJ_UINT32)sizeof(O
PJ_UINT32 );\ | 688 * (OPJ_UINT32)(l_tilec->y1 - l_tilec->y0) * (OPJ_UINT32)sizeof(O
PJ_UINT32 );\ |
| 692 l_tilec->numresolutions = l_tccp->numresolutions; \ | 689 l_tilec->numresolutions = l_tccp->numresolutions; \ |
| 693 if (l_tccp->numresolutions < l_cp->m_specific_param.m_dec.m_redu
ce) {
\ | 690 if (l_tccp->numresolutions < l_cp->m_specific_param.m_dec.m_redu
ce) {
\ |
| 694 l_tilec->minimum_num_resolutions = 1; \ | 691 l_tilec->minimum_num_resolutions = 1; \ |
| 695 } \ | 692 } \ |
| 696 else { \ | 693 else { \ |
| 697 l_tilec->minimum_num_resolutions = l_tccp->numresolution
s
\ | 694 l_tilec->minimum_num_resolutions = l_tccp->numresolution
s
\ |
| 698 - l_cp->m_specific_param.m_dec.m_reduce; \ | 695 - l_cp->m_specific_param.m_dec.m_reduce; \ |
| 699 } \ | 696 } \ |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768
\ | 765
\ |
| 769 /* border for each resolution level (global) */
\ | 766 /* border for each resolution level (global) */
\ |
| 770 l_res->x0 = opj_int_ceildivpow2(l_tilec->x0, (OPJ_INT32)
l_level_no);
\ | 767 l_res->x0 = opj_int_ceildivpow2(l_tilec->x0, (OPJ_INT32)
l_level_no);
\ |
| 771 l_res->y0 = opj_int_ceildivpow2(l_tilec->y0, (OPJ_INT32)
l_level_no);
\ | 768 l_res->y0 = opj_int_ceildivpow2(l_tilec->y0, (OPJ_INT32)
l_level_no);
\ |
| 772 l_res->x1 = opj_int_ceildivpow2(l_tilec->x1, (OPJ_INT32)
l_level_no);
\ | 769 l_res->x1 = opj_int_ceildivpow2(l_tilec->x1, (OPJ_INT32)
l_level_no);
\ |
| 773 l_res->y1 = opj_int_ceildivpow2(l_tilec->y1, (OPJ_INT32)
l_level_no);
\ | 770 l_res->y1 = opj_int_ceildivpow2(l_tilec->y1, (OPJ_INT32)
l_level_no);
\ |
| 774 /*fprintf(stderr, "\t\t\tres_x0= %d, res_y0 =%d, res_x1=
%d, res_y1=%d\n", l_res->x0, l_res->y0, l_res->x1, l_res->y1);*/
\ | 771 /*fprintf(stderr, "\t\t\tres_x0= %d, res_y0 =%d, res_x1=
%d, res_y1=%d\n", l_res->x0, l_res->y0, l_res->x1, l_res->y1);*/
\ |
| 775 /* p. 35, table A-23, ISO/IEC FDIS154444-1 : 2000 (18 au
gust 2000) */
\ | 772 /* p. 35, table A-23, ISO/IEC FDIS154444-1 : 2000 (18 au
gust 2000) */
\ |
| 776 l_pdx = l_tccp->prcw[resno];
\ | 773 l_pdx = l_tccp->prcw[resno];
\ |
| 777 l_pdy = l_tccp->prch[resno];
\ | 774 l_pdy = l_tccp->prch[resno];
\ |
| 778 if (l_pdx == 0 || l_pdy == 0)
\ | |
| 779 return OPJ_FALSE;
\ | |
| 780 /*fprintf(stderr, "\t\t\tpdx=%d, pdy=%d\n", l_pdx, l_pdy
);*/
\ | 775 /*fprintf(stderr, "\t\t\tpdx=%d, pdy=%d\n", l_pdx, l_pdy
);*/
\ |
| 781 /* p. 64, B.6, ISO/IEC FDIS15444-1 : 2000 (18 august 200
0) */
\ | 776 /* p. 64, B.6, ISO/IEC FDIS15444-1 : 2000 (18 august 200
0) */
\ |
| 782 l_tl_prc_x_start = opj_int_floordivpow2(l_res->x0, (OPJ_
INT32)l_pdx) << l_pdx;
\ | 777 l_tl_prc_x_start = opj_int_floordivpow2(l_res->x0, (OPJ_
INT32)l_pdx) << l_pdx;
\ |
| 783 l_tl_prc_y_start = opj_int_floordivpow2(l_res->y0, (OPJ_
INT32)l_pdy) << l_pdy;
\ | 778 l_tl_prc_y_start = opj_int_floordivpow2(l_res->y0, (OPJ_
INT32)l_pdy) << l_pdy;
\ |
| 784 l_br_prc_x_end = opj_int_ceildivpow2(l_res->x1, (OPJ_INT
32)l_pdx) << l_pdx;
\ | 779 l_br_prc_x_end = opj_int_ceildivpow2(l_res->x1, (OPJ_INT
32)l_pdx) << l_pdx;
\ |
| 785 l_br_prc_y_end = opj_int_ceildivpow2(l_res->y1, (OPJ_INT
32)l_pdy) << l_pdy;
\ | 780 l_br_prc_y_end = opj_int_ceildivpow2(l_res->y1, (OPJ_INT
32)l_pdy) << l_pdy;
\ |
| 786 /*fprintf(stderr, "\t\t\tprc_x_start=%d, prc_y_start=%d,
br_prc_x_end=%d, br_prc_y_end=%d \n", l_tl_prc_x_start, l_tl_prc_y_start, l_br_
prc_x_end ,l_br_prc_y_end );*/ \ | 781 /*fprintf(stderr, "\t\t\tprc_x_start=%d, prc_y_start=%d,
br_prc_x_end=%d, br_prc_y_end=%d \n", l_tl_prc_x_start, l_tl_prc_y_start, l_br_
prc_x_end ,l_br_prc_y_end );*/ \ |
| 787
\ | 782
\ |
| 788 l_res->pw = (l_res->x0 == l_res->x1) ? 0 : (OPJ_UINT32)(
(l_br_prc_x_end - l_tl_prc_x_start) >> l_pdx);
\ | 783 l_res->pw = (l_res->x0 == l_res->x1) ? 0 : (OPJ_UINT32)(
(l_br_prc_x_end - l_tl_prc_x_start) >> l_pdx);
\ |
| 789 l_res->ph = (l_res->y0 == l_res->y1) ? 0 : (OPJ_UINT32)(
(l_br_prc_y_end - l_tl_prc_y_start) >> l_pdy);
\ | 784 l_res->ph = (l_res->y0 == l_res->y1) ? 0 : (OPJ_UINT32)(
(l_br_prc_y_end - l_tl_prc_y_start) >> l_pdy);
\ |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 | 1011 |
| 1017 p_code_block->data = (OPJ_BYTE*) opj_malloc(OPJ_J2K_DEFAULT_CBLK
_DATA_SIZE*2); /*why +1 ?*/ | 1012 p_code_block->data = (OPJ_BYTE*) opj_malloc(OPJ_J2K_DEFAULT_CBLK
_DATA_SIZE*2); /*why +1 ?*/ |
| 1018 if(! p_code_block->data) { | 1013 if(! p_code_block->data) { |
| 1019 return OPJ_FALSE; | 1014 return OPJ_FALSE; |
| 1020 } | 1015 } |
| 1021 | 1016 |
| 1022 p_code_block->data[0] = 0; | 1017 p_code_block->data[0] = 0; |
| 1023 p_code_block->data+=1; | 1018 p_code_block->data+=1; |
| 1024 | 1019 |
| 1025 /* no memset since data */ | 1020 /* no memset since data */ |
| 1026 p_code_block->layers = (opj_tcd_layer_t*) opj_malloc(100 * sizeo
f(opj_tcd_layer_t)); | 1021 p_code_block->layers = (opj_tcd_layer_t*) opj_calloc(100, sizeof
(opj_tcd_layer_t)); |
| 1027 if (! p_code_block->layers) { | 1022 if (! p_code_block->layers) { |
| 1028 return OPJ_FALSE; | 1023 return OPJ_FALSE; |
| 1029 } | 1024 } |
| 1030 | 1025 |
| 1031 p_code_block->passes = (opj_tcd_pass_t*) opj_malloc(100 * sizeof
(opj_tcd_pass_t)); | 1026 p_code_block->passes = (opj_tcd_pass_t*) opj_calloc(100, sizeof(
opj_tcd_pass_t)); |
| 1032 if (! p_code_block->passes) { | 1027 if (! p_code_block->passes) { |
| 1033 return OPJ_FALSE; | 1028 return OPJ_FALSE; |
| 1034 } | 1029 } |
| 1035 } | 1030 } |
| 1036 | 1031 |
| 1037 memset(p_code_block->layers,0,100 * sizeof(opj_tcd_layer_t)); | |
| 1038 memset(p_code_block->passes,0,100 * sizeof(opj_tcd_pass_t)); | |
| 1039 | |
| 1040 return OPJ_TRUE; | 1032 return OPJ_TRUE; |
| 1041 } | 1033 } |
| 1042 | 1034 |
| 1043 /** | 1035 /** |
| 1044 * Allocates memory for a decoding code block. | 1036 * Allocates memory for a decoding code block. |
| 1045 */ | 1037 */ |
| 1046 OPJ_BOOL opj_tcd_code_block_dec_allocate (opj_tcd_cblk_dec_t * p_code_block) | 1038 OPJ_BOOL opj_tcd_code_block_dec_allocate (opj_tcd_cblk_dec_t * p_code_block) |
| 1047 { | 1039 { |
| 1048 OPJ_UINT32 l_seg_size; | |
| 1049 | |
| 1050 if (! p_code_block->data) { | 1040 if (! p_code_block->data) { |
| 1051 | 1041 |
| 1052 p_code_block->data = (OPJ_BYTE*) opj_malloc(OPJ_J2K_DEFAULT_CBLK
_DATA_SIZE); | 1042 p_code_block->data = (OPJ_BYTE*) opj_malloc(OPJ_J2K_DEFAULT_CBLK
_DATA_SIZE); |
| 1053 if (! p_code_block->data) { | 1043 if (! p_code_block->data) { |
| 1054 return OPJ_FALSE; | 1044 return OPJ_FALSE; |
| 1055 } | 1045 } |
| 1056 p_code_block->data_max_size = OPJ_J2K_DEFAULT_CBLK_DATA_SIZE; | 1046 p_code_block->data_max_size = OPJ_J2K_DEFAULT_CBLK_DATA_SIZE; |
| 1057 /*fprintf(stderr, "Allocate 8192 elements of code_block->data\n"
);*/ | 1047 /*fprintf(stderr, "Allocate 8192 elements of code_block->data\n"
);*/ |
| 1058 | 1048 |
| 1059 l_seg_size = OPJ_J2K_DEFAULT_NB_SEGS * sizeof(opj_tcd_seg_t); | 1049 p_code_block->segs = (opj_tcd_seg_t *) opj_calloc(OPJ_J2K_DEFAUL
T_NB_SEGS,sizeof(opj_tcd_seg_t)); |
| 1060 p_code_block->segs = (opj_tcd_seg_t *) opj_malloc(l_seg_size); | |
| 1061 if (! p_code_block->segs) { | 1050 if (! p_code_block->segs) { |
| 1062 return OPJ_FALSE; | 1051 return OPJ_FALSE; |
| 1063 } | 1052 } |
| 1064 memset(p_code_block->segs,0,l_seg_size); | |
| 1065 /*fprintf(stderr, "Allocate %d elements of code_block->data\n",
OPJ_J2K_DEFAULT_NB_SEGS * sizeof(opj_tcd_seg_t));*/ | 1053 /*fprintf(stderr, "Allocate %d elements of code_block->data\n",
OPJ_J2K_DEFAULT_NB_SEGS * sizeof(opj_tcd_seg_t));*/ |
| 1066 | 1054 |
| 1067 p_code_block->m_current_max_segs = OPJ_J2K_DEFAULT_NB_SEGS; | 1055 p_code_block->m_current_max_segs = OPJ_J2K_DEFAULT_NB_SEGS; |
| 1068 /*fprintf(stderr, "m_current_max_segs of code_block->data = %d\n
", p_code_block->m_current_max_segs);*/ | 1056 /*fprintf(stderr, "m_current_max_segs of code_block->data = %d\n
", p_code_block->m_current_max_segs);*/ |
| 1069 } | 1057 } |
| 1070 /* TODO */ | 1058 /* TODO */ |
| 1071 /*p_code_block->numsegs = 0; */ | 1059 /*p_code_block->numsegs = 0; */ |
| 1072 | 1060 |
| 1073 return OPJ_TRUE; | 1061 return OPJ_TRUE; |
| 1074 } | 1062 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 opj_tcd_resolution_t *l_res_idx = &l_tilec_idx->
resolutions[i]; | 1118 opj_tcd_resolution_t *l_res_idx = &l_tilec_idx->
resolutions[i]; |
| 1131 | 1119 |
| 1132 p_cstr_info->tile[p_tile_no].pw[i] = (int)l_res_
idx->pw; | 1120 p_cstr_info->tile[p_tile_no].pw[i] = (int)l_res_
idx->pw; |
| 1133 p_cstr_info->tile[p_tile_no].ph[i] = (int)l_res_
idx->ph; | 1121 p_cstr_info->tile[p_tile_no].ph[i] = (int)l_res_
idx->ph; |
| 1134 | 1122 |
| 1135 l_num_packs += l_res_idx->pw * l_res_idx->ph; | 1123 l_num_packs += l_res_idx->pw * l_res_idx->ph; |
| 1136 p_cstr_info->tile[p_tile_no].pdx[i] = (int)l_tcc
p->prcw[i]; | 1124 p_cstr_info->tile[p_tile_no].pdx[i] = (int)l_tcc
p->prcw[i]; |
| 1137 p_cstr_info->tile[p_tile_no].pdy[i] = (int)l_tcc
p->prch[i]; | 1125 p_cstr_info->tile[p_tile_no].pdy[i] = (int)l_tcc
p->prch[i]; |
| 1138 } | 1126 } |
| 1139 p_cstr_info->tile[p_tile_no].packet = (opj_packet_info_t
*) opj_calloc((size_t)p_cstr_info->numcomps * (size_t)p_cstr_info->numlayers * l
_num_packs, sizeof(opj_packet_info_t)); | 1127 p_cstr_info->tile[p_tile_no].packet = (opj_packet_info_t
*) opj_calloc((size_t)p_cstr_info->numcomps * (size_t)p_cstr_info->numlayers * l
_num_packs, sizeof(opj_packet_info_t)); |
| 1128 if (!p_cstr_info->tile[p_tile_no].packet) { |
| 1129 /* FIXME event manager error callback */ |
| 1130 return OPJ_FALSE; |
| 1131 } |
| 1140 } | 1132 } |
| 1141 /* << INDEX */ | 1133 /* << INDEX */ |
| 1142 | 1134 |
| 1143 /* FIXME _ProfStart(PGROUP_DC_SHIFT); */ | 1135 /* FIXME _ProfStart(PGROUP_DC_SHIFT); */ |
| 1144 /*---------------TILE-------------------*/ | 1136 /*---------------TILE-------------------*/ |
| 1145 if (! opj_tcd_dc_level_shift_encode(p_tcd)) { | 1137 if (! opj_tcd_dc_level_shift_encode(p_tcd)) { |
| 1146 return OPJ_FALSE; | 1138 return OPJ_FALSE; |
| 1147 } | 1139 } |
| 1148 /* FIXME _ProfStop(PGROUP_DC_SHIFT); */ | 1140 /* FIXME _ProfStop(PGROUP_DC_SHIFT); */ |
| 1149 | 1141 |
| (...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2122 } | 2114 } |
| 2123 break; | 2115 break; |
| 2124 } | 2116 } |
| 2125 | 2117 |
| 2126 ++l_img_comp; | 2118 ++l_img_comp; |
| 2127 ++l_tilec; | 2119 ++l_tilec; |
| 2128 } | 2120 } |
| 2129 | 2121 |
| 2130 return OPJ_TRUE; | 2122 return OPJ_TRUE; |
| 2131 } | 2123 } |
| OLD | NEW |