[FFmpeg-devel] [PATCH] ffserver: Use avcodec_copy_context instead of manually copying a context

Martin Storsjö martin
Tue Jun 22 08:45:32 CEST 2010


On Mon, 21 Jun 2010, Baptiste Coudurier wrote:

> On 6/21/10 1:40 AM, Martin Storsj? wrote:
> > Hi,
> > 
> > This makes ffserver use avcodec_copy_context at once place instead of
> > manually memcpying it and copying extradata separately. This fixes an
> > issue where rc_eq in the copy pointed to a string owned by the source
> > AVCodecContext, and which was later free'd when the original context was
> > closed.
> > 
> > // Martin
> > 
> > 
> > 0001-ffserver-Use-avcodec_copy_context-instead-of-manuall.patch
> > 
> > 
> >  From b36d7df28a9d4a2d7eccbcf52375ba461b3d93d4 Mon Sep 17 00:00:00 2001
> > From: Martin Storsjo<martin at martin.st>
> > Date: Mon, 21 Jun 2010 10:47:59 +0300
> > Subject: [PATCH] ffserver: Use avcodec_copy_context instead of manually
> > copying an AVCodecContext
> > 
> > ---
> >   ffserver.c |    9 +--------
> >   1 files changed, 1 insertions(+), 8 deletions(-)
> > 
> > diff --git a/ffserver.c b/ffserver.c
> > index 31d0268..14141f7 100644
> > --- a/ffserver.c
> > +++ b/ffserver.c
> > @@ -2748,14 +2748,7 @@ static int http_receive_data(HTTPContext *c)
> >               for (i = 0; i<  s->nb_streams; i++) {
> >                   AVStream *fst = feed->streams[i];
> >                   AVStream *st = s->streams[i];
> > -                memcpy(fst->codec, st->codec, sizeof(AVCodecContext));
> > -                if (fst->codec->extradata_size) {
> > -                    fst->codec->extradata =
> > av_malloc(fst->codec->extradata_size);
> > -                    if (!fst->codec->extradata)
> > -                        goto fail;
> > -                    memcpy(fst->codec->extradata, st->codec->extradata,
> > -                           fst->codec->extradata_size);
> > -                }
> > +                avcodec_copy_context(fst->codec, st->codec);
> >               }
> > 
> >               av_close_input_stream(s);
> > 
> > 
> 
> ok

Applied

// Martin



More information about the ffmpeg-devel mailing list