could someone please help me modify the below c program to work for AT91RM9200(ARM7TDMI)using keil simulation. the program is for finding dct coefficients for input pixel values #include<stdio.h> #include<conio.h> #include<math.h> #define N 8 void main() { int i,j,k,l; float f[10][10],fdct[10][10],a[10][10]; //input pixel values and output DCT coefficients clrscr(); /*printf("\n Enter the input pixel values:\n"); for(i=0;i<N;i=i+1) { for(j=0;j<N;j=j+1) { scanf("%f\n ",&f[i][j]); //Reading input pixel values given by user } } */ a[0][0]=23; a[0][1]=12; a[0][2]=14; a[0][3]=15; a[0][4]=30; a[0][5]=34; a[0][6]=10; a[0][7]=30;
a[1][0]=60; a[1][1]=70; a[1][2]=50; a[1][3]=70; a[1][4]=85; a[1][5]=90; a[1][6]=50; a[1][7]=94;
a[2][0]=54; a[2][1]=84; a[2][2]=30; a[2][3]=44; a[2][4]=50; a[2][5]=76; a[2][6]=80; a[2][7]=34;
a[3][0]=20; a[3][1]=22; a[3][2]=20; a[3][3]=33; a[3][4]=20; a[3][5]=93; a[3][6]=40; a[3][7]=58;
a[4][0]=43; a[4][1]=20; a[4][2]=10; a[4][3]=10; a[4][4]=40; a[4][5]=50; a[4][6]=60; a[4][7]=70;
a[5][0]=66; a[5][2]=60; a[5][3]=67; a[5][4]=60; a[5][5]=62; a[5][6]=70; a[5][7]=81;
a[6][0]=39; a[6][1]=35; a[6][2]=30; a[6][3]=38; a[6][4]=0; a[6][5]=34; a[6][6]=40; a[6][7]=42;
a[7][0]=60; a[7][1]=74 ; a[7][2]=70; a[7][3]=40; a[7][4]=35; a[7][5]=50; a[7][6]=40; a[7][7]=63;
a[8][0]=30; a[8][1]=40; a[8][2]=50; a[8][3]=42; a[8][4]=30; a[8][5]=21; a[8][6]=120; a[8][7]=230; for(i=0;i<N;i=i+1) { for(j=0;j<N;j=j+1) { f[i][j]=a[i][j]; } } for(i=0;i<N;i=i+1) { for(j=0;j<N;j=j+1) { printf("%f ",f[i][j]); } printf("\n"); } for(i=0;i<N;i=i+1) { for(j=0;j<N;j=j+1) { fdct[i][j]=0; for(k=0;k<N;k=k+1) { for(l=0;l<N;l=l+1) { if(i==0&&j==0) fdct[i][j]= fdct[i][j]+(1/4)*(1/2)*f[k][l]*cos((2*k+1)*i*3.14/16)*cos((2*l+1)*j*3.14/16); /*printf("%f ",fdct[i][j]); printf("%f ",(1/4)*(1/2)*f[k][l]); printf("%f ",f[k][l]); printf("%f ",cos((2*k+1)*i*3.14/16));*/ if(i==0&&j!=0) fdct[i][j]= fdct[i][j]+(1/sqrt(2))*(1/4)*f[k][l]*cos((2*k+1)*i*3.14/16)*cos((2*l+1)*j*3.14/16); if(i!=0&&j==0) fdct[i][j]= fdct[i][j]+(1/4)*(1/sqrt(2))*f[k][l]*cos((2*k+1)*i*3.14/16)*cos((2*l+1)*j*3.14/16); if(i!=0&&j!=0) fdct[i][j]= fdct[i][j]+(1/4)*f[k][l]*cos((2*k+1)*i*3.14/16)*cos((2*l+1)*j*3.14/16); } } } }
printf("\n"); printf("\n"); for(i=0;i<N;i=i+1) { for(j=0;j<N;j=j+1) { printf("%f ",fdct[i][j]); } printf("\n"); }
getch(); }
Does the code look readable to you?
Don't you think you should read _all_ posting information (see the text above the "Message:" textbox) and this time try to post your code as source code?
I'm extremely sorry for posting my thread in a bad way...I would be greatfull if u could help me in modifying the below source code(which is purely in c)to work for ARM PROCESSOR(AT91RM9200)
//C-program for chen algorithm to compute 2-D DCT
#include<stdio.h> #include<conio.h> #include<math.h> #define N 8 #define c1 0.9808 #define c2 0.9239 #define c3 0.8316 #define c4 0.7073 #define c5 0.5559 #define c6 0.3832 #define c7 0.1957 void main() { float f[10][10],Fdash[10][10],F[10][10]; //input pixel values and output DCT coefficients float i0,i1,i2,i3,i4,i5,i6,i7; //First stage intermediate values float j0,j1,j2,j3,j4,j5,j6,j7; //Second stage intermediate values float k0,k1,k2,k3,k4,k5,k6,k7; //Third stage intermediate values int i,j; clrscr(); printf("\n Enter the input pixel values:\n"); for(i=0;i<N;i=i+1) { for(j=0;j<N;j=j+1) { scanf("%f\n ",&f[i][j]); //Reading input pixel values given by user } } for(i=0;i<N;i=i+1) { for(j=0;j<N;j=j+1) { printf("%f ",f[i][j]); } printf("\n"); } printf("\n"); printf("\n"); //For every row in the input pixel matrix for(i=0;i<N;i=i+1) { i0=f[i][0]+f[i][7]; i1=f[i][1]+f[i][6]; i2=f[i][2]+f[i][5]; i3=f[i][3]+f[i][4]; i4=f[i][3]-f[i][4]; i5=f[i][2]-f[i][5]; i6=f[i][1]-f[i][6]; i7=f[i][0]-f[i][7]; //second stage j0=i0+i3; j1=i1+i2; j2=i1-i2; j3=i0-i3; j4=i4; j5=c4*(i6-i5); j6=c4*(i6+i5); j7=i7; //third stage k0=c4*(j0+j1); k1=c4*(j0-j1); k2=(c6*j2)+(c2*j3); k3=(c6*j3)-(c2*j2); k4=j4+j5; k5=j4-j5; k6=j7-j6; k7=j6+j7; //Final stage F[i][0]=0.5*k0; F[i][4]=0.5* k1; F[i][2]=0.5*k2; F[i][6]=0.5*k3; F[i][1]=(0.5*((k4*c7)+(k7*c1))); F[i][5]=(0.5*((k5*c3)+(k6*c5))); F[i][3]=(0.5*((k6*c3)-(k5*c5))); F[i][7]=(0.5*((k7*c7)-(k4*c1))); printf("\n"); } printf("\n"); for(i=0;i<N;i++) { for(j=0;j<N;j++) { printf("%f ",F[i][j]); } printf("\n"); } //For every column in the input pixel matrix for(j=0;j<N;j=j+1) { i0=F[0][j]+F[7][j]; i1=F[1][j]+F[6][j]; i2=F[2][j]+F[5][j]; i3=F[3][j]+F[4][j]; i4=F[3][j]-F[4][j]; i5=F[2][j]-F[5][j]; i6=F[1][j]-F[6][j]; i7=F[0][j]-F[7][j]; printf("\n"); //second stage j0=i0+i3; j1=i1+i2; j2=i1-i2; j3=i0-i3; j4=i4; j5=c4*(i6-i5); j6=c4*(i6+i5); j7=i7; //third stage k0=c4*(j0+j1); k1=c4*(j0-j1); k2=(c6*j2)+(c2*j3); k3=(c6*j3)-(c2*j2); k4=j4+j5; k5=j4-j5; k6=j7-j6; k7=j6+j7; //Final stage Fdash[0][j]=0.5*k0; Fdash[4][j]=0.5* k1; Fdash[2][j]=0.5*k2; Fdash[6][j]=0.5*k3; Fdash[1][j]=(0.5*((k4*c7)+(k7*c1))); Fdash[5][j]=(0.5*((k5*c3)+(k6*c5))); Fdash[3][j]=(0.5*((k6*c3)-(k5*c5))); Fdash[7][j]=(0.5*((k7*c7)-(k4*c1))); printf("\n"); } for(i=0;i<N;i++) { for(j=0;j<N;j++) { printf("%f ",Fdash[i][j]); } printf("\n"); } getch(); }
microwave(popcorn);
Let's try a third time, and this time please try to read the four bullet items directly above the "Message:" input box. Notice the bullet starting with: "Place source code..."?
Also try to use space instead of tab characters when indenting your code.
thank u for being patient with me and correcting me...could u please help me in modefying the below source code //C-program for chen algorithm to compute 2-D DCT
Notice that the first loops seems to have been indented with spaces.
Anyway: Your algorithm would probably work without any change at all.
But your processor may not have floating point support, and emulation of floating point will make it slow.
And the ARM compiler will not have the TurboC-specific include file <conio.h>.
If y ou are going to run the code in an embedded environment, you must decide where to get input data. You would normally not have any keyboard for manually entering it. And you must figure out what to do with the result. It isn't likely that you have a CRT for presenting the answers.
So, start by telling why you need to move this code from a PC? Then describe the data source (since an embedded system does not compute _one_ result but is used to continuously supervise/monitor something. Then describe what the results of the computation should be used for - either to control something by the ARM, or if they should be sent to another unit somewhere.
Another thing: Since embedded systems don't do one thing, and then ends, you should normally repeatedly run the code you have in your main - there is no operating system to return to after you return from main().
I'm working on 2D DCT for JPEG encoder. I tried compiling and running the above program in keil uVision(ARM Development Tools), it was showing an error- "code size limit exceeding 32k,running in evaluation mode"... -can i use the arrays as it is in the program or should i set registers of the corresponding ARM processor?
-I'm trying to simulate the output in the keil software itself and check for the output dct coefficients and the estimated time, is it possible?
-I'm trying to input the pixel values manually(pixel values were found out using matlab,directly read from the image), is there an option in keil also for taking the pixel values directly from the image or culd u suggest me any other possibility?
If I remember correctly, the Keil tools will count both code and data when deciding the max size possible for the evaluation version. But you can change arrays to pointers and then assign values to these pointers when the program starts.
But I didn't see any large arrays in your code. Just three arrays of 400 bytes each. It is probably the need of floating point emulation that makes you fail the limit of the evaluation version.
The ARM processor AT91RM9200 is a 32 bit processor. It is compatible for a floating point operation. Could u suggest any other processor which is better suited for the program