Unhandled exception in .exe 0xC0000005 access violation

Hi all!
I'm trying to run this program, but at one point it crashes and gives me the following error:

Unhandled exception in VideoColorExtraction.exe 0xC0000005: access violation 


The error usually occurs when I get to the line:

while (feof(InFile)!=EOF)

Now I'll post the whole program:

VIDEO COLOR EXTRACTION main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
void main()
{
	
	H263Video OutVideo(300);
	VideoColourExtraction Test;
	int k=0,j=0,i=0;
	char* ptr;
	//char *INPUT_FILE;
	//char *OUT_PATH;
	const char *INPUT_FILE ="C:\\Test\\";
	const char *OUT_PATH="C:\\Test\\OutTest\\";   // L'errore è indipendente dal percorso scelto per i file, xk ank posto il percorso pari a "" continua a crashare!
	string headerIn(INPUT_FILE),fname,fpathIN,ext(".263");
	string headerOut(OUT_PATH),outfile,fpathOUT;
//////////////////////////////////////////////////////////////////////////////

	H263Video            Video(500); // BlackVideo(500);
	BitStream            InStream,OutStream;
	H263Decoder          Dec;
	H263Coder            Cod;

	clock_t start,end;
	
//  string fpathIN(INPUT_FILE);
//  string fpathOUT(OUT_PATH);

////////////// Inserimento Dati Da Input ///////////////////////////////////
	
	cout<<"Insert input file name (don't type .263 extension!!): ";
	cin>>fname;
	fpathIN=headerIn+fname+ext;
	
	cout<<"Insert output file name: ";
    cin>>outfile;
    fpathOUT=headerOut+outfile+ext;

//////////// Preparazione File In Ingresso  /////////////////////////////
	FILE *InFile;
	InFile=fopen(fpathIN.c_str(),"rb");

	   while (feof(InFile)!=EOF)   //// Il programma crasha qui..
	   {
		fread(InStream.CurrFrame(),sizeof(Word16),50,InFile);
		InStream.MoveNext();
		//InStream.AddFrame(Data.Ptr);
	   }

	fclose(InFile);

	InStream.BuildStream(20000,100,Stream_Def_TLen, Stream_Def_TStr);
	
//	string fpathIN(INPUT_FILE);
//	string fpathOUT(OUT_PATH);
	   
	Word16 low=0,up=0;
	
	MemoryBlock Data(100);

	FileClass fc(fpathIN.c_str());

	while (((low=fc.fp().get())!=EOF)){
	   
		   if((up=fc.fp().get())!=EOF)
		   {
			   
			   Data.Ptr[i]=(up<<8)|(low&0x00FF);
			   i++;
			   if(i==50){
				   //i=Data.Ptr[49];
				   InStream.AddFrame(Data.Ptr);
				   i=0;
				   }
		   }
		   else
			   break;
           
	}
//////////////////  Decodifica del InStream  /////////////////////////////////
	Dec.SetIn(&InStream);
	Dec.SetOut(&Video);
	Dec.Execute();
 /////////////////  Blocco di estrazione VideoColourExtraction   ///////////////
	Test.SetIn(&Video);
	Test.SetOut(&OutVideo);
	Test.MBAnalyse();
	OutVideo = Test.GetOut();
//////////////////////////   Codifica H263Codec  ////////////////////
	Cod.SetIn(&OutVideo);
	Cod.SetOut(&OutStream);
	Cod.Execute();
	OutStream=Cod.GetOut();
///////////////////////// Preparazione File In Uscita ////////////////////
    FILE *fp=fopen(fpathOUT.c_str(),"wb");


	 while(k<((OutStream.GetPos().FrameHandler))){

	 
		 fwrite(OutStream.GetFrameByHandler(k),1,1000,fp);
	     k++;
	 }

	 j=0;

	 ptr=(char*)OutStream.GetFrameByHandler(k);

	 while(j<((OutStream.GetPos().Position)+1))
	 {    
		 
	     fputc(*ptr,fp);

		  (*ptr++);
		  j++;
	 
	 }

	 fclose(fp);
////////////////////////////////////////////////////////////////////////////////
}


Now I know it's difficult to tell me exactly what is wrong, but could you give me some guidance, at least about what might generate? because even with debugging I can not fix it! : (
Thank you all :)
fread(InStream.CurrFrame(),sizeof(Word16),50,InFile);
¿what is `InStream.CurrFrame()' ? ¿does it have enough space?
closed account (Dy7SLyTq)
i think you are trying to access files that you need to be admin(windows) or root(linux) to use
Topic archived. No new replies allowed.