[FFmpeg-devel] [PATCH 03/11] Implement av_get_codec_tag_string() and use it in ffprobe.

Stefano Sabatini stefano.sabatini-lala
Wed May 26 01:11:23 CEST 2010


On date Monday 2010-05-24 23:16:22 +0200, Michael Niedermayer encoded:
> On Sun, May 23, 2010 at 06:22:08PM +0200, Stefano Sabatini wrote:
> > On date Sunday 2010-05-23 17:01:21 +0200, Michael Niedermayer encoded:
> > > On Sun, May 23, 2010 at 02:07:16PM +0200, Stefano Sabatini wrote:
> > [...]
> > > > diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> > > > index 56d4dbd..0daf331 100644
> > > > --- a/libavcodec/utils.c
> > > > +++ b/libavcodec/utils.c
> > > > @@ -798,6 +798,21 @@ static int get_bit_rate(AVCodecContext *ctx)
> > > >      return bit_rate;
> > > >  }
> > > >  
> > > > +int av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag)
> > > > +{
> > > > +    int i, len, ret = 0;
> > > > +
> > > > +    for (i = 0; i < 4; i++) {
> > > > +        const char *tmpl = isprint(codec_tag&0xFF) ? "%c" : "[%d]";
> > > > +        len = snprintf(buf, buf_size, tmpl, codec_tag&0xFF);
> > > > +        buf      += len;
> > > > +        buf_size  = len >= buf_size ? 0 : buf_size - len;
> > > > +        ret      += len;
> > > > +        codec_tag>>=8;
> > > > +    }
> > > 
> > > hmm, i see now av_strlcatf() would have been simpler, it wasnt my intent to
> > > complicate this
> > 
> > Anyway I think that to return the total required size is useful, so I
> > prefer this variant.
> 
> av_strlcatf() also returns the size

OK, indeed with it is much simpler.

Regards.
-- 
FFmpeg = Fierce Forgiving Maxi Pure Educated Game



More information about the ffmpeg-devel mailing list