]> Creatis software - gdcm.git/blobdiff - src/jpeg/libijg/jdsample.c
ENH: Fix the remaining warnings using: diff -u --strip-trailing-cr --ignore-space...
[gdcm.git] / src / jpeg / libijg / jdsample.c
index 80ffefb2a1ccf5ddc1530b921df0eef6e3e45c18..f42cc33301c02c1ca3cb0322f0dbfd216dde165e 100644 (file)
 
 /* Pointer to routine to upsample a single component */
 typedef JMETHOD(void, upsample1_ptr,
-               (j_decompress_ptr cinfo, jpeg_component_info * compptr,
-                JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr));
+    (j_decompress_ptr cinfo, jpeg_component_info * compptr,
+     JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr));
 
 /* Private subobject */
 
 typedef struct {
-  struct jpeg_upsampler pub;   /* public fields */
+  struct jpeg_upsampler pub;  /* public fields */
 
   /* Color conversion buffer.  When using separate upsampling and color
    * conversion steps, this buffer holds one upsampled row group until it
@@ -45,8 +45,8 @@ typedef struct {
   /* Per-component upsampling method pointers */
   upsample1_ptr methods[MAX_COMPONENTS];
 
-  int next_row_out;            /* counts rows emitted from color_buf */
-  JDIMENSION rows_to_go;       /* counts rows remaining in image */
+  int next_row_out;    /* counts rows emitted from color_buf */
+  JDIMENSION rows_to_go;  /* counts rows remaining in image */
 
   /* Height of an input row group for each component. */
   int rowgroup_height[MAX_COMPONENTS];
@@ -87,26 +87,27 @@ start_pass_upsample (j_decompress_ptr cinfo)
 
 METHODDEF(void)
 sep_upsample (j_decompress_ptr cinfo,
-             JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
-             JDIMENSION in_row_groups_avail,
-             JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
-             JDIMENSION out_rows_avail)
+        JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
+        JDIMENSION in_row_groups_avail,
+        JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
+        JDIMENSION out_rows_avail)
 {
   my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
   int ci;
   jpeg_component_info * compptr;
   JDIMENSION num_rows;
 
+  in_row_groups_avail = 0;
   /* Fill the conversion buffer, if it's empty */
   if (upsample->next_row_out >= cinfo->max_v_samp_factor) {
     for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
-        ci++, compptr++) {
+   ci++, compptr++) {
       /* Invoke per-component upsample method.  Notice we pass a POINTER
        * to color_buf[ci], so that fullsize_upsample can change it.
        */
       (*upsample->methods[ci]) (cinfo, compptr,
-       input_buf[ci] + (*in_row_group_ctr * upsample->rowgroup_height[ci]),
-       upsample->color_buf + ci);
+  input_buf[ci] + (*in_row_group_ctr * upsample->rowgroup_height[ci]),
+  upsample->color_buf + ci);
     }
     upsample->next_row_out = 0;
   }
@@ -126,9 +127,9 @@ sep_upsample (j_decompress_ptr cinfo,
     num_rows = out_rows_avail;
 
   (*cinfo->cconvert->color_convert) (cinfo, upsample->color_buf,
-                                    (JDIMENSION) upsample->next_row_out,
-                                    output_buf + *out_row_ctr,
-                                    (int) num_rows);
+             (JDIMENSION) upsample->next_row_out,
+             output_buf + *out_row_ctr,
+             (int) num_rows);
 
   /* Adjust counts */
   *out_row_ctr += num_rows;
