Exemplo n.º 1
0
void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
{
	DOUBLE	*sig,*wcp,*tmp;
	mxArray *temp;
	unsigned int	m,n;
	int nr,nc,nn,J;

	/* Check for proper number of arguments */

	if (nrhs != 1) {
		mexErrMsgTxt("DCTIV requires one input arguments.");
	} else if (nlhs != 1) {
		mexErrMsgTxt("DCTIV requires one output argument.");
	}


	/* Check the dimensions of signal.  signal can be n X 1 or 1 X n. */
    /* future enhancement -- vectorize, do each column of matrix */
	m  = mxGetM(Sig_IN);
	n = mxGetN(Sig_IN);
    if(m == 1){
      nr = (int) n;
      nc = 1;
    } else {
      nr = (int) m;
	  nc = (int) n;
    }
    J = 0;
    for( nn = 1; nn < nr;  nn *= 2 )  
         J ++;
    if(  nn  !=  nr){
		mexErrMsgTxt("DCTIV requires dyadic length");
	}

	/* Create a matrix for the return argument */

	FT_OUT = mxCreateDoubleMatrix(m, n, mxREAL);
	temp   = mxCreateDoubleMatrix(8*nr,1,mxREAL);

	/* Assign pointers to the various parameters */

	wcp = mxGetPr(FT_OUT);
	sig = mxGetPr(Sig_IN);
	tmp = mxGetPr(temp);
	/* Do the actual computations in a subroutine */
	dctiv(sig,wcp,tmp,nr);
	mxDestroyArray(temp);
}
Exemplo n.º 2
0
void dctiv_2(float **x, int n1, int n2, float **c1, float **c2)
/*****************************************************************************
 in place IV-type 2D-DCT
******************************************************************************
x        array[][] of the signal before and after transform
n1       length of the signal along the 1st dimension
n2       length of the signal along the 2nd dimension
c1       table for the 1st dimension
c2       table for the 2nd dimension
******************************************************************************
Author:		Tong Chen, 03/16/95
Modifier:       Tong Chen, 06/01/95, use pre-generated table
*****************************************************************************/
{
   int i;
   
   /* first along the faster dimension */
   for(i=0; i<n2; i++)
      dctiv(x[i], n1, c1);

   /* then along the slower dimension */
   dctiv_row(x, n1, n2, c2);
}