diff options
author | Nicolas George <nicolas.george@normalesup.org> | 2012-08-13 11:27:20 +0200 |
---|---|---|
committer | Nicolas George <nicolas.george@normalesup.org> | 2012-08-14 11:35:30 +0200 |
commit | 9bb936a80e72ae3439ded56f08f3d558700537c2 (patch) | |
tree | 7de758924c81f745e8e7eddb23493f95f8754295 /libavcodec | |
parent | 690ef618b1b0deae8a63ff7f3e4517c4adb70929 (diff) | |
download | ffmpeg-9bb936a80e72ae3439ded56f08f3d558700537c2.tar.gz |
lavc: reimplement avcodec_get_name with descriptors.
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/Makefile | 8 | ||||
-rwxr-xr-x | libavcodec/codec_names.sh | 84 | ||||
-rw-r--r-- | libavcodec/utils.c | 9 |
3 files changed, 4 insertions, 97 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 251a6b22fc..34e4cc302b 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -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 diff --git a/libavcodec/codec_names.sh b/libavcodec/codec_names.sh deleted file mode 100755 index 44ccb45afe..0000000000 --- a/libavcodec/codec_names.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/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 diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 90df647db7..03caf1c026 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -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; |