lavc: add a table of all codecs names.

The table is automatically generated from the definition of enum CodecID in
avcodec.h and contains the name of all known codecs, even those for which no
encoder nor decoder exists or is enabled.

The table is queried using the avcodec_get_name function.

If CONFIG_SMALL is true, the table is not compiled in; the avcodec_get_name
looks for names in the list of available decoders and encoders.
This commit is contained in:
Nicolas George
2011-08-17 13:54:49 +02:00
parent 8b52b46c97
commit b3be9f4a88
5 changed files with 117 additions and 0 deletions

View File

@@ -984,6 +984,25 @@ static int get_bit_rate(AVCodecContext *ctx)
return bit_rate;
}
const char *avcodec_get_name(enum CodecID id)
{
AVCodec *codec;
#if !CONFIG_SMALL
switch (id) {
#include "libavcodec/codec_names.h"
}
av_log(NULL, AV_LOG_WARNING, "Codec 0x%x is not in the full list.\n", id);
#endif
codec = avcodec_find_decoder(id);
if (codec)
return codec->name;
codec = avcodec_find_encoder(id);
if (codec)
return codec->name;
return "unknown_codec";
}
size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag)
{
int i, len, ret = 0;