@@ -155,8 +156,10 @@ sep_upsample (j_decompress_ptr cinfo,
 
 METHODDEF(void)
 fullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
-                  JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
+       JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
 {
+  cinfo = 0;
+  compptr = 0;
   *output_data_ptr = input_data;
 }
 
@@ -168,9 +171,12 @@ fullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
 
 METHODDEF(void)
 noop_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
-              JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
+         JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
 {
-  *output_data_ptr = NULL;     /* safety check */
+  cinfo = 0;
+  compptr = 0;
+  input_data = 0;
+  *output_data_ptr = NULL;  /* safety check */
 }
 
 
@@ -187,7 +193,7 @@ noop_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
 
 METHODDEF(void)
 int_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
-             JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
+        JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
 {
   my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
   JSAMPARRAY output_data = *output_data_ptr;
@@ -208,15 +214,15 @@ int_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
     outptr = output_data[outrow];
     outend = outptr + cinfo->output_width;
     while (outptr < outend) {
-      invalue = *inptr++;      /* don't need GETJSAMPLE() here */
+      invalue = *inptr++;  /* don't need GETJSAMPLE() here */
       for (h = h_expand; h > 0; h--) {
-       *outptr++ = invalue;
+  *outptr++ = invalue;
       }
     }
     /* Generate any additional output rows by duplicating the first one */
     if (v_expand > 1) {
       jcopy_sample_rows(output_data, outrow, output_data, outrow+1,
-                       v_expand-1, cinfo->output_width);
+      v_expand-1, cinfo->output_width);
     }
     inrow++;
     outrow += v_expand;
@@ -231,7 +237,7 @@ int_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
 
 METHODDEF(void)
 h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
-              JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
+         JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
 {
   JSAMPARRAY output_data = *output_data_ptr;
   register JSAMPROW inptr, outptr;
@@ -239,12 +245,13 @@ h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
   JSAMPROW outend;
   int inrow;
 
+  compptr = 0;
   for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) {
     inptr = input_data[inrow];
     outptr = output_data[inrow];
     outend = outptr + cinfo->output_width;
     while (outptr < outend) {
-      invalue = *inptr++;      /* don't need GETJSAMPLE() here */
+      invalue = *inptr++;  /* don't need GETJSAMPLE() here */
       *outptr++ = invalue;
       *outptr++ = invalue;
     }
@@ -259,7 +266,7 @@ h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
 
 METHODDEF(void)
 h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
-              JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
+         JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
 {
   JSAMPARRAY output_data = *output_data_ptr;
   register JSAMPROW inptr, outptr;
@@ -267,18 +274,19 @@ h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
   JSAMPROW outend;
   int inrow, outrow;
 
+  compptr = 0;
   inrow = outrow = 0;
   while (outrow < cinfo->max_v_samp_factor) {
     inptr = input_data[inrow];
     outptr = output_data[outrow];
     outend = outptr + cinfo->output_width;
     while (outptr < outend) {
-      invalue = *inptr++;      /* don't need GETJSAMPLE() here */
+      invalue = *inptr++;  /* don't need GETJSAMPLE() here */
       *outptr++ = invalue;
       *outptr++ = invalue;
     }
     jcopy_sample_rows(output_data, outrow, output_data, outrow+1,
-                     1, cinfo->output_width);
+          1, cinfo->output_width);
     inrow++;
     outrow += 2;
   }
@@ -302,7 +310,7 @@ h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
 
 METHODDEF(void)
 h2v1_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
-                    JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
+         JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
 {
   JSAMPARRAY output_data = *output_data_ptr;
   register JSAMPROW inptr, outptr;
@@ -343,7 +351,7 @@ h2v1_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
 
 METHODDEF(void)
 h2v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
-                    JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
+         JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
 {
   JSAMPARRAY output_data = *output_data_ptr;
   register JSAMPROW inptr0, inptr1, outptr;
@@ -360,10 +368,10 @@ h2v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
     for (v = 0; v < 2; v++) {
       /* inptr0 points to nearest input row, inptr1 points to next nearest */
       inptr0 = input_data[inrow];
-      if (v == 0)              /* next nearest is row above */
-       inptr1 = input_data[inrow-1];
-      else                     /* next nearest is row below */
-       inptr1 = input_data[inrow+1];
+      if (v == 0)    /* next nearest is row above */
+  inptr1 = input_data[inrow-1];
+      else      /* next nearest is row below */
+  inptr1 = input_data[inrow+1];
       outptr = output_data[outrow++];
 
       /* Special case for first column */
@@ -374,12 +382,12 @@ h2v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
       lastcolsum = thiscolsum; thiscolsum = nextcolsum;
 
       for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) {
-       /* General case: 3/4 * nearer pixel + 1/4 * further pixel in each */
-       /* dimension, thus 9/16, 3/16, 3/16, 1/16 overall */
-       nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
-       *outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4);
-       *outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4);
-       lastcolsum = thiscolsum; thiscolsum = nextcolsum;
+  /* General case: 3/4 * nearer pixel + 1/4 * further pixel in each */
+  /* dimension, thus 9/16, 3/16, 3/16, 1/16 overall */
+  nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
+  *outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4);
+  *outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4);
+  lastcolsum = thiscolsum; thiscolsum = nextcolsum;
       }
 
       /* Special case for last column */
