[FFmpeg-devel] [PATCH]Fix for issue694. Dirac A/V sync loss

Anuradha Suraparaju anuradha
Thu Dec 4 06:04:40 CET 2008


Hi, 

On Sat, 2008-11-29 at 02:44 +0100, Michael Niedermayer wrote:

[...]

> [...]
> > +    if ( next == -1) {
> > +        /* Found a possible frame start but not a frame end */
> > +        void *new_buffer = av_realloc (pc->buffer,
> > +                              pc->buffer_size + (*buf_size - pc->sync_offset));
> > +        pc->buffer = new_buffer;
> > +        memcpy (pc->buffer+pc->buffer_size, (*buf + pc->sync_offset),
> > +                *buf_size - pc->sync_offset);
> > +        pc->buffer_size += *buf_size - pc->sync_offset;
> > +        return -1;
> > +    } else {
> > +        /* Found a possible frame start and a  possible frame end */
> > +        DiracParseUnit pu1, pu;
> > +        void *new_buffer = av_realloc (pc->buffer, pc->buffer_size + next);
> > +        pc->buffer = new_buffer;
> > +        memcpy (pc->buffer + pc->buffer_size, *buf, next);
> 
> I would prefer if av_realloc() and or memcpy() could be avoided more often,
> if av_realloc() cant be avoided easily, then av_fast_realloc() could be
> considered as its quite a bit faster at least last time ive seen benchmarks
> of it
> 

Done. I've replaced av_realloc with av_fast_realloc.

> 
> [...]
> >  static int dirac_parse(AVCodecParserContext *s, AVCodecContext *avctx,
> >                         const uint8_t **poutbuf, int *poutbuf_size,
> >                         const uint8_t *buf, int buf_size)
> >  {
> > -    ParseContext *pc = s->priv_data;
> > +    DiracParseContext *pc = s->priv_data;
> >      int next;
> >  
> > +    *poutbuf = NULL;
> > +    *poutbuf_size = 0;
> > +
> >      if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
> >          next = buf_size;
> > -    }else{
> > +        *poutbuf = buf;
> > +        *poutbuf_size = buf_size;
> > +        /* Assume that data has been packetized into an encapsulation unit */
> > +    } else {
> >          next = find_frame_end(pc, buf, buf_size);
> > +        if (!pc->is_synced && next == -1) {
> > +            /* Did not find a frame start yet. So throw away the entire
> > +               buffer */
> > +            *poutbuf = NULL;
> > +            *poutbuf_size = 0;
> > +            return buf_size;
> > +        }
> >  
> > -        if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
> > +        if (dirac_combine_frame(s, avctx, next, &buf, &buf_size) < 0) {
> >              *poutbuf = NULL;
> >              *poutbuf_size = 0;
> 
> i think poutbuf / poutbuf_size are alraedy 0 here and above
> 

Fixed.

[...]

I've attached a new patch with the changes.

Regards,
Anuradha
-------------- next part --------------
A non-text attachment was scrubbed...
Name: issue694_libdirac_libschroedinger_svn_16001.diff
Type: text/x-patch
Size: 9702 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20081204/3c59bf2e/attachment.bin>



More information about the ffmpeg-devel mailing list