[FFmpeg-devel] [RFC] WC3 decoder without AVPaletteControl
Michael Niedermayer
michaelni
Wed Apr 15 20:47:24 CEST 2009
On Wed, Apr 15, 2009 at 05:29:14PM +0200, Reimar D?ffinger wrote:
> On Wed, Apr 15, 2009 at 04:17:24PM +0200, Michael Niedermayer wrote:
> > On Sun, Apr 12, 2009 at 01:26:33PM +0200, Reimar D?ffinger wrote:
> > > +int av_grow_packet(AVPacket *pkt, int grow_by)
> > > +{
> > > + void *new_ptr;
> >
> > > + if (!grow_by)
> > > + return 0;
> >
> > for what is that good for?
>
> Avoiding a pointless realloc in case someone does something stupid like
> av_grow_packet(pkt, 0);
people should not do such stupid things
>
> > > + 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 ;)
>
> Hm. Bad "documentation", I hadn't decided what grow_by < 0 is supposed to
> mean or if I should just make it unsigned (the latter I admit would not
> help here).
> So
> > if (grow_by < 0 || pkt->size + FF_INPUT_BUFFER_PADDING_SIZE > INT_MAX - grow_by)
> good enough?
> I also assumed that pkt->size + FF_INPUT_BUFFER_PADDING_SIZE would not
> overflow since the allocated buffer must already be that big, if you
> dislike that.
maybe
(unsigned)grow_by > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE
|| pkt->size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE - grow_by
?
>
> > > 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 ?
>
> Yes, but it only allocates a new packet then. av_get_packet also sets
> pkt->pos. Sure, maybe a bit overkill for a single assignment, just
> thought it might be more future-proof.
well, fine leave that then
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090415/73ad0ff4/attachment.pgp>
More information about the ffmpeg-devel
mailing list