Commit 9bb936a8 authored by Nicolas George's avatar Nicolas George

lavc: reimplement avcodec_get_name with descriptors.

parent 690ef618
......@@ -785,7 +785,6 @@ OBJS-$(!CONFIG_SMALL) += inverse.o
SKIPHEADERS += %_tablegen.h \
%_tables.h \
aac_tablegen_decl.h \
codec_names.h \
fft-internal.h \
old_codec_ids.h \
tableprint.h \
......@@ -860,10 +859,3 @@ $(SUBDIR)motionpixels.o: $(SUBDIR)motionpixels_tables.h
$(SUBDIR)pcm.o: $(SUBDIR)pcm_tables.h
$(SUBDIR)qdm2.o: $(SUBDIR)qdm2_tables.h
endif
CODEC_NAMES_SH := $(SRC_PATH)/$(SUBDIR)codec_names.sh
AVCODEC_H := $(SRC_PATH)/$(SUBDIR)avcodec.h
$(SUBDIR)codec_names.h: $(CODEC_NAMES_SH) config.h $(AVCODEC_H)
$(CC) $(CPPFLAGS) $(CFLAGS) -E $(AVCODEC_H) | \
$(CODEC_NAMES_SH) config.h $@
$(SUBDIR)utils.o: $(SUBDIR)codec_names.h
#!/bin/sh
# Copyright (c) 2011 Nicolas George
#
# This file is part of FFmpeg.
#
# FFmpeg is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# FFmpeg is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with FFmpeg; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
set -e
config="$1"
out="$2"
test -n "$out"
outval=""
add_line () {
outval="$outval$*
"
}
parse_config_h () {
while read define var value; do
case "$define $var $value" in
"#define CONFIG_"*_*" 1") eval "$var=1";;
esac
done
}
define_codecid () {
id="$1"
n=${1#AV_CODEC_ID_}
add_line "case ${id}:"
eval "c=\${CONFIG_${n}_DECODER}:\${CONFIG_${n}_ENCODER}"
case "$c" in
1:*) s="decoder";;
*:1) s="encoder";;
*) s="";;
esac
case "$s" in
"") add_line " return \"$n\";" ;;
*)
add_line " { extern AVCodec ff_${n}_${s};"
add_line " return ff_${n}_${s}.name; }"
;;
esac
}
parse_enum_codecid () {
while read line; do
case "$line" in
"};") break;;
*AV_CODEC_ID_FIRST*=*) ;;
AV_CODEC_ID_*) define_codecid ${line%%[=,]*};;
esac
done
}
parse_avcodec_h () {
while read line; do
case "$line" in
"enum AVCodecID {") parse_enum_codecid; break;;
esac
done
}
parse_config_h < "$config"
parse_avcodec_h # use stdin
sed -e '/case.*:/!y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' \
-e 's/extern avcodec /extern AVCodec /' > "$out" <<EOF
$outval
EOF
......@@ -1847,14 +1847,13 @@ AVCodec *avcodec_find_decoder_by_name(const char *name)
const char *avcodec_get_name(enum AVCodecID id)
{
const AVCodecDescriptor *cd;
AVCodec *codec;
#if !CONFIG_SMALL
switch (id) {
#include "libavcodec/codec_names.h"
}
cd = avcodec_descriptor_get(id);
if (cd)
return cd->name;
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment