On Sun, Apr 12, 2009 at 01:26:33PM +0200, Reimar D?ffinger wrote:
On Sun, Apr 12, 2009 at 12:19:07AM +0200, Reimar D?ffinger wrote:
attached patch implements this. It is a bit ugly because it adds a lot of seeking to the demuxer, but I think for such a fringe format there is no point in extra work for avoiding it. The patch also adds two helper functions, one to increase the size of a packet and one that appends data read from a file to a possibly already filled packet. I expect that there will be more that a few bugs still, e.g. while the video looks visually ok in ffplay the FATE regressions do not match at all.
A minor update. It only fixes the gamma correction and provides a fixed point integer-implementation, which might help explain some of its weirdness like clipping to 253.
[...]
Index: libavcodec/avcodec.h =================================================================== --- libavcodec/avcodec.h (revision 18467) +++ libavcodec/avcodec.h (working copy) @@ -2666,6 +2666,14 @@ void av_shrink_packet(AVPacket *pkt, int size);
/** + * Increase packet size, correctly zeroing padding + * + * @param pkt packet + * @param grow_by number of bytes by which to increase the size of the packet + */ +int av_grow_packet(AVPacket *pkt, int grow_by); + +/** * @warning This is a hack - the packet memory allocation stuff is broken. The * packet is allocated if it was not really allocated. */ Index: libavcodec/avpacket.c =================================================================== --- libavcodec/avpacket.c (revision 18467) +++ libavcodec/avpacket.c (working copy) @@ -69,6 +69,24 @@ memset(pkt->data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); }
+int av_grow_packet(AVPacket *pkt, int grow_by) +{ + void *new_ptr;
+ if (!grow_by) + return 0;
for what is that good for?
+ if (!pkt->size) + return av_new_packet(pkt, grow_by);
+ if (pkt->size + FF_INPUT_BUFFER_PADDING_SIZE > INT_MAX - grow_by) + return -1;
could you write this in a way that is free of overflows please ;) [...]
Index: libavformat/utils.c =================================================================== --- libavformat/utils.c (revision 18467) +++ libavformat/utils.c (working copy) @@ -277,6 +277,20 @@ return ret; }
+int av_append_packet(ByteIOContext *s, AVPacket *pkt, int size) +{ + int ret; + int old_size; + if (!pkt->size) + return av_get_packet(s, pkt, size); + old_size = pkt->size; + ret = av_grow_packet(pkt, size);
isnt av_grow_packet already checking for pkt->size==0 ? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I do not agree with what you have to say, but I'll defend to the death your right to say it. -- Voltaire