]> Creatis software - gdcm.git/blobdiff - src/jpeg/libijg/jdcolor.c
ENH: Fix the remaining warnings using: diff -u --strip-trailing-cr --ignore-space...
[gdcm.git] / src / jpeg / libijg / jdcolor.c
index 6c04dfe8aa1b36e4ab4c9909c77e9cd26b74e9d7..cb9333ae0087671de530b5a08286e0d4057f0ad2 100644 (file)
@@ -19,10 +19,10 @@ typedef struct {
   struct jpeg_color_deconverter pub; /* public fields */
 
   /* Private state for YCC->RGB conversion */
-  int * Cr_r_tab;              /* => table for Cr to R conversion */
-  int * Cb_b_tab;              /* => table for Cb to B conversion */
-  INT32 * Cr_g_tab;            /* => table for Cr to G conversion */
-  INT32 * Cb_g_tab;            /* => table for Cb to G conversion */
+  int * Cr_r_tab;    /* => table for Cr to R conversion */
+  int * Cb_b_tab;    /* => table for Cb to B conversion */
+  INT32 * Cr_g_tab;    /* => table for Cr to G conversion */
+  INT32 * Cb_g_tab;    /* => table for Cb to G conversion */
 } my_color_deconverter;
 
 typedef my_color_deconverter * my_cconvert_ptr;
@@ -34,9 +34,9 @@ typedef my_color_deconverter * my_cconvert_ptr;
  * YCbCr is defined per CCIR 601-1, except that Cb and Cr are
  * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
  * The conversion equations to be implemented are therefore
- *     R = Y                + 1.40200 * Cr
- *     G = Y - 0.34414 * Cb - 0.71414 * Cr
- *     B = Y + 1.77200 * Cb
+ *  R = Y                + 1.40200 * Cr
+ *  G = Y - 0.34414 * Cb - 0.71414 * Cr
+ *  B = Y + 1.77200 * Cb
  * where Cb and Cr represent the incoming values less CENTERJSAMPLE.
  * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.)
  *
@@ -57,9 +57,9 @@ typedef my_color_deconverter * my_cconvert_ptr;
  * together before rounding.
  */
 
-#define SCALEBITS      16      /* speediest right-shift on some machines */
-#define ONE_HALF       ((INT32) 1 << (SCALEBITS-1))
-#define FIX(x)         ((INT32) ((x) * (1L<<SCALEBITS) + 0.5))
+#define SCALEBITS  16  /* speediest right-shift on some machines */
+#define ONE_HALF  ((INT32) 1 << (SCALEBITS-1))
+#define FIX(x)    ((INT32) ((x) * (1L<<SCALEBITS) + 0.5))
 
 
 /*
@@ -76,26 +76,26 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
 
   cconvert->Cr_r_tab = (int *)
     (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
-                               (MAXJSAMPLE+1) * SIZEOF(int));
+        (MAXJSAMPLE+1) * SIZEOF(int));
   cconvert->Cb_b_tab = (int *)
     (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
-                               (MAXJSAMPLE+1) * SIZEOF(int));
+        (MAXJSAMPLE+1) * SIZEOF(int));
   cconvert->Cr_g_tab = (INT32 *)
     (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
-                               (MAXJSAMPLE+1) * SIZEOF(INT32));
+        (MAXJSAMPLE+1) * SIZEOF(INT32));
   cconvert->Cb_g_tab = (INT32 *)
     (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
-                               (MAXJSAMPLE+1) * SIZEOF(INT32));
+        (MAXJSAMPLE+1) * SIZEOF(INT32));
 
   for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
     /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
     /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
     /* Cr=>R value is nearest int to 1.40200 * x */
     cconvert->Cr_r_tab[i] = (int)
-                   RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS);
+        RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS);
     /* Cb=>B value is nearest int to 1.77200 * x */
     cconvert->Cb_b_tab[i] = (int)
-                   RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS);
+        RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS);
     /* Cr=>G value is scaled-up -0.71414 * x */
     cconvert->Cr_g_tab[i] = (- FIX(0.71414)) * x;
     /* Cb=>G value is scaled-up -0.34414 * x */
@@ -118,8 +118,8 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
 
 METHODDEF(void)
 ycc_rgb_convert (j_decompress_ptr cinfo,
-                JSAMPIMAGE input_buf, JDIMENSION input_row,
-                JSAMPARRAY output_buf, int num_rows)
+     JSAMPIMAGE input_buf, JDIMENSION input_row,
+     JSAMPARRAY output_buf, int num_rows)
 {
   my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
   register int y, cb, cr;
@@ -148,8 +148,8 @@ ycc_rgb_convert (j_decompress_ptr cinfo,
       /* Range-limiting is essential due to noise introduced by DCT losses. */
       outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
       outptr[RGB_GREEN] = range_limit[y +
-                             ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
-                                                SCALEBITS))];
+            ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
+             SCALEBITS))];
       outptr[RGB_BLUE] =  range_limit[y + Cbbtab[cb]];
       outptr += RGB_PIXELSIZE;
     }
