C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 4th, 2003, 10:10 AM
azntekkan azntekkan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 6 azntekkan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Reading in Files HELP!!!!

Hi, I am currently using hmmio to read in data for a multimedia player. When I run my program is starts off fast but then starts to slow down. I pin pointed the problem to the part where i read in the data. I read in about 15 megs at a time, about 30 frames.

It starts off at about 500ms per read but then slowly goes to an occsillating effect where it takes 500 ms to read then it takes 4 sec to read and so on. Does anyone know why this is happening? here is my code(short version)

char * fileBuffer=(char *)malloc(15552000);
byte* YP=(char *)malloc(15552000);

/****other stuff****/

void OpenFile()
{
hmmio = mmioOpen("C:\\Documents and Settings\\mliu\\Desktop\\YUVPLAYER\\pond.yuv", NULL, MMIO_READ );

mmioSetBuffer(hmmio,fileBuffer,15552000,0);

mmioRead(hmmio,(char *)YP,15552000);
}

//***calculation and direct draw functions ****//

Reply With Quote
  #2  
Old June 4th, 2003, 12:32 PM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,966 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 52 m 24 sec
Reputation Power: 189
You want to read15 megs in 500ms, i.e. 30MB/s constantly. What media are you reading from?
If it is a single hard disk, the difference in speed is probably due to fragmentation of the file. It would also be affected by
- Hard disk cache
- Controller cache
- OS cache / efficiency of this
- available memory / swapping / memory fragmentation
- interrupt sharing between the controller and another card that is frequently accessed (common: graphics card)
- driver efficiency / bugs
- [ ... ]

I donīt know these libraries you are using, but it looks like a Windows program - Windows was not made for high-performance apps like yours

Some tweaking in the OS settings could eliminate your problem, but maybe not...
__________________
--
Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more.

Reply With Quote
  #3  
Old June 4th, 2003, 12:56 PM
azntekkan azntekkan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 6 azntekkan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I'm reading in a video file in YUV 4:1:1 format. its about 300 megs for 600 frames. Its reading off a local harddrive(7200 rpm).

I have also tried using fread functions and ReadFile functions and they also resulted in the same problem.

I don't need to read at 30megs/s, I only need to read in at about 15meg/s(30 frames per sec). I know it can't be a hardware problem since a similar program developed by a software company can play this file smoothly.

Please help me out and let me know there is any way to stablize to read in.

Last edited by azntekkan : June 4th, 2003 at 12:59 PM.

Reply With Quote
  #4  
Old June 5th, 2003, 03:54 PM
azntekkan azntekkan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 6 azntekkan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Problem Fixed, for anyone who cares or has the same problem. Use CreateFile instead of hmmio. The when using ReadFile specify
dwFlagsAndAttributes as FILE_FLAG_NO_BUFFERING and FILE_FLAG_OVERLAPPED. That will make it much faster and stable.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Reading in Files HELP!!!!

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap