[FFmpeg-devel] [PATCH] Add the function libavcodec/utils.c:avcodec_type_string
Stefano Sabatini
stefano.sabatini-lala
Wed Nov 21 09:58:35 CET 2007
On date Monday 2007-11-12 09:53:39 +0100, Stefano Sabatini encoded:
> On date Friday 2007-11-09 15:26:22 +0100, Stefano Sabatini encoded:
> > On date Friday 2007-11-09 11:34:25 +0100, Stefano Sabatini encoded:
> > > On date Friday 2007-11-09 09:00:05 +0000, M?ns Rullg?rd encoded:
> > [...]
> > > > Why don't you declare the argument as type CodecType? That should
> > > > make it abundantly clear what is expected.
> > > >
> > > > Also, why do you use snprintf() here, when av_strlcpy() would do just
> > > > as well, or even simply returning the string constants.
> > > [...]
> > >
> > > Yes, it looks like a simpler solution, which I prefer over the
> > > previous ones.
>
> Ping (resubmitting in the case it gets unnoticed).
>
> Best regards.
[...]
> Index: libavcodec/avcodec.h
> ===================================================================
> --- libavcodec/avcodec.h (revision 10968)
> +++ libavcodec/avcodec.h (working copy)
> @@ -33,8 +33,8 @@
> #define AV_STRINGIFY(s) AV_TOSTRING(s)
> #define AV_TOSTRING(s) #s
>
> -#define LIBAVCODEC_VERSION_INT ((51<<16)+(48<<8)+0)
> -#define LIBAVCODEC_VERSION 51.48.0
> +#define LIBAVCODEC_VERSION_INT ((51<<16)+(49<<8)+0)
> +#define LIBAVCODEC_VERSION 51.49.0
> #define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT
>
> #define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
> @@ -2477,6 +2477,16 @@
> void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
>
> /**
> + * Return a string corresponding to the codec type \p codec_type.
> + *
> + * @param codec_type[in] Codec type, currently supported are:
> + * CODEC_TYPE_VIDEO, CODEC_TYPE_AUDIO, CODEC_TYPE_DATA,
> + * CODEC_TYPE_SUBTITLE.
> + * @return Pointer to a static string representing the codec type.
> + */
> +const char *avcodec_type_string (enum CodecType codec_type);
> +
> +/**
> * Sets the fields of the given AVCodecContext to default values.
> *
> * @param s The AVCodecContext of which the fields should be set to default values.
> Index: libavcodec/utils.c
> ===================================================================
> --- libavcodec/utils.c (revision 10968)
> +++ libavcodec/utils.c (working copy)
> @@ -1230,6 +1230,21 @@
> }
> }
>
> +static const char *codec_type_strings[] = {
> + [CODEC_TYPE_VIDEO] = "video",
> + [CODEC_TYPE_AUDIO] = "audio",
> + [CODEC_TYPE_DATA] = "data",
> + [CODEC_TYPE_SUBTITLE] = "subtitle",
> + [CODEC_TYPE_NB] = "unknown"
> +};
> +
> +const char *avcodec_type_string (enum CodecType codec_type)
> +{
> + if ((unsigned)codec_type>CODEC_TYPE_NB)
> + codec_type = CODEC_TYPE_NB;
> + return codec_type_strings[codec_type];
> +}
> +
> unsigned avcodec_version( void )
> {
> return LIBAVCODEC_VERSION_INT;
Sorry for replying to myself, rereading avcodec.h I see these
semantically correlated functions:
void avcodec_pix_fmt_string (char *buf, int buf_size, int pix_fmt);
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
The function I'd like to add seems to belong to this group instead:
const char *avcodec_get_pix_fmt_name(int pix_fmt);
char av_get_pict_type_char(int pict_type);
so it could be:
const char *avcodec_get_type_name(int codec_type);
or
const char *avcodec_get_type_string(int codec_type);
New patch corresponds to the avcodec_get_type_name() solution.
Best regards.
--
Stefano Sabatini
Linux user number 337176 (see http://counter.li.org)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: add-avcodec-type-string-function-06.patch
Type: text/x-diff
Size: 1915 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20071121/64b99c12/attachment.patch>
More information about the ffmpeg-devel
mailing list