diff options
Diffstat (limited to '2.3-1/src/c/signalProcessing')
-rw-r--r-- | 2.3-1/src/c/signalProcessing/includes/dct.h | 36 | ||||
-rw-r--r-- | 2.3-1/src/c/signalProcessing/includes/idct.h | 36 | ||||
-rw-r--r-- | 2.3-1/src/c/signalProcessing/includes/modk.h | 28 | ||||
-rw-r--r-- | 2.3-1/src/c/signalProcessing/interfaces/int_dct.h | 32 | ||||
-rw-r--r-- | 2.3-1/src/c/signalProcessing/interfaces/int_idct.h | 26 | ||||
-rw-r--r-- | 2.3-1/src/c/signalProcessing/interfaces/int_modk.h | 18 | ||||
-rw-r--r-- | 2.3-1/src/c/signalProcessing/modk/dmodka.c | 97 | ||||
-rw-r--r-- | 2.3-1/src/c/signalProcessing/transforms/dct/cdcta.c | 177 | ||||
-rw-r--r-- | 2.3-1/src/c/signalProcessing/transforms/dct/ddcta.c | 160 | ||||
-rw-r--r-- | 2.3-1/src/c/signalProcessing/transforms/dct/zdcta.c | 177 | ||||
-rw-r--r-- | 2.3-1/src/c/signalProcessing/transforms/idct/cidcta.c | 97 | ||||
-rw-r--r-- | 2.3-1/src/c/signalProcessing/transforms/idct/didcta.c | 83 | ||||
-rw-r--r-- | 2.3-1/src/c/signalProcessing/transforms/idct/zidcta.c | 97 |
13 files changed, 1064 insertions, 0 deletions
diff --git a/2.3-1/src/c/signalProcessing/includes/dct.h b/2.3-1/src/c/signalProcessing/includes/dct.h new file mode 100644 index 00000000..5255241e --- /dev/null +++ b/2.3-1/src/c/signalProcessing/includes/dct.h @@ -0,0 +1,36 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Ukasha Noor + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#ifndef __DCT_H__ +#define __DCT_H__ + +#include <math.h> +#include "types.h" +#include "doubleComplex.h" +#include "addition.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void ddcta(double *in,int row,int col,int sign,double *out); + +void zdcta(doubleComplex *in,int row,int col,int sign,doubleComplex *out); + +void cdcta(floatComplex *in,int row,int col,int sign,floatComplex *out); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/2.3-1/src/c/signalProcessing/includes/idct.h b/2.3-1/src/c/signalProcessing/includes/idct.h new file mode 100644 index 00000000..13458b7d --- /dev/null +++ b/2.3-1/src/c/signalProcessing/includes/idct.h @@ -0,0 +1,36 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Ukasha Noor + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#ifndef __IDCT_H__ +#define __IDCT_H__ + +#include <math.h> +#include "types.h" +#include "doubleComplex.h" +#include "addition.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void didcta(double *in,int row,int col,double *out); + +void zidcta(doubleComplex *in,int row,int col,doubleComplex *out); + +void cidcta(floatComplex *in,int row,int col,floatComplex *out); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/2.3-1/src/c/signalProcessing/includes/modk.h b/2.3-1/src/c/signalProcessing/includes/modk.h new file mode 100644 index 00000000..5040eb7f --- /dev/null +++ b/2.3-1/src/c/signalProcessing/includes/modk.h @@ -0,0 +1,28 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Ankit Raj + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ + +#ifndef __MODK_H__ +#define __MODK_H__ +#include "types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void dmodka(double* inp,int size,double* oup); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* __MODK_H__ */ + diff --git a/2.3-1/src/c/signalProcessing/interfaces/int_dct.h b/2.3-1/src/c/signalProcessing/interfaces/int_dct.h new file mode 100644 index 00000000..6cfb21c7 --- /dev/null +++ b/2.3-1/src/c/signalProcessing/interfaces/int_dct.h @@ -0,0 +1,32 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Ukasha Noor + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + + +#ifndef __INT_DCT_H__ +#define __INT_DCT_H__ + + + +#define d2dctd2(in,size,out) ddcta(in,size[0],size[1],-1,out) + +#define d2d0dctd2(in,size,sign,out) ddcta(in,size[0],size[1],sign,out) + +#define z2dctz2(in,size,out) zdcta(in,size[0],size[1],-1,out) + +#define z2d0dctz2(in,size,sign,out) zdcta(in,size[0],size[1],sign,out) + +#define c2dctc2(in,size,out) cdcta(in,size[0],size[1],-1,out) + +#define c2s0dctc2(in,size,sign,out) cdcta(in,size[0],size[1],sign,out) + +#endif diff --git a/2.3-1/src/c/signalProcessing/interfaces/int_idct.h b/2.3-1/src/c/signalProcessing/interfaces/int_idct.h new file mode 100644 index 00000000..c3a174ac --- /dev/null +++ b/2.3-1/src/c/signalProcessing/interfaces/int_idct.h @@ -0,0 +1,26 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Ukasha Noor + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + + +#ifndef __INT_IDCT_H__ +#define __INT_IDCT_H__ + + + +#define d2idctd2(in,size,out) didcta(in,size[0],size[1],out) + +#define z2idctz2(in,size,out) zidcta(in,size[0],size[1],out) + +#define c2idctc2(in,size,out) cidcta(in,size[0],size[1],out) + +#endif diff --git a/2.3-1/src/c/signalProcessing/interfaces/int_modk.h b/2.3-1/src/c/signalProcessing/interfaces/int_modk.h new file mode 100644 index 00000000..441b9b13 --- /dev/null +++ b/2.3-1/src/c/signalProcessing/interfaces/int_modk.h @@ -0,0 +1,18 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Ankit Raj + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ + +#ifndef __INT_MODK_H__ +#define __INT_MODK_H__ + +#define d2modkd2(inp,size,oup) dmodka(inp,size[1],oup) + +#endif /* !INT_MODK_H__! */ diff --git a/2.3-1/src/c/signalProcessing/modk/dmodka.c b/2.3-1/src/c/signalProcessing/modk/dmodka.c new file mode 100644 index 00000000..c0630ec0 --- /dev/null +++ b/2.3-1/src/c/signalProcessing/modk/dmodka.c @@ -0,0 +1,97 @@ +#include<stdio.h> +#include<math.h> +#include "modk.h" +double max_calc(double* ptr,int sz) +{ + int i=0; + double mx; + if(ptr[0]<0) + { + ptr[0]=-1*ptr[0]; + } + mx=(ptr[0]); + //printf("%lf\n",mx); + for(i=1;i<sz;i++) + { + if(ptr[i]<0) + { + ptr[i]=-1*ptr[i]; + } + if(mx<(ptr[i])) + mx=(ptr[i]); + } + return mx; +} +void dmodka(double* inp,int size,double* oup) +{ + double ones[size],PI=M_PI; + double eps=pow(2,-52); + int i; + for(i=0;i<size;i++) + { + ones[i]=1; + } + double a[size],b[size],c[size],an[size],bn[size],cn[size],kans[size]; + + int j,kk,l,m; + for(j=0;j<size;j++) + { + a[j]=1; + } + for(kk=0;kk<size;kk++) + { + b[kk]=sqrt(ones[kk]-inp[kk]); + } + for(l=0;l<size;l++) + { + c[l]=sqrt(inp[l]); + + } + int x=0; + //double maxi; + //maxi=max_calc(c,size); + //printf("%lf",maxi); + + while(max_calc(c,size)>eps) + { + int q,w,r; + for(q=0;q<size;q++) + { + an[q]=0.5*(a[q]+b[q]); + } + for(w=0;w<size;w++) + { + bn[w]=sqrt(a[w]*b[w]); + } + for(r=0;r<size;r++) + { + cn[r]=0.5*(a[r]-b[r]); + } + int x,y,z; + for(x=0;x<size;x++) + { + a[x]=an[x]; + } + for(y=0;y<size;y++) + { + b[y]=bn[y]; + } + for(z=0;z<size;z++) + { + c[z]=cn[z]; + } + } + int q,w; + for(q=0;q<size;q++) + { + oup[q]=PI*(ones[q]/(2*a[q])); + } + +} +/* +int main() +{ + double m[3]={0.1,0.2,0.3}; + dka(m,3); +} +*/ diff --git a/2.3-1/src/c/signalProcessing/transforms/dct/cdcta.c b/2.3-1/src/c/signalProcessing/transforms/dct/cdcta.c new file mode 100644 index 00000000..5bc27929 --- /dev/null +++ b/2.3-1/src/c/signalProcessing/transforms/dct/cdcta.c @@ -0,0 +1,177 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Ukasha Noor + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#include "dct.h" +#include "addition.h" +#include "types.h" +#include "floatComplex.h" +/*#include "matrixMultiplication"*/ +/*#include <fftw3.h>*/ +#include <math.h> + +void cdcta(floatComplex *in,int row,int col,int sign,floatComplex *out) +{ + int i,j,k,u,v; + int n; + int x,y; + float res,ress; + float re,z,q,m; + floatComplex accu = DoubleComplex(0, 0); + floatComplex temp,mm; + if(sign==-1) + { + if(row==1) + { + n=col; + for(u=0;u<row;u++) + { + for(v=0;v<col;v++) + { + x=v*row+u; + out[x]=FloatComplex(0,0); + for(i=0;i<row;i++) + { + for(j=0;j<col;j++) + { + y=row*j+i; + temp=in[y]*(cos(((M_PI)*(y+1-1./2.)*(x))/n)); + out[x]=cadds(out[x],temp); + } + } + if(x==0) + out[x]*=1./(sqrt(n)); + else + { + float res=2./n; + out[x]*=sqrt(res); + } + } + } + } + else + { + n=col*row; + for(u=0;u<row;u++) + { + for(v=0;v<col;v++) + { + x=v*row+u; + out[x]=FloatComplex(0,0); + for(i=0;i<row;i++) + { + temp=FloatComplex(0,0); + mm=FloatComplex(0,0); + for(j=0;j<col;j++) + { + y=j*row+i; + z=(float)(((float)j+1.0/2.0)*(float)v); + q=(float)(M_PI/(float)col); + mm=in[y]*(cos(q*z)); + temp=cadds(temp,mm); + } + z=(float)(((float)i+1.0/2.0)*(float)u); + q=(float)(M_PI/(float)row); + temp*=cos(q*z); + out[x]=cadds(out[x],temp); + } + if(u==0) + { + out[x]*=1./sqrt((float)row); + if(v==0) + out[x]*=1./sqrt((float)col); + else + out[x]*=sqrt(2./col); + } + else + { + out[x]*=sqrt(2./row); + if(v==0) + out[x]*=1./sqrt((float)col); + else + out[x]*=sqrt(2./col); + } + } + } + } + } + else if(sign==1) + { + n=col; + if(row==1) + { + res=1./sqrt(n); + ress=sqrt(2./n); + for(u=0;u<row;u++) + { + for(v=0;v<col;v++) + { + x=v*row+u; + out[x]=FloatComplex(0,0); + for(i=0;i<row;i++) + { + for(j=0;j<col;j++) + { + y=row*j+i; + if(y==0) + { + q=res*(cos(((M_PI)*(j)*(v+1./2.))/n)); + out[x]=cadds(out[x],in[y]*q); + } + else + { + q=ress*(cos(((M_PI)*(j)*(v+1./2.))/n)); + out[x]=cadds(out[x],in[y]*q); + } + } + } + } + + } + } + else + { + for(u=0;u<row;u++) + { + for(v=0;v<col;v++) + { + x=v*row+u; + out[x]=FloatComplex(0,0); + for(i=0;i<row;i++) + { + re=0; + mm=FloatComplex(0,0); + temp=FloatComplex(0,0); + for(j=0;j<col;j++) + { + y=row*j+i; + mm=in[j*row+i]; + z=(float)(((float)v+1.0/2.0)*(float)j); + q=(float)(M_PI/(float)col); + mm=mm*(cos(q*z)); + if(j==0) + temp=cadds(temp,mm*(1./sqrt((float)col))); + else + temp=cadds(temp,mm*sqrt(2./col)); + } + z=(float)(((float)u+1.0/2.0)*(float)i); + q=(float)(M_PI/(float)row); + if(i==0) + out[x]=cadds(out[x],temp*((cos(z*q))*(1./sqrt(row)))); + else + out[x]=cadds(out[x],temp*((cos(z*q))*sqrt(2./row))); + } + } + } + } + } +} diff --git a/2.3-1/src/c/signalProcessing/transforms/dct/ddcta.c b/2.3-1/src/c/signalProcessing/transforms/dct/ddcta.c new file mode 100644 index 00000000..3802c816 --- /dev/null +++ b/2.3-1/src/c/signalProcessing/transforms/dct/ddcta.c @@ -0,0 +1,160 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Ukasha Noor + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#include "dct.h" +/*#include <fftw3.h>*/ +#include <math.h> + +void ddcta(double *in,int row,int col,int sign,double *out) +{ + int i,j,k,u,v; + int n; + int x,y; + double res,ress; + double re,z,q,m; + if(sign==-1) + { + if(row==1) + { + n=col; + for(u=0;u<row;u++) + { + for(v=0;v<col;v++) + { + x=v*row+u; + out[x]=0; + for(i=0;i<row;i++) + { + for(j=0;j<col;j++) + { + y=row*j+i; + out[x]+=in[y]*(cos(((M_PI)*(y+1-1./2.)*(x))/n)); + } + } + if(x==0) + out[x]*=1./(sqrt(n)); + else + { + double res=2./n; + out[x]*=sqrt(res); + } + } + } + } + else + { + n=col*row; + for(u=0;u<row;u++) + { + for(v=0;v<col;v++) + { + x=v*row+u; + out[x]=0; + for(i=0;i<row;i++) + { + re=0; + for(j=0;j<col;j++) + { + m=(double)in[j*row+i]; + z=(double)(((double)j+1.0/2.0)*(double)v); + q=(double)(M_PI/(double)col); + re+=m*(cos(q*z)); + } + z=(double)(((double)i+1.0/2.0)*(double)u); + q=(double)(M_PI/(double)row); + out[x]+=re*(cos(q*z)); + } + if(u==0) + { + out[x]/=sqrt((double)row); + if(v==0) + out[x]/=sqrt((double)col); + else + out[x]*=sqrt(2./col); + } + else + { + out[x]*=sqrt(2./row); + if(v==0) + out[x]/=sqrt((double)col); + else + out[x]*=sqrt(2./col); + } + } + } + + } + } + else if(sign==1) + { + n=col; + if(row==1) + { + res=1./sqrt(n); + ress=sqrt(2./n); + for(u=0;u<row;u++) + { + for(v=0;v<col;v++) + { + x=v*row+u; + out[x]=0; + for(i=0;i<row;i++) + { + for(j=0;j<col;j++) + { + y=row*j+i; + if(y==0) + out[x]+=res*in[y]*(cos(((M_PI)*(j)*(v+1./2.))/n)); + else + out[x]+=ress*in[y]*(cos(((M_PI)*(j)*(v+1./2.))/n)); + } + } + } + + } + } + else + { + for(u=0;u<row;u++) + { + for(v=0;v<col;v++) + { + x=v*row+u; + out[x]=0; + for(i=0;i<row;i++) + { + re=0; + for(j=0;j<col;j++) + { + y=row*j+i; + m=(double)in[j*row+i]; + z=(double)(((double)v+1.0/2.0)*(double)j); + q=(double)(M_PI/(double)col); + m=m*(cos(q*z)); + if(j==0) + re+=m/sqrt((double)col); + else + re+=m*sqrt(2./col); + } + z=(double)(((double)u+1.0/2.0)*(double)i); + q=(double)(M_PI/(double)row); + if(i==0) + out[x]+=(re*(cos(z*q)))/sqrt((double)row); + else + out[x]+=(re*(cos(z*q))*sqrt(2./row)); + } + } + } + } + } +} diff --git a/2.3-1/src/c/signalProcessing/transforms/dct/zdcta.c b/2.3-1/src/c/signalProcessing/transforms/dct/zdcta.c new file mode 100644 index 00000000..0204d682 --- /dev/null +++ b/2.3-1/src/c/signalProcessing/transforms/dct/zdcta.c @@ -0,0 +1,177 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Ukasha Noor + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#include "dct.h" +#include "addition.h" +#include "types.h" +#include "doubleComplex.h" +/*#include "matrixMultiplication"*/ +/*#include <fftw3.h>*/ +#include <math.h> + +void zdcta(doubleComplex *in,int row,int col,int sign,doubleComplex *out) +{ + int i,j,k,u,v; + int n; + int x,y; + double res,ress; + double re,z,q,m; + doubleComplex accu = DoubleComplex(0, 0); + doubleComplex temp,mm; + if(sign==-1) + { + if(row==1) + { + n=col; + for(u=0;u<row;u++) + { + for(v=0;v<col;v++) + { + x=v*row+u; + out[x]=DoubleComplex(0,0); + for(i=0;i<row;i++) + { + for(j=0;j<col;j++) + { + y=row*j+i; + temp=in[y]*(cos(((M_PI)*(y+1-1./2.)*(x))/n)); + out[x]=zadds(out[x],temp); + } + } + if(x==0) + out[x]*=1./(sqrt(n)); + else + { + double res=2./n; + out[x]*=sqrt(res); + } + } + } + } + else + { + n=col*row; + for(u=0;u<row;u++) + { + for(v=0;v<col;v++) + { + x=v*row+u; + out[x]=DoubleComplex(0,0); + for(i=0;i<row;i++) + { + temp=DoubleComplex(0,0); + mm=DoubleComplex(0,0); + for(j=0;j<col;j++) + { + y=j*row+i; + z=(double)(((double)j+1.0/2.0)*(double)v); + q=(double)(M_PI/(double)col); + mm=in[y]*(cos(q*z)); + temp=zadds(temp,mm); + } + z=(double)(((double)i+1.0/2.0)*(double)u); + q=(double)(M_PI/(double)row); + temp*=cos(q*z); + out[x]=zadds(out[x],temp); + } + if(u==0) + { + out[x]*=1./sqrt((double)row); + if(v==0) + out[x]*=1./sqrt((double)col); + else + out[x]*=sqrt(2./col); + } + else + { + out[x]*=sqrt(2./row); + if(v==0) + out[x]*=1./sqrt((double)col); + else + out[x]*=sqrt(2./col); + } + } + } + } + } + else if(sign==1) + { + n=col; + if(row==1) + { + res=1./sqrt(n); + ress=sqrt(2./n); + for(u=0;u<row;u++) + { + for(v=0;v<col;v++) + { + x=v*row+u; + out[x]=DoubleComplex(0,0); + for(i=0;i<row;i++) + { + for(j=0;j<col;j++) + { + y=row*j+i; + if(y==0) + { + q=res*(cos(((M_PI)*(j)*(v+1./2.))/n)); + out[x]=zadds(out[x],in[y]*q); + } + else + { + q=ress*(cos(((M_PI)*(j)*(v+1./2.))/n)); + out[x]=zadds(out[x],in[y]*q); + } + } + } + } + + } + } + else + { + for(u=0;u<row;u++) + { + for(v=0;v<col;v++) + { + x=v*row+u; + out[x]=DoubleComplex(0,0); + for(i=0;i<row;i++) + { + re=0; + mm=DoubleComplex(0,0); + temp=DoubleComplex(0,0); + for(j=0;j<col;j++) + { + y=row*j+i; + mm=in[j*row+i]; + z=(double)(((double)v+1.0/2.0)*(double)j); + q=(double)(M_PI/(double)col); + mm=mm*(cos(q*z)); + if(j==0) + temp=zadds(temp,mm*(1./sqrt((double)col))); + else + temp=zadds(temp,mm*sqrt(2./col)); + } + z=(double)(((double)u+1.0/2.0)*(double)i); + q=(double)(M_PI/(double)row); + if(i==0) + out[x]=zadds(out[x],temp*((cos(z*q))*(1./sqrt(row)))); + else + out[x]=zadds(out[x],temp*((cos(z*q))*sqrt(2./row))); + } + } + } + } + } +} diff --git a/2.3-1/src/c/signalProcessing/transforms/idct/cidcta.c b/2.3-1/src/c/signalProcessing/transforms/idct/cidcta.c new file mode 100644 index 00000000..ec0df0c7 --- /dev/null +++ b/2.3-1/src/c/signalProcessing/transforms/idct/cidcta.c @@ -0,0 +1,97 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Ukasha Noor + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#include "idct.h" +#include "addition.h" +#include "types.h" +#include "floatComplex.h" +/*#include "matrixMultiplication"*/ +/*#include <fftw3.h>*/ +#include <math.h> + +void cidcta(floatComplex *in,int row,int col,floatComplex *out) +{ + int i,j,k,u,v; + int n=col; + int x,y; + float res,ress; + float re,z,q,m; + floatComplex accu = DoubleComplex(0, 0); + floatComplex temp,mm; + if(row==1) + { + res=1./sqrt(n); + ress=sqrt(2./n); + for(u=0;u<row;u++) + { + for(v=0;v<col;v++) + { + x=v*row+u; + out[x]=FloatComplex(0,0); + for(i=0;i<row;i++) + { + for(j=0;j<col;j++) + { + y=row*j+i; + if(y==0) + { + q=res*(cos(((M_PI)*(j)*(v+1./2.))/n)); + out[x]=cadds(out[x],in[y]*q); + } + else + { + q=ress*(cos(((M_PI)*(j)*(v+1./2.))/n)); + out[x]=cadds(out[x],in[y]*q); + } + } + } + } + + } + } + else + { + for(u=0;u<row;u++) + { + for(v=0;v<col;v++) + { + x=v*row+u; + out[x]=FloatComplex(0,0); + for(i=0;i<row;i++) + { + re=0; + mm=FloatComplex(0,0); + temp=FloatComplex(0,0); + for(j=0;j<col;j++) + { + y=row*j+i; + mm=in[j*row+i]; + z=(float)(((float)v+1.0/2.0)*(float)j); + q=(float)(M_PI/(float)col); + mm=mm*(cos(q*z)); + if(j==0) + temp=cadds(temp,mm*(1./sqrt((float)col))); + else + temp=cadds(temp,mm*sqrt(2./col)); + } + z=(float)(((float)u+1.0/2.0)*(float)i); + q=(float)(M_PI/(float)row); + if(i==0) + out[x]=cadds(out[x],temp*((cos(z*q))*(1./sqrt(row)))); + else + out[x]=cadds(out[x],temp*((cos(z*q))*sqrt(2./row))); + } + } + } + } +} diff --git a/2.3-1/src/c/signalProcessing/transforms/idct/didcta.c b/2.3-1/src/c/signalProcessing/transforms/idct/didcta.c new file mode 100644 index 00000000..5f475160 --- /dev/null +++ b/2.3-1/src/c/signalProcessing/transforms/idct/didcta.c @@ -0,0 +1,83 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Ukasha Noor + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#include "idct.h" +/*#include <fftw3.h>*/ +#include <math.h> + +void didcta(double *in,int row,int col,double *out) +{ + int i,j,k,u,v; + int n=col; + int x,y; + double res,ress; + double re,z,q,m; + if(row==1) + { + res=1./sqrt(n); + ress=sqrt(2./n); + for(u=0;u<row;u++) + { + for(v=0;v<col;v++) + { + x=v*row+u; + out[x]=0; + for(i=0;i<row;i++) + { + for(j=0;j<col;j++) + { + y=row*j+i; + if(y==0) + out[x]+=res*in[y]*(cos(((M_PI)*(j)*(v+1./2.))/n)); + else + out[x]+=ress*in[y]*(cos(((M_PI)*(j)*(v+1./2.))/n)); + } + } + } + + } + } + else + { + for(u=0;u<row;u++) + { + for(v=0;v<col;v++) + { + x=v*row+u; + out[x]=0; + for(i=0;i<row;i++) + { + re=0; + for(j=0;j<col;j++) + { + y=row*j+i; + m=(double)in[j*row+i]; + z=(double)(((double)v+1.0/2.0)*(double)j); + q=(double)(M_PI/(double)col); + m=m*(cos(q*z)); + if(j==0) + re+=m/sqrt((double)col); + else + re+=m*sqrt(2./col); + } + z=(double)(((double)u+1.0/2.0)*(double)i); + q=(double)(M_PI/(double)row); + if(i==0) + out[x]+=(re*(cos(z*q)))/sqrt((double)row); + else + out[x]+=(re*(cos(z*q))*sqrt(2./row)); + } + } + } + } +} diff --git a/2.3-1/src/c/signalProcessing/transforms/idct/zidcta.c b/2.3-1/src/c/signalProcessing/transforms/idct/zidcta.c new file mode 100644 index 00000000..2177b18c --- /dev/null +++ b/2.3-1/src/c/signalProcessing/transforms/idct/zidcta.c @@ -0,0 +1,97 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Ukasha Noor + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#include "idct.h" +#include "addition.h" +#include "types.h" +#include "doubleComplex.h" +/*#include "matrixMultiplication"*/ +/*#include <fftw3.h>*/ +#include <math.h> + +void zidcta(doubleComplex *in,int row,int col,doubleComplex *out) +{ + int i,j,k,u,v; + int n=col; + int x,y; + double res,ress; + double re,z,q,m; + doubleComplex accu = DoubleComplex(0, 0); + doubleComplex temp,mm; + if(row==1) + { + res=1./sqrt(n); + ress=sqrt(2./n); + for(u=0;u<row;u++) + { + for(v=0;v<col;v++) + { + x=v*row+u; + out[x]=DoubleComplex(0,0); + for(i=0;i<row;i++) + { + for(j=0;j<col;j++) + { + y=row*j+i; + if(y==0) + { + q=res*(cos(((M_PI)*(j)*(v+1./2.))/n)); + out[x]=zadds(out[x],in[y]*q); + } + else + { + q=ress*(cos(((M_PI)*(j)*(v+1./2.))/n)); + out[x]=zadds(out[x],in[y]*q); + } + } + } + } + + } + } + else + { + for(u=0;u<row;u++) + { + for(v=0;v<col;v++) + { + x=v*row+u; + out[x]=DoubleComplex(0,0); + for(i=0;i<row;i++) + { + re=0; + mm=DoubleComplex(0,0); + temp=DoubleComplex(0,0); + for(j=0;j<col;j++) + { + y=row*j+i; + mm=in[j*row+i]; + z=(double)(((double)v+1.0/2.0)*(double)j); + q=(double)(M_PI/(double)col); + mm=mm*(cos(q*z)); + if(j==0) + temp=zadds(temp,mm*(1./sqrt((double)col))); + else + temp=zadds(temp,mm*sqrt(2./col)); + } + z=(double)(((double)u+1.0/2.0)*(double)i); + q=(double)(M_PI/(double)row); + if(i==0) + out[x]=zadds(out[x],temp*((cos(z*q))*(1./sqrt(row)))); + else + out[x]=zadds(out[x],temp*((cos(z*q))*sqrt(2./row))); + } + } + } + } +} |