From cc9b8a9e45af12106656055b0958fa6d10d93916 Mon Sep 17 00:00:00 2001 From: ukashanoor Date: Tue, 4 Jul 2017 16:17:19 +0530 Subject: after debugging 2 --- src/c/signalProcessing/transforms/dct/cdcta.c | 97 ++++++++++++++----- src/c/signalProcessing/transforms/dct/zdcta.c | 121 +++++++++++++++++------- src/c/signalProcessing/transforms/idct/cidcta.c | 43 ++++++--- src/c/signalProcessing/transforms/idct/zidcta.c | 43 ++++++--- 4 files changed, 226 insertions(+), 78 deletions(-) (limited to 'src/c/signalProcessing/transforms') diff --git a/src/c/signalProcessing/transforms/dct/cdcta.c b/src/c/signalProcessing/transforms/dct/cdcta.c index bd15e5b..7ff8364 100644 --- a/src/c/signalProcessing/transforms/dct/cdcta.c +++ b/src/c/signalProcessing/transforms/dct/cdcta.c @@ -15,6 +15,7 @@ #include "addition.h" #include "types.h" #include "floatComplex.h" +#include "multiplication.h" /*#include "matrixMultiplication"*/ /*#include */ #include @@ -24,10 +25,10 @@ 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 res,ress,vv,ff; float re,z,q,m; floatComplex accu = FloatComplex(0, 0); - floatComplex temp,mm; + floatComplex temp,mm,aa,bb,cc; if(sign==-1) { if(row==1) @@ -43,17 +44,25 @@ void cdcta(floatComplex *in,int row,int col,int sign,floatComplex *out) { for(j=0;j*/ #include @@ -24,10 +25,10 @@ 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; + double res,ress,vv,ff; + double re,z,q,m; doubleComplex accu = DoubleComplex(0, 0); - doubleComplex temp,mm; + doubleComplex temp,mm,aa,bb,cc; if(sign==-1) { if(row==1) @@ -43,22 +44,30 @@ void zdcta(doubleComplex *in,int row,int col,int sign,doubleComplex *out) { for(j=0;j*/ #include @@ -24,10 +25,10 @@ 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 res,ress,vv,ff; float re,z,q,m; floatComplex accu = FloatComplex(0, 0); - floatComplex temp,mm; + floatComplex temp,mm,aa,bb; if(row==1) { res=1./sqrt(n); @@ -46,12 +47,14 @@ void cidcta(floatComplex *in,int row,int col,floatComplex *out) if(y==0) { q=res*(cos(((M_PI)*(j)*(v+1./2.))/n)); - out[x]=cadds(out[x],in[y]*q); + aa=FloatComplex(q,0); + out[x]=cadds(out[x],cmuls(in[y],aa)); } else { q=ress*(cos(((M_PI)*(j)*(v+1./2.))/n)); - out[x]=cadds(out[x],in[y]*q); + aa=FloatComplex(q,0); + out[x]=cadds(out[x],cmuls(in[y],aa)); } } } @@ -77,19 +80,37 @@ void cidcta(floatComplex *in,int row,int col,floatComplex *out) 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)); + q=(float)(M_PI/(float)col); + vv=cos(q*z); + aa=FloatComplex(vv,0); + mm=cmuls(mm,aa); if(j==0) - temp=cadds(temp,mm*(1./sqrt((float)col))); + { + vv=1./sqrt((float)col); + aa=FloatComplex(vv,0); + temp=cadds(temp,cmuls(mm,aa)); + } else - temp=cadds(temp,mm*sqrt(2./col)); + { + vv=sqrt(2./col); + aa=FloatComplex(vv,0); + temp=cadds(temp,cmuls(mm,aa)); + } } 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)))); + { + vv=(cos(z*q))*(1./sqrt(row)); + aa=FloatComplex(vv,0); + out[x]=cadds(out[x],cmuls(temp,aa)); + } else - out[x]=cadds(out[x],temp*((cos(z*q))*sqrt(2./row))); + { + vv=(cos(z*q))*sqrt(2./row); + aa=FloatComplex(vv,0); + out[x]=cadds(out[x],cmuls(temp,aa)); + } } } } diff --git a/src/c/signalProcessing/transforms/idct/zidcta.c b/src/c/signalProcessing/transforms/idct/zidcta.c index 2177b18..cc01c96 100644 --- a/src/c/signalProcessing/transforms/idct/zidcta.c +++ b/src/c/signalProcessing/transforms/idct/zidcta.c @@ -15,6 +15,7 @@ #include "addition.h" #include "types.h" #include "doubleComplex.h" +#include "multiplication.h" /*#include "matrixMultiplication"*/ /*#include */ #include @@ -24,10 +25,10 @@ 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 res,ress,vv,ff; double re,z,q,m; doubleComplex accu = DoubleComplex(0, 0); - doubleComplex temp,mm; + doubleComplex temp,mm,aa,bb; if(row==1) { res=1./sqrt(n); @@ -46,17 +47,19 @@ void zidcta(doubleComplex *in,int row,int col,doubleComplex *out) if(y==0) { q=res*(cos(((M_PI)*(j)*(v+1./2.))/n)); - out[x]=zadds(out[x],in[y]*q); + aa=DoubleComplex(q,0); + out[x]=zadds(out[x],zmuls(in[y],aa)); } else { q=ress*(cos(((M_PI)*(j)*(v+1./2.))/n)); - out[x]=zadds(out[x],in[y]*q); + aa=DoubleComplex(q,0); + out[x]=zadds(out[x],zmuls(in[y],aa)); } } } } - + } } else @@ -77,19 +80,37 @@ void zidcta(doubleComplex *in,int row,int col,doubleComplex *out) 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)); + q=(double)(M_PI/(double)col); + vv=cos(q*z); + aa=DoubleComplex(vv,0); + mm=zmuls(mm,aa); if(j==0) - temp=zadds(temp,mm*(1./sqrt((double)col))); + { + vv=1./sqrt((double)col); + aa=DoubleComplex(vv,0); + temp=zadds(temp,zmuls(mm,aa)); + } else - temp=zadds(temp,mm*sqrt(2./col)); + { + vv=sqrt(2./col); + aa=DoubleComplex(vv,0); + temp=zadds(temp,zmuls(mm,aa)); + } } 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)))); + { + vv=(cos(z*q))*(1./sqrt(row)); + aa=DoubleComplex(vv,0); + out[x]=zadds(out[x],zmuls(temp,aa)); + } else - out[x]=zadds(out[x],temp*((cos(z*q))*sqrt(2./row))); + { + vv=(cos(z*q))*sqrt(2./row); + aa=DoubleComplex(vv,0); + out[x]=zadds(out[x],zmuls(temp,aa)); + } } } } -- cgit