Update openjpeg
[pdfium.git] / core / src / fxcodec / fx_libopenjpeg / libopenjpeg20 / pi.c
index 02bbefe..b3fe9af 100644 (file)
@@ -815,7 +815,6 @@ opj_pi_iterator_t * opj_pi_create(  const opj_image_t *image,
        if (!l_pi) {
                return NULL;
        }
-       memset(l_pi,0,l_poc_bound * sizeof(opj_pi_iterator_t));
 
        l_current_pi = l_pi;
        for (pino = 0; pino < l_poc_bound ; ++pino) {
@@ -827,21 +826,19 @@ opj_pi_iterator_t * opj_pi_create(        const opj_image_t *image,
                }
 
                l_current_pi->numcomps = image->numcomps;
-               memset(l_current_pi->comps,0,image->numcomps * sizeof(opj_pi_comp_t));
 
                for (compno = 0; compno < image->numcomps; ++compno) {
                        opj_pi_comp_t *comp = &l_current_pi->comps[compno];
 
                        tccp = &tcp->tccps[compno];
 
-                       comp->resolutions = (opj_pi_resolution_t*) opj_malloc(tccp->numresolutions * sizeof(opj_pi_resolution_t));
+                       comp->resolutions = (opj_pi_resolution_t*) opj_calloc(tccp->numresolutions, sizeof(opj_pi_resolution_t));
                        if (!comp->resolutions) {
                                opj_pi_destroy(l_pi, l_poc_bound);
                                return 00;
                        }
 
                        comp->numresolutions = tccp->numresolutions;
-                       memset(comp->resolutions,0,tccp->numresolutions * sizeof(opj_pi_resolution_t));
                }
                ++l_current_pi;
        }
@@ -1108,7 +1105,8 @@ OPJ_BOOL opj_pi_check_next_level( OPJ_INT32 pos,
                            break;
                    case 'P':
                            switch(tcp->prg){
-                                   case OPJ_LRCP||OPJ_RLCP:
+                    case OPJ_LRCP: // fall through
+                    case OPJ_RLCP:
                                            if(tcp->prc_t == tcp->prcE){
                                                    if(opj_pi_check_next_level(i-1,cp,tileno,pino,prog)){
                                                            return OPJ_TRUE;
@@ -1242,7 +1240,6 @@ opj_pi_iterator_t *opj_pi_create_decode(opj_image_t *p_image,
                opj_pi_destroy(l_pi, l_bound);
                return 00;
        }
-       memset(l_current_pi->include,0, (l_tcp->numlayers + 1) * l_step_l* sizeof(OPJ_INT16));
 
        /* special treatment for the first packet iterator */
        l_current_comp = l_current_pi->comps;
@@ -1439,7 +1436,6 @@ opj_pi_iterator_t *opj_pi_initialise_encode(const opj_image_t *p_image,
                opj_pi_destroy(l_pi, l_bound);
                return 00;
        }
-       memset(l_current_pi->include,0,l_tcp->numlayers * l_step_l* sizeof(OPJ_INT16));
 
        /* special treatment for the first packet iterator*/
        l_current_comp = l_current_pi->comps;
@@ -1525,7 +1521,7 @@ opj_pi_iterator_t *opj_pi_initialise_encode(const opj_image_t *p_image,
        opj_free(l_tmp_ptr);
        l_tmp_ptr = 00;
 
-       if (l_tcp->POC && ( p_cp->m_specific_param.m_enc.m_cinema || p_t2_mode == FINAL_PASS)) {
+    if (l_tcp->POC && (OPJ_IS_CINEMA(p_cp->rsiz) || p_t2_mode == FINAL_PASS)) {
                opj_pi_update_encode_poc_and_final(p_cp,p_tile_no,l_tx0,l_tx1,l_ty0,l_ty1,l_max_prec,l_max_res,l_dx_min,l_dy_min);
        }
        else {
@@ -1554,7 +1550,7 @@ void opj_pi_create_encode(        opj_pi_iterator_t *pi,
        pi[pino].first = 1;
        pi[pino].poc.prg = tcp->prg;
 
-       if(!(cp->m_specific_param.m_enc.m_tp_on && ((!cp->m_specific_param.m_enc.m_cinema && (t2_mode == FINAL_PASS)) || cp->m_specific_param.m_enc.m_cinema))){
+    if(!(cp->m_specific_param.m_enc.m_tp_on && ((!OPJ_IS_CINEMA(cp->rsiz) && (t2_mode == FINAL_PASS)) || OPJ_IS_CINEMA(cp->rsiz)))){
                pi[pino].poc.resno0 = tcp->resS;
                pi[pino].poc.resno1 = tcp->resE;
                pi[pino].poc.compno0 = tcp->compS;