Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CreateFile & ReadFile Questions

Status
Not open for further replies.

azntekkan

Programmer
Jun 5, 2003
10
CA
Hi, i'm currently using the CreateFile and ReadFile functions in my program. I need to read in large chunks of data really fast. But i'm having some trouble with the functions.

Code:
videoYUV=CreateFile("C:\\Documents and Settings\\mliu\\Desktop\\YUVPLAYER\\pond.yuv", GENERIC_READ, FILE_SHARE_READ,NULL, OPEN_EXISTING,  FILE_ATTRIBUTE_NORMAL|FILE_FLAG_NO_BUFFERING ,NULL);  


	for(int k=0;k<5;k++)
	{
		ReadFile(videoYUV,YP[k],518400*2,&bytesread,&gOverLapped);
		
		gOverLapped.Offset+=518400*2;
	}

I'm currently using the FILE_FLAG_NO_BUFFERING, because i need the speed.

The problem is that the readFile only works if i read in exactly 518400*2 bytes, any less the function fails.

I need this value to be dynamic, i.e i'm reading in frames, each frame is width*height*1.5 bytes.

If anyone who is fimilar with these functions could help me out or suggest another function of would be greatly appreciated.
 
for(int k=0;k<5;k++)
{
ReadFile(videoYUV,YP[k],518400*2,&bytesread,NULL);

gOverLapped.Offset+=518400*2;
}
 
>> readFile only works if i read in exactly 518400*2
>> bytes, any less the function fails.

There is no such limitation of ReadFile(), please clarify the function fails, that does not tell us anything.


-pete
 
Hey, Sorry if I was unclear, but i have fixed my error. It turns out if i set the no buffer flag i can only use increments of 512(harddrive sector size). Thanks for all the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top