[FFmpeg-devel] [PATCH v2 1/6] lavc: add new API for iterating codecs and codec parsers

wm4 nfxjfg at googlemail.com
Wed Jan 3 18:54:12 EET 2018


On Wed, 3 Jan 2018 16:50:00 +0000
Rostislav Pehlivanov <atomnuker at gmail.com> wrote:

> On 3 January 2018 at 15:25, wm4 <nfxjfg at googlemail.com> wrote:
> 
> > On Wed, 3 Jan 2018 00:42:36 +0000
> > Josh de Kock <josh at itanimul.li> wrote:
> >  

> > > +static AVCodec *find_codec_by_name(const char *name, int (*x)(const  
> > AVCodec *))  
> > > +{
> > > +    void *i = 0;
> > > +    const AVCodec *p;
> > > +
> > > +    if (!name)
> > > +        return NULL;
> > > +
> > > +    while ((p = av_codec_iterate(&i))) {
> > > +        if (!x(p))
> > > +            continue;
> > > +        if (strcmp(name, p->name) == 0)
> > > +            return (AVCodec*)p;
> > > +    }
> > > +
> > > +    return NULL;
> > > +}
> > > +
> > > +AVCodec *avcodec_find_encoder_by_name(const char *name)
> > > +{
> > > +    return find_codec_by_name(name, av_codec_is_encoder);
> > > +}
> > > +
> > > +AVCodec *avcodec_find_decoder_by_name(const char *name)
> > > +{
> > > +    return find_codec_by_name(name, av_codec_is_decoder);
> > >  }  
> >
> > Personally I'd argue a bool parameter or so to select encoders vs.
> > decoders would be less roudnabout (like it was before), but I have no
> > strong opinion. Could be considered an improvement as well.
> >
> >  
> I think separate functions would be better in this case.

My comment was just about how find_codec_by_name() is called. Certainly
we don't want to duplicate the actual code.


More information about the ffmpeg-devel mailing list