c - Fast data reading from CD-ROM -


I have to read a large file with several animation frames from CD / DVDR and display it in the form of an animation. When reading from a hard disk, the strategy of reading one frame in memory, processing, displaying and then reading the next frame is good, but when I read from optical device, the access timed out.

I use C and WinAPi OpenFile / ReadFile methods

How to read the contents of the file I stored on an optical device to get realtime motion of the animation? (I have seen a program which also does it in dual speed, to ensure that before the whole file does not buffer the animation starts)?

Two techniques:

  1. Large buffer or cache, As in multiple MBs there is a proper sequential I / O in the CD / DVD, but very slow looking / access speed (as you have noted), so refilling the buffer is faster than you just buffer Need to allow the disc to spin in a few seconds when it is enough, and look for a spin already.

  2. Multi-threading: Keep a thread continuous reading and separate thread decoding animation. The reader thread should be blocked if it is ahead of too far decoding.

These techniques apply to any programming language, and it can be added to the best effect, with a reading buffer and a decoded frame buffer, Along with decoding time and save time.

Edit: These techniques are using MPlayer In addition, you should consider your encoding format if you can - decoding for less data to read from disk But different formats can separate CPU time.

  • Read speed for 1x CD-ROM: 150 kb / s (minimum minimum speed)
  • Read speed 4x CD-ROM: 600 kb / s (standard minimum drive) )
  • Read speed 16x CD-ROM: 1600 KB / s (Maximum receivable, usually only up to 8x)
  • Compressed standard definition video with MPEG 2 on DDD quality: ~ 600 KB / s
  • The standard definition video is compressed on DVD quality with MPEG4: ~ 100KB / s
  • Uncompressed standard definition Video: ~ 30 MB / s
  • Standard 1000x1000 (1 megapixel) image in 24 bit color: 3 MB
  • On standard 1 megapixel image 8-bit color (grayscale): 1 MB
  • Edit 2: Additional Information

    • Note that DVDs can usually be read 8x if your drive It supports (mostly now).
    • Animations look smooth on 24 + frames / second, below they will see the audience jerky.
    • Loss compression is usually good for a 50% reduction in size for photographic images. Although your mileage might vary.
    • The smooth playback of the animation will be partly dependent on how you talk to the video hardware. Some methods will provide better results than others. I highly recommend that you see the code for MPlayer in this case.

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -