On 26/07/13 01:39, Josh Allmann wrote:
> From: Nicolas George <[email protected]>
>
> Useful for getting a codec name from its ID if the AVCodec is
> otherwise unavailable.
>
> Signed-off-by: Josh Allmann <[email protected]>
> ---
> doc/APIchanges | 3 +++
> libavcodec/avcodec.h | 6 ++++++
> libavcodec/utils.c | 20 ++++++++++++++++++++
> libavcodec/version.h | 2 +-
> 4 files changed, 30 insertions(+), 1 deletion(-)
>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index afececf..1e09437 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -13,6 +13,9 @@ libavutil: 2012-10-22
>
> API changes, most recent first:
>
> +2013-xx-xx - xxxxxxx - lavc 55.11.0 - avcodec.h
> + Add avcodec_get_name utility.
> +
> 2013-xx-xx - xxxxxxx - lavu 52.14.0 - error.h
> Add av_make_error_string() and av_err2str() utilities.
>
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index f4a10e1..741e3dd 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -4161,6 +4161,12 @@ int av_lockmgr_register(int (*cb)(void **mutex, enum
> AVLockOp op));
> enum AVMediaType avcodec_get_type(enum AVCodecID codec_id);
>
> /**
> + * Get the name of a codec.
> + * @return a static string identifying the codec; never NULL
> + */
> +const char *avcodec_get_name(enum AVCodecID id);
> +
> +/**
> * @return a positive value if s is open (i.e. avcodec_open2() was called on
> it
> * with no corresponding avcodec_close()), 0 otherwise.
> */
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index ee0b571..e327d05 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -1603,6 +1603,26 @@ AVCodec *avcodec_find_decoder_by_name(const char *name)
> return NULL;
> }
>
> +const char *avcodec_get_name(enum AVCodecID id)
> +{
> + const AVCodecDescriptor *cd;
> + AVCodec *codec;
> +
> + if (id == AV_CODEC_ID_NONE)
> + return "none";
> + cd = avcodec_descriptor_get(id);
> + if (cd)
> + return cd->name;
This part is maybe useful sugar.
const char *avcodec_name_get(enum AVCodecID id)
{
const AVCodecDescriptor *cd = avcodec_descriptor_get(id);
if (cd)
return cd->name;
return "none";
}
might be better.
> + av_log(NULL, AV_LOG_WARNING, "Codec 0x%x is not in the full list.\n",
> id);
> + codec = avcodec_find_decoder(id);
> + if (codec)
> + return codec->name;
> + codec = avcodec_find_encoder(id);
This is impossible.
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel