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

Michael Niedermayer michaelni
Mon May 24 23:16:22 CEST 2010


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

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Everything should be made as simple as possible, but not simpler.
-- Albert Einstein
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100524/a4d5b4c2/attachment.pgp>



More information about the ffmpeg-devel mailing list