aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/codec_names.sh
diff options
context:
space:
mode:
authorNicolas George <nicolas.george@normalesup.org>2011-08-17 13:54:49 +0200
committerNicolas George <nicolas.george@normalesup.org>2011-08-22 10:54:44 +0200
commitb3be9f4a88787d2d6692ffced187db677afdc726 (patch)
tree5bfbc8a747d6613676add5e3f91fb9bdcdfaceac /libavcodec/codec_names.sh
parent8b52b46c97f2badf6095275f6c5a91ad4c2a9d51 (diff)
downloadffmpeg-b3be9f4a88787d2d6692ffced187db677afdc726.tar.gz
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.
Diffstat (limited to 'libavcodec/codec_names.sh')
-rwxr-xr-xlibavcodec/codec_names.sh85
1 files changed, 85 insertions, 0 deletions
diff --git a/libavcodec/codec_names.sh b/libavcodec/codec_names.sh
new file mode 100755
index 0000000000..4d86c197ec
--- /dev/null
+++ b/libavcodec/codec_names.sh
@@ -0,0 +1,85 @@
+#!/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"
+codecs="$2"
+out="$3"
+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#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;;
+ *CODEC_ID_FIRST*///*dummy*) ;;
+ CODEC_ID_*) define_codecid ${line%%[=,]*};;
+ esac
+ done
+}
+
+parse_avcodec_h () {
+ while read line; do
+ case "$line" in
+ "enum CodecID {") parse_enum_codecid; break;;
+ esac
+ done
+}
+
+parse_config_h < "$config"
+parse_avcodec_h < "$codecs"
+sed -e '/case.*:/ ! y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' \
+ -e 's/extern avcodec /extern AVCodec /' > "$out" <<EOF
+$outval
+EOF