Page 1 of 1

Allocating huge memory

Posted: Sun Mar 21, 2004 1:27 pm
by Ozguxxx
Hi, in c++ I am blindly used to malloc and I am definitely unaware of win32 api and its superior memory management functions, now I need to have some more functionality. Can somebody tell me how these mp3 players or video players allocate that much memory? I mean for instance when you watch a movie with windows media player you are unaware of memory loading stuff, how can windows media player load these 100s of mbytes of movie and does not give a sign of insufficient memory? Only one thing that comes to my mind to solve this problem is by simply dividing movie file into parts and then load each part time by time? But that cannot be really a case since movie file is an encoded file that cannot be decoded part by part... Anyway, can that be a way to handle this situation? Any guru or non guru ideas are welcome.

Re:Allocating huge memory

Posted: Sun Mar 21, 2004 4:04 pm
by Tim
An audio or video player only needs to load a small portion of the file into memory at once, enough to keep the sound card buffers full (for audio) or one frame (for video). So it's enough to have a loop which reads data from the file, then sends it to the sound card/screen.

Re:Allocating huge memory

Posted: Sun Mar 21, 2004 11:43 pm
by Schol-R-LEA
Ozgunh82 wrote:Only one thing that comes to my mind to solve this problem is by simply dividing movie file into parts and then load each part time by time? But that cannot be really a case since movie file is an encoded file that cannot be decoded part by part...
Actually, most practical audio or motion-video formats can be decoded from a partial file image; otherwise, streaming would be impossible.

Re:Allocating huge memory

Posted: Mon Mar 22, 2004 4:58 am
by Ozguxxx
Well I understand that files can should be divided into parts so that streaming can be done but I meant that you need to divide the file at correct positions so that decoding can be done, anyway... You can actually have one frame in video memory but then loading the frames becomes a very time critical task I mean playing a video is a real time task (a soft one) so for getting a good frames/sec (min of 25) your decoder should be able to stabilize the byte stream from file and also should be able to handle the very huge computational load of decoding the file. Well I think the trick is not using good memory functions but making use of capable devices like mmx fpu, directx video drivers and etc. so that we do not load all load on cpu.

Re:Allocating huge memory

Posted: Mon Mar 22, 2004 5:07 am
by Candy
Schol-R-LEA wrote: Actually, most practical audio or motion-video formats can be decoded from a partial file image; otherwise, streaming would be impossible.
Nearly impossible. A 640*480*24-bit stream at 25 fps is 200mbit/s which CAN be done over GBIT ethernet. It's not efficient though :).

Re:Allocating huge memory

Posted: Mon Mar 22, 2004 7:10 am
by Ozguxxx
Hi,
[electrical engineer]
Well, firstly the length of bits needed to dcode a frame is not always (in fact in an mpeg is nearly never) 640x480x24, I am not talking about 640x480 size but the theory of coding is solely based on decreasing bit-rate of data so that we can both decrease its size and also decrease the needed bit rate (or speed) to decode the data. In jpeg 1:20-30 compression is possible by some quality sacrifice and mpeg which is some more efficient by getting rid of interframe redundancy compresses much better than jpeg or mjpeg. So that we do not really need a gbit ethernet link to watch movies on computer. :)
[/electrical engineer]

Re:Allocating huge memory

Posted: Tue Mar 23, 2004 2:18 am
by bubach
movies are often like: 300x300 or something in 100% size. but u can enlarge them to full screen..