summaryrefslogtreecommitdiff
path: root/2.3-1/src/c/signalProcessing
diff options
context:
space:
mode:
Diffstat (limited to '2.3-1/src/c/signalProcessing')
-rw-r--r--2.3-1/src/c/signalProcessing/includes/dct.h2
-rw-r--r--2.3-1/src/c/signalProcessing/includes/idct.h2
-rw-r--r--2.3-1/src/c/signalProcessing/interfaces/int_dct.h4
-rw-r--r--2.3-1/src/c/signalProcessing/interfaces/int_idct.h2
-rw-r--r--2.3-1/src/c/signalProcessing/transforms/dct/sdcta.c160
-rw-r--r--2.3-1/src/c/signalProcessing/transforms/idct/sidcta.c83
6 files changed, 253 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
index 5255241e..80668ffa 100644
--- a/2.3-1/src/c/signalProcessing/includes/dct.h
+++ b/2.3-1/src/c/signalProcessing/includes/dct.h
@@ -25,6 +25,8 @@ extern "C" {
void ddcta(double *in,int row,int col,int sign,double *out);
+void sdcta(float *in,int row,int col,int sign,float *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);
diff --git a/2.3-1/src/c/signalProcessing/includes/idct.h b/2.3-1/src/c/signalProcessing/includes/idct.h
index 13458b7d..1e7b85b3 100644
--- a/2.3-1/src/c/signalProcessing/includes/idct.h
+++ b/2.3-1/src/c/signalProcessing/includes/idct.h
@@ -25,6 +25,8 @@ extern "C" {
void didcta(double *in,int row,int col,double *out);
+void sidcta(float *in,int row,int col,float *out);
+
void zidcta(doubleComplex *in,int row,int col,doubleComplex *out);
void cidcta(floatComplex *in,int row,int col,floatComplex *out);
diff --git a/2.3-1/src/c/signalProcessing/interfaces/int_dct.h b/2.3-1/src/c/signalProcessing/interfaces/int_dct.h
index 6cfb21c7..3481c4d5 100644
--- a/2.3-1/src/c/signalProcessing/interfaces/int_dct.h
+++ b/2.3-1/src/c/signalProcessing/interfaces/int_dct.h
@@ -21,6 +21,10 @@
#define d2d0dctd2(in,size,sign,out) ddcta(in,size[0],size[1],sign,out)
+#define s2dcts2(in,size,out) sdcta(in,size[0],size[1],-1,out)
+
+#define s2s0dcts2(in,size,sign,out) sdcta(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)
diff --git a/2.3-1/src/c/signalProcessing/interfaces/int_idct.h b/2.3-1/src/c/signalProcessing/interfaces/int_idct.h
index c3a174ac..f705fe2d 100644
--- a/2.3-1/src/c/signalProcessing/interfaces/int_idct.h
+++ b/2.3-1/src/c/signalProcessing/interfaces/int_idct.h
@@ -19,6 +19,8 @@
#define d2idctd2(in,size,out) didcta(in,size[0],size[1],out)
+#define s2idcts2(in,size,out) sidcta(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)
diff --git a/2.3-1/src/c/signalProcessing/transforms/dct/sdcta.c b/2.3-1/src/c/signalProcessing/transforms/dct/sdcta.c
new file mode 100644
index 00000000..9f380e8b
--- /dev/null
+++ b/2.3-1/src/c/signalProcessing/transforms/dct/sdcta.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 sdcta(float *in,int row,int col,int sign,float *out)
+{
+ int i,j,k,u,v;
+ int n;
+ int x,y;
+ float res,ress;
+ float 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
+ {
+ 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]=0;
+ for(i=0;i<row;i++)
+ {
+ re=0;
+ for(j=0;j<col;j++)
+ {
+ m=(float)in[j*row+i];
+ z=(float)(((float)j+1.0/2.0)*(float)v);
+ q=(float)(M_PI/(float)col);
+ re+=m*(cos(q*z));
+ }
+ z=(float)(((float)i+1.0/2.0)*(float)u);
+ q=(float)(M_PI/(float)row);
+ out[x]+=re*(cos(q*z));
+ }
+ if(u==0)
+ {
+ out[x]/=sqrt((float)row);
+ if(v==0)
+ out[x]/=sqrt((float)col);
+ else
+ out[x]*=sqrt(2./col);
+ }
+ else
+ {
+ out[x]*=sqrt(2./row);
+ if(v==0)
+ out[x]/=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]=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=(float)in[j*row+i];
+ z=(float)(((float)v+1.0/2.0)*(float)j);
+ q=(float)(M_PI/(float)col);
+ m=m*(cos(q*z));
+ if(j==0)
+ re+=m/sqrt((float)col);
+ else
+ re+=m*sqrt(2./col);
+ }
+ z=(float)(((float)u+1.0/2.0)*(float)i);
+ q=(float)(M_PI/(float)row);
+ if(i==0)
+ out[x]+=(re*(cos(z*q)))/sqrt((float)row);
+ else
+ out[x]+=(re*(cos(z*q))*sqrt(2./row));
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/2.3-1/src/c/signalProcessing/transforms/idct/sidcta.c b/2.3-1/src/c/signalProcessing/transforms/idct/sidcta.c
new file mode 100644
index 00000000..62f85da0
--- /dev/null
+++ b/2.3-1/src/c/signalProcessing/transforms/idct/sidcta.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 sidcta(float *in,int row,int col,float *out)
+{
+ int i,j,k,u,v;
+ int n=col;
+ int x,y;
+ float res,ress;
+ float 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=(float)in[j*row+i];
+ z=(float)(((float)v+1.0/2.0)*(float)j);
+ q=(float)(M_PI/(float)col);
+ m=m*(cos(q*z));
+ if(j==0)
+ re+=m/sqrt((float)col);
+ else
+ re+=m*sqrt(2./col);
+ }
+ z=(float)(((float)u+1.0/2.0)*(float)i);
+ q=(float)(M_PI/(float)row);
+ if(i==0)
+ out[x]+=(re*(cos(z*q)))/sqrt((float)row);
+ else
+ out[x]+=(re*(cos(z*q))*sqrt(2./row));
+ }
+ }
+ }
+ }
+}