Main Page   File List   File Members  

dct_trf.c File Reference

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "support_routines.h"

Go to the source code of this file.

Defines

#define PI   3.14159265358979
#define BUFFER_SIZE   (256)

Functions

float ** gen_1d_dct (int N)
void trf_one_block_dct_2d (float **matrix, int pi, int pj, float **trf, int si, int sj, int bx, float **H)
void inv_trf_one_block_dct_2d (float **trf, int si, int sj, float **matrix, int pi, int pj, int bx, float **H)


Define Documentation

#define BUFFER_SIZE   (256)
 

Definition at line 34 of file dct_trf.c.

Referenced by inv_trf_one_block_dct_2d, and trf_one_block_dct_2d.

#define PI   3.14159265358979
 

Definition at line 12 of file dct_trf.c.

Referenced by gen_1d_dct.


Function Documentation

float** gen_1d_dct int    N
 

Definition at line 19 of file dct_trf.c.

References allocate_2d_float, and PI.

00021 {
00022    int i,j;
00023    float **H;
00024 
00025    H=allocate_2d_float(N,N,0);
00026    for(i=0;i<N;i++)
00027       for(j=0;j<N;j++)
00028          H[i][j]=(float)(sqrt(2.0/N)*cos(PI*i*(2.0*j+1)/(2.0*N)));
00029    for(j=0;j<N;j++)
00030       H[0][j]/=(float)sqrt(2.0);
00031    return(H);
00032    }

void inv_trf_one_block_dct_2d float **    trf,
int    si,
int    sj,
float **    matrix,
int    pi,
int    pj,
int    bx,
float **    H
 

Definition at line 87 of file dct_trf.c.

References BUFFER_SIZE.

00090 {
00091         int k,l,m;
00092         float tmp,buf[BUFFER_SIZE];
00093 
00094 
00095         if(bx>BUFFER_SIZE) {
00096 
00097                 printf("Large DCT_SIZE, please increase BUFFER_SIZE in code to match\n");
00098                 exit(1);
00099         }
00100 
00101         // Inverse transform rows first.
00102         for(k=0;k<bx;k++)
00103                 for(l=0;l<bx;l++) {
00104 
00105                         tmp=0;
00106                         for(m=0;m<bx;m++)
00107                                 tmp+=H[m][l]*trf[si+k][sj+m];
00108                         matrix[pi+k][pj+l]=tmp;
00109                         }
00110 
00111         // Now inverse transform columns.
00112         for(l=0;l<bx;l++) {
00113                         
00114                 for(k=0;k<bx;k++) {
00115 
00116                         tmp=0;
00117                         for(m=0;m<bx;m++)
00118                                 tmp+=H[m][k]*matrix[pi+m][pj+l];
00119                         buf[k]=tmp;
00120                 }
00121                 for(k=0;k<bx;k++)
00122                         matrix[pi+k][pj+l]=buf[k];
00123         }
00124 }

void trf_one_block_dct_2d float **    matrix,
int    pi,
int    pj,
float **    trf,
int    si,
int    sj,
int    bx,
float **    H
 

Definition at line 40 of file dct_trf.c.

References BUFFER_SIZE.

00043 {
00044         int k,l,m;
00045         float tmp,buf[BUFFER_SIZE];
00046 
00047 
00048         if(bx>BUFFER_SIZE) {
00049 
00050                 printf("Large DCT_SIZE, please increase BUFFER_SIZE in code to match\n");
00051                 exit(1);
00052         }
00053 
00054         // Transform columns first.
00055         for(k=0;k<bx;k++)
00056                 for(l=0;l<bx;l++) {
00057 
00058                         tmp=0;
00059                         for(m=0;m<bx;m++)
00060                                 tmp+=H[k][m]*matrix[pi+m][pj+l];
00061                         trf[si+k][sj+l]=tmp;
00062                         }
00063 
00064         // Now transform rows.
00065         for(k=0;k<bx;k++) {
00066 
00067                 for(l=0;l<bx;l++) {
00068 
00069                         tmp=0;
00070                         for(m=0;m<bx;m++)
00071                                 tmp+=H[l][m]*trf[si+k][sj+m];
00072                         buf[l]=tmp;
00073                 }
00074                                 
00075                 for(l=0;l<bx;l++)
00076                         trf[si+k][sj+l]=buf[l];
00077         }
00078 
00079 }


Generated on Fri Jan 16 00:15:42 2004 for Image_Recovery_Proof_of_Concept_Code by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002