[FFmpeg-devel] [PATCH] h264 bitstream filter

Michael Niedermayer michaelni
Mon Sep 3 13:04:02 CEST 2007


Hi

On Mon, Sep 03, 2007 at 09:43:15AM +0200, Benoit Fouet wrote:
> Hi,
> 
> Michael Niedermayer wrote:
> > Hi
> >
> > On Fri, Aug 31, 2007 at 12:31:59PM +0200, Benoit Fouet wrote:
> >   
> >> +    if (!ctx->sps_pps_data) {
> >> +        uint16_t unit_size;
> >> +        uint32_t total_size = 0;
> >> +        uint8_t *out = NULL, unit_nb, sps_done = 0;
> >> +        const uint8_t *extradata = avctx->extradata+4;
> >> +        static const uint8_t nalu_header[4] = {0, 0, 0, 1};
> >> +
> >> +        /* retrieve length coded size */
> >> +        ctx->length_size = (*extradata++ & 0x03) + 1;
> >> +
> >> +        /* retrieve sps and pps unit(s) */
> >> +        unit_nb = *extradata++ & 0x1f; /* number of sps unit(s) */
> >> +        if (!unit_nb) {
> >> +            unit_nb = *extradata++; /* number of pps unit(s) */
> >> +            sps_done++;
> >> +        }
> >> +        while (unit_nb--) {
> >> +            unit_size = AV_RB16(extradata);
> >> +            total_size += unit_size+4;
> >> +            if (extradata+2+unit_size > avctx->extradata+avctx->extradata_size) {
> >> +                av_free(out);
> >> +                return -1;
> >> +            }
> >> +            out = av_realloc(out, total_size);
> >> +            memcpy(out+total_size-unit_size-4, nalu_header, 4);
> >>     
> >
> > out==NULL should be checked as we dont start writing at out but later
> > theres a small risk that this could be exploitable
> >
> >   
> 
> ok
> btw, how is this memory freed (if it is) ?
> as there is no close function, i guess i'll have to alloc / free sps &
> pps at each filter call, no ?
> if it is so, would it be acceptable to change AVBitStreamFilter
> structure to add such a function ?

yes, feel free to add a close function (in a seperate commit of course)


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

Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato 
-------------- 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/20070903/acdfa79c/attachment.pgp>



More information about the ffmpeg-devel mailing list