www.pudn.com > vcmatlab20060426WaterMark.zip > idct2.cpp


// 
// MATLAB Compiler: 2.2 
// Date: Mon May 16 13:27:20 2005 
// Arguments: "-B" "macro_default" "-O" "all" "-O" "fold_scalar_mxarrays:on" 
// "-O" "fold_non_scalar_mxarrays:on" "-O" "optimize_integer_for_loops:on" "-O" 
// "array_indexing:on" "-O" "optimize_conditionals:on" "-B" "sglcpp" "-p" "-W" 
// "main" "-L" "Cpp" "-t" "-T" "link:exe" "-h" "libmmfile.mlib" "-W" "mainhg" 
// "libmwsglm.mlib" "-l" "-p" "-W" "main" "-L" "Cpp" "-t" "-T" "link:exe" "-h" 
// "libmmfile.mlib" "-h" "C_idct2"  
// 
#include "idct2.hpp" 
#include "images_private_idct.hpp" 
#include "libmatlbm.hpp" 
 
static mxChar _array1_[128] = { 'R', 'u', 'n', '-', 't', 'i', 'm', 'e', ' ', 
                                'E', 'r', 'r', 'o', 'r', ':', ' ', 'F', 'i', 
                                'l', 'e', ':', ' ', 'i', 'd', 'c', 't', '2', 
                                ' ', 'L', 'i', 'n', 'e', ':', ' ', '1', ' ', 
                                'C', 'o', 'l', 'u', 'm', 'n', ':', ' ', '1', 
                                ' ', 'T', 'h', 'e', ' ', 'f', 'u', 'n', 'c', 
                                't', 'i', 'o', 'n', ' ', '"', 'i', 'd', 'c', 
                                't', '2', '"', ' ', 'w', 'a', 's', ' ', 'c', 
                                'a', 'l', 'l', 'e', 'd', ' ', 'w', 'i', 't', 
                                'h', ' ', 'm', 'o', 'r', 'e', ' ', 't', 'h', 
                                'a', 'n', ' ', 't', 'h', 'e', ' ', 'd', 'e', 
                                'c', 'l', 'a', 'r', 'e', 'd', ' ', 'n', 'u', 
                                'm', 'b', 'e', 'r', ' ', 'o', 'f', ' ', 'o', 
                                'u', 't', 'p', 'u', 't', 's', ' ', '(', '1', 
                                ')', '.' }; 
static mwArray _mxarray0_ = mclInitializeString(128, _array1_); 
 
static mxChar _array3_[127] = { 'R', 'u', 'n', '-', 't', 'i', 'm', 'e', ' ', 
                                'E', 'r', 'r', 'o', 'r', ':', ' ', 'F', 'i', 
                                'l', 'e', ':', ' ', 'i', 'd', 'c', 't', '2', 
                                ' ', 'L', 'i', 'n', 'e', ':', ' ', '1', ' ', 
                                'C', 'o', 'l', 'u', 'm', 'n', ':', ' ', '1', 
                                ' ', 'T', 'h', 'e', ' ', 'f', 'u', 'n', 'c', 
                                't', 'i', 'o', 'n', ' ', '"', 'i', 'd', 'c', 
                                't', '2', '"', ' ', 'w', 'a', 's', ' ', 'c', 
                                'a', 'l', 'l', 'e', 'd', ' ', 'w', 'i', 't', 
                                'h', ' ', 'm', 'o', 'r', 'e', ' ', 't', 'h', 
                                'a', 'n', ' ', 't', 'h', 'e', ' ', 'd', 'e', 
                                'c', 'l', 'a', 'r', 'e', 'd', ' ', 'n', 'u', 
                                'm', 'b', 'e', 'r', ' ', 'o', 'f', ' ', 'i', 
                                'n', 'p', 'u', 't', 's', ' ', '(', '3', ')', 
                                '.' }; 
static mwArray _mxarray2_ = mclInitializeString(127, _array3_); 
static mwArray _mxarray4_ = mclInitializeDouble(1.0); 
static mwArray _mxarray5_ = mclInitializeDouble(0.0); 
static mwArray _mxarray6_ = mclInitializeDouble(2.0); 
 
void InitializeModule_idct2() { 
} 
 
void TerminateModule_idct2() { 
} 
 
static mwArray Midct2(int nargout_, mwArray arg1, mwArray mrows, mwArray ncols); 
 
