Merge pull request #545 from mayeut/master
[openjpeg.git] / src / lib / openjpip / cachemodel_manager.c
index 70bbb2c382043f450489dc772c0bd2384d7a8a1f..da30d94057499dc13bf1e76242c9ea8f509916de 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * $Id$
  *
- * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2011, Professor Benoit Macq
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
  * Copyright (c) 2010-2011, Kaori Hagihara
  * All rights reserved.
  *
@@ -56,7 +56,7 @@ cachemodellist_param_t * gene_cachemodellist(void)
   return cachemodellist;
 }
 
-cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, target_param_t *target, bool reqJPP)
+cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, target_param_t *target, OPJ_BOOL reqJPP)
 {
   cachemodel_param_t *cachemodel;
   faixbox_param_t *tilepart;
@@ -71,27 +71,27 @@ cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, ta
   
   if( reqJPP){
     if( target->jppstream)
-      cachemodel->jppstream = true;
+      cachemodel->jppstream = OPJ_TRUE;
     else
-      cachemodel->jppstream = false;
+      cachemodel->jppstream = OPJ_FALSE;
   } else{ /* reqJPT */
     if( target->jptstream)
-      cachemodel->jppstream = false;
+      cachemodel->jppstream = OPJ_FALSE;
     else
-      cachemodel->jppstream = true;
+      cachemodel->jppstream = OPJ_TRUE;
   }
 
-  cachemodel->mhead_model = false;
+  cachemodel->mhead_model = OPJ_FALSE;
   
   tilepart = target->codeidx->tilepart;
   numOftiles = get_m( tilepart);
   numOfelem = get_nmax( tilepart)*numOftiles;
-  cachemodel->tp_model = (bool *)opj_calloc( 1, numOfelem*sizeof(bool));
-  cachemodel->th_model = (bool *)opj_calloc( 1, numOftiles*sizeof(bool));
-  cachemodel->pp_model = (bool **)opj_malloc( target->codeidx->SIZ.Csiz*sizeof(bool *));
+  cachemodel->tp_model = (OPJ_BOOL *)opj_calloc( 1, numOfelem*sizeof(OPJ_BOOL));
+  cachemodel->th_model = (OPJ_BOOL *)opj_calloc( 1, numOftiles*sizeof(OPJ_BOOL));
+  cachemodel->pp_model = (OPJ_BOOL **)opj_malloc( target->codeidx->SIZ.Csiz*sizeof(OPJ_BOOL *));
   for( i=0; i<target->codeidx->SIZ.Csiz; i++){
     precpacket = target->codeidx->precpacket[i];
-    cachemodel->pp_model[i] = (bool *)opj_calloc( 1, get_nmax(precpacket)*get_m(precpacket)*sizeof(bool));
+    cachemodel->pp_model[i] = (OPJ_BOOL *)opj_calloc( 1, get_nmax(precpacket)*get_m(precpacket)*sizeof(OPJ_BOOL));
   }
   cachemodel->next = NULL;
   
@@ -196,7 +196,7 @@ void delete_cachemodel( cachemodel_param_t **cachemodel)
   opj_free( *cachemodel);
 }
 
-bool is_allsent( cachemodel_param_t cachemodel)
+OPJ_BOOL is_allsent( cachemodel_param_t cachemodel)
 {
   target_param_t *target;
   Byte8_t TPnum; /* num of tile parts in each tile */
@@ -207,30 +207,30 @@ bool is_allsent( cachemodel_param_t cachemodel)
   target = cachemodel.target;
   
   if( !cachemodel.mhead_model)
-    return false;
+    return OPJ_FALSE;
 
   TPnum = get_nmax( target->codeidx->tilepart);
 
   if( cachemodel.jppstream){
     for( i=0; i<target->codeidx->SIZ.XTnum*target->codeidx->SIZ.YTnum; i++){
       if( !cachemodel.th_model[i])
-       return false;
+       return OPJ_FALSE;
       
       for( j=0; j<target->codeidx->SIZ.Csiz; j++){
        Pmax = get_nmax( target->codeidx->precpacket[j]);
        for( k=0; k<Pmax; k++)
          if( !cachemodel.pp_model[j][i*Pmax+k])
-           return false;
+           return OPJ_FALSE;
       }
     }
-    return true;
+    return OPJ_TRUE;
   }
   else{
     for( i=0, n=0; i<target->codeidx->SIZ.YTnum; i++)
       for( j=0; j<target->codeidx->SIZ.XTnum; j++)
        for( k=0; k<TPnum; k++)
          if( !cachemodel.tp_model[n++])
-           return false;
-    return true;
+           return OPJ_FALSE;
+    return OPJ_TRUE;
   }
 }