fixed many warnings from GCC 4.6.1
[profile/ivi/opencv.git] / modules / core / src / dxt.cpp
index d7f0c89..a2074a1 100644 (file)
@@ -44,8 +44,8 @@
 namespace cv
 {
 
-// On Win64 (IA64) optimized versions of DFT and DCT fail the tests
-#if defined WIN64 && !defined EM64T
+// On Win64 optimized versions of DFT and DCT fail the tests (fixed in VS2010)
+#if defined _MSC_VER && !defined CV_ICC && defined _M_X64 && _MSC_VER < 1600
 #pragma optimize("", off)
 #endif
 
@@ -1449,27 +1449,25 @@ static void CCSIDFT_64f( const double* src, double* dst, int n, int nf, int* fac
     CCSIDFT( src, dst, n, nf, factors, itab, wave, tab_size, spec, buf, flags, scale);
 }
     
+}
+    
 
-void dft( const Mat& src0, Mat& dst, int flags, int nonzero_rows )
+void cv::dft( InputArray _src0, OutputArray _dst, int flags, int nonzero_rows )
 {
-    static DFTFunc dft_tbl[6];
-    static int inittab = 0;
-
-    if( !inittab )
+    static DFTFunc dft_tbl[6] =
     {
-        dft_tbl[0] = (DFTFunc)DFT_32f;
-        dft_tbl[1] = (DFTFunc)RealDFT_32f;
-        dft_tbl[2] = (DFTFunc)CCSIDFT_32f;
-        dft_tbl[3] = (DFTFunc)DFT_64f;
-        dft_tbl[4] = (DFTFunc)RealDFT_64f;
-        dft_tbl[5] = (DFTFunc)CCSIDFT_64f;
-        inittab = 1;
-    }
+        (DFTFunc)DFT_32f,
+        (DFTFunc)RealDFT_32f,
+        (DFTFunc)CCSIDFT_32f,
+        (DFTFunc)DFT_64f,
+        (DFTFunc)RealDFT_64f,
+        (DFTFunc)CCSIDFT_64f
+    };
 
     AutoBuffer<uchar> buf;
     void *spec = 0;
     
-    Mat src = src0;
+    Mat src0 = _src0.getMat(), src = src0;
     int prev_len = 0, stage = 0;
     bool inv = (flags & DFT_INVERSE) != 0;
     int nf = 0, real_transform = src.channels() == 1 || (inv && (flags & DFT_REAL_OUTPUT)!=0);
@@ -1477,19 +1475,21 @@ void dft( const Mat& src0, Mat& dst, int flags, int nonzero_rows )
     int elem_size = (int)src.elemSize1(), complex_elem_size = elem_size*2;
     int factors[34];
     bool inplace_transform = false;
-    int ipp_norm_flag = 0;
 #ifdef HAVE_IPP
     void *spec_r = 0, *spec_c = 0;
+    int ipp_norm_flag = !(flags & DFT_SCALE) ? 8 : inv ? 2 : 1;
 #endif
 
     CV_Assert( type == CV_32FC1 || type == CV_32FC2 || type == CV_64FC1 || type == CV_64FC2 );
 
     if( !inv && src.channels() == 1 && (flags & DFT_COMPLEX_OUTPUT) )
-        dst.create( src.size(), CV_MAKETYPE(depth, 2) );
+        _dst.create( src.size(), CV_MAKETYPE(depth, 2) );
     else if( inv && src.channels() == 2 && (flags & DFT_REAL_OUTPUT) )
-        dst.create( src.size(), depth );
+        _dst.create( src.size(), depth );
     else
-        dst.create( src.size(), type );
+        _dst.create( src.size(), type );
+    
+    Mat dst = _dst.getMat();
 
     if( !real_transform )
         elem_size = complex_elem_size;
@@ -1506,8 +1506,6 @@ void dft( const Mat& src0, Mat& dst, int flags, int nonzero_rows )
          (src.cols > 1 && inv && real_transform)) )
         stage = 1;
 
-    ipp_norm_flag = !(flags & DFT_SCALE) ? 8 : inv ? 2 : 1;
-
     for(;;)
     {
         double scale = 1;
@@ -1840,14 +1838,15 @@ void dft( const Mat& src0, Mat& dst, int flags, int nonzero_rows )
 }
 
 
-void idft( const Mat& src, Mat& dst, int flags, int nonzero_rows )
+void cv::idft( InputArray src, OutputArray dst, int flags, int nonzero_rows )
 {
     dft( src, dst, flags | DFT_INVERSE, nonzero_rows );
 }
 