_mexLocalFunctionTable _local_function_table_idct2 
  = { 0, (mexFunctionTableEntry *)NULL }; 
 
// 
// The function "idct2" contains the normal interface for the "idct2" 
// M-function from file "D:\matlab\matlab\toolbox\images\images\idct2.m" (lines 
// 1-56). This function processes any input arguments and passes them to the 
// implementation version of the function, appearing above. 
// 
mwArray idct2(mwArray arg1, mwArray mrows, mwArray ncols) { 
    int nargout(1); 
    mwArray a(mclGetUninitializedArray()); 
    a = Midct2(nargout, arg1, mrows, ncols); 
    return a; 
} 
 
// 
// The function "mlxIdct2" contains the feval interface for the "idct2" 
// M-function from file "D:\matlab\matlab\toolbox\images\images\idct2.m" (lines 
// 1-56). The feval function calls the implementation version of idct2 through 
// this function. This function processes any input arguments and passes them 
// to the implementation version of the function, appearing above. 
// 
void mlxIdct2(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) { 
    MW_BEGIN_MLX(); 
    { 
        mwArray mprhs[3]; 
        mwArray mplhs[1]; 
        int i; 
        mclCppUninitializeArrays(1, mplhs); 
        if (nlhs > 1) { 
            error(_mxarray0_); 
        } 
        if (nrhs > 3) { 
            error(_mxarray2_); 
        } 
        for (i = 0; i < 3 && i < nrhs; ++i) { 
            mprhs[i] = mwArray(prhs[i], 0); 
        } 
        for (; i < 3; ++i) { 
            mprhs[i].MakeDIN(); 
        } 
        mplhs[0] = Midct2(nlhs, mprhs[0], mprhs[1], mprhs[2]); 
        plhs[0] = mplhs[0].FreezeData(); 
    } 
    MW_END_MLX(); 
} 
 
