[gs-cvs] rev 8530 - trunk/gs/src

leonardo at ghostscript.com leonardo at ghostscript.com
Sun Feb 17 15:36:50 PST 2008


Author: leonardo
Date: 2008-02-17 15:36:50 -0800 (Sun, 17 Feb 2008)
New Revision: 8530

Modified:
   trunk/gs/src/gxipixel.c
   trunk/gs/src/gxiscale.c
   trunk/gs/src/siscale.c
Log:
Fix (images) : Improve coordinate precision when scaling an image (continued 4).

DETAILS :

Ghostscript Bug 687345 "Image interpolation problem at a band boundary"

This patch doesn't change the algorithm.
It only removes tracks of dead development branches.

EXPECTED DIFFERENCES :

None.


Modified: trunk/gs/src/gxipixel.c
===================================================================
--- trunk/gs/src/gxipixel.c	2008-02-17 23:25:47 UTC (rev 8529)
+++ trunk/gs/src/gxipixel.c	2008-02-17 23:36:50 UTC (rev 8530)
@@ -220,38 +220,6 @@
 	      mat.xx, mat.xy, mat.yx, mat.yy, mat.tx, mat.ty);
     /* following works for 1, 2, 4, 8, 12, 16 */
     index_bps = (bps < 8 ? bps >> 1 : (bps >> 2) + 1);
-#if 0 /* replaced due to inaccurate precision, bug 687345 , text -r300 455690-1.pdf . */
-    mtx = float2fixed(mat.tx);
-    mty = float2fixed(mat.ty);
-    row_extent.x = float2fixed(width * mat.xx + mat.tx) - mtx;
-    row_extent.y =
-	(is_fzero(mat.xy) ? fixed_0 :
-	 float2fixed(width * mat.xy + mat.ty) - mty);
-    col_extent.x =
-	(is_fzero(mat.yx) ? fixed_0 :
-	 float2fixed(height * mat.yx + mat.tx) - mtx);
-    col_extent.y = float2fixed(height * mat.yy + mat.ty) - mty;
-    gx_image_enum_common_init((gx_image_enum_common_t *)penum,
-			      (const gs_data_image_t *)pim,
-			      &image1_enum_procs, dev,
-			      (masked ? 1 : (penum->alpha ? cs_num_components(pcs)+1 : cs_num_components(pcs))),
-			      format);
-    if (penum->rect.w == width && penum->rect.h == height) {
-	x_extent = row_extent;
-	y_extent = col_extent;
-    } else {
-	int rw = penum->rect.w, rh = penum->rect.h;
-
-	x_extent.x = float2fixed(rw * mat.xx + mat.tx) - mtx;
-	x_extent.y =
-	    (is_fzero(mat.xy) ? fixed_0 :
-	     float2fixed(rw * mat.xy + mat.ty) - mty);
-	y_extent.x =
-	    (is_fzero(mat.yx) ? fixed_0 :
-	     float2fixed(rh * mat.yx + mat.tx) - mtx);
-	y_extent.y = float2fixed(rh * mat.yy + mat.ty) - mty;
-    }
-#else
     /* 
      * Compute extents with distance transformation.
      */
@@ -298,7 +266,6 @@
 	     float2fixed_rounded(rh * mat.yx));
 	y_extent.y = float2fixed_rounded(rh * mat.yy);
     }
-#endif
     if (masked) {	/* This is imagemask. */
 	if (bps != 1 || pcs != NULL || penum->alpha || decode[0] == decode[1]) {
 	    gs_free_object(mem, penum, "gx_default_begin_image");

Modified: trunk/gs/src/gxiscale.c
===================================================================
--- trunk/gs/src/gxiscale.c	2008-02-17 23:25:47 UTC (rev 8529)
+++ trunk/gs/src/gxiscale.c	2008-02-17 23:36:50 UTC (rev 8530)
@@ -102,13 +102,9 @@
     iss.BitsPerComponentOut = sizeof(frac) * 8;
     iss.MaxValueOut = frac_1;
     iss.WidthOut = (int)ceil(fabs(dst_xy.x));
-#if 0
-    iss.HeightOut = (int)ceil(fabs(dst_xy.y));
-#else
     iss.HeightOut = fixed2int_pixround_perfect((fixed)((int64_t)(penum->rect.y + penum->rect.h) * 
 						penum->dst_height / penum->Height))
 	- fixed2int_pixround_perfect((fixed)((int64_t)penum->rect.y * penum->dst_height / penum->Height));
-#endif
     iss.WidthIn = penum->rect.w;
     iss.HeightIn = penum->rect.h;
     iss.src_y_offset = penum->rect.y;
@@ -191,13 +187,9 @@
 	    dda_advance(x0, penum->rect.w);
 	penum->xyi.x = fixed2int_pixround(dda_current(x0));
     }
-#if 0
-    penum->xyi.y = fixed2int_pixround(dda_current(penum->dda.pixel0.y));
-#else
     penum->xyi.y = penum->yi0 + fixed2int_pixround_perfect((fixed)((int64_t)penum->rect.y 
 				    * penum->dst_height / penum->Height))
 		* (penum->matrix.yy > 0 ? 1 : -1);
-#endif
     if_debug0('b', "[b]render=interpolate\n");
     return &image_render_interpolate;
 }