@@ -406,13 +414,13 @@ jinit_upsampler (j_decompress_ptr cinfo)
 
   upsample = (my_upsample_ptr)
     (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
-                               SIZEOF(my_upsampler));
+        SIZEOF(my_upsampler));
   cinfo->upsample = (struct jpeg_upsampler *) upsample;
   upsample->pub.start_pass = start_pass_upsample;
   upsample->pub.upsample = sep_upsample;
   upsample->pub.need_context_rows = FALSE; /* until we find out differently */
 
-  if (cinfo->CCIR601_sampling) /* this isn't supported */
+  if (cinfo->CCIR601_sampling)  /* this isn't supported */
     ERREXIT(cinfo, JERR_CCIR601_NOTIMPL);
 
   /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1,
@@ -429,9 +437,9 @@ jinit_upsampler (j_decompress_ptr cinfo)
      * are to be converted to max_h_samp_factor * max_v_samp_factor pixels.
      */
     h_in_group = (compptr->h_samp_factor * compptr->DCT_scaled_size) /
-                cinfo->min_DCT_scaled_size;
+     cinfo->min_DCT_scaled_size;
     v_in_group = (compptr->v_samp_factor * compptr->DCT_scaled_size) /
-                cinfo->min_DCT_scaled_size;
+     cinfo->min_DCT_scaled_size;
     h_out_group = cinfo->max_h_samp_factor;
     v_out_group = cinfo->max_v_samp_factor;
     upsample->rowgroup_height[ci] = v_in_group; /* save for use later */
@@ -445,22 +453,22 @@ jinit_upsampler (j_decompress_ptr cinfo)
       upsample->methods[ci] = fullsize_upsample;
       need_buffer = FALSE;
     } else if (h_in_group * 2 == h_out_group &&
-              v_in_group == v_out_group) {
+         v_in_group == v_out_group) {
       /* Special cases for 2h1v upsampling */
       if (do_fancy && compptr->downsampled_width > 2)
-       upsample->methods[ci] = h2v1_fancy_upsample;
+  upsample->methods[ci] = h2v1_fancy_upsample;
       else
-       upsample->methods[ci] = h2v1_upsample;
+  upsample->methods[ci] = h2v1_upsample;
     } else if (h_in_group * 2 == h_out_group &&
-              v_in_group * 2 == v_out_group) {
+         v_in_group * 2 == v_out_group) {
       /* Special cases for 2h2v upsampling */
       if (do_fancy && compptr->downsampled_width > 2) {
-       upsample->methods[ci] = h2v2_fancy_upsample;
-       upsample->pub.need_context_rows = TRUE;
+  upsample->methods[ci] = h2v2_fancy_upsample;
+  upsample->pub.need_context_rows = TRUE;
       } else
-       upsample->methods[ci] = h2v2_upsample;
+  upsample->methods[ci] = h2v2_upsample;
     } else if ((h_out_group % h_in_group) == 0 &&
-              (v_out_group % v_in_group) == 0) {
+         (v_out_group % v_in_group) == 0) {
       /* Generic integral-factors upsampling method */
       upsample->methods[ci] = int_upsample;
       upsample->h_expand[ci] = (UINT8) (h_out_group / h_in_group);
@@ -469,10 +477,10 @@ jinit_upsampler (j_decompress_ptr cinfo)
       ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);
     if (need_buffer) {
       upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray)
-       ((j_common_ptr) cinfo, JPOOL_IMAGE,
-        (JDIMENSION) jround_up((long) cinfo->output_width,
-                               (long) cinfo->max_h_samp_factor),
-        (JDIMENSION) cinfo->max_v_samp_factor);
+  ((j_common_ptr) cinfo, JPOOL_IMAGE,
+   (JDIMENSION) jround_up((long) cinfo->output_width,
+        (long) cinfo->max_h_samp_factor),
+   (JDIMENSION) cinfo->max_v_samp_factor);
     }
   }
 }