[FFmpeg-devel] [PATCH] imx/d-10 remove klv bitstream filter

Michael Niedermayer michaelni
Fri May 15 23:15:10 CEST 2009


On Sun, May 10, 2009 at 06:37:01PM -0700, Baptiste Coudurier wrote:
> Hi Michael,
> 
> On 5/10/2009 6:07 PM, Michael Niedermayer wrote:
> > On Sat, May 09, 2009 at 07:33:46PM -0700, Baptiste Coudurier wrote:
> >> Hi,
> >>
> >> $subject, and remove the check for d-10 in mpeg2 decoder which will no
> >> longer be needed.
> >>
> >> [...]
> >>
> >> +
> >> +    if (!memcmp(buf, d10_klv_header, 15)) {
> >> +        int64_t frame_size;
> >> +        bufp += 16;
> >> +        if ((frame_size = klv_decode_ber_length(&bufp)) < 0) {
> >> +            av_log(avctx, AV_LOG_ERROR, "error decoding klv length\n");
> >> +            return -1;
> >> +        }
> >> +        if (bufp - buf + frame_size > buf_size) {
> >> +            av_log(avctx, AV_LOG_ERROR, "wrong frame size\n");
> >> +            return -1;
> >> +        }
> >> +        *poutbuf = av_malloc(frame_size);
> >> +        if (!*poutbuf)
> >> +            return AVERROR(ENOMEM);
> >> +        memcpy(*poutbuf, bufp, frame_size);
> > 
> > frame_size is int64_t, av_malloc() takes unsigned int and memcpy takes
> > size_t
> > this is a risky combination i think if int64_t does not fit in int but
> > in size_t
> > av_malloc*() really should take size_t as well
> 
> Added a check for frame_size.
> 

> > also we should maybe extend the API so that a bitstream filter knows
> > if it can saftely change the content of the input buffer and thus avoid
> > a malloc&copy
> 
> Sure.

AVBitStreamFilter could contain a flag that says that it needs to modify the
buffer. With that the memcpy if needed would be outside the filters,
simplifing them

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No great genius has ever existed without some touch of madness. -- Aristotle
-------------- 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/20090515/51b369a3/attachment.pgp>



More information about the ffmpeg-devel mailing list