Various corrections to avoid "signed/unsigned mismatch" warnings during compilation
authorAntonin Descampe <antonin@gmail.com>
Fri, 30 Apr 2004 09:20:22 +0000 (09:20 +0000)
committerAntonin Descampe <antonin@gmail.com>
Fri, 30 Apr 2004 09:20:22 +0000 (09:20 +0000)
codec/convert.c
codec/image_to_j2k.c
libopenjpeg/j2k.c
libopenjpeg/tcd.c

index 864cbd47929cd7dcabccaaafa7fb37338378b72e..f8c65884cf92433ca32d1af6f196a5c4992324cc 100644 (file)
@@ -75,8 +75,10 @@ int bmptoimage(char *filename, j2k_image_t * img, int subsampling_dx,
   BITMAPINFOHEADER_t Info_h;
   unsigned char *RGB;
   unsigned char *table_R, *table_G, *table_B;
-  int i, w, h, PAD, type = 0;
-  int gray_scale = 1, not_end_file = 1, line = 0, col = 0;
+  unsigned int j, w, h, PAD, type = 0;
+  int i;
+  int gray_scale = 1, not_end_file = 1; 
+  unsigned int line = 0, col = 0;
   unsigned char v, v2;
   UINT4 W, H;
 
@@ -226,12 +228,12 @@ int bmptoimage(char *filename, j2k_image_t * img, int subsampling_dx,
 
       fread(RGB, sizeof(unsigned char), (3 * W + PAD) * H, IN);
 
-      for (i = 0; i < (3 * W + PAD) * H; i++) {
+      for (j = 0; j < (3 * W + PAD) * H; j++) {
        unsigned char elmt;
        int Wp = 3 * W + PAD;
 
-       elmt = RGB[(H - (i / Wp + 1)) * Wp + i % Wp];
-       if ((i % Wp) < (3 * W)) {
+       elmt = RGB[(H - (j / Wp + 1)) * Wp + j % Wp];
+       if ((j % Wp) < (3 * W)) {
          switch (type) {
          case 0:
            fprintf(Compo2, "%c", elmt);
@@ -269,13 +271,13 @@ int bmptoimage(char *filename, j2k_image_t * img, int subsampling_dx,
       table_G = (unsigned char *) malloc(256 * sizeof(unsigned char));
       table_B = (unsigned char *) malloc(256 * sizeof(unsigned char));
 
-      for (i = 0; i < Info_h.biClrUsed; i++) {
-       table_B[i] = getc(IN);
-       table_G[i] = getc(IN);
-       table_R[i] = getc(IN);
+      for (j = 0; j < Info_h.biClrUsed; j++) {
+       table_B[j] = getc(IN);
+       table_G[j] = getc(IN);
+       table_R[j] = getc(IN);
        getc(IN);
-       if (table_R[i] != table_G[i] && table_R[i] != table_B[i]
-           && table_G[i] != table_B[i])
+       if (table_R[j] != table_G[j] && table_R[j] != table_B[j]
+           && table_G[j] != table_B[j])
          gray_scale = 0;
       }
 
@@ -305,11 +307,11 @@ int bmptoimage(char *filename, j2k_image_t * img, int subsampling_dx,
          fprintf(stderr,
                  "\033[0;33mFailed to open Compo0 for writing !\033[0;39m\n");
        }
-       for (i = 0; i < W * H; i++) {
-         if ((i % W < W - 1 && Info_h.biWidth % 2)
+       for (j = 0; j < W * H; j++) {
+         if ((j % W < W - 1 && Info_h.biWidth % 2)
              || !(Info_h.biWidth % 2))
            fprintf(Compo0, "%c",
-                   table_R[RGB[W * H - ((i) / (W) + 1) * W + (i) % (W)]]);
+                   table_R[RGB[W * H - ((j) / (W) + 1) * W + (j) % (W)]]);
        }
        fclose(Compo0);
       } else {
@@ -340,15 +342,15 @@ int bmptoimage(char *filename, j2k_image_t * img, int subsampling_dx,
                  "\033[0;33mFailed to open Compo2 for writing !\033[0;39m\n");
        }
 
-       for (i = 0; i < W * H; i++) {
-         if ((i % W < W - 1 && Info_h.biWidth % 2)
+       for (j = 0; j < W * H; j++) {
+         if ((j % W < W - 1 && Info_h.biWidth % 2)
              || !(Info_h.biWidth % 2)) {
            fprintf(Compo0, "%c",
-                   table_R[RGB[W * H - ((i) / (W) + 1) * W + (i) % (W)]]);
+                   table_R[RGB[W * H - ((j) / (W) + 1) * W + (j) % (W)]]);
            fprintf(Compo1, "%c",
-                   table_G[RGB[W * H - ((i) / (W) + 1) * W + (i) % (W)]]);
+                   table_G[RGB[W * H - ((j) / (W) + 1) * W + (j) % (W)]]);
            fprintf(Compo2, "%c",
-                   table_B[RGB[W * H - ((i) / (W) + 1) * W + (i) % (W)]]);
+                   table_B[RGB[W * H - ((j) / (W) + 1) * W + (j) % (W)]]);
          }
 
        }
@@ -374,13 +376,13 @@ int bmptoimage(char *filename, j2k_image_t * img, int subsampling_dx,
       table_G = (unsigned char *) malloc(256 * sizeof(unsigned char));
       table_B = (unsigned char *) malloc(256 * sizeof(unsigned char));
 
-      for (i = 0; i < Info_h.biClrUsed; i++) {
-       table_B[i] = getc(IN);
-       table_G[i] = getc(IN);
-       table_R[i] = getc(IN);
+      for (j = 0; j < Info_h.biClrUsed; j++) {
+       table_B[j] = getc(IN);
+       table_G[j] = getc(IN);
+       table_R[j] = getc(IN);
        getc(IN);
-       if (table_R[i] != table_G[i] && table_R[i] != table_B[i]
-           && table_G[i] != table_B[i])
+       if (table_R[j] != table_G[j] && table_R[j] != table_B[j]
+           && table_G[j] != table_B[j])
          gray_scale = 0;
       }
 
index 2f5cd1376108f0befa81301dbfbf86873ce6eea4..5fcfcc57a0534f7379949690b6af7031fc2557c6 100644 (file)
@@ -124,7 +124,7 @@ void help_display()
     ("-x             : Create an index file *.Idx (-x index_name.Idx) optional\n");
   printf("\n");
   printf
-    ("-ROI:c=%%d,U=%%d : quantization indices upshifted for component c=%%d [\%%d = 0,1,2]\n");
+    ("-ROI:c=%%d,U=%%d : quantization indices upshifted for component c=%%d [%%d = 0,1,2]\n");
   printf
     ("                 with a value of U=%%d [0 <= %%d <= 37] (i.e. -ROI:c=0,U=25) optional\n");
   printf("\n");
index 3c427df3913a9b8cf5518e434b54f18a038aa093..df14b1736f1999f3e5017ff2fdeeefb77f0a7af4 100644 (file)
@@ -1347,7 +1347,7 @@ int j2k_decode_jpt_stream(unsigned char *src, int len, j2k_image_t ** img,
       return 0;
     }
     /* data-bin read -> need to read a new header */
-    if ((cio_tell() - position) == header.Msg_length) {
+    if ((unsigned int)(cio_tell() - position) == header.Msg_length) {
       jpt_read_Msg_Header(&header);
       position = cio_tell();
       if (header.Class_Id != 4) {      /* 4 : Tile data-bin message */
index fed44ecfb74433dae7cf377c38b742e39942dd10..85b0003825cce30641c3ff6f6c348ec32c9af2ba 100644 (file)
@@ -130,9 +130,9 @@ void tcd_malloc_encode(j2k_image_t * img, j2k_cp_t * cp, int curtileno)
     /* Modification of the RATE >> */
     for (j = 0; j < tcp->numlayers; j++) {
       tcp->rates[j] =
-       ceil(tile->numcomps * (tile->x1 - tile->x0) *
+       int_ceildiv(tile->numcomps * (tile->x1 - tile->x0) *
             (tile->y1 -
-             tile->y0) * img->comps[0].prec / (tcp->rates[j] * 8 *
+             tile->y0) * img->comps[0].prec , (tcp->rates[j] * 8 *
                                                img->comps[0].dx *
                                                img->comps[0].dy));
       if (j && tcp->rates[j] < tcp->rates[j - 1] + 10) {
@@ -389,9 +389,9 @@ void tcd_init_encode(j2k_image_t * img, j2k_cp_t * cp, int curtileno)
     /* Modification of the RATE >> */
     for (j = 0; j < tcp->numlayers; j++) {
       tcp->rates[j] =
-       ceil(tile->numcomps * (tile->x1 - tile->x0) *
+       int_ceildiv(tile->numcomps * (tile->x1 - tile->x0) *
             (tile->y1 -
-             tile->y0) * img->comps[0].prec / (tcp->rates[j] * 8 *
+             tile->y0) * img->comps[0].prec , (tcp->rates[j] * 8 *
                                                img->comps[0].dx *
                                                img->comps[0].dy));
       if (j && tcp->rates[j] < tcp->rates[j - 1] + 10) {
@@ -580,8 +580,8 @@ void tcd_init_encode(j2k_image_t * img, j2k_cp_t * cp, int curtileno)
 
 void tcd_init(j2k_image_t * img, j2k_cp_t * cp)
 {
-  int tileno, compno, resno, bandno, precno, cblkno, i;
-  unsigned int x0 = 0, y0 = 0, x1 = 0, y1 = 0, w, h, j, p, q;
+  int tileno, compno, resno, bandno, precno, cblkno, i, j;
+  unsigned int x0 = 0, y0 = 0, x1 = 0, y1 = 0, w, h, p, q;
   tcd_img = img;
   tcd_cp = cp;
   tcd_image.tw = cp->tw;