svn commit: r358594 - in head/graphics/pfstmo: . files

Danilo Egea Gondolfo danilo at FreeBSD.org
Fri Jun 20 15:46:30 UTC 2014


Author: danilo
Date: Fri Jun 20 15:46:27 2014
New Revision: 358594
URL: http://svnweb.freebsd.org/changeset/ports/358594
QAT: https://qat.redports.org/buildarchive/r358594/

Log:
  - Update from 1.2 to 1.5
  - Add stage support
  
  PR:		ports/191180
  Submitted by:	ii at any.com.ru

Added:
  head/graphics/pfstmo/files/patch-configure   (contents, props changed)
  head/graphics/pfstmo/files/patch-src-durand02-fastbilateral.cpp   (contents, props changed)
  head/graphics/pfstmo/files/patch-src-fattal02-pde.cpp   (contents, props changed)
  head/graphics/pfstmo/files/patch-src-fattal02-tmo_fattal02.cpp   (contents, props changed)
  head/graphics/pfstmo/files/patch-src-mantiuk06-pfstmo_mantiuk06.cpp   (contents, props changed)
  head/graphics/pfstmo/files/patch-src-mantiuk08-display_adaptive_tmo.cpp   (contents, props changed)
  head/graphics/pfstmo/files/patch-src-mantiuk08-pfstmo_mantiuk08.cpp   (contents, props changed)
  head/graphics/pfstmo/files/patch-src-reinhard02-approx.cpp   (contents, props changed)
  head/graphics/pfstmo/files/patch-src-reinhard02-pfstmo_reinhard02.1   (contents, props changed)
  head/graphics/pfstmo/files/patch-src-reinhard02-pfstmo_reinhard02.cpp   (contents, props changed)
  head/graphics/pfstmo/files/patch-src-reinhard02-tmo_reinhard02.cpp   (contents, props changed)
  head/graphics/pfstmo/files/patch-src-reinhard02-tmo_reinhard02.h   (contents, props changed)
  head/graphics/pfstmo/files/patch-src-reinhard05-pfstmo_reinhard05.cpp   (contents, props changed)
Modified:
  head/graphics/pfstmo/Makefile
  head/graphics/pfstmo/distinfo
  head/graphics/pfstmo/files/patch-src-mantiuk06-contrast_domain.cpp
  head/graphics/pfstmo/pkg-plist

Modified: head/graphics/pfstmo/Makefile
==============================================================================
--- head/graphics/pfstmo/Makefile	Fri Jun 20 15:40:12 2014	(r358593)
+++ head/graphics/pfstmo/Makefile	Fri Jun 20 15:46:27 2014	(r358594)
@@ -2,37 +2,27 @@
 # $FreeBSD$
 
 PORTNAME=	pfstmo
-PORTVERSION=	1.2
-PORTREVISION=	3
+PORTVERSION=	1.5
 CATEGORIES=	graphics
-MASTER_SITES=	SF/pfstools/${PORTNAME}/${PORTVERSION}
+MASTER_SITES=	SF
+MASTER_SITE_SUBDIR=	pfstools/${PORTNAME}/${PORTVERSION}
 
 MAINTAINER=	ii at any.com.ru
 COMMENT=	Tone mapping operators
 
-LIB_DEPENDS=	pfs-1.2:${PORTSDIR}/graphics/pfstools
+LIB_DEPENDS=	libpfs-1.2.so:${PORTSDIR}/graphics/pfstools \
+		libfftw3.so:${PORTSDIR}/math/fftw3 \
+		libfftw3f.so:${PORTSDIR}/math/fftw3-float \
+		libgsl.so:${PORTSDIR}/math/gsl
 
 PFS_CPPFLAGS=	-I${LOCALBASE}/include
 PFS_LDFLAGS=	-L${LOCALBASE}/lib
 
-USES=		pkgconfig gmake
 GNU_CONFIGURE=	yes
-CPPFLAGS+=	${PFS_CPPFLAGS}
-LDFLAGS+=	${PFS_LDFLAGS}
+CONFIGURE_TARGET=	--build=${MACHINE_ARCH}-portbld-freebsd${OSREL}
+CONFIGURE_ENV+=	CPPFLAGS="${PFS_CPPFLAGS} ${DEBUG_FLAGS}" \
+		LDFLAGS="${PFS_LDFLAGS}"
 
-MAN1=		pfstmo_pattanaik00.1 \
-		pfstmo_reinhard05.1 \
-		pfstmo_reinhard02.1 \
-		pfstmo_durand02.1 \
-		pfstmo_drago03.1 \
-		pfstmo_mantiuk06.1 \
-		pfstmo_fattal02.1
-
-NO_STAGE=	yes
-.include <bsd.port.pre.mk>
-
-.if defined(WITH_FFTW3F)
-LIB_DEPENDS+=	fftw3f:${PORTSDIR}/math/fftw3-float
-.endif
+USES=		gmake pkgconfig compiler:openmp
 
-.include <bsd.port.post.mk>
+.include <bsd.port.mk>

Modified: head/graphics/pfstmo/distinfo
==============================================================================
--- head/graphics/pfstmo/distinfo	Fri Jun 20 15:40:12 2014	(r358593)
+++ head/graphics/pfstmo/distinfo	Fri Jun 20 15:46:27 2014	(r358594)
@@ -1,2 +1,2 @@
-SHA256 (pfstmo-1.2.tar.gz) = 796555f3c60fc8f2cb56e4288dc035aa3f0a6b8812a7388ce3c002103c2e5aa1
-SIZE (pfstmo-1.2.tar.gz) = 384037
+SHA256 (pfstmo-1.5.tar.gz) = 614599faecddb925cf51458f0d111f42bb624d91a9181181b63c81cbb9cc8ac9
+SIZE (pfstmo-1.5.tar.gz) = 461375

