In pi.c, removed the Recursive function pi_check_next_level() and modified the code.
authorParvatha Elangovan <p.elangovan@intopix.com>
Wed, 19 Dec 2007 12:28:40 +0000 (12:28 +0000)
committerParvatha Elangovan <p.elangovan@intopix.com>
Wed, 19 Dec 2007 12:28:40 +0000 (12:28 +0000)
ChangeLog
libopenjpeg/j2k.c
libopenjpeg/pi.c
libopenjpeg/pi.h
libopenjpeg/t2.c
libopenjpeg/t2.h
libopenjpeg/tcd.c

index 9177fbdd64047fbe1549c422c80f8ec8ee2922d9..eeafa865ce504f3bd28fca8e4799e39fd19bc4e1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,9 @@ What's New for OpenJPEG
 ! : changed
 + : added
 
+December 19, 2007
+! [Parvatha] In pi.c, removed the Recursive function pi_check_next_level() and modified the code.
+
 December 19, 2007
 + [FOD] In mqc.h, changed MQC_NUMCTXS from 32 to 19 as there are only 19 possible contexts
 
index c7a6f4a7c80bb07f959ad3e88b06e686132b2523..8e7b1ce081f2ca101cc7daa3a077b280d8c3bfd6 100644 (file)
@@ -258,43 +258,6 @@ char *j2k_convert_progression_order(OPJ_PROG_ORDER prg_order){
        return po->str_prog;
 }
 
