[FFmpeg-devel] [PATCH 03/11] Implement av_get_codec_tag_string() and use it in ffprobe.
Stefano Sabatini
stefano.sabatini-lala
Sun May 23 14:07:16 CEST 2010
On date Sunday 2010-05-23 11:19:31 +0200, Michael Niedermayer encoded:
> On Sat, May 22, 2010 at 05:58:07PM +0200, Stefano Sabatini wrote:
> > ---
> [...]
> > --- a/libavcodec/avcodec.h
> > +++ b/libavcodec/avcodec.h
> > @@ -3088,6 +3088,15 @@ attribute_deprecated enum PixelFormat avcodec_get_pix_fmt(const char* name);
> > */
> > unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat pix_fmt);
> >
> > +/**
> > + * Returns a string representing a codec tag, NULL if the codec_tag is
> > + * unknown.
> > + *
>
> > + * @param buf buffer with size buf_size where the function puts the
> > + * codec tag string
>
> doesnt match code
I changed the signature, now it is inspired upon that of snprintf().
> > + */
> > +const char *av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag);
> > +
> > #define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */
> > #define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */
> > #define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */
> > diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> > index 56d4dbd..8d8826a 100644
> > --- a/libavcodec/utils.c
> > +++ b/libavcodec/utils.c
> > @@ -798,6 +798,22 @@ static int get_bit_rate(AVCodecContext *ctx)
> > return bit_rate;
> > }
> >
> > +const char *av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag)
>
> const?
Fixed.
> > +{
> > + int i, fourcc[4];
> > + fourcc[0] = codec_tag & 0xff;
> > + fourcc[1] = codec_tag>>8 & 0xff;
> > + fourcc[2] = codec_tag>>16 & 0xff;
> > + fourcc[3] = codec_tag>>24 & 0xff;
> > +
> > + buf[0] = 0;
> > + for (i = 0; i < 4; i++) {
> > + if (isprint(fourcc[i])) av_strlcatf(buf, buf_size, "%c" , fourcc[i]);
> > + else av_strlcatf(buf, buf_size, "[%d]", fourcc[i]);
>
> snprintf()
>
> codec_tag&0xFF
> codec_tag>>=8;
Yes.
Please check again the updated patch, regards.
--
FFmpeg = Fantastic and Fabulous Martial Power Elegant Game
More information about the ffmpeg-devel
mailing list