// 
// The function "Midct2" is the implementation version of the "idct2" 
// M-function from file "D:\matlab\matlab\toolbox\images\images\idct2.m" (lines 
// 1-56). It contains the actual compiled code for that M-function. It is a 
// static function and must only be called from one of the interface functions, 
// appearing below. 
// 
// 
// function a = idct2(arg1,mrows,ncols) 
// 
static mwArray Midct2(int nargout_, 
                      mwArray arg1, 
                      mwArray mrows, 
                      mwArray ncols) { 
    mclMlineEnterFunction( 
      "D:\\matlab\\matlab\\toolbox\\images\\images\\idct2.m", "idct2") 
    mwLocalFunctionTable save_local_function_table_ 
      (&_local_function_table_idct2); 
    int nargin_(nargin(3, mwVarargin(arg1, mrows, ncols))); 
    mwArray a(mclGetUninitializedArray()); 
    mwArray npad(mclGetUninitializedArray()); 
    mwArray mpad(mclGetUninitializedArray()); 
    mwArray b(mclGetUninitializedArray()); 
    mwArray n(mclGetUninitializedArray()); 
    mwArray m(mclGetUninitializedArray()); 
    // 
    // %IDCT2 Compute 2-D inverse discrete cosine transform. 
    // %   B = IDCT2(A) returns the two-dimensional inverse discrete 
    // %   cosine transform of A. 
    // % 
    // %   B = IDCT2(A,[M N]) or B = IDCT2(A,M,N) pads A with zeros (or 
    // %   truncates A) to create a matrix of size M-by-N before 
    // %   transforming.  
    // % 
    // %   For any A, IDCT2(DCT2(A)) equals A to within roundoff error. 
    // % 
    // %   The discrete cosine transform is often used for image 
    // %   compression applications. 
    // % 
    // %   Class Support 
    // %   ------------- 
    // %   The input matrix A can be of class double or of any 
    // %   numeric class. The output matrix B is of class double. 
    // % 
    // %   See also DCT2, DCTMTX, FFT2, IFFT2. 
    //  
    // %   Copyright 1993-2001 The MathWorks, Inc.   
    // %   $Revision: 5.15 $  $Date: 2001/01/18 15:29:15 $ 
    //  
    // %   References:  
    // %   1) A. K. Jain, "Fundamentals of Digital Image 
    // %      Processing", pp. 150-153. 
    // %   2) Wallace, "The JPEG Still Picture Compression Standard", 
    // %      Communications of the ACM, April 1991. 
    //  
    // [m, n] = size(arg1); 
    // 
    mclMline(31); 
    size(mwVarargout(m, n), mwVa(arg1, "arg1")); 
    // 
    // % Basic algorithm. 
    // if (nargin == 1), 
    // 
    mclMline(33); 
    if (nargin_ == 1) { 
        // 
        // if (m > 1) & (n > 1), 
        // 
        mclMline(34); 
        mwArray a_(mwVv(m, "m") > _mxarray4_); 
        if (tobool(a_) && tobool(a_ & mwVv(n, "n") > _mxarray4_)) { 
            // 
            // a = idct(idct(arg1).').'; 
            // 
            mclMline(35); 
            a 
              = transpose( 
                  mwVe( 
                    images_private_idct( 
                      transpose( 
                        mwVe(images_private_idct(mwVa(arg1, "arg1"))))))); 
            // 
            // return; 
            // 
            mclMline(36); 
            goto return_; 
        // 
        // else 
        // 
        } else { 
            // 
            // mrows = m; 
            // 
            mclMline(38); 
            mrows = mwVsv(m, "m"); 
            // 
            // ncols = n; 
            // 
            mclMline(39); 
            ncols = mwVsv(n, "n"); 
        } 
    // 
    // end 
    // end 
    // 
    mclMline(41); 
    } 
    // 
    //  
    // % Padding for vector input. 
    //  
    // b = arg1; 
    // 
    mclMline(45); 
    b = mwVsa(arg1, "arg1"); 
    // 
    // if nargin==2, ncols = mrows(2); mrows = mrows(1); end 
    // 
    mclMline(46); 
    if (nargin_ == 2) { 
        ncols = mclIntArrayRef(mwVsa(mrows, "mrows"), 2); 
        mrows = mclIntArrayRef(mwVsa(mrows, "mrows"), 1); 
    } 
    // 
    // mpad = mrows; npad = ncols; 
    // 
    mclMline(47); 
    mpad = mwVsa(mrows, "mrows"); 
    npad = mwVsa(ncols, "ncols"); 
    // 
    // if m == 1 & mpad > m, b(2, 1) = 0; m = 2; end 
    // 
    mclMline(48); 
    { 
        mwArray a_(mwVv(m, "m") == _mxarray4_); 
        if (tobool(a_) && tobool(a_ & mwVv(mpad, "mpad") > mwVv(m, "m"))) { 
            mclIntArrayAssign(&b, _mxarray5_, 2, 1); 
            m = _mxarray6_; 
        } else { 
        } 
    } 
    // 
    // if n == 1 & npad > n, b(1, 2) = 0; n = 2; end 
    // 
    mclMline(49); 
    { 
        mwArray a_(mwVv(n, "n") == _mxarray4_); 
        if (tobool(a_) && tobool(a_ & mwVv(npad, "npad") > mwVv(n, "n"))) { 
            mclIntArrayAssign(&b, _mxarray5_, 1, 2); 
            n = _mxarray6_; 
        } else { 
        } 
    } 
    // 
    // if m == 1, mpad = npad; npad = 1; end   % For row vector. 
    // 
    mclMline(50); 
    if (mclEqBool(mwVv(m, "m"), _mxarray4_)) { 
        mpad = mwVsv(npad, "npad"); 
        npad = _mxarray4_; 
    } 
    // 
    //  
    // % Transform. 
    //  
    // a = idct(b, mpad); 
    // 
    mclMline(54); 
    a = images_private_idct(mwVv(b, "b"), mwVv(mpad, "mpad")); 
    // 
    // if m > 1 & n > 1, a = idct(a.', npad).'; end 
    // 
    mclMline(55); 
    { 
        mwArray a_(mwVv(m, "m") > _mxarray4_); 
        if (tobool(a_) && tobool(a_ & mwVv(n, "n") > _mxarray4_)) { 
            a 
              = transpose( 
                  mwVe( 
                    images_private_idct( 
                      transpose(mwVv(a, "a")), mwVv(npad, "npad")))); 
        } else { 
        } 
    } 
    return_: 
    mwValidateOutput(a, 1, nargout_, "a", "idct2"); 
    mclMlineFunctionReturn() 
    return a; 
    mclMlineExitFunctionReturn(); 
}