On Wed, Apr 15, 2009 at 02:40:43PM +0200, Reimar D?ffinger wrote:
On Wed, Apr 15, 2009 at 02:06:55PM +0200, Michael Niedermayer wrote:
i never felt the need for a grow or append packet function when thinking about palettes
Well, the problem is that at least for some formats the palettes are stored apart from the frame data, so at least you have to store them until you have the video data. Now add to that that some formats allow an "arbitrary" number of palettes or other "opcodes" that operate on the palette that you all need to merge into one AVPacket, and you must set the position to that of the first part so you can merge them all together, if possible handling read/malloc errors at least somewhat sensibly and consistently it seemed like the best approach to do it.
If you had a look at the CDXL demuxer I think the issue is similar: you have a header which contains the size of video and palette packets and some other information the decoder needs anyway. You can either manually write the information the decoder needs into a manually allocated AVPacket, hoping someone will notice the missing integer overflow check, or you just read the header via av_get_packet, extract the sizes, and use av_append_packet to have a full video packet with all the info necessary.
realloc() is not free, it needs time and i dont like doing 1 realloc call per packet if it can be avoided. and someone working with demuxers or decoders needs to understand the issues with integer overflows IMHO [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Those who are too smart to engage in politics are punished by being governed by those who are dumber. -- Plato