@@ -167,8 +167,8 @@ ycc_rgb_convert (j_decompress_ptr cinfo,
 
 METHODDEF(void)
 null_convert (j_decompress_ptr cinfo,
-             JSAMPIMAGE input_buf, JDIMENSION input_row,
-             JSAMPARRAY output_buf, int num_rows)
+        JSAMPIMAGE input_buf, JDIMENSION input_row,
+        JSAMPARRAY output_buf, int num_rows)
 {
   register JSAMPROW inptr, outptr;
   register JDIMENSION count;
@@ -181,8 +181,8 @@ null_convert (j_decompress_ptr cinfo,
       inptr = input_buf[ci][input_row];
       outptr = output_buf[0] + ci;
       for (count = num_cols; count > 0; count--) {
-       *outptr = *inptr++;     /* needn't bother with GETJSAMPLE() here */
-       outptr += num_components;
+  *outptr = *inptr++;  /* needn't bother with GETJSAMPLE() here */
+  outptr += num_components;
       }
     }
     input_row++;
@@ -199,11 +199,11 @@ null_convert (j_decompress_ptr cinfo,
 
 METHODDEF(void)
 grayscale_convert (j_decompress_ptr cinfo,
-                  JSAMPIMAGE input_buf, JDIMENSION input_row,
-                  JSAMPARRAY output_buf, int num_rows)
+       JSAMPIMAGE input_buf, JDIMENSION input_row,
+       JSAMPARRAY output_buf, int num_rows)
 {
   jcopy_sample_rows(input_buf[0], (int) input_row, output_buf, 0,
-                   num_rows, cinfo->output_width);
+        num_rows, cinfo->output_width);
 }
 
 
@@ -215,8 +215,8 @@ grayscale_convert (j_decompress_ptr cinfo,
 
 METHODDEF(void)
 gray_rgb_convert (j_decompress_ptr cinfo,
-                 JSAMPIMAGE input_buf, JDIMENSION input_row,
-                 JSAMPARRAY output_buf, int num_rows)
+      JSAMPIMAGE input_buf, JDIMENSION input_row,
+      JSAMPARRAY output_buf, int num_rows)
 {
   register JSAMPROW inptr, outptr;
   register JDIMENSION col;
@@ -243,8 +243,8 @@ gray_rgb_convert (j_decompress_ptr cinfo,
 
 METHODDEF(void)
 ycck_cmyk_convert (j_decompress_ptr cinfo,
-                  JSAMPIMAGE input_buf, JDIMENSION input_row,
-                  JSAMPARRAY output_buf, int num_rows)
+       JSAMPIMAGE input_buf, JDIMENSION input_row,
+       JSAMPARRAY output_buf, int num_rows)
 {
   my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
   register int y, cb, cr;
@@ -272,13 +272,13 @@ ycck_cmyk_convert (j_decompress_ptr cinfo,
       cb = GETJSAMPLE(inptr1[col]);
       cr = GETJSAMPLE(inptr2[col]);
       /* Range-limiting is essential due to noise introduced by DCT losses. */
-      outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])];  /* red */
-      outptr[1] = range_limit[MAXJSAMPLE - (y +                        /* green */
-                             ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
-                                                SCALEBITS)))];
-      outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])];  /* blue */
+      outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])];  /* red */
+      outptr[1] = range_limit[MAXJSAMPLE - (y +      /* green */
+            ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
+             SCALEBITS)))];
+      outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])];  /* blue */
       /* K passes through unchanged */
-      outptr[3] = inptr3[col]; /* don't need GETJSAMPLE here */
+      outptr[3] = inptr3[col];  /* don't need GETJSAMPLE here */
       outptr += 4;
     }
   }
@@ -292,6 +292,7 @@ ycck_cmyk_convert (j_decompress_ptr cinfo,
 METHODDEF(void)
 start_pass_dcolor (j_decompress_ptr cinfo)
 {
+  cinfo = 0;
   /* no work needed */
 }
 
@@ -308,7 +309,7 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
 
   cconvert = (my_cconvert_ptr)
     (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
-                               SIZEOF(my_color_deconverter));
+        SIZEOF(my_color_deconverter));
   cinfo->cconvert = (struct jpeg_color_deconverter *) cconvert;
   cconvert->pub.start_pass = start_pass_dcolor;
 
@@ -331,7 +332,7 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
       ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
     break;
 
-  default:                     /* JCS_UNKNOWN can be anything */
+  default:      /* JCS_UNKNOWN can be anything */
     if (cinfo->num_components < 1)
       ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
     break;
@@ -346,11 +347,11 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
   case JCS_GRAYSCALE:
     cinfo->out_color_components = 1;
     if (cinfo->jpeg_color_space == JCS_GRAYSCALE ||
-       cinfo->jpeg_color_space == JCS_YCbCr) {
+  cinfo->jpeg_color_space == JCS_YCbCr) {
       cconvert->pub.color_convert = grayscale_convert;
       /* For color->grayscale conversion, only the Y (0) component is needed */
       for (ci = 1; ci < cinfo->num_components; ci++)
-       cinfo->comp_info[ci].component_needed = FALSE;
+  cinfo->comp_info[ci].component_needed = FALSE;
     } else
       ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
     break;
@@ -384,7 +385,7 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
     if (cinfo->out_color_space == cinfo->jpeg_color_space) {
       cinfo->out_color_components = cinfo->num_components;
       cconvert->pub.color_convert = null_convert;
-    } else                     /* unsupported non-null conversion */
+    } else      /* unsupported non-null conversion */
       ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
     break;
   }