[FFmpeg-devel] [PATCH 2/5] avformat/ffmdec: replace most codec uses by codecpar

Michael Niedermayer michael at niedermayer.cc
Sat Dec 3 14:31:18 EET 2016


On Sat, Dec 03, 2016 at 01:19:05AM +0100, Andreas Cadhalpun wrote:
> On 03.12.2016 00:52, Michael Niedermayer wrote:
> > This is a bit messy as codecar does not support AVOptions so we need
> > to use AVCodecContext where AVOptions are required and copy back and forth.
> > 
> > Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> > ---
> >  libavformat/ffmdec.c | 159 ++++++++++++++++++++++++++-------------------------
> >  1 file changed, 82 insertions(+), 77 deletions(-)
> > 
> > diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
> > index 9192bff507..25edeebb7e 100644
> > --- a/libavformat/ffmdec.c
> > +++ b/libavformat/ffmdec.c
> > @@ -250,11 +250,6 @@ static void adjust_write_index(AVFormatContext *s)
> >  
> >  static int ffm_close(AVFormatContext *s)
> >  {
> > -    int i;
> > -
> > -    for (i = 0; i < s->nb_streams; i++)
> > -        av_freep(&s->streams[i]->codec->rc_eq);
> > -
> >      return 0;
> >  }
> 
> Why not remove the entire function?
> 
> > @@ -514,9 +518,6 @@ static int ffm2_read_header(AVFormatContext *s)
> >          avio_seek(pb, next, SEEK_SET);
> >      }
> >  
> > -    for (i = 0; i < s->nb_streams; i++)
> > -        avcodec_parameters_from_context(s->streams[i]->codecpar, s->streams[i]->codec);
> > -
> 
> This loop is the only place the variable i is used, so please remove it's
> declaration, too.
> 
> > @@ -539,7 +542,8 @@ static int ffm_read_header(AVFormatContext *s)
> >      FFMContext *ffm = s->priv_data;
> >      AVStream *st;
> >      AVIOContext *pb = s->pb;
> > -    AVCodecContext *codec;
> > +    AVCodecContext *codec, *dummy_codec = NULL;
> > +    AVCodecParameters *codecpar;
> >      const AVCodecDescriptor *codec_desc;
> >      int i, nb_streams, ret;
> >      uint32_t tag;
> > @@ -562,6 +566,7 @@ static int ffm_read_header(AVFormatContext *s)
> >      } else {
> >          ffm->file_size = (UINT64_C(1) << 63) - 1;
> >      }
> > +    dummy_codec = avcodec_alloc_context3(NULL);
> >  
> >      nb_streams = avio_rb32(pb);
> >      avio_rb32(pb); /* total bitrate */
> > @@ -577,31 +582,31 @@ static int ffm_read_header(AVFormatContext *s)
> >  
> >          codec = st->codec;
> 
> Here should be:
>            codecpar = st->codecpar;
> 
> >          /* generic info */
> > -        codec->codec_id = avio_rb32(pb);
> > -        codec_desc = avcodec_descriptor_get(codec->codec_id);
> > +        codecpar->codec_id = avio_rb32(pb);
> 
> Otherwise codecpar is uninitialized here.

all done locally, some of this code is btw not tested by fate

thx


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you fake or manipulate statistics in a paper in physics you will never
get a job again.
If you fake or manipulate statistics in a paper in medicin you will get
a job for life at the pharma industry.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20161203/faf4d1c6/attachment.sig>


More information about the ffmpeg-devel mailing list