]> granicus.if.org Git - openjpeg/commitdiff
[trunk] add tcd_get_encoded_tile_size in trunk from branch v2alpha
authorMickael Savinaud <savmickael@users.noreply.github.com>
Fri, 9 Mar 2012 17:16:04 +0000 (17:16 +0000)
committerMickael Savinaud <savmickael@users.noreply.github.com>
Fri, 9 Mar 2012 17:16:04 +0000 (17:16 +0000)
libopenjpeg/tcd.c
libopenjpeg/tcd.h

index ea09a17f94702d5028e9704dbac7273798bf8a8c..706d265472b98eb7c047f11a14632835870898f8 100644 (file)
@@ -2623,4 +2623,31 @@ void tcd_code_block_dec_deallocate (opj_tcd_precinct_v2_t * p_precinct)
        }
 }
 
+OPJ_UINT32 tcd_get_encoded_tile_size ( opj_tcd_v2_t *p_tcd )
+{
+       OPJ_UINT32 i,l_data_size = 0;
+       opj_image_comp_t * l_img_comp = 00;
+       opj_tcd_tilecomp_t * l_tilec = 00;
+       OPJ_UINT32 l_size_comp, l_remaining;
+
+       l_tilec = p_tcd->tcd_image->tiles->comps;
+       l_img_comp = p_tcd->image->comps;
+       for (i=0;i<p_tcd->image->numcomps;++i) {
+               l_size_comp = l_img_comp->prec >> 3; /*(/ 8)*/
+               l_remaining = l_img_comp->prec & 7;  /* (%8) */
 
+               if (l_remaining) {
+                       ++l_size_comp;
+               }
+
+               if (l_size_comp == 3) {
+                       l_size_comp = 4;
+               }
+
+               l_data_size += l_size_comp * (l_tilec->x1 - l_tilec->x0) * (l_tilec->y1 - l_tilec->y0);
+               ++l_img_comp;
+               ++l_tilec;
+       }
+
+       return l_data_size;
+}
index cb9967cdd8d4ccebde0a0f7c36d49da1bc87b8f5..7fdf258b0c41a7cd6fbce75b30a841cf86b12668 100644 (file)
@@ -486,11 +486,14 @@ opj_bool tcd_decode_tile_v2(opj_tcd_v2_t *tcd,
 /**
  * Copies tile data from the system onto the given memory block.
  */
-opj_bool tcd_update_tile_data (
-                                                opj_tcd_v2_t *p_tcd,
-                                                OPJ_BYTE * p_dest,
-                                                OPJ_UINT32 p_dest_length
-                                                );
+opj_bool tcd_update_tile_data (        opj_tcd_v2_t *p_tcd,
+                                                               OPJ_BYTE * p_dest,
+                                                               OPJ_UINT32 p_dest_length );
+
+/**
+ *
+ */
+OPJ_UINT32 tcd_get_encoded_tile_size ( opj_tcd_v2_t *p_tcd );
 
 /* ----------------------------------------------------------------------- */
 /*@}*/