-void mulSpectrums( const Mat& srcA, const Mat& srcB,
-                   Mat& dst, int flags, bool conjB )
+void cv::mulSpectrums( InputArray _srcA, InputArray _srcB,
+                       OutputArray _dst, int flags, bool conjB )
 {
+    Mat srcA = _srcA.getMat(), srcB = _srcB.getMat();
     int depth = srcA.depth(), cn = srcA.channels(), type = srcA.type();
     int rows = srcA.rows, cols = srcA.cols;
     int j, k;
@@ -1855,7 +1854,8 @@ void mulSpectrums( const Mat& srcA, const Mat& srcB,
     CV_Assert( type == srcB.type() && srcA.size() == srcB.size() );
     CV_Assert( type == CV_32FC1 || type == CV_32FC2 || type == CV_64FC1 || type == CV_64FC2 );
 
-    dst.create( srcA.rows, srcA.cols, type );
+    _dst.create( srcA.rows, srcA.cols, type );
+    Mat dst = _dst.getMat();
     
     bool is_1d = (flags & DFT_ROWS) || (rows == 1 || (cols == 1 &&
              srcA.isContinuous() && srcB.isContinuous() && dst.isContinuous()));
@@ -2008,6 +2008,9 @@ void mulSpectrums( const Mat& srcA, const Mat& srcB,
                                Discrete Cosine Transform
 \****************************************************************************************/
 
+namespace cv
+{
+
 /* DCT is calculated using DFT, as described here:
    http://www.ece.utexas.edu/~bevans/courses/ee381k/lectures/09_DCT/lecture9/:
 */
@@ -2210,26 +2213,24 @@ static void IDCT_64f(const double* src, int src_step, double* dft_src, double* d
     IDCT(src, src_step, dft_src, dft_dst, dst, dst_step,
          n, nf, factors, itab, dft_wave, dct_wave, spec, buf);
 }    
+
+}
     
-void dct( const Mat& src0, Mat& dst, int flags )
+void cv::dct( InputArray _src0, OutputArray _dst, int flags )
 {
-    static DCTFunc dct_tbl[4];
-    static int inittab = 0;
-    
-    if( !inittab )
+    static DCTFunc dct_tbl[4] =
     {
-        dct_tbl[0] = (DCTFunc)DCT_32f;
-        dct_tbl[1] = (DCTFunc)IDCT_32f;
-        dct_tbl[2] = (DCTFunc)DCT_64f;
-        dct_tbl[3] = (DCTFunc)IDCT_64f;
-        inittab = 1;
-    }
+        (DCTFunc)DCT_32f,
+        (DCTFunc)IDCT_32f,
+        (DCTFunc)DCT_64f,
+        (DCTFunc)IDCT_64f
+    };
 
     bool inv = (flags & DCT_INVERSE) != 0;
-    Mat src = src0;
+    Mat src0 = _src0.getMat(), src = src0;
     int type = src.type(), depth = src.depth();
     void /* *spec_dft = 0, */ *spec = 0;
-    
+
     double scale = 1.;
     int prev_len = 0, nf = 0, stage, end_stage;
     uchar *src_dft_buf = 0, *dst_dft_buf = 0;
@@ -2242,7 +2243,8 @@ void dct( const Mat& src0, Mat& dst, int flags )
     AutoBuffer<uchar> buf;
 
     CV_Assert( type == CV_32FC1 || type == CV_64FC1 );
-    dst.create( src.rows, src.cols, type );
+    _dst.create( src.rows, src.cols, type );
+    Mat dst = _dst.getMat();
 
     DCTFunc dct_func = dct_tbl[inv + (depth == CV_64F)*2];
 
@@ -2369,11 +2371,14 @@ void dct( const Mat& src0, Mat& dst, int flags )
 }
 
 
-void idct( const Mat& src, Mat& dst, int flags )
+void cv::idct( InputArray src, OutputArray dst, int flags )
 {
     dct( src, dst, flags | DCT_INVERSE );
 }
 
+namespace cv
+{
+
 static const int optimalDFTSizeTab[] = {
 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 25, 27, 30, 32, 36, 40, 45, 48, 
 50, 54, 60, 64, 72, 75, 80, 81, 90, 96, 100, 108, 120, 125, 128, 135, 144, 150, 160, 
@@ -2555,8 +2560,9 @@ static const int optimalDFTSizeTab[] = {
 2097152000, 2099520000, 2109375000, 2123366400, 2125764000
 };
 
-int
-getOptimalDFTSize( int size0 )
+}
+    
+int cv::getOptimalDFTSize( int size0 )
 {
     int a = 0, b = sizeof(optimalDFTSizeTab)/sizeof(optimalDFTSizeTab[0]) - 1;
     if( (unsigned)size0 >= (unsigned)optimalDFTSizeTab[b] )
@@ -2574,8 +2580,6 @@ getOptimalDFTSize( int size0 )
     return optimalDFTSizeTab[b];
 }
 
-}
-
 CV_IMPL void
 cvDFT( const CvArr* srcarr, CvArr* dstarr, int flags, int nonzero_rows )
 {
@@ -2584,7 +2588,7 @@ cvDFT( const CvArr* srcarr, CvArr* dstarr, int flags, int nonzero_rows )
         ((flags & CV_DXT_SCALE) ? cv::DFT_SCALE : 0) |
         ((flags & CV_DXT_ROWS) ? cv::DFT_ROWS : 0);
 
-    CV_Assert( src.size() == dst.size() );
+    CV_Assert( src.size == dst.size );
 
     if( src.type() != dst.type() )
     {
@@ -2606,7 +2610,7 @@ cvMulSpectrums( const CvArr* srcAarr, const CvArr* srcBarr,
     cv::Mat srcA = cv::cvarrToMat(srcAarr),
         srcB = cv::cvarrToMat(srcBarr),
         dst = cv::cvarrToMat(dstarr);
-    CV_Assert( srcA.size() == dst.size() && srcA.type() == dst.type() );
+    CV_Assert( srcA.size == dst.size && srcA.type() == dst.type() );
 
     cv::mulSpectrums(srcA, srcB, dst,
         (flags & CV_DXT_ROWS) ? cv::DFT_ROWS : 0,
@@ -2618,7 +2622,7 @@ CV_IMPL void
 cvDCT( const CvArr* srcarr, CvArr* dstarr, int flags )
 {
     cv::Mat src = cv::cvarrToMat(srcarr), dst = cv::cvarrToMat(dstarr);
-    CV_Assert( src.size() == dst.size() && src.type() == dst.type() );
+    CV_Assert( src.size == dst.size && src.type() == dst.type() );
     int _flags = ((flags & CV_DXT_INVERSE) ? cv::DCT_INVERSE : 0) |
             ((flags & CV_DXT_ROWS) ? cv::DCT_ROWS : 0);
     cv::dct( src, dst, _flags );