Removed Windows-style line breaks (^M) from all .cc and .h source files.

This commit is contained in:
Wyatt Olson
2010-05-01 16:26:14 -06:00
parent e1a028e535
commit 1b563a4b82
284 changed files with 39262 additions and 39262 deletions

View File

@@ -1,48 +1,48 @@
/*
* This file is part of RawTherapee.
*
* Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
*
* RawTherapee is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RawTherapee is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* This file is part of RawTherapee.
*
* Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
*
* RawTherapee is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RawTherapee is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _BILATERAL2_
#define _BILATERAL2_
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <alignedbuffer.h>
#include <mytime.h>
#include <gauss.h>
#include <glibmm.h>
#define ELEM(a,b) (src[i - a][j - b] * ec[src[i - a][j - b]-src[i][j]+0x10000])
#define ELEM(a,b) (src[i - a][j - b] * ec[src[i - a][j - b]-src[i][j]+0x10000])
#define SULY(a,b) (ec[src[i - a][j - b]-src[i][j]+0x10000])
#define BL_BEGIN(a,b) double scale = (a); \
int* ec = new int [0x20000]; \
for (int i=0; i<0x20000; i++) \
ec[i] = (int)(exp(-(double)(i-0x10000)*(double)(i-0x10000) / (2.0*sens*sens))*scale); \
int* ec = new int [0x20000]; \
for (int i=0; i<0x20000; i++) \
ec[i] = (int)(exp(-(double)(i-0x10000)*(double)(i-0x10000) / (2.0*sens*sens))*scale); \
int start = row_from; \
if (start<(b)) start = (b); \
int end = row_to; \
if (end>H-(b)) end = H-(b); \
for (int i=start; i<end; i++) { \
for (int i=start; i<end; i++) { \
for (int j=(b); j<W-(b); j++) {
#define BL_END(b) buffer[i][j] = v; }} delete [] ec; \
for (int i=row_from; i<row_to; i++) \
for (int i=row_from; i<row_to; i++) \
for (int j=0; j<W; j++) \
if (i<start || j<(b) || i>=end || j>=W-(b)) \
dst[i][j] = src[i][j]; \
@@ -55,18 +55,18 @@
v /= a11*SULY(-1,-1) + a12*SULY(-1,0) + a11*SULY(-1,1) + \
a21*SULY(0,-1) + a22*SULY(0,0) + a21*SULY(0,1) + \
a11*SULY(1,-1) + a12*SULY(1,0) + a11*SULY(1,1);
#define BL_OPER5(a11,a12,a13,a21,a22,a23,a31,a32,a33) A v = a11*ELEM(-2,-2) + a12*ELEM(-2,-1) + a13*ELEM(-2,0) + a12*ELEM(-2,1) + a11*ELEM(-2,2) + \
#define BL_OPER5(a11,a12,a13,a21,a22,a23,a31,a32,a33) A v = a11*ELEM(-2,-2) + a12*ELEM(-2,-1) + a13*ELEM(-2,0) + a12*ELEM(-2,1) + a11*ELEM(-2,2) + \
a21*ELEM(-1,-2) + a22*ELEM(-1,-1) + a23*ELEM(-1,0) + a22*ELEM(-1,1) + a21*ELEM(-1,2) + \
a31*ELEM(0,-2) + a32*ELEM(0,-1) + a33*ELEM(0,0) + a32*ELEM(0,1) + a31*ELEM(0,2) + \
a21*ELEM(1,-2) + a22*ELEM(1,-1) + a23*ELEM(1,0) + a22*ELEM(1,1) + a21*ELEM(1,2) + \
a11*ELEM(2,-2) + a12*ELEM(2,-1) + a13*ELEM(2,0) + a12*ELEM(2,1) + a11*ELEM(2,2); \
v /= a11*SULY(-2,-2) + a12*SULY(-2,-1) + a13*SULY(-2,0) + a12*SULY(-2,1) + a11*SULY(-2,2) + \
v /= a11*SULY(-2,-2) + a12*SULY(-2,-1) + a13*SULY(-2,0) + a12*SULY(-2,1) + a11*SULY(-2,2) + \
a21*SULY(-1,-2) + a22*SULY(-1,-1) + a23*SULY(-1,0) + a22*SULY(-1,1) + a21*SULY(-1,2) + \
a31*SULY(0,-2) + a32*SULY(0,-1) + a33*SULY(0,0) + a32*SULY(0,1) + a31*SULY(0,2) + \
a21*SULY(1,-2) + a22*SULY(1,-1) + a23*SULY(1,0) + a22*SULY(1,1) + a21*SULY(1,2) + \
a11*SULY(2,-2) + a12*SULY(2,-1) + a13*SULY(2,0) + a12*SULY(2,1) + a11*SULY(2,2);
a11*SULY(2,-2) + a12*SULY(2,-1) + a13*SULY(2,0) + a12*SULY(2,1) + a11*SULY(2,2);
#define BL_OPER7(a11,a12,a13,a14,a21,a22,a23,a24,a31,a32,a33,a34,a41,a42,a43,a44) \
A v = a11*ELEM(-3,-3) + a12*ELEM(-3,-2) + a13*ELEM(-3,-1) + a14*ELEM(-3,0) + a13*ELEM(-3,1) + a12*ELEM(-3,2) + a11*ELEM(-3,3) + \
@@ -83,7 +83,7 @@
a31*SULY(1,-3) + a32*SULY(1,-2) + a33*SULY(1,-1) + a34*SULY(1,0) + a33*SULY(1,1) + a32*SULY(1,2) + a31*SULY(1,3) + \
a21*SULY(2,-3) + a22*SULY(2,-2) + a23*SULY(2,-1) + a24*SULY(2,0) + a23*SULY(2,1) + a22*SULY(2,2) + a21*SULY(2,3) + \
a11*SULY(3,-3) + a12*SULY(3,-2) + a13*SULY(3,-1) + a14*SULY(3,0) + a13*SULY(3,1) + a12*SULY(3,2) + a11*SULY(3,3);
#define BL_OPER9(a11,a12,a13,a14,a15,a21,a22,a23,a24,a25,a31,a32,a33,a34,a35,a41,a42,a43,a44,a45,a51,a52,a53,a54,a55) \
A v = a11*ELEM(-4,-4) + a12*ELEM(-4,-3) + a13*ELEM(-4,-2) + a14*ELEM(-4,-1) + a15*ELEM(-4,0) + a14*ELEM(-4,1) + a13*ELEM(-4,2) + a12*ELEM(-4,3) + a11*ELEM(-4,4) + \
@@ -192,7 +192,7 @@ template<class T, class A> void bilateral12 (T** src, T** dst, T** buffer, int W
BL_BEGIN(322,3)
BL_OPER7(0,0,1,1,0,1,4,6,1,4,11,16,1,6,16,23)
BL_END(3)
}
}
// sigma = 1.3
template<class T, class A> void bilateral13 (T** src, T** dst, T** buffer, int W, int H, int row_from, int row_to, double sens) {
@@ -217,7 +217,7 @@ template<class T, class A> void bilateral15 (T** src, T** dst, T** buffer, int W
BL_OPER9(0,0,0,1,1,0,1,2,4,5,0,2,6,12,14,1,4,12,22,28,1,5,14,28,35)
BL_END(4)
}
// sigma = 1.6
template<class T, class A> void bilateral16 (T** src, T** dst, T** buffer, int W, int H, int row_from, int row_to, double sens) {
@@ -233,7 +233,7 @@ template<class T, class A> void bilateral17 (T** src, T** dst, T** buffer, int W
BL_OPER9(0,0,1,1,1,0,1,2,3,4,1,2,5,8,9,1,3,8,13,16,1,4,9,16,19)
BL_END(4)
}
// sigma = 1.8
template<class T, class A> void bilateral18 (T** src, T** dst, T** buffer, int W, int H, int row_from, int row_to, double sens) {
@@ -250,53 +250,53 @@ template<class T, class A> void bilateral19 (T** src, T** dst, T** buffer, int W
BL_END(4)
}
// sigma = 2
template<class T, class A> void bilateral20 (T** src, T** dst, T** buffer, int W, int H, int row_from, int row_to, double sens) {
// sigma = 2
template<class T, class A> void bilateral20 (T** src, T** dst, T** buffer, int W, int H, int row_from, int row_to, double sens) {
BL_BEGIN(116,5)
BL_OPER11(0,0,0,1,1,1,0,0,1,2,3,3,0,1,2,4,7,7,1,2,4,8,12,14,1,3,7,12,18,20,1,3,7,14,20,23)
BL_END(5)
}
// sigma = 2.1
template<class T, class A> void bilateral21 (T** src, T** dst, T** buffer, int W, int H, int row_from, int row_to, double sens) {
}
// sigma = 2.1
template<class T, class A> void bilateral21 (T** src, T** dst, T** buffer, int W, int H, int row_from, int row_to, double sens) {
BL_BEGIN(127,5)
BL_OPER11(0,0,0,1,1,1,0,0,1,2,3,3,0,1,2,4,6,7,1,2,4,8,11,12,1,3,6,11,15,17,1,3,7,12,17,19)
BL_END(5)
}
}
// sigma = 2.2
template<class T, class A> void bilateral22 (T** src, T** dst, T** buffer, int W, int H, int row_from, int row_to, double sens) {
// sigma = 2.2
template<class T, class A> void bilateral22 (T** src, T** dst, T** buffer, int W, int H, int row_from, int row_to, double sens) {
BL_BEGIN(109,5)
BL_OPER11(0,0,0,1,1,2,0,1,2,3,3,4,1,2,3,5,7,8,1,3,5,9,12,13,1,3,7,12,16,18,2,4,8,13,18,20)
BL_END(5)
}
// sigma = 2.3
template<class T, class A> void bilateral23 (T** src, T** dst, T** buffer, int W, int H, int row_from, int row_to, double sens) {
// sigma = 2.3
template<class T, class A> void bilateral23 (T** src, T** dst, T** buffer, int W, int H, int row_from, int row_to, double sens) {
BL_BEGIN(132,5)
BL_OPER11(0,0,1,1,1,1,0,1,1,2,3,3,1,1,3,5,6,7,1,2,5,7,10,11,1,3,6,10,13,14,1,3,7,11,14,16)
BL_END(5)
}
// sigma = 2.4
template<class T, class A> void bilateral24 (T** src, T** dst, T** buffer, int W, int H, int row_from, int row_to, double sens) {
// sigma = 2.4
template<class T, class A> void bilateral24 (T** src, T** dst, T** buffer, int W, int H, int row_from, int row_to, double sens) {
BL_BEGIN(156,5)
BL_OPER11(0,0,1,1,1,1,0,1,1,2,3,3,1,1,3,4,5,6,1,2,4,6,8,9,1,3,5,8,10,11,1,3,6,9,11,12)
BL_END(5)
}
// sigma = 2.5
template<class T, class A> void bilateral25 (T** src, T** dst, T** buffer, int W, int H, int row_from, int row_to, double sens) {
// sigma = 2.5
template<class T, class A> void bilateral25 (T** src, T** dst, T** buffer, int W, int H, int row_from, int row_to, double sens) {
BL_BEGIN(173,5)
BL_OPER11(0,0,1,1,1,1,0,1,1,2,3,3,1,1,2,4,5,5,1,2,4,5,7,7,1,3,5,7,9,9,1,3,5,7,9,10)
BL_END(5)
}
}
class Dim {
@@ -368,59 +368,59 @@ void bilateral_unsigned (unsigned short** src, unsigned short** dst, unsigned sh
void bilateral_signed (short** src, short** dst, short** buffer, Dim dim, double sigma, double sens);
/*
template<class T> void bilateral (T** src, int** dst, int W, int H, int sigmar, double sigmas) {
time_t t1 = clock ();
int r = 2.0*sigmas + 0.5;
double scaleg = 1024.0;
double MAXINT = 65536.0*65536.0;
double sgmax = 275000/(MAXINT/2.0/sigmar/sigmar+(r+1)*(r+1)/sigmas/sigmas);
printf ("sgmax = %lf\n", sgmax);
if (scaleg>sgmax)
scaleg = sgmax;
// kernel vector for the spatial gaussian filter * 1024
int* kernel = new int[1+2*r];
for (int i=0; i<2*r+1; i++) {
kernel[i] = scaleg / (2.0*sigmas*sigmas) * (i-r)*(i-r) + 0.25;
printf ("kerneli = %d\n", kernel[i]);
}
// exponential lookup table
int scale = (2.0*sigmar*sigmar) / scaleg;
int scalem = 65535/((1+2*r)*(1+2*r));
int ec[256000];
for (int i=0; i<256000; i++)
ec[i] = exp (-i/scaleg) * scalem;
for (int i=r; i<H-r; i++) {
for (int j=r; j<W-r; j++) {
int sum = 0.0;
int val = 0.0;
int c = src[i][j];
for (int x=-r; x<=r; x++)
for (int y=-r; y<=r; y++) {
unsigned int d = src[i-x][j-y];
unsigned int mul = ec[(c-d)*(c-d)/scale + kernel[x+r] + kernel[y+r]];
// if (mul<275000) {
val += d*mul;
sum += mul;
// }
// else {
// printf ("out!!!\n");
// }
}
dst[i][j] = val / sum;
}
}
delete [] kernel;
time_t t2 = clock ();
printf ("bilateral: %d\n", t2-t1);
}
template<class T> void bilateral (T** src, int** dst, int W, int H, int sigmar, double sigmas) {
time_t t1 = clock ();
int r = 2.0*sigmas + 0.5;
double scaleg = 1024.0;
double MAXINT = 65536.0*65536.0;
double sgmax = 275000/(MAXINT/2.0/sigmar/sigmar+(r+1)*(r+1)/sigmas/sigmas);
printf ("sgmax = %lf\n", sgmax);
if (scaleg>sgmax)
scaleg = sgmax;
// kernel vector for the spatial gaussian filter * 1024
int* kernel = new int[1+2*r];
for (int i=0; i<2*r+1; i++) {
kernel[i] = scaleg / (2.0*sigmas*sigmas) * (i-r)*(i-r) + 0.25;
printf ("kerneli = %d\n", kernel[i]);
}
// exponential lookup table
int scale = (2.0*sigmar*sigmar) / scaleg;
int scalem = 65535/((1+2*r)*(1+2*r));
int ec[256000];
for (int i=0; i<256000; i++)
ec[i] = exp (-i/scaleg) * scalem;
for (int i=r; i<H-r; i++) {
for (int j=r; j<W-r; j++) {
int sum = 0.0;
int val = 0.0;
int c = src[i][j];
for (int x=-r; x<=r; x++)
for (int y=-r; y<=r; y++) {
unsigned int d = src[i-x][j-y];
unsigned int mul = ec[(c-d)*(c-d)/scale + kernel[x+r] + kernel[y+r]];
// if (mul<275000) {
val += d*mul;
sum += mul;
// }
// else {
// printf ("out!!!\n");
// }
}
dst[i][j] = val / sum;
}
}
delete [] kernel;
time_t t2 = clock ();
printf ("bilateral: %d\n", t2-t1);
}
*/
#define MAXVAL 0xffff