Re: Decoding B and P frames
Stephan Assmus <[email protected]>
| Newsgroups | gmane.comp.video.xvid.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, reno reballos wrote: > another thing i want to ask if you know about this with regards to > decoding a compressed frame. why decoder could not decode them one time? > i mean decoder will have to execute again to decode the remaining > compressed frame... what is the reason behind...? Ah, I think I may know what the problem is: This has been discussed here very recently: The decoder needs to be fed with complete frames, which is normally taken care of when the stream is embedded into an AVI container for example. So in your case, I assume you are dealing with the raw xvid stream and read fixed size buffers. I believe the frames inside the stream are arbitrarily broken up by the fixed buffer sizes and that is your problem. You need to embed "markers" into the stream. I mean, the stream already contains MPEG4 markers for frames, but it will be easier if you write some markers yourself. For example, you could write the size of the next chunk of encoded data. Right now, I assume you do the following: 1) encode a frame 2) write encoded data to disk 3) goto 1) while frames are left Replace this with this: 1) encode a frame 2) write a 32 bit value with the size of the encoded data to disk 3) write encoded data to disk 4) goto 1) while frames are left Your decoding loop probably looks like this: 1) read fixed size buffer of data from disk 2) feed data into decoder 3) goto 1) while not yet encoded a frame 4) display frame 5) goto 1) while data left Replace this with this: 1) read 32 bit value from disk 2) create buffer with that size 3) read entire buffer from disk 4) feed data into decoder 5) goto 1) while not yet encoded a frame 6) display frame 7) goto 1) while data left This way, you simulate the buffers with chunk size which you would get from containers like AVI. Note that 5) is still necessary! Hoping my guess is right at what your problem is and also hoping this makes it clear what I envision for a solution. Best regards, -Stephan