Added: head/graphics/pfstmo/files/patch-configure
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/graphics/pfstmo/files/patch-configure	Fri Jun 20 15:46:27 2014	(r358594)
@@ -0,0 +1,11 @@
+--- configure.orig	2012-06-25 13:03:44.000000000 +0000
++++ configure	2014-06-18 15:31:54.008958029 +0000
+@@ -14272,7 +14272,7 @@
+ 
+ 
+ 
+-#CXXFLAGS="-O3 -funroll-loops -fstrength-reduce -fschedule-insns2 -felide-constructors -frerun-loop-opt -fexceptions -fno-strict-aliasing -fexpensive-optimizations -ffast-math -pipe"
++#CXXFLAGS="-O3 -funroll-loops -fstrength-reduce -felide-constructors -fexceptions -fno-strict-aliasing -fexpensive-optimizations -ffast-math -pipe"
+ enable_fftw3f="yes"
+ 
+ 

Added: head/graphics/pfstmo/files/patch-src-durand02-fastbilateral.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/graphics/pfstmo/files/patch-src-durand02-fastbilateral.cpp	Fri Jun 20 15:46:27 2014	(r358594)
@@ -0,0 +1,27 @@
+--- src/durand02/fastbilateral.cpp.orig	2008-09-09 18:10:49.000000000 +0000
++++ src/durand02/fastbilateral.cpp	2014-06-18 15:29:52.288954426 +0000
+@@ -66,11 +66,11 @@
+   {
+     int ox = nx;
+     int oy = ny/2 + 1;            // saves half of the data
+-    const int osize = ox * oy;
+-    source =  (float*)fftwf_malloc(sizeof(float) * nx * 2 * (ny/2+1) );
++    const size_t osize = ox * oy;
++    source =  (float*)fftwf_malloc(sizeof(float) * (size_t)nx * 2 * ((size_t)ny/2+1) );
+     freq = (fftwf_complex*) fftwf_malloc(sizeof(fftwf_complex) * osize);
+-//    if( source == NULL || freq == NULL )
+-    //TODO: throw exception
++    if( source == NULL || freq == NULL )
++        throw std::bad_alloc();
+     fplan_fw = fftwf_plan_dft_r2c_2d(nx, ny, source, freq, FFTW_ESTIMATE);
+     fplan_in = fftwf_plan_dft_c2r_2d(nx, ny, freq, source, FFTW_ESTIMATE);    
+   }
+@@ -100,7 +100,7 @@
+     for( x=0 ; x<ox/2 ; x++ )
+       for( y=0 ; y<oy ; y++ )
+       {
+-        float d2 = x*x + y*y;
++        float d2 = (float)x*x + (float)y*y;
+         float kernel = exp( -d2 / sig2 );
+         
+         freq[x*oy+y][0] *= kernel;

Added: head/graphics/pfstmo/files/patch-src-fattal02-pde.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/graphics/pfstmo/files/patch-src-fattal02-pde.cpp	Fri Jun 20 15:46:27 2014	(r358594)
@@ -0,0 +1,185 @@
+--- src/fattal02/pde.cpp.orig	2012-06-21 13:27:13.000000000 +0000
++++ src/fattal02/pde.cpp	2014-06-18 15:29:52.288954426 +0000
+@@ -70,15 +70,15 @@
+ // precision
+ #define EPS 1.0e-12
+ 
+-void linbcg(unsigned long n, float b[], float x[], int itol, float tol,
++static void linbcg(unsigned long n, float b[], float x[], int itol, float tol,
+   int itmax, int *iter, float *err);
+ 
+-inline float max( float a, float b )
++static inline float max( float a, float b )
+ {
+   return a > b ? a : b;
+ }
+ 
+-inline float min( float a, float b )
++static inline float min( float a, float b )
+ {
+   return a < b ? a : b;
+ }
+@@ -109,7 +109,7 @@
+ // Full Multigrid Algorithm for solving partial differential equations
+ //////////////////////////////////////////////////////////////////////
+ 
+-void restrict( const pfstmo::Array2D *in, pfstmo::Array2D *out )
++static void restrict( const pfstmo::Array2D *in, pfstmo::Array2D *out )
+ {
+   const float inRows = in->getRows();
+   const float inCols = in->getCols();
+@@ -172,7 +172,7 @@
+ // }
+ 
+ 
+-void prolongate( const pfstmo::Array2D *in, pfstmo::Array2D *out )
++static void prolongate( const pfstmo::Array2D *in, pfstmo::Array2D *out )
+ {
+   float dx = (float)in->getCols() / (float)out->getCols();
+   float dy = (float)in->getRows() / (float)out->getRows();
+@@ -216,7 +216,7 @@
+ }
+ 
+ // to_level<from_level, from_size<to_size
+-void prolongate_old( pfstmo::Array2D *F, pfstmo::Array2D *T )
++static void prolongate_old( pfstmo::Array2D *F, pfstmo::Array2D *T )
+ {
+ //   DEBUG_STR << "prolongate" << endl;
+ 
+@@ -277,7 +277,7 @@
+     }
+ }
+ 
+-void exact_sollution( pfstmo::Array2D *F, pfstmo::Array2D *U )
++static void exact_sollution( pfstmo::Array2D *F, pfstmo::Array2D *U )
+ {
+ //   DEBUG_STR << "exact sollution" << endl;
+ 
+@@ -314,13 +314,13 @@
+ 
+ static int rows, cols;
+ 
+-inline int idx( int r, int c )
++static inline int idx( int r, int c )
+ {
+   return r*cols+c+1;
+ }
+ 
+ // smooth u using f at level
+-void smooth( pfstmo::Array2D *U, pfstmo::Array2D *F )
++static void smooth( pfstmo::Array2D *U, pfstmo::Array2D *F )
+ {
+ //   DEBUG_STR << "smooth" << endl;
+   
+@@ -369,7 +369,7 @@
+ //   }
+ }
+ 
+-void calculate_defect( pfstmo::Array2D *D, pfstmo::Array2D *U, pfstmo::Array2D *F )
++static void calculate_defect( pfstmo::Array2D *D, pfstmo::Array2D *U, pfstmo::Array2D *F )
+ {
+ //   DEBUG_STR << "calculate defect" << endl;
+ 
+@@ -395,7 +395,7 @@
+   
+ }
+ 
+-void add_correction( pfstmo::Array2D *U, pfstmo::Array2D *C )
++static void add_correction( pfstmo::Array2D *U, pfstmo::Array2D *C )
+ {
+ //   DEBUG_STR << "add_correction" << endl;
+ 
+@@ -646,7 +646,7 @@
+ 
+ //#define EPS 1.0e-14
+ 
+-void asolve(unsigned long n, float b[], float x[], int itrnsp)
++static void asolve(float b[], float x[])
+ {
+     for( int r = 0; r < rows; r++ )
+       for( int c = 0; c < cols; c++ ) {
+@@ -654,7 +654,7 @@
+       }
+ }
+ 
+-void atimes(unsigned long n, float x[], float res[], int itrnsp)
++static void atimes(float x[], float res[])
+ {
+   for( int r = 1; r < rows-1; r++ )
+     for( int c = 1; c < cols-1; c++ ) {
+@@ -682,7 +682,7 @@
+     - 2*x[idx(rows-1,cols-1)];  
+ }
+ 
+-float snrm(unsigned long n, float sx[], int itol)
++static float snrm(unsigned long n, float sx[], int itol)
+ {
+ 	unsigned long i,isamax;
+ 	float ans;
+@@ -704,7 +704,7 @@
+  * Biconjugate Gradient Method
+  * from Numerical Recipes in C
+  */
+-void linbcg(unsigned long n, float b[], float x[], int itol, float tol,	int itmax, int *iter, float *err)
++static void linbcg(unsigned long n, float b[], float x[], int itol, float tol,	int itmax, int *iter, float *err)
+ {	
+ 	unsigned long j;
+ 	float ak,akden,bk,bkden,bknum,bnrm,dxnrm,xnrm,zm1nrm,znrm;
+@@ -718,30 +718,30 @@
+ 	zz=new float[n+1];
+ 
+ 	*iter=0;
+-	atimes(n,x,r,0);
++	atimes(x,r);
+ 	for (j=1;j<=n;j++) {
+ 		r[j]=b[j]-r[j];
+ 		rr[j]=r[j];
+ 	}
+-	atimes(n,r,rr,0);       // minimum residual
++	atimes(r,rr);       // minimum residual
+         znrm=1.0;
+ 	if (itol == 1) bnrm=snrm(n,b,itol);
+ 	else if (itol == 2) {
+-		asolve(n,b,z,0);
++		asolve(b,z);
+ 		bnrm=snrm(n,z,itol);
+ 	}
+ 	else if (itol == 3 || itol == 4) {
+-		asolve(n,b,z,0);
++		asolve(b,z);
+ 		bnrm=snrm(n,z,itol);
+-		asolve(n,r,z,0);
++		asolve(r,z);
+ 		znrm=snrm(n,z,itol);
+ 	} else printf("illegal itol in linbcg");
+-	asolve(n,r,z,0);        
++	asolve(r,z);        
+ 
+ 	while (*iter <= itmax) {
+ 		++(*iter);
+ 		zm1nrm=znrm;
+-		asolve(n,rr,zz,1);
++		asolve(rr,zz);
+ 		for (bknum=0.0,j=1;j<=n;j++) bknum += z[j]*rr[j];
+ 		if (*iter == 1) {
+ 			for (j=1;j<=n;j++) {
+@@ -757,16 +757,16 @@
+ 			}
+ 		}                
+ 		bkden=bknum;
+-		atimes(n,p,z,0);
++		atimes(p,z);
+ 		for (akden=0.0,j=1;j<=n;j++) akden += z[j]*pp[j];
+ 		ak=bknum/akden;
+-		atimes(n,pp,zz,1);
++		atimes(pp,zz);
+ 		for (j=1;j<=n;j++) {
+ 			x[j] += ak*p[j];
+ 			r[j] -= ak*z[j];
+ 			rr[j] -= ak*zz[j];
+ 		}
+-		asolve(n,r,z,0);
++		asolve(r,z);
+ 		if (itol == 1 || itol == 2) {
+ 			znrm=1.0;
+ 			*err=snrm(n,r,itol)/bnrm;

Added: head/graphics/pfstmo/files/patch-src-fattal02-tmo_fattal02.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/graphics/pfstmo/files/patch-src-fattal02-tmo_fattal02.cpp	Fri Jun 20 15:46:27 2014	(r358594)
@@ -0,0 +1,10 @@
+--- src/fattal02/tmo_fattal02.cpp.orig	2012-06-22 10:59:15.000000000 +0000
++++ src/fattal02/tmo_fattal02.cpp	2014-06-18 15:29:52.298957047 +0000
+@@ -105,7 +105,6 @@
+ {
+   int width = I->getCols();
+   int height = I->getRows();
+-  int size = width*height;
+   int x,y;
+ 
+   pfstmo::Array2D* T = new pfstmo::Array2D(width,height);

Modified: head/graphics/pfstmo/files/patch-src-mantiuk06-contrast_domain.cpp
==============================================================================
--- head/graphics/pfstmo/files/patch-src-mantiuk06-contrast_domain.cpp	Fri Jun 20 15:40:12 2014	(r358593)
+++ head/graphics/pfstmo/files/patch-src-mantiuk06-contrast_domain.cpp	Fri Jun 20 15:46:27 2014	(r358594)
@@ -1,16 +1,263 @@
---- src/mantiuk06/contrast_domain.cpp.orig	2008-03-12 09:20:28.000000000 +0000
-+++ src/mantiuk06/contrast_domain.cpp	2008-03-12 09:27:16.000000000 +0000
-@@ -58,6 +58,13 @@
- #define LOOKUP_W_TO_R 107
- 
- 
-+#if defined(__FreeBSD__)
-+static inline float exp10f(float x) {
-+	return powf(10.,x);
-+}
-+#endif
-+
-+
- static void contrast_equalization( pyramid_t *pp, const float contrastFactor );
+--- src/mantiuk06/contrast_domain.cpp.orig	2012-04-22 13:14:14.000000000 +0000
++++ src/mantiuk06/contrast_domain.cpp	2014-06-18 15:29:52.298957047 +0000
+@@ -74,8 +74,6 @@
+ static void matrix_copy(const int n, const float* const a, float* const b);
+ static void matrix_multiply_const(const int n, float* const a, const float val);
+ static void matrix_divide(const int n, const float* const a, float* const b);
+-static float* matrix_alloc(const int size);
+-static void matrix_free(float* m);
+ static float matrix_DotProduct(const int n, const float* const a, const float* const b);
+ static void matrix_zero(const int n, float* const m);
+ static void calculate_and_add_divergence(const int rows, const int cols, const float* const Gx, const float* const Gy, float* const divG);
+@@ -317,24 +315,6 @@
+ }
  
- static void transform_to_luminance(pyramid_t* pyramid, float* const x, progress_callback progress_cb, const bool bcg);
+ 
+-// alloc memory for the float table
+-static inline float* matrix_alloc(int size){
+-
+-  float* m = (float*)malloc(sizeof(float)*size);
+-  if(m == NULL){
+-    fprintf(stderr, "ERROR: malloc in matrix_alloc() (size:%d)", size);
+-    exit(155);
+-  }
+-
+-  return m;
+-}
+-
+-// free memory for matrix
+-static inline void matrix_free(float* m){
+-  if(m != NULL)
+-    free(m);
+-}
+-
+ // multiply vector by vector (each vector should have one dimension equal to 1)
+ static inline float matrix_DotProduct(const int n, const float* const a, const float* const b){
+   float val = 0;
+@@ -382,7 +362,7 @@
+ // temp is a temporary matrix of size (cols, rows), assumed to already be allocated
+ static void pyramid_calculate_divergence_sum(pyramid_t* pyramid, float* divG_sum)
+ {
+-  float* temp = matrix_alloc(pyramid->rows*pyramid->cols);
++  float* temp = new float[pyramid->rows*pyramid->cols];
+ 
+   // Find the coarsest pyramid, and the number of pyramid levels
+   int levels = 1;
+@@ -426,7 +406,7 @@
+       pyramid = pyramid->prev;
+     }
+ 
+-  matrix_free(temp);
++  delete[] temp;
+ }
+ 
+ // calculate scale factors (Cx,Cy) for gradients (Gx,Gy)
+@@ -495,20 +475,10 @@
+ {
+   while (pyramid)
+     {
+-      if(pyramid->Gx != NULL)
+-	{
+-	  free(pyramid->Gx);
+-	  pyramid->Gx = NULL;
+-	}
+-      if(pyramid->Gy != NULL)
+-	{
+-	  free(pyramid->Gy);
+-	  pyramid->Gy = NULL;
+-	}
++      delete[] pyramid->Gx;
++      delete[] pyramid->Gy;
+       pyramid_t* const next = pyramid->next;
+-      pyramid->prev = NULL;
+-      pyramid->next = NULL;
+-      free(pyramid);
++      delete pyramid;
+       pyramid = next;
+     }			
+ }
+@@ -523,19 +493,14 @@
+ 
+   while(rows >= PYRAMID_MIN_PIXELS && cols >= PYRAMID_MIN_PIXELS)
+     {
+-      level = (pyramid_t *) malloc(sizeof(pyramid_t));
+-      if(level == NULL)
+-	{
+-	  fprintf(stderr, "ERROR: malloc in pyramid_alloc() (size:%d)", (int)sizeof(pyramid_t));
+-	  exit(155);
+-	}
++      level = new pyramid_t;
+       memset( level, 0, sizeof(pyramid_t) );
+       
+       level->rows = rows;
+       level->cols = cols;
+       const int size = level->rows * level->cols;
+-      level->Gx = matrix_alloc(size);
+-      level->Gy = matrix_alloc(size);
++      level->Gx = new float[size];
++      level->Gy = new float[size];
+       
+       level->prev = prev;
+       if(prev != NULL)
+@@ -598,7 +563,7 @@
+ // lum_temp gets overwritten!
+ static void pyramid_calculate_gradient(pyramid_t* pyramid, float* lum_temp)
+ {
+-  float* temp = matrix_alloc((pyramid->rows/2)*(pyramid->cols/2));
++  float* temp = new float[(pyramid->rows/2)*(pyramid->cols/2)];
+   float* const temp_saved = temp;
+ 
+   calculate_gradient(pyramid->cols, pyramid->rows, lum_temp, pyramid->Gx, pyramid->Gy);	
+@@ -626,7 +591,7 @@
+       pyramid = pyramid->next;
+   }
+ 
+-  matrix_free(temp_saved);
++  delete[] temp_saved;
+ }
+ 
+ 
+@@ -658,13 +623,13 @@
+   const int n = rows*cols;
+   const float tol2 = tol*tol;
+ 	
+-  float* const z = matrix_alloc(n);
+-  float* const zz = matrix_alloc(n);
+-  float* const p = matrix_alloc(n);
+-  float* const pp = matrix_alloc(n);
+-  float* const r = matrix_alloc(n);
+-  float* const rr = matrix_alloc(n);	
+-  float* const x_save = matrix_alloc(n);	
++  float* const z = new float[n];
++  float* const zz = new float[n];
++  float* const p = new float[n];
++  float* const pp = new float[n];
++  float* const r = new float[n];
++  float* const rr = new float[n];	
++  float* const x_save = new float[n];	
+ 	
+   const float bnrm2 = matrix_DotProduct(n, b, b);
+ 	
+@@ -799,13 +764,13 @@
+     progress_cb(100);
+     
+   
+-  matrix_free(x_save);
+-  matrix_free(p);
+-  matrix_free(pp);
+-  matrix_free(z);
+-  matrix_free(zz);
+-  matrix_free(r);
+-  matrix_free(rr);
++  delete[] x_save;
++  delete[] p;
++  delete[] pp;
++  delete[] z;
++  delete[] zz;
++  delete[] r;
++  delete[] rr;
+ }
+ 
+ 
+@@ -818,10 +783,10 @@
+   const int n = rows*cols;
+   const float tol2 = tol*tol;
+ 	
+-  float* const x_save = matrix_alloc(n);
+-  float* const r = matrix_alloc(n);
+-  float* const p = matrix_alloc(n);
+-  float* const Ap = matrix_alloc(n);	
++  float* const x_save = new float[n];
++  float* const r = new float[n];
++  float* const p = new float[n];
++  float* const Ap = new float[n];	
+ 	
+   // bnrm2 = ||b||
+   const float bnrm2 = matrix_DotProduct(n, b, b);
+@@ -943,10 +908,10 @@
+   else if (progress_cb != NULL)
+     progress_cb(100);
+     
+-  matrix_free(x_save);
+-  matrix_free(p);
+-  matrix_free(Ap);
+-  matrix_free(r);
++  delete[] x_save;
++  delete[] p;
++  delete[] Ap;
++  delete[] r;
+ }
+ 
+ 
+@@ -1070,7 +1035,7 @@
+   pyramid_calculate_scale_factor(pp, pC); // calculate (Cx,Cy)
+   pyramid_scale_gradient(pp, pC); // scale small gradients by (Cx,Cy);
+ 
+-  float* b = matrix_alloc(pp->cols * pp->rows);
++  float* b = new float[pp->cols * pp->rows];
+   pyramid_calculate_divergence_sum(pp, b); // calculate the sum of divergences (equal to b)
+   
+   // calculate luminances from gradients
+@@ -1079,7 +1044,7 @@
+   else
+     lincg(pp, pC, b, x, itmax, tol, progress_cb);
+   
+-  matrix_free(b);
++  delete[] b;
+   pyramid_free(pC);
+ }
+ 
+@@ -1121,12 +1086,7 @@
+     }
+   
+   // Allocate memory
+-  struct hist_data* hist = (struct hist_data*) malloc(sizeof(struct hist_data) * total_pixels);
+-  if (hist == NULL)
+-    {
+-      fprintf(stderr, "ERROR: malloc in contrast_equalization() (size:%d)", (int)sizeof(struct hist_data) * total_pixels);
+-      exit(155);
+-    }
++  struct hist_data* hist = new hist_data[total_pixels];
+     
+   // Build histogram info
+   l = pp;
+@@ -1175,7 +1135,7 @@
+     l = l->next;
+   }
+ 
+-  free(hist);
++  delete[] hist;
+ }
+ 
+ 
+@@ -1211,10 +1171,10 @@
+     }
+ 	
+   pyramid_t* pp = pyramid_allocate(c,r); // create pyramid
+-  float* tY = matrix_alloc(n);
++  float* tY = new float[n];
+   matrix_copy(n, Y, tY); // copy Y to tY
+   pyramid_calculate_gradient(pp,tY); // calculate gradients for pyramid, destroys tY
+-  matrix_free(tY);
++  delete[] tY;
+   pyramid_transform_to_R(pp); // transform gradients to R
+ 
+   /* Contrast map */
+@@ -1228,7 +1188,7 @@
+   pyramid_free(pp);
+ 
+   /* Renormalize luminance */
+-  float* temp = matrix_alloc(n);
++  float* temp = new float[n];
+ 	
+   matrix_copy(n, Y, temp); // copy Y to temp
+   qsort(temp, n, sizeof(float), sort_float); // sort temp in ascending order
+@@ -1244,7 +1204,7 @@
+   delta = trim - floorf(trim);
+   const float l_max = temp[(int)floorf(trim)] * delta + temp[(int)ceilf(trim)] * (1.0f-delta);	
+ 	
+-  matrix_free(temp);
++  delete[] temp;
+ 	
+   const float disp_dyn_range = 2.3f;
+ #pragma omp parallel for schedule(static)

Added: head/graphics/pfstmo/files/patch-src-mantiuk06-pfstmo_mantiuk06.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/graphics/pfstmo/files/patch-src-mantiuk06-pfstmo_mantiuk06.cpp	Fri Jun 20 15:46:27 2014	(r358594)
@@ -0,0 +1,17 @@
+--- src/mantiuk06/pfstmo_mantiuk06.cpp.orig	2009-09-02 01:11:39.000000000 +0000
++++ src/mantiuk06/pfstmo_mantiuk06.cpp	2014-06-18 15:29:52.298957047 +0000
+@@ -219,6 +219,14 @@
+   try {
+     tmo_mantiuk06( argc, argv );
+   }
++  catch (std::bad_alloc ex) {
++    fprintf(stderr, PROG_NAME " error: out of memory\n");
++    return EXIT_FAILURE;
++  }
++  catch (std::exception ex) {
++    fprintf(stderr, PROG_NAME " error: %s\n", ex.what());
++    return EXIT_FAILURE;
++  }
+   catch( pfs::Exception ex ) {
+     fprintf( stderr, PROG_NAME " error: %s\n", ex.getMessage() );
+     return EXIT_FAILURE;

Added: head/graphics/pfstmo/files/patch-src-mantiuk08-display_adaptive_tmo.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/graphics/pfstmo/files/patch-src-mantiuk08-display_adaptive_tmo.cpp	Fri Jun 20 15:46:27 2014	(r358594)
@@ -0,0 +1,20 @@
+--- src/mantiuk08/display_adaptive_tmo.cpp.orig	2012-06-25 13:03:28.000000000 +0000
++++ src/mantiuk08/display_adaptive_tmo.cpp	2014-06-18 15:29:52.308951834 +0000
+@@ -201,7 +201,7 @@
+   
+ };
+ 
+-#define PFSEOL "\x0a"
++/*#define PFSEOL "\x0a"
+ static void dumpPFS( const char *fileName, const int width, const int height, float *data, const char *channelName )
+ {
+   FILE *fh = fopen( fileName, "wb" );
+@@ -216,7 +216,7 @@
+     }
+   
+   fclose( fh );
+-}
++}*/
+ 
+ 
+ void compute_gaussian_level( const int width, const int height, const pfstmo::Array2D& in, pfstmo::Array2D& out, int level, pfstmo::Array2D& temp )

Added: head/graphics/pfstmo/files/patch-src-mantiuk08-pfstmo_mantiuk08.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/graphics/pfstmo/files/patch-src-mantiuk08-pfstmo_mantiuk08.cpp	Fri Jun 20 15:46:27 2014	(r358594)
@@ -0,0 +1,25 @@
+--- src/mantiuk08/pfstmo_mantiuk08.cpp.orig	2012-06-25 13:03:28.000000000 +0000
++++ src/mantiuk08/pfstmo_mantiuk08.cpp	2014-06-18 15:29:52.308951834 +0000
+@@ -31,7 +31,6 @@
+ 
+ #include <config.h>
+ 
+-#include <iostream>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <math.h>
+@@ -356,6 +355,14 @@
+   try {
+     tmo_mantiuk08( argc, argv );
+   }
++  catch (std::bad_alloc ex) {
++    fprintf(stderr, PROG_NAME " error: out of memory\n");
++    return EXIT_FAILURE;
++  }
++  catch (std::exception ex) {
++    fprintf(stderr, PROG_NAME " error: %s\n", ex.what());
++    return EXIT_FAILURE;
++  }
+   catch( pfs::Exception ex ) {
+     fprintf( stderr, PROG_NAME " error: %s\n", ex.getMessage() );
+     return EXIT_FAILURE;

Added: head/graphics/pfstmo/files/patch-src-reinhard02-approx.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/graphics/pfstmo/files/patch-src-reinhard02-approx.cpp	Fri Jun 20 15:46:27 2014	(r358594)
@@ -0,0 +1,223 @@
+--- src/reinhard02/approx.cpp.orig	2007-06-14 16:41:30.000000000 +0000
++++ src/reinhard02/approx.cpp	2014-06-18 15:29:52.308951834 +0000
+@@ -17,36 +17,36 @@
+ #include <stdio.h>
+ #include <math.h>
+ 
++#include <pfstmo.h>
++
+ // interpolated version of approximation (always use this one!) (:krawczyk)
+ #define INTERPOLATED
+ 
+-extern double **luminance; 
+-int      ImageWidth, ImageHeight;
++extern pfstmo::Array2D *lum;
++extern int             width, height;
+ 
+-double ***Pyramid;
+-int       PyramidHeight;
+-int       PyramidWidth0;
++int PyramidHeight;
+ 
+-void build_pyramid( double **luminance, int ImageWidth, int ImageHeight );
+-double V1( int x, int y, int level );
++static float ***Pyramid;
++static int   PyramidWidth0;
+ 
+-int div2( const unsigned int n )
++static int div2( const unsigned int n )
+ {
+   const int q = n/2;
+   return(2*q < n ? q + 1 : q);
+ }
+ 
+-double pyramid_lookup( int x, int y, int level )
++static float pyramid_lookup( int x, int y, int level )
+   /* PRE:  */
+ {
+   int n, s;
+   
+   /* Level 0 is a special case, the value is just the image */
+   if (level == 0) {
+-    if ( (x < 0) || (y < 0) || (x >= ImageWidth) || (y >= ImageHeight) )
++    if ( (x < 0) || (y < 0) || (x >= width) || (y >= height) )
+       return(0.0);
+     else
+-      return(luminance[y][x]);
++      return((*lum)(x,y));
+   }
+ 
+   /* Compute the size of the slice */
+@@ -58,25 +58,24 @@
+   //y = y >> level;
+ 
+   if ( (x < 0) || (y < 0) || (x >= s) || (y >= s) )
+-    return(0.0);
++    return(0.0f);
+   else
+     return(Pyramid[level][y][x]);
+ }
+ 
+-void build_pyramid( double **luminance, int image_width, int image_height )
++void build_pyramid()
+ {
+   int k;
+   int x, y;
+   int i, j;
+-  int width, height;
+   int max_dim;
+-  int pyramid_height;
+-  double sum = 0;
++  int pyramid_width;
++  double sum = 0.f;
+   
+-  double a = 0.4;
+-  double b = 0.25;
+-  double c = b - a/2;
+-  double w[5];
++  float a = 0.4f;
++  float b = 0.25f;
++  float c = b - a/2.f;
++  float w[5];
+ 
+   /* Compute the "filter kernel" */
+   w[0] = c;
+@@ -90,50 +89,35 @@
+   /* For simplicity, the first level is padded to a square whose side is a */
+   /* power of two.                                                         */
+ 
+-  ImageWidth = image_width;
+-  ImageHeight = image_height;
+-  
+   /* Compute the size of the Pyramid array */
+-  max_dim = (ImageHeight > ImageWidth ? ImageHeight : ImageWidth);
+-  PyramidHeight = (int) floor(log(max_dim - 0.5)/log(2)) + 1;
++  max_dim = (height > width ? height : width);
++  PyramidHeight = (int)floorf(logf(max_dim - 0.5f)/logf(2)) + 1;
+ 
+   /* Compute the dimensions of the first level */
+-  width = 1 << (PyramidHeight - 1);
+-  PyramidWidth0 = width;
++  pyramid_width = 1 << (PyramidHeight - 1);
++  PyramidWidth0 = pyramid_width;
+ 
+ //  fprintf(stderr, "max_dim %d   height %d\n", max_dim, PyramidHeight);
+   
+   /* Allocate the outer Pyramid array */
+-  Pyramid = (double***) calloc(PyramidHeight, sizeof(double**));
+-  if (!Pyramid) {
+-    fprintf(stderr, "Unable to allocate pyramid array.\n");
+-    exit(1);
+-  }
++  Pyramid = new float**[PyramidHeight];
+ 
+   /* Allocate and assign the Pyramid slices */
+   k = 0;
+   
+-  while (width) {
++  while (pyramid_width) {
+ 
+ //    fprintf(stderr, "level %d, width = %d\n", k, width);
+     
+     /* Allocate the slice */
+-    Pyramid[k] = (double**) calloc(width, sizeof(double*));
+-    if (!Pyramid[k]) {
+-      fprintf(stderr, "Unable to allocate pyramid array.\n");
+-      exit(1);
+-    }
+-    for (y = 0; y < width; y++) {
+-      Pyramid[k][y] = (double*) calloc(width, sizeof(double));
+-      if (!Pyramid[k][y]) {
+-        fprintf(stderr, "Unable to allocate pyramid array.\n");
+-        exit(1);
+-      }
++    Pyramid[k] = new float*[pyramid_width];
++    for (y = 0; y < pyramid_width; y++) {
++      Pyramid[k][y] = new float[pyramid_width];
+     }
+ 
+     /* Compute the values in the slice */
+-    for (y = 0; y < width; y++) {
+-      for (x = 0; x < width; x++) {
++    for (y = 0; y < pyramid_width; y++) {
++      for (x = 0; x < pyramid_width; x++) {
+ 
+         sum = 0;
+         for (i = 0; i < 5; i++) {
+@@ -146,7 +130,7 @@
+     }
+ 
+     /* compute the width of the next slice */
+-    width /= 2;
++    pyramid_width /= 2;
+     k++;
+   }
+ }
+@@ -154,27 +138,27 @@
+ void clean_pyramid()
+ {
+   int k=0;
+-  int width = PyramidWidth0;
+-  while(width)
++  int pyramid_width = PyramidWidth0;
++  while(pyramid_width)
+   {
+-    for( int y=0 ; y<width ; y++ )
+-      free(Pyramid[k][y]);
+-    free(Pyramid[k]);
++    for( int y=0 ; y<pyramid_width ; y++ )
++      delete[] Pyramid[k][y];
++    delete[] Pyramid[k];
+     k++;
+-    width /= 2;
++    pyramid_width /= 2;
+   }
+-  free(Pyramid);
++  delete[] Pyramid;
+ }
+ 
+ #ifndef INTERPOLATED
+-double V1( int x, int y, int level )
++float V1( int x, int y, int level )
+   /* PRE:  */
+ {
+   int n, s;
+ 
+   /* Level 0 is a special case, the value is just the image */
+   if (level <= 0)
+-      return(luminance[y][x]);
++      return((*lum)(x,y));
+ 
+   /* Compute the size of the slice */
+   
+@@ -184,16 +168,16 @@
+   return(Pyramid[level-1][y][x]);
+ }
+ #else
+-double V1( int x, int y, int level )
++float V1( int x, int y, int level )
+   /* PRE:  */
+ {
+   int x0, y0;
+   int l, size;
+-  double s, t;
++  float s, t;
+   
+   /* Level 0 is a special case, the value is just the image */
+   if (level == 0)
+-      return(luminance[y][x]);
++      return((*lum)(x,y));
+ 
+   /* Compute the size of the slice */
+   l = 1 << level;
+@@ -204,8 +188,8 @@
+   x0 = (x0 >= size ? size - 1 : x0);
+   y0 = (y0 >= size ? size - 1 : y0);
+   
+-  s = (double)(x - x0*l)/(double)l;
+-  t = (double)(y - y0*l)/(double)l;
++  s = (float)(x - x0*l)/(float)l;
++  t = (float)(y - y0*l)/(float)l;
+   
+   level--;
+ 

Added: head/graphics/pfstmo/files/patch-src-reinhard02-pfstmo_reinhard02.1
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/graphics/pfstmo/files/patch-src-reinhard02-pfstmo_reinhard02.1	Fri Jun 20 15:46:27 2014	(r358594)
@@ -0,0 +1,63 @@
+--- src/reinhard02/pfstmo_reinhard02.1.orig	2007-06-14 16:41:30.000000000 +0000
++++ src/reinhard02/pfstmo_reinhard02.1	2014-06-18 15:29:52.318951701 +0000
+@@ -6,6 +6,7 @@
+ [--scales] [--key <val>] [--phi <val>]
+ [--range <val>] [--lower <val>] [--upper <val>]
+ [--temporal-coherent]
++[--border <val>]
+ [--verbose] [--help]
+ .SH DESCRIPTION
+ This command implements a tone mapping operator as described in:
+@@ -17,32 +18,32 @@
+ According to the paper, results of this TMO require gamma correction.
+ .SH OPTIONS
+ .TP
+-[--scales] 
++[--scales] [-s]
+ 
+ Use scales to calculate local adaptation. That means: use local
+ version of this operator. By default, global version is used.
+ .TP
+-[--key <val>] 
++[--key <val>] [-k <val>]
+ 
+ Set key value for the image (refer to paper for details).
+ Default value: 0.18, accepted range <0..1>.
+ .TP
+-[--phi <val>]
++[--phi <val>] [-p <val>]
+ 
+ Set phi value (refer to paper for details).
+ Default value: 1.0, accepted range >=0.0.
+ .TP
+-[--range <val>] 
++[--range <val>] [-r <val>]
+ 
+ Set range size (refer to paper for details).
+ Default value: 8, accepted range >1.
+ .TP
+-[--lower <val>] 
++[--lower <val>] [-l <val>]
+ 
+ Set lower scale size (refer to paper for details).
+ Default value: 1, accepted range >=1.
+ .TP
+-[--upper <val>]
++[--upper <val>] [-u <val>]
+ 
+ Set upper scale size (refer to paper for details).
+ Default value: 43, accepted range >=1.
+@@ -54,6 +55,13 @@
+ luminance value can change at most by 1% between two consecutive
+ frames.
+ .TP
++[--border <val>] [-b <val>]
++
++Use border mechanism with specified relative border width.
++Actual border size will be calculated as the minimal size of the image
++(width or height) multiplied on relative border width.
++Default value: 0 (don't use border mechanism), accepted range: 0 >= b < 0.5.
++.TP
+ --verbose
+ 
+ Print additional information during program execution.

Added: head/graphics/pfstmo/files/patch-src-reinhard02-pfstmo_reinhard02.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/graphics/pfstmo/files/patch-src-reinhard02-pfstmo_reinhard02.cpp	Fri Jun 20 15:46:27 2014	(r358594)
@@ -0,0 +1,142 @@
+--- src/reinhard02/pfstmo_reinhard02.cpp.orig	2008-09-04 12:46:49.000000000 +0000
++++ src/reinhard02/pfstmo_reinhard02.cpp	2014-06-18 15:29:52.318951701 +0000
+@@ -33,6 +33,7 @@
+ 
+ #include <config.h>
+ 
++#include <exception>
+ #include <iostream>
+ #include <stdio.h>
+ #include <stdlib.h>
+@@ -40,8 +41,9 @@
+ #include <math.h>
+ 
+ #include <pfs.h>
++#include <pfstmo.h>
+ 
+-#include <tmo_reinhard02.h>
++#include "tmo_reinhard02.h"
+ 
+ using namespace std;
+ 
+@@ -61,6 +63,7 @@
+     "\t[--key <val>] [--phi <val>] \n"
+     "\t[--range <val>] [--lower <val>] [--upper <val>] \n"
+     "\t[--temporal-coherent]\n"
++    "\t[--border <val>] \n"
+     "\t[--verbose] [--help] \n"
+     "See man page for more information.\n" );
+ }
+@@ -77,6 +80,7 @@
+   int high = 43;
+   bool use_scales = false;
+   bool temporal_coherent = false;  
++  float border = 0.f;
+ 
+   static struct option cmdLineOptions[] = {
+     { "help", no_argument, NULL, 'h' },
+@@ -88,12 +92,13 @@
+     { "lower", required_argument, NULL, 'l' },
+     { "upper", required_argument, NULL, 'u' },
+     { "temporal-coherent", no_argument, NULL, 't' },
++    { "border", required_argument, NULL, 'b' },
+     { NULL, 0, NULL, 0 }
+   };
+ 
+   int optionIndex = 0;
+   while( 1 ) {
+-    int c = getopt_long (argc, argv, "hvsk:p:r:l:u:t", cmdLineOptions, &optionIndex);
++    int c = getopt_long (argc, argv, "hvsk:p:r:l:u:tb:", cmdLineOptions, &optionIndex);

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-ports-all mailing list