Modified: trunk/gs/src/siscale.c
===================================================================
--- trunk/gs/src/siscale.c	2008-02-17 23:25:47 UTC (rev 8529)
+++ trunk/gs/src/siscale.c	2008-02-17 23:36:50 UTC (rev 8530)
@@ -203,44 +203,6 @@
     npixels = (int)(WidthIn * 2 + 1);
 
     for (i = 0; i < size; ++i) {
-#if 0
-	double center = (starting_output_index + i) / scale;
-	int left = (int)ceil(center - WidthIn);
-	int right = (int)floor(center + WidthIn);
-
-	/*
-	 * In pathological cases, the limit may be much less
-	 * than the support.  We do need to deal with this.
-	 */
-#define clamp_pixel(j)\
-  (j < 0 ? (-j >= limit ? limit - 1 : -j) :\
-   j >= limit ? (j >> 1 >= limit ? 0 : (limit - j) + limit - 1) :\
-   j)
-	int lmin =
-	(left < 0 ? 0 : left);
-	int lmax =
-	(left < 0 ? (-left >= limit ? limit - 1 : -left) : left);
-	int rmin =
-	(right >= limit ?
-	 (right >> 1 >= limit ? 0 : (limit - right) + limit - 1) :
-	 right);
-	int rmax =
-	(right >= limit ? limit - 1 : right);
-	int first_pixel = min(lmin, rmin);
-	int last_pixel = max(lmax, rmax);
-#else
-#if 0
-#if 1 /* CET 148-14 */
-	float dst_offset_fraction = floor(dst_offset) - dst_offset; /* Compensate 
-				rounding for penum->xyi.y in gs_image_class_0_interpolate. */
-#else  /* CET 148-13 */
-	float dst_offset_fraction = ceil(dst_offset) - dst_offset; /* Compensate 
-				rounding for penum->xyi.y in gs_image_class_0_interpolate. */
-#endif
-	double center = (starting_output_index  + i + dst_offset_fraction) / scale - 0.5;
-	int left = (int)ceil(center - WidthIn);
-	int right = (int)floor(center + WidthIn);
-#else
 	/* Here we need :
 	   double scale = (double)dst_size / src_size;
 	   float dst_offset_fraction = floor(dst_offset) - dst_offset;
@@ -251,28 +213,18 @@
 	   In older versions tt caused a 1 pixel bias of image bands due to 
 	   rounding direction appears to depend on src_y_offset. So compute in rartionals.
 	 */
-#if 0
-#if 0 /* CET 148-14 */
-	int dst_y_offset_fraction_num = -(int)((int64_t)src_y_offset * dst_size % src_size);
-#else /* CET 148-13 */
-	int dst_y_offset_fraction_num = (src_size - (int)((int64_t)src_y_offset * dst_size % src_size)) % src_size;
-#endif
-#else
 	int dst_y_offset_fraction_num = (int)((int64_t)src_y_offset * dst_size % src_size) * 2 <= src_size
 			? -(int)((int64_t)src_y_offset * dst_size % src_size)
 			: src_size - (int)((int64_t)src_y_offset * dst_size % src_size);
-#endif
 	int center_denom = dst_size; 
 	int64_t center_num = /* center * center_denom = */ 
 	    (starting_output_index  + i) * src_size + dst_y_offset_fraction_num - (center_denom / 2);
 	int left = (int)((center_num - WidthIn * center_denom + (center_denom - 1)) / center_denom);
 	int right = (int)((center_num + WidthIn * center_denom) / center_denom);
 	double center = (double)center_num / center_denom;
-#endif
 #define clamp_pixel(j) (j < 0 ? 0 : j >= limit ? limit - 1 : j)
 	int first_pixel = clamp_pixel(left);
 	int last_pixel = clamp_pixel(right);
-#endif
 	CONTRIB *p;
 
 	if_debug4('w', "[w]i=%d, i+offset=%lg scale=%lg center=%lg : ", starting_output_index + i, 



More information about the gs-cvs mailing list