1 /*
2  * * Copyright (C) 2006-2011 Anders Brander <anders@brander.dk>,
3  * * Anders Kvist <akv@lnxbx.dk> and Klaus Post <klauspost@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
19 
20 #ifndef floatplanarimage_h__
21 #define floatplanarimage_h__
22 #include "floatimageplane.h"
23 #include "jobqueue.h"
24 #include "fftwindow.h"
25 
26 namespace RawStudio {
27 namespace FFTFilter {
28 
29 // A container and utility class
30 
31 #define WB_R_CORR 2.4150f
32 #define WB_B_CORR 1.4140f
33 
34 
35 class FloatPlanarImage
36 {
37 public:
38   FloatPlanarImage(void);
39   FloatPlanarImage( const FloatPlanarImage &img );  // Creates image with similar features
40 
41   virtual ~FloatPlanarImage(void);
42   void allocate_planes();
43   void mirrorEdges();
44   FloatImagePlane **p;
45   int nPlanes;
46   void unpackInterleaved(const RS_IMAGE16* image);
47   void packInterleaved( RS_IMAGE16* image );
48   void setFilter( int plane, ComplexFilter *f, FFTWindow *window);
49   JobQueue* getJobs(FloatPlanarImage &outImg);
50   void unpackInterleavedYUV( const ImgConvertJob* j );
51 #if defined (__i386__) || defined (__x86_64__)
52   void packInterleavedYUV_SSE2( const ImgConvertJob* j);
53 #endif
54 #if defined (__x86_64__)
55   void unpackInterleavedYUV_SSE2( const ImgConvertJob* j );
56 //  void packInterleavedYUV_SSE4( const ImgConvertJob* j);
57 #endif
58   void packInterleavedYUV( const ImgConvertJob* j);
59   JobQueue* getUnpackInterleavedYUVJobs(RS_IMAGE16* image);
60   JobQueue* getPackInterleavedYUVJobs(RS_IMAGE16* image);
61   FloatImagePlane* getPlaneSliceFrom(int plane, int x, int y);
62 
63   int bw;  // Block width
64   int bh;  // Block height
65   int ox;  // Overlap pixels
66   int oy;  // Overlap pixels
67 
68   float redCorrection;
69   float blueCorrection;
70 
71   static void initConvTable();
72   static float shortToFloat[65536*4];
73 };
74 
75 }} // namespace RawStudio::FFTFilter
76 
77 #endif // floatplanarimage_h__
78 
clampbits(gint x,guint n)79 inline guint clampbits(gint x, guint n) { guint32 _y_temp; if( (_y_temp=x>>n) ) x = ~_y_temp >> (32-n); return x;}
80