pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/graphics/resize_image Don't use nested functions. Bump...
details: https://anonhg.NetBSD.org/pkgsrc/rev/dc2102001c2e
branches: trunk
changeset: 610648:dc2102001c2e
user: joerg <joerg%pkgsrc.org@localhost>
date: Thu Nov 01 19:52:03 2012 +0000
description:
Don't use nested functions. Bump revisions.
diffstat:
graphics/resize_image/Makefile | 4 +-
graphics/resize_image/distinfo | 3 +-
graphics/resize_image/patches/patch-image_image__trans.c | 573 +++++++++++++++
3 files changed, 577 insertions(+), 3 deletions(-)
diffs (truncated from 605 to 300 lines):
diff -r 77c0c6edde85 -r dc2102001c2e graphics/resize_image/Makefile
--- a/graphics/resize_image/Makefile Thu Nov 01 19:50:59 2012 +0000
+++ b/graphics/resize_image/Makefile Thu Nov 01 19:52:03 2012 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.17 2012/10/06 14:11:19 asau Exp $
+# $NetBSD: Makefile,v 1.18 2012/11/01 19:52:03 joerg Exp $
#
DISTNAME= resize_image-0.6
-PKGREVISION= 4
+PKGREVISION= 5
CATEGORIES= graphics
MASTER_SITES= http://lab.erasme.org/resize_image/
diff -r 77c0c6edde85 -r dc2102001c2e graphics/resize_image/distinfo
--- a/graphics/resize_image/distinfo Thu Nov 01 19:50:59 2012 +0000
+++ b/graphics/resize_image/distinfo Thu Nov 01 19:52:03 2012 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.4 2010/12/18 08:15:51 dsainty Exp $
+$NetBSD: distinfo,v 1.5 2012/11/01 19:52:03 joerg Exp $
SHA1 (resize_image-0.6.tar.gz) = e26f53db67de09bc641caf1ced4742a97be0c4a4
RMD160 (resize_image-0.6.tar.gz) = 42d2ab8813835d51aa984546cb5f2c003e01f667
@@ -7,3 +7,4 @@
SHA1 (patch-ab) = 1ef571f47e79a018dfa73d5996265059edd746d1
SHA1 (patch-ac) = 98b9d32e7d6ba96244a27288a9b36b3a7d41fbd1
SHA1 (patch-ad) = a11e21c71ef4dda8d4ff5311dc57c857fe84f064
+SHA1 (patch-image_image__trans.c) = 1457b87bdbc7aa1f21c6cc8b0004cbbf9fe6b334
diff -r 77c0c6edde85 -r dc2102001c2e graphics/resize_image/patches/patch-image_image__trans.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics/resize_image/patches/patch-image_image__trans.c Thu Nov 01 19:52:03 2012 +0000
@@ -0,0 +1,573 @@
+$NetBSD: patch-image_image__trans.c,v 1.1 2012/11/01 19:52:03 joerg Exp $
+
+Remove nested functions.
+
+--- image/image_trans.c.orig 2012-10-30 19:37:02.000000000 +0000
++++ image/image_trans.c
+@@ -200,6 +200,7 @@ void image_resize_dct(image *pdest, imag
+ uint8 val[8][8];
+ float dct_res[8][8]; /* coefficient 3d qui correspondent a nos pixels */
+ float dc_coeff;
++ uint8 res;
+
+ /* initialise le tableau des fonctions de bases */
+ double f1,f2,tmp;
+@@ -215,70 +216,65 @@ void image_resize_dct(image *pdest, imag
+ uint32 nb_pix;
+ float percent_done,percent_tmp;
+
+- void init_dct(void)
+- {
+- f1 = 2.0*atan(1.0)/8.0;
+- for(y=0;y<8;y++){ /* de la fonction 0 a la 7 */
+- f2=(double)y*f1;
+- for(x=0;x<8;x++){ /* du point 0 au point 7 de la fonction */
+- tmp=cos((double)(2*x+1)*f2);
+- if(y==0) dct_coeff[y][x]=(float)(1.0/sqrt(2.0));
+- else dct_coeff[y][x]=(float)tmp;
+- }
+- }
+- dc_coeff = 1.0/sqrt(2.0);
+- }
+-
+- void calcul_dct(void)
+- {
+- for(i2 = 0; i2 < 8; i2++)
+- {
+- for(i1 = 0; i1 < 8; i1++)
+- {
+- dct_res[i2][i1] = 0.0;
+-
+- for(y = 0; y < 8; y++)
+- for(x = 0; x < 8; x++)
+- dct_res[i2][i1] += dct_coeff[i1][x] * dct_coeff[i2][y]
+- * (float)val[y][x];
+- dct_res[i2][i1] /= 16.0;
+- }
+- }
+- } /* fin de calcul_dct() */
+-
+- uint8 calcul_pix(float px, float py)
+- { uint8 res;
+-
+- float temp;
+- float dct_coeff_hor[8],dct_coeff_ver[8];
+-
+- for(y=0;y<8;y++)
+- {
+- f2=(double)y*f1;
+- if(y==0) {
+- dct_coeff_hor[y]=dc_coeff;
+- } else {
+- tmp=cos((double)(2.0*(4.0-px)+1.0)*f2);
+- dct_coeff_hor[y]=(float)tmp;
+- }
+- if(y==0) {
+- dct_coeff_ver[y]=dc_coeff;
+- } else {
+- tmp=cos((double)(2.0*(4.0-py)+1.0)*f2);
+- dct_coeff_ver[y]=(float)tmp;
+- }
+- }
+-
+- temp = 0.0;
+- for(y=0;y<8;y++)
+- for(x=0;x<8;x++)
+- temp += dct_coeff_hor[x] * dct_coeff_ver[y] * dct_res[y][x];
+-
+- if(temp > 255.0) res = 255;
+- else if(temp < 0.0) res = 0;
+- else res = (uint8)temp;
+- return(res);
+- }
++#define init_dct() do { \
++ f1 = 2.0*atan(1.0)/8.0; \
++ for(y=0;y<8;y++){ /* de la fonction 0 a la 7 */ \
++ f2=(double)y*f1; \
++ for(x=0;x<8;x++){ /* du point 0 au point 7 de la fonction */ \
++ tmp=cos((double)(2*x+1)*f2); \
++ if(y==0) dct_coeff[y][x]=(float)(1.0/sqrt(2.0)); \
++ else dct_coeff[y][x]=(float)tmp; \
++ } \
++ } \
++ dc_coeff = 1.0/sqrt(2.0); \
++ } while (0)
++
++#define calcul_dct() do { \
++ for(i2 = 0; i2 < 8; i2++) \
++ { \
++ for(i1 = 0; i1 < 8; i1++) \
++ { \
++ dct_res[i2][i1] = 0.0; \
++ \
++ for(y = 0; y < 8; y++) \
++ for(x = 0; x < 8; x++) \
++ dct_res[i2][i1] += dct_coeff[i1][x] * dct_coeff[i2][y] \
++ * (float)val[y][x]; \
++ dct_res[i2][i1] /= 16.0; \
++ } \
++ } \
++ } /* fin de calcul_dct() */ while (0)
++
++#define calcul_pix(px, py) do { \
++ float temp; \
++ float dct_coeff_hor[8],dct_coeff_ver[8]; \
++ \
++ for(y=0;y<8;y++) \
++ { \
++ f2=(double)y*f1; \
++ if(y==0) { \
++ dct_coeff_hor[y]=dc_coeff; \
++ } else { \
++ tmp=cos((double)(2.0*(4.0-px)+1.0)*f2); \
++ dct_coeff_hor[y]=(float)tmp; \
++ } \
++ if(y==0) { \
++ dct_coeff_ver[y]=dc_coeff; \
++ } else { \
++ tmp=cos((double)(2.0*(4.0-py)+1.0)*f2); \
++ dct_coeff_ver[y]=(float)tmp; \
++ } \
++ } \
++ \
++ temp = 0.0; \
++ for(y=0;y<8;y++) \
++ for(x=0;x<8;x++) \
++ temp += dct_coeff_hor[x] * dct_coeff_ver[y] * dct_res[y][x]; \
++ \
++ if(temp > 255.0) res = 255; \
++ else if(temp < 0.0) res = 0; \
++ else res = (uint8)temp; \
++ } while(0)
+
+ /* corp de la procedure */
+ init_dct();
+@@ -314,19 +310,22 @@ void image_resize_dct(image *pdest, imag
+ for(x=0;x<8;x++)
+ val[y][x] = COL_RED(get_pix(psrc,((int32)rx)-x+4,((int32)ry)-y+4));
+ calcul_dct();
+- SET_COL_RED(vcol,calcul_pix(x_dist, y_dist));
++ calcul_pix(x_dist, y_dist);
++ SET_COL_RED(vcol, res);
+ /* pour le vert */
+ for(y=0;y<8;y++)
+ for(x=0;x<8;x++)
+ val[y][x] = COL_GREEN(get_pix(psrc,((int32)rx)-x+4,((int32)ry)-y+4));
+ calcul_dct();
+- SET_COL_GREEN(vcol,calcul_pix(x_dist, y_dist));
++ calcul_pix(x_dist, y_dist);
++ SET_COL_GREEN(vcol,res);
+ /* pour le bleu */
+ for(y=0;y<8;y++)
+ for(x=0;x<8;x++)
+ val[y][x] = COL_BLUE(get_pix(psrc,((int32)rx)-x+4,((int32)ry)-y+4));
+ calcul_dct();
+- SET_COL_BLUE(vcol,calcul_pix(x_dist, y_dist));
++ calcul_pix(x_dist, y_dist);
++ SET_COL_BLUE(vcol,res);
+ /* on place le pixel calcule */
+ put_pix_alpha_replace(pdest, vx, vy, vcol);
+
+@@ -370,25 +369,26 @@ void image_resize_catmull_rom(image *pde
+ image *img_width;
+
+ /* calcul la valeur du point a la position t */
+- void calcul_dot(float t)
+- { float t2,t3;
+- float xt,yt,zt,wt;
+-
+- /* calcul t au carre */
+- t2 = t*t;
+- /* calcul t au cube */
+- t3 = t2*t;
+-
+- /* on multiplie le vecteur (t3,t2,t,1) par la matrice mat */
+- xt = t3*mat[0] + t2*mat[4] + t*mat[ 8] + mat[12];
+- yt = t3*mat[1] + t2*mat[5] + t*mat[ 9] + mat[13];
+- zt = t3*mat[2] + t2*mat[6] + t*mat[10] + mat[14];
+- wt = t3*mat[3] + t2*mat[7] + t*mat[11] + mat[15];
+- /* on multiplie le resultat par la matrice des contraintes */
+- x = xt*dot[0] + yt*dot[3] + zt*dot[6] + wt*dot[9];
+- y = xt*dot[1] + yt*dot[4] + zt*dot[7] + wt*dot[10];
+- z = xt*dot[2] + yt*dot[5] + zt*dot[8] + wt*dot[11];
+- }
++#define calcul_dot(t_) do { \
++ float t = (t_); \
++ float t2,t3; \
++ float xt,yt,zt,wt; \
++ \
++ /* calcul t au carre */ \
++ t2 = t*t; \
++ /* calcul t au cube */ \
++ t3 = t2*t; \
++ \
++ /* on multiplie le vecteur (t3,t2,t,1) par la matrice mat */ \
++ xt = t3*mat[0] + t2*mat[4] + t*mat[ 8] + mat[12]; \
++ yt = t3*mat[1] + t2*mat[5] + t*mat[ 9] + mat[13]; \
++ zt = t3*mat[2] + t2*mat[6] + t*mat[10] + mat[14]; \
++ wt = t3*mat[3] + t2*mat[7] + t*mat[11] + mat[15]; \
++ /* on multiplie le resultat par la matrice des contraintes */ \
++ x = xt*dot[0] + yt*dot[3] + zt*dot[6] + wt*dot[9]; \
++ y = xt*dot[1] + yt*dot[4] + zt*dot[7] + wt*dot[10]; \
++ z = xt*dot[2] + yt*dot[5] + zt*dot[8] + wt*dot[11]; \
++ } while (0)
+
+ width_scale = (float)psrc->width / (float)width;
+ height_scale = (float)psrc->height / (float)height;
+@@ -572,40 +572,43 @@ void image_resize_tv2(image *pdest, imag
+ { pix vcol,vcol1,vcol2,vcol3,vcol4;
+ int32 vx,vy;
+
+- void redim_col(float dim)
+- {
+- vcol = COL(
+- (uint8)MIN(255,MAX(0,(((float)COL_RED(vcol))*dim))),
+- (uint8)MIN(255,MAX(0,(((float)COL_GREEN(vcol))*dim))),
+- (uint8)MIN(255,MAX(0,(((float)COL_BLUE(vcol))*dim))));
+- }
+-
+- void redim_lum(float dim_y,float dim_cr,float dim_cb)
+- { float cr,cb,y;
+- float r,g,b;
+-
+- y = 0.299*(float)COL_RED(vcol)+
+- 0.587*(float)COL_GREEN(vcol)+
+- 0.114*(float)COL_BLUE(vcol);
+- cr = (float)COL_RED(vcol) - y;
+- cb = (float)COL_BLUE(vcol) - y;
+-
+-/* y = (1.0+cos(M_PI+((y/255.0)*M_PI)))*128.0;*/
+-
+- y *= dim_y;
+- cr *= dim_cr;
+- cb *= dim_cb;
+-
+- r = cr + y;
+- b = cb + y;
+- g = y*1.7 - r*0.509 - b*0.194;
+-
+- r = MIN(255.0,MAX(0,r));
+- g = MIN(255.0,MAX(0,g));
+- b = MIN(255.0,MAX(0,b));
+-
+- vcol = COL((uint8)r,(uint8)g,(uint8)b);
+- }
++#define redim_col(dim_) do { \
++ float dim = (dim_); \
++ vcol = COL( \
++ (uint8)MIN(255,MAX(0,(((float)COL_RED(vcol))*dim))), \
++ (uint8)MIN(255,MAX(0,(((float)COL_GREEN(vcol))*dim))), \
++ (uint8)MIN(255,MAX(0,(((float)COL_BLUE(vcol))*dim)))); \
++ } while(0)
++
++#define redim_lum(dim_y_, dim_cr_, dim_cb_) do { \
++ float dim_y = (dim_y_); \
++ float dim_cr = (dim_cr_); \
++ float dim_cb = (dim_cb_); \
++ float cr,cb,y; \
++ float r,g,b; \
Home |
Main Index |
Thread Index |
Old Index