-static void j2k_check_poc_val(opj_cparameters_t *parameters, int numcomps, int numlayers){
-       int* packet_array;
-       int index, resno, compno, layno, i;
-       int step_c = 1;
-       int step_r = numcomps * step_c;
-       int step_l = parameters->numresolution * step_r;
-       bool loss = false;
-       packet_array = (int*) opj_calloc(step_l * numlayers, sizeof(int));
-       
-       for (i = 0; i < parameters->numpocs ; i++) {
-               int layno0 = 0;
-               if(i > 0)
-                       layno0 = (parameters->POC[i].layno1 > parameters->POC[i-1].layno1 )? parameters->POC[i-1].layno1 : 0;
-               for (resno = parameters->POC[i].resno0 ; resno < parameters->POC[i].resno1 ; resno++) {
-                       for (compno = parameters->POC[i].compno0 ; compno < parameters->POC[i].compno1 ; compno++) {
-                               for (layno = layno0; layno < parameters->POC[i].layno1 ; layno++) {
-                                       index = step_r * resno + step_c * compno + step_l * layno;
-                                       packet_array[index]= 1;
-                               }
-                       }
-               }
-       }
-       for (resno = 0; resno < parameters->numresolution; resno++) {
-               for (compno = 0; compno < numcomps; compno++) {
-                       for (layno = 0; layno < numlayers ; layno++) {
-                               index = step_r * resno + step_c * compno + step_l * layno;
-                               if(!(   packet_array[index]== 1)){
-                                       loss = true;
-                               }
-                       }
-               }
-       }
-       if(loss)
-               fprintf(stdout,"Missing packets possible loss of data\n");
-       opj_free(packet_array);
-}
-
 void j2k_dump_image(FILE *fd, opj_image_t * img) {
        int compno;
        fprintf(fd, "image {\n");
@@ -2213,7 +2176,6 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_
                if (parameters->numpocs) {
                        /* initialisation of POC */
                        tcp->POC = 1;
-                       j2k_check_poc_val(parameters, image->numcomps, tcp->numlayers);
                        for (i = 0; i < parameters->numpocs; i++) {
                                if((tileno == parameters->POC[i].tile - 1) || (parameters->POC[i].tile == -1)) {
                                        opj_poc_t *tcp_poc = &tcp->pocs[numpocs_tile];
@@ -2533,3 +2495,4 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre
 
 
 
+
index b5e8656d1bc7716a3c16a4d68f1e4c2106f71d82..7bd571eac2d1ea7a290d24b507608c9de0f2d27d 100644 (file)
@@ -726,99 +726,30 @@ bool pi_next(opj_pi_iterator_t * pi) {
        return false;
 }
 
-int pi_check_next_level(int pos,opj_cp_t *cp,int tileno, int pino, char *prog){
-       int i,l;
-       opj_tcp_t *tcps =&cp->tcps[tileno];
-       opj_poc_t *tcp = &tcps->pocs[pino];
-       if(pos>=0){
-               for(i=pos;pos>=0;i--){
-                       switch(prog[i]){
-               case 'R':
-                       if(tcp->res_t==tcp->resE){
-                               l=pi_check_next_level(pos-1,cp,tileno,pino,prog);
-                               if(l==1){
-                                       return 1;
-                               }else{
-                                       return 0;
-                               }
-                       }else{
-                               return 1;
-                       }
-                       break;
-               case 'C':
-                       if(tcp->comp_t==tcp->compE){
-                               l=pi_check_next_level(pos-1,cp,tileno,pino,prog);
-                               if(l==1){
-                                       return 1;
-                               }else{
-                                       return 0;
-                               }
-                       }else{
-                               return 1;
-                       }
-                       break;
-               case 'L':
-                       if(tcp->lay_t==tcp->layE){
-                               l=pi_check_next_level(pos-1,cp,tileno,pino,prog);
-                               if(l==1){
-                                       return 1;
-                               }else{
-                                       return 0;
-                               }
-                       }else{
-                               return 1;
-                       }
-                       break;
-               case 'P':
-                       switch(tcp->prg){
-                               case LRCP||RLCP:
-                                       if(tcp->prc_t == tcp->prcE){
-                                               l=pi_check_next_level(i-1,cp,tileno,pino,prog);
-                                               if(l==1){
-                                                       return 1;
-                                               }else{
-                                                       return 0;
-                                               }
-                                       }else{
-                                               return 1;
-                                       }
-                                       break;
-                       default:
-                               if(tcp->tx0_t == tcp->txE){
-                                       //TY 
-                                       if(tcp->ty0_t == tcp->tyE){
-                                               l=pi_check_next_level(i-1,cp,tileno,pino,prog);
-                                               if(l==1){
-                                                       return 1;
-                                               }else{
-                                                       return 0;
-                                               }
-                                       }else{
-                                               return 1;
-                                       }//TY
-                               }else{
-                                       return 1;
-                               }
-                               break;
-                       }//end case P
-               }//end switch
-               }//end for
-       }//end if
-       return 0;
-}
-
-
-void pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode){
+void pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp){
        char *prog;
-       int i,l;
+       int i;
        int incr_top=1,resetX=0;
        opj_tcp_t *tcps =&cp->tcps[tileno];
        opj_poc_t *tcp= &tcps->pocs[pino];
-       prog = j2k_convert_progression_order(tcp->prg);
 
        pi[pino].first = 1;
-       pi[pino].poc.prg = tcp->prg;    
-       
+       pi[pino].poc.prg = tcp->prg;
+       prog = (char*)malloc(4*sizeof(char));
+
+       switch(tcp->prg){
+               case CPRL: strncpy(prog, "CPRL",4);
+                       break;
+               case LRCP: strncpy(prog, "LRCP",4);
+                       break;
+               case PCRL: strncpy(prog, "PCRL",4);
+                       break;
+               case RLCP: strncpy(prog, "RLCP",4);
+                       break;
+               case RPCL: strncpy(prog, "RPCL",4);
+                       break; 
+       }
+
        if(!(cp->tp_on && ((!cp->cinema && (t2_mode == FINAL_PASS)) || cp->cinema))){
                pi[pino].poc.resno0 = tcp->resS;
                pi[pino].poc.resno1 = tcp->resE;
@@ -833,208 +764,164 @@ void pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,
                pi[pino].poc.tx1 = tcp->txE;
                pi[pino].poc.ty1 = tcp->tyE;
        }else {
-               for(i=tppos+1;i<4;i++){
-                       switch(prog[i]){
-                       case 'R':
-                               pi[pino].poc.resno0 = tcp->resS;
-                               pi[pino].poc.resno1 = tcp->resE;
-                               break;
-                       case 'C':
-                               pi[pino].poc.compno0 = tcp->compS;
-                               pi[pino].poc.compno1 = tcp->compE;
-                               break;
-                       case 'L':
-                               pi[pino].poc.layno0 = tcp->layS;
-                               pi[pino].poc.layno1 = tcp->layE;
-                               break;
-                       case 'P':
-                               switch(tcp->prg){
-                                       case LRCP:
-                                       case RLCP:
-                                               pi[pino].poc.precno0 = tcp->prcS;
-                                               pi[pino].poc.precno1 = tcp->prcE;
-                                               break;
-                                       default:
-                                               pi[pino].poc.tx0 = tcp->txS;
-                                               pi[pino].poc.ty0 = tcp->tyS;
-                                               pi[pino].poc.tx1 = tcp->txE;
-                                               pi[pino].poc.ty1 = tcp->tyE;
-                                               break;
-                               }
-                               break;
-                       }
-               }
-
-               if(tpnum==0){
-                       for(i=tppos;i>=0;i--){
+               if( tpnum < cur_totnum_tp){
+                       for(i=3;i>=0;i--){
                                switch(prog[i]){
-                                               case 'C':
+                               case 'C':
+                                       if (i > tppos){
+                                               pi[pino].poc.compno0 = tcp->compS;
+                                               pi[pino].poc.compno1 = tcp->compE;
+                                       }else{
+                                               if (tpnum == 0){
                                                        tcp->comp_t = tcp->compS;
                                                        pi[pino].poc.compno0 = tcp->comp_t;
                                                        pi[pino].poc.compno1 = tcp->comp_t+1;
                                                        tcp->comp_t+=1;
-                                                       break;
-                                               case 'R':
+                                               }else{
+                                                       if (incr_top == 1){
+                                                               if(tcp->comp_t ==tcp->compE){
+                                                                       tcp->comp_t = tcp->compS;
+                                                                       pi[pino].poc.compno0 = tcp->comp_t;
+                                                                       pi[pino].poc.compno1 = tcp->comp_t+1;
+                                                                       tcp->comp_t+=1;
+                                                                       incr_top=1;
+                                                               }else{
+                                                                       pi[pino].poc.compno0 = tcp->comp_t;
+                                                                       pi[pino].poc.compno1 = tcp->comp_t+1;
+                                                                       tcp->comp_t+=1;
+                                                                       incr_top=0;
+                                                               }
+                                                       }else{
+                                                               pi[pino].poc.compno0 = tcp->comp_t-1;
+                                                               pi[pino].poc.compno1 = tcp->comp_t;
+                                                       }
+                                               }
+                                       }
+                                       break;
+
+                               case 'R':
+                                       if (i > tppos){
+                                               pi[pino].poc.resno0 = tcp->resS;
+                                               pi[pino].poc.resno1 = tcp->resE;
+                                       }else{
+                                               if (tpnum == 0){
                                                        tcp->res_t = tcp->resS;
                                                        pi[pino].poc.resno0 = tcp->res_t;
                                                        pi[pino].poc.resno1 = tcp->res_t+1;
                                                        tcp->res_t+=1;
-                                                       break;
-                                               case 'L':
-                                                       tcp->lay_t = tcp->layS;
-                                                       pi[pino].poc.layno0 = tcp->lay_t;
-                                                       pi[pino].poc.layno1 = tcp->lay_t+1;
-                                                       tcp->lay_t+=1;
-                                                       break;
-                                               case 'P':
-                                                       switch(tcp->prg){
-                                                               case LRCP:
-                                                               case RLCP:
-                                                                       tcp->prc_t = tcp->prcS;
-                                                                       pi[pino].poc.precno0 = tcp->prc_t;
-                                                                       pi[pino].poc.precno1 = tcp->prc_t+1;
-                                                                       tcp->prc_t+=1; 
-                                                                       break;
-                                                               default:
-                                                                       tcp->tx0_t = tcp->txS;
-                                                                       tcp->ty0_t = tcp->tyS;
-                                                                       pi[pino].poc.tx0 = tcp->tx0_t;
-                                                                       pi[pino].poc.tx1 = tcp->tx0_t + tcp->dx - (tcp->tx0_t % tcp->dx);
-                                                                       pi[pino].poc.ty0 = tcp->ty0_t;
-                                                                       pi[pino].poc.ty1 = tcp->ty0_t + tcp->dy - (tcp->ty0_t % tcp->dy);
-                                                                       tcp->tx0_t = pi[pino].poc.tx1;
-                                                                       tcp->ty0_t = pi[pino].poc.ty1;
-                                                                       break;
-                                                       }
-                                                       break;
-                               }
-                       }
-                       incr_top=1;
-               }else{
-                       for(i=tppos;i>=0;i--){
-                               switch(prog[i]){
-                                               case 'C':
-                                                       pi[pino].poc.compno0 = tcp->comp_t-1;
-                                                       pi[pino].poc.compno1 = tcp->comp_t;
-                                                       break;
-                                               case 'R':
-                                                       pi[pino].poc.resno0 = tcp->res_t-1;
-                                                       pi[pino].poc.resno1 = tcp->res_t;
-                                                       break;
-                                               case 'L':
-                                                       pi[pino].poc.layno0 = tcp->lay_t-1;
-                                                       pi[pino].poc.layno1 = tcp->lay_t;
-                                                       break;
-                                               case 'P':
-                                                       switch(tcp->prg){
-                                                               case LRCP:
-                                                               case RLCP:
-                                                                       pi[pino].poc.precno0 = tcp->prc_t-1;
-                                                                       pi[pino].poc.precno1 = tcp->prc_t;
-                                                                       break;
-                                                               default:
-                                                                       pi[pino].poc.tx0 = tcp->tx0_t - tcp->dx - (tcp->tx0_t % tcp->dx);
-                                                                       pi[pino].poc.tx1 = tcp->tx0_t ;
-                                                                       pi[pino].poc.ty0 = tcp->ty0_t - tcp->dy - (tcp->ty0_t % tcp->dy);
-                                                                       pi[pino].poc.ty1 = tcp->ty0_t ;
-                                                                       break;
-                                                       }
-                                                       break;
-                               }
-                               if(incr_top==1){
-                                       switch(prog[i]){
-                                                       case 'R':
+                                               }else{
+                                                       if (incr_top == 1){
                                                                if(tcp->res_t==tcp->resE){
-                                                                       l=pi_check_next_level(i-1,cp,tileno,pino,prog);
-                                                                       if(l==1){
-                                                                               tcp->res_t = tcp->resS;
-                                                                               pi[pino].poc.resno0 = tcp->res_t;
-                                                                               pi[pino].poc.resno1 = tcp->res_t+1;
-                                                                               tcp->res_t+=1;
-                                                                               incr_top=1;
-                                                                       }else{
-                                                                               incr_top=0;
-                                                                       }
-                                                               }else{
+                                                                       tcp->res_t = tcp->resS;
                                                                        pi[pino].poc.resno0 = tcp->res_t;
                                                                        pi[pino].poc.resno1 = tcp->res_t+1;
                                                                        tcp->res_t+=1;
-                                                                       incr_top=0;
-                                                               }
-                                                               break;
-                                                       case 'C':
-                                                               if(tcp->comp_t ==tcp->compE){
-                                                                       l=pi_check_next_level(i-1,cp,tileno,pino,prog);
-                                                                       if(l==1){
-                                                                               tcp->comp_t = tcp->compS;
-                                                                               pi[pino].poc.compno0 = tcp->comp_t;
-                                                                               pi[pino].poc.compno1 = tcp->comp_t+1;
-                                                                               tcp->comp_t+=1;
-                                                                               incr_top=1;
-                                                                       }else{
-                                                                               incr_top=0;
-                                                                       }
+                                                                       incr_top=1;
                                                                }else{
-                                                                       pi[pino].poc.compno0 = tcp->comp_t;
-                                                                       pi[pino].poc.compno1 = tcp->comp_t+1;
-                                                                       tcp->comp_t+=1;
+                                                                       pi[pino].poc.resno0 = tcp->res_t;
+                                                                       pi[pino].poc.resno1 = tcp->res_t+1;
+                                                                       tcp->res_t+=1;
                                                                        incr_top=0;
                                                                }
-                                                               break;  
-                                                       case 'L':
+                                                       }else{
+                                                               pi[pino].poc.resno0 = tcp->res_t - 1;
+                                                               pi[pino].poc.resno1 = tcp->res_t;
+                                                       }
+                                               }
+                                       }
+                                       break;
+
+                               case 'L':
+                                       if (i > tppos){
+                                               pi[pino].poc.layno0 = tcp->layS;
+                                               pi[pino].poc.layno1 = tcp->layE;
+                                       }else{
+                                               if (tpnum == 0){
+                                                       tcp->lay_t = tcp->layS;
+                                                       pi[pino].poc.layno0 = tcp->lay_t;
+                                                       pi[pino].poc.layno1 = tcp->lay_t+1;
+                                                       tcp->lay_t+=1;
+                                               }else{
+                                                       if (incr_top == 1){
                                                                if(tcp->lay_t == tcp->layE){
-                                                                       l=pi_check_next_level(i-1,cp,tileno,pino,prog);
-                                                                       if(l==1){
-                                                                               tcp->lay_t = tcp->layS;
-                                                                               pi[pino].poc.layno0 = tcp->lay_t;
-                                                                               pi[pino].poc.layno1 = tcp->lay_t+1;
-                                                                               tcp->lay_t+=1;
-                                                                               incr_top=1;
-                                                                       }else{
-                                                                               incr_top=0;
-                                                                       }
+                                                                       tcp->lay_t = tcp->layS;
+                                                                       pi[pino].poc.layno0 = tcp->lay_t;
+                                                                       pi[pino].poc.layno1 = tcp->lay_t+1;
+                                                                       tcp->lay_t+=1;
+                                                                       incr_top=1;
                                                                }else{
                                                                        pi[pino].poc.layno0 = tcp->lay_t;
                                                                        pi[pino].poc.layno1 = tcp->lay_t+1;
                                                                        tcp->lay_t+=1;
                                                                        incr_top=0;
                                                                }
-                                                               break;
-                                                       case 'P':
-                                                               switch(tcp->prg){
-                                                                       case LRCP:
-                                                                       case RLCP:
+                                                       }else{
+                                                               pi[pino].poc.layno0 = tcp->lay_t - 1;
+                                                               pi[pino].poc.layno1 = tcp->lay_t;
+                                                       }
+                                               }
+                                       }
+                                       break;
+
+                               case 'P':
+                                       switch(tcp->prg){
+                                               case LRCP:
+                                               case RLCP:
+                                                       if (i > tppos){
+                                                               pi[pino].poc.precno0 = tcp->prcS;
+                                                               pi[pino].poc.precno1 = tcp->prcE;
+                                                       }else{
+                                                               if (tpnum == 0){
+                                                                       tcp->prc_t = tcp->prcS;
+                                                                       pi[pino].poc.precno0 = tcp->prc_t;
+                                                                       pi[pino].poc.precno1 = tcp->prc_t+1;
+                                                                       tcp->prc_t+=1; 
+                                                               }else{
+                                                                       if (incr_top == 1){
                                                                                if(tcp->prc_t == tcp->prcE){
-                                                                                       l=pi_check_next_level(i-1,cp,tileno,pino,prog);
-                                                                                       if(l==1){
-                                                                                               tcp->prc_t = tcp->prcS;
-                                                                                               pi[pino].poc.precno0 = tcp->prc_t;
-                                                                                               pi[pino].poc.precno1 = tcp->prc_t+1;
-                                                                                               tcp->prc_t+=1;
-                                                                                               incr_top=1;
-                                                                                       }else{
-                                                                                               incr_top=0;
-                                                                                       }
+                                                                                       tcp->prc_t = tcp->prcS;
+                                                                                       pi[pino].poc.precno0 = tcp->prc_t;
+                                                                                       pi[pino].poc.precno1 = tcp->prc_t+1;
+                                                                                       tcp->prc_t+=1;
+                                                                                       incr_top=1;
                                                                                }else{
                                                                                        pi[pino].poc.precno0 = tcp->prc_t;
                                                                                        pi[pino].poc.precno1 = tcp->prc_t+1;
                                                                                        tcp->prc_t+=1;
                                                                                        incr_top=0;
                                                                                }
-                                                                               break;
-                                                                       default:
+                                                                       }else{
+                                                                               pi[pino].poc.precno0 = tcp->prc_t - 1;
+                                                                               pi[pino].poc.precno1 = tcp->prc_t;
+                                                                       }
+                                                               }
+                                                       }
+                                               break;
+                                               default:
+                                                       if (i > tppos){
+                                                               pi[pino].poc.tx0 = tcp->txS;
+                                                               pi[pino].poc.ty0 = tcp->tyS;
+                                                               pi[pino].poc.tx1 = tcp->txE;
+                                                               pi[pino].poc.ty1 = tcp->tyE;
+                                                       }else{
+                                                               if (tpnum == 0){
+                                                                       tcp->tx0_t = tcp->txS;
+                                                                       tcp->ty0_t = tcp->tyS;
+                                                                       pi[pino].poc.tx0 = tcp->tx0_t;
+                                                                       pi[pino].poc.tx1 = tcp->tx0_t + tcp->dx - (tcp->tx0_t % tcp->dx);
+                                                                       pi[pino].poc.ty0 = tcp->ty0_t;
+                                                                       pi[pino].poc.ty1 = tcp->ty0_t + tcp->dy - (tcp->ty0_t % tcp->dy);
+                                                                       tcp->tx0_t = pi[pino].poc.tx1;
+                                                                       tcp->ty0_t = pi[pino].poc.ty1;
+                                                               }else{
+                                                                       if (incr_top == 1){
                                                                                if(tcp->tx0_t >= tcp->txE){
                                                                                        if(tcp->ty0_t >= tcp->tyE){
-                                                                                               l=pi_check_next_level(i-1,cp,tileno,pino,prog);
-                                                                                               if(l==1){
-                                                                                                       tcp->ty0_t = tcp->tyS;
-                                                                                                       pi[pino].poc.ty0 = tcp->ty0_t;
-                                                                                                       pi[pino].poc.ty1 = tcp->ty0_t + tcp->dy - (tcp->ty0_t % tcp->dy);
-                                                                                                       tcp->ty0_t = pi[pino].poc.ty1;
-                                                                                                       incr_top=1;resetX=1;
-                                                                                               }else{
-                                                                                                       incr_top=0;resetX=0;
-                                                                                               }
+                                                                                               tcp->ty0_t = tcp->tyS;
+                                                                                               pi[pino].poc.ty0 = tcp->ty0_t;
+                                                                                               pi[pino].poc.ty1 = tcp->ty0_t + tcp->dy - (tcp->ty0_t % tcp->dy);
+                                                                                               tcp->ty0_t = pi[pino].poc.ty1;
+                                                                                               incr_top=1;resetX=1;
                                                                                        }else{
                                                                                                pi[pino].poc.ty0 = tcp->ty0_t;
                                                                                                pi[pino].poc.ty1 = tcp->ty0_t + tcp->dy - (tcp->ty0_t % tcp->dy);
@@ -1051,17 +938,24 @@ void pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,
                                                                                        pi[pino].poc.tx0 = tcp->tx0_t;
                                                                                        pi[pino].poc.tx1 = tcp->tx0_t + tcp->dx- (tcp->tx0_t % tcp->dx);
                                                                                        tcp->tx0_t = pi[pino].poc.tx1;
+                                                                                       pi[pino].poc.ty0 = tcp->ty0_t - tcp->dy - (tcp->ty0_t % tcp->dy);
+                                                                                       pi[pino].poc.ty1 = tcp->ty0_t ;
                                                                                        incr_top=0;
                                                                                }
-                                                                               break;
+                                                                       }else{
+                                                                               pi[pino].poc.tx0 = tcp->tx0_t - tcp->dx - (tcp->tx0_t % tcp->dx);
+                                                                               pi[pino].poc.tx1 = tcp->tx0_t ;
+                                                                               pi[pino].poc.ty0 = tcp->ty0_t - tcp->dy - (tcp->ty0_t % tcp->dy);
+                                                                               pi[pino].poc.ty1 = tcp->ty0_t ;
+                                                                       }
                                                                }
-                                                               break;
-                                       }
-                               }
-                       }
+                                                       }
+                                               break;
+                                               }
+                                               break;
+                               }               
+                       } 
                }
-       }
+       }       
 }
 
-
-
index f2274922c425f658ce6b339a98c5c391bfafc6b7..9498ead8b80302971f3f95c48e239cdf15d6a144 100644 (file)
@@ -117,8 +117,9 @@ Modify the packet iterator for enabling tile part generation
 @param tileno Number that identifies the tile for which to list the packets
 @param tpnum Tile part number of the current tile
 @param tppos The position of the tile part flag in the progression order
+@param cur_totnum_tp The total number of tile parts in the current tile
 */
-void pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode);
+void pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp);
 /**
 Create a packet iterator for Decoder
 @param image Raw image for which the packets will be listed
index 81f46cd46b8504f035b3e8bc0181921c7c80f578..a841cf0b1a3f9d71a2dd74367e980f373a5e6577 100644 (file)
@@ -589,7 +589,7 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t
 
 /* ----------------------------------------------------------------------- */
 
-int t2_encode_packets(opj_t2_t* t2,int tileno, opj_tcd_tile_t *tile, int maxlayers, unsigned char *dest, int len, opj_codestream_info_t *cstr_info,int tpnum, int tppos,int pino, J2K_T2_MODE t2_mode){
+int t2_encode_packets(opj_t2_t* t2,int tileno, opj_tcd_tile_t *tile, int maxlayers, unsigned char *dest, int len, opj_codestream_info_t *cstr_info,int tpnum, int tppos,int pino, J2K_T2_MODE t2_mode, int cur_totnum_tp){
        unsigned char *c = dest;
        int e = 0;
        int compno;
@@ -612,7 +612,7 @@ int t2_encode_packets(opj_t2_t* t2,int tileno, opj_tcd_tile_t *tile, int maxlaye
                        for(poc = 0; poc < pocno ; poc++){
                                int comp_len = 0;
                                int tpnum = compno;
-                               pi_create_encode(pi, cp,tileno,poc,tpnum,tppos,t2_mode); 
+                               pi_create_encode(pi, cp,tileno,poc,tpnum,tppos,t2_mode,cur_totnum_tp); 
                                while (pi_next(&pi[poc])) {
                                        if (pi[poc].layno < maxlayers) {
                                                e = t2_encode_packet(tile, &cp->tcps[tileno], &pi[poc], c, dest + len - c, cstr_info, tileno);
@@ -635,7 +635,7 @@ int t2_encode_packets(opj_t2_t* t2,int tileno, opj_tcd_tile_t *tile, int maxlaye
                        if (e == -999)  break;
                }
        }else{  /* t2_mode == FINAL_PASS  */
-               pi_create_encode(pi, cp,tileno,pino,tpnum,tppos,t2_mode);
+               pi_create_encode(pi, cp,tileno,pino,tpnum,tppos,t2_mode,cur_totnum_tp);
                while (pi_next(&pi[pino])) {
                        if (pi[pino].layno < maxlayers) {
                                e = t2_encode_packet(tile, &cp->tcps[tileno], &pi[pino], c, dest + len - c, cstr_info, tileno);
@@ -781,3 +781,4 @@ void t2_destroy(opj_t2_t *t2) {
 
 
 
+
index 101608994afc6ed768f1bd56663ea1da067b5daf..b15b752001936507bbfd0d0a007088cc0b492117 100644 (file)
@@ -68,8 +68,9 @@ Encode the packets of a tile to a destination buffer
 @param tpnum Tile part number of the current tile
 @param tppos The position of the tile part flag in the progression order
 @param t2_mode If == 0 In Threshold calculation ,If == 1 Final pass
+@param cur_totnum_tp The total number of tile parts in the current tile
 */
-int t2_encode_packets(opj_t2_t* t2,int tileno, opj_tcd_tile_t *tile, int maxlayers, unsigned char *dest, int len, opj_codestream_info_t *cstr_info,int tpnum, int tppos,int pino,J2K_T2_MODE t2_mode);
+int t2_encode_packets(opj_t2_t* t2,int tileno, opj_tcd_tile_t *tile, int maxlayers, unsigned char *dest, int len, opj_codestream_info_t *cstr_info,int tpnum, int tppos,int pino,J2K_T2_MODE t2_mode,int cur_totnum_tp);
 /**
 Decode the packets of a tile from a source buffer
 @param t2 T2 handle
index 4a58ebeb71407cbf5684bfb7b26c9a831f6a8e41..f4a54553e28a5747cc6be0fc3b4beed799ee235b 100644 (file)
@@ -1094,7 +1094,7 @@ bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestre
                                
                                if (cp->fixed_quality) {        /* fixed_quality */
                                        if(cp->cinema){
-                                               l = t2_encode_packets(t2,tcd->tcd_tileno, tcd_tile, layno + 1, dest, maxlen, cstr_info,tcd->cur_tp_num,tcd->tp_pos,tcd->cur_pino,THRESH_CALC);
+                                               l = t2_encode_packets(t2,tcd->tcd_tileno, tcd_tile, layno + 1, dest, maxlen, cstr_info,tcd->cur_tp_num,tcd->tp_pos,tcd->cur_pino,THRESH_CALC, tcd->cur_totnum_tp);
                                                if (l == -999) {
                                                        lo = thresh;
                                                        continue;
@@ -1120,7 +1120,7 @@ bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestre
                                                lo = thresh;
                                        }
                                } else {
-                                       l = t2_encode_packets(t2, tcd->tcd_tileno, tcd_tile, layno + 1, dest, maxlen, cstr_info,tcd->cur_tp_num,tcd->tp_pos,tcd->cur_pino,THRESH_CALC);
+                                       l = t2_encode_packets(t2, tcd->tcd_tileno, tcd_tile, layno + 1, dest, maxlen, cstr_info,tcd->cur_tp_num,tcd->tp_pos,tcd->cur_pino,THRESH_CALC, tcd->cur_totnum_tp);
                                        /* TODO: what to do with l ??? seek / tell ??? */
                                        /* opj_event_msg(tcd->cinfo, EVT_INFO, "rate alloc: len=%d, max=%d\n", l, maxlen); */
                                        if (l == -999) {
@@ -1284,7 +1284,7 @@ int tcd_encode_tile(opj_tcd_t *tcd, int tileno, unsigned char *dest, int len, op
        }
 
        t2 = t2_create(tcd->cinfo, image, cp);
-       l = t2_encode_packets(t2,tileno, tile, tcd_tcp->numlayers, dest, len, cstr_info,tcd->tp_num,tcd->tp_pos,tcd->cur_pino,FINAL_PASS);
+       l = t2_encode_packets(t2,tileno, tile, tcd_tcp->numlayers, dest, len, cstr_info,tcd->tp_num,tcd->tp_pos,tcd->cur_pino,FINAL_PASS,tcd->cur_totnum_tp);
        t2_destroy(t2);
        
        /*---------------CLEAN-------------------*/
@@ -1503,3 +1503,4 @@ void tcd_free_decode_tile(opj_tcd_t *tcd, int tileno) {
        opj_free(tile->comps);
 }
 
+