Go Back   Club CDFreaks - Knowledge is Power > International Chat: Software related > Video Edit Software


Commercial message



Video Edit Software Discuss, I'm making a stupid mistake, I'm sure... DCT Algorithm at International Chat: Software related forum; While using the Bloodshed Dev-C++ Compiler, Compiling the following program, I'm getting 31 errors, all in standard headers... The program computes the DCT of a 16x16 pixel input of all 1's... #include <math.h> #include <fstream.h> #define pi 3.14159 unsigned long


Reply
 
Thread Tools
Old 23-07-2002   #1 (permalink)
CDFreaks Resident
 
SirDavidGuy's Avatar
 
Join Date: Nov 2001
Posts: 1,467
I'm making a stupid mistake, I'm sure... DCT Algorithm

While using the Bloodshed Dev-C++ Compiler, Compiling the following program, I'm getting 31 errors, all in standard headers...
The program computes the DCT of a 16x16 pixel input of all 1's...

#include <math.h>
#include <fstream.h>
#define pi 3.14159

unsigned long int N = 16; //The size of the block the DCT is performed on
int Pixel[16][16];
long int DCTmatrix[16][16];

float Cosines(int x, int pixelnum)
{
float y = (2*x+1)*pixelnum*pi/(2*N);
return y;
}
void DCT()
{
unsigned long int j;
unsigned long int i;
unsigned long int x;
unsigned long int y;
long int temprounded;
float temp;
for (i = 0; i < N; i++)
{
for (j = 0; j < N; j++)
{
temp = 0;
for (x = 0; x < N; x++)
{
for (y = 0; y < N; y++)
{
temp = temp+Cosines(x, i)* Cosines(y, j)*Pixel[x][y];
}
}
}
temp = temp * sqrt (2 * N);
temprounded = temp;
DCTmatrix[i][j] = temprounded;
}
}

int main()
{
int counter;
int counter2;
for (counter = 0; counter < 16; counter++)
{
for (counter2 = 0; counter2 < 16; counter2++)
{
Pixel[counter][counter2] = 0;
}
}
DCT();
ofstream a_file("DCT.txt");
for (counter = 0; counter < 16; counter++)
{
for (counter2 = 0; counter2 < 16; counter2++)
{
a_file<<DCTmatrix[counter][counter2];
}
}
system("PAUSE");
return 0;
}
SirDavidGuy is offline   Reply With Quote
Old 23-07-2002   #2 (permalink)
Moderator
 
Truman's Avatar
 
Join Date: Apr 2001
Location: London, UK
Posts: 539
I'm a bit rusty on C/C++, but my suggestion is that the fstream is implemented differently on many compilers - maybe this is causing problems. Try using the fopen, fwrite and fclose instead:

#include <math.h>
#include <stdio.h>
//#include <fstream.h>
#define pi 3.14159

unsigned long int N = 16; //The size of the block the DCT is performed on
int Pixel[16][16];
long int DCTmatrix[16][16];

float Cosines(int x, int pixelnum)
{
float y = (2*x+1)*pixelnum*pi/(2*N);
return y;
}
void DCT()
{
unsigned long int j;
unsigned long int i;
unsigned long int x;
unsigned long int y;
long int temprounded;
float temp;
for (i = 0; i < N; i++)
{
for (j = 0; j < N; j++)
{
temp = 0;
for (x = 0; x < N; x++)
{
for (y = 0; y < N; y++)
{
temp = temp+Cosines(x, i)* Cosines(y, j)*Pixel[x][y];
}
}
}
temp = temp * sqrt (2 * N);
temprounded = temp;
DCTmatrix[i][j] = temprounded;
}
}

int main()
{
int counter;
int counter2;
for (counter = 0; counter < 16; counter++)
{
for (counter2 = 0; counter2 < 16; counter2++)
{
Pixel[counter][counter2] = 0;
}
}
DCT();
FILE *fp = fopen("DCT.txt", "w");
//ofstream a_file("DCT.txt");
for (counter = 0; counter < 16; counter++)
{
for (counter2 = 0; counter2 < 16; counter2++)
{
fwrite(&(DCTmatrix[counter][counter2]), 1, 1, fp);
//a_file<<DCTmatrix[counter][counter2];
}
}
fclose(fp);
//system("PAUSE");
return 0;
}
Truman is offline   Reply With Quote
Old 23-07-2002   #3 (permalink)
CDFreaks Resident
 
Join Date: May 2002
Location: Germany
Posts: 4,613
What line does the first error point at?
__________________
Asus P4C800E-Deluxe, Win XP, P4/2800 HT, 2048 MB RAM, 600 GB HDD, Plextor PX712/716/755/Premium, LG 4120B, Pioneer A08, Pioneer A09, NEC ND-3540A/4550A
------------------------------------------------
If at first you don't succeed, redefine success!
How a troll wants to force users of Linux to buy Windows just to make use of Plextor DVD writer unique functions
------------------------------------------------
PxScan/PxView (compatible to Premium, PX-712, PX-714, PX-716), now with built-in picture file output
Bitsetting via Autostart
My Blog about DADVSI (new french copyright)
alexnoe is offline   Reply With Quote
Old 23-07-2002   #4 (permalink)
CDFreaks Resident
 
SirDavidGuy's Avatar
 
Join Date: Nov 2001
Posts: 1,467
Quote:
Originally posted by alexnoe
What line does the first error point at?
First Line:

31 c:\dev-c_~1\include\g__~1\iostream.h
from C:\DEV-C_~1\INCLUDE\G__~1\fstream.h:30,

Second Line:

6 c:/windows/desktop/dct.c
C:\DEV-C_~1\INCLUDE\G__~1\streambuf.h:35: parse error before string constant
SirDavidGuy is offline   Reply With Quote
Old 23-07-2002   #5 (permalink)
CDFreaks Resident
 
SirDavidGuy's Avatar
 
Join Date: Nov 2001
Posts: 1,467
I solved it... I don't know how, but I solved it.

I first switched the compilation type from C++ to C.

Then I switched it back to C++.

Maybe the compiler was accidentaly trying to compile it as a C program and not a C++ program...
SirDavidGuy is offline   Reply With Quote
Old 23-07-2002   #6 (permalink)
CDFreaks Resident
 
SirDavidGuy's Avatar
 
Join Date: Nov 2001
Posts: 1,467
Well, another problem...

Now the program outputs nonsense...

eg... A matrix that doesn't correspond to the input...

I'll try and work it out, I suppose.
SirDavidGuy is offline   Reply With Quote
 
Reply


If you can't find where you are looking for, then become a member and get an answer fast! We have thousands of people online every moment of the day to help you! Click here



Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Suggestion to improve automatic splitting algorithm FordMan DVDFab / DVD Region+CSS Free 2 25-09-2007 14:32
DVD EDC algorithm in C. anyone? xt5 Optical Storage Technical Discussions 2 01-06-2006 01:32
Google Mistake - or is it a mistake? rfjr23 CD Freaks Living Room 11 04-11-2005 16:20
Datawrite 8x - £5.99 per 50 at SVP. Am I making a mistake? Johntea Blank Media 14 30-07-2005 17:37
New Sector Patching Algorithm! SirDavidGuy Optical Storage Technical Discussions 67 23-02-2003 13:57


All times are GMT +2. The time now is 01:29.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0