Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--libavcodec/Makefile6
-rw-r--r--libavcodec/avcodec.h6
-rwxr-xr-xlibavcodec/codec_names.sh85
-rw-r--r--libavcodec/utils.c19
5 files changed, 117 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 958dd71668..e7585e3d7f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,6 +20,7 @@ avconv
libavcodec/*_tablegen
libavcodec/*_tables.c
libavcodec/*_tables.h
+libavcodec/codec_names.h
libavcodec/libavcodec*
libavcore/libavcore*
libavdevice/libavdevice*
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 147c1b3587..ac47c99aab 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -735,3 +735,9 @@ $(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)
+ $(M)$(CODEC_NAMES_SH) config.h $(AVCODEC_H) $@
+$(SUBDIR)utils.o: $(SUBDIR)codec_names.h
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 2617f65ccc..2c5e70b136 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3433,6 +3433,12 @@ int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width,
int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height);
void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *v_shift);
+/**
+ * Get the name of a codec.
+ * @return a static string identifying the codec; never NULL
+ */
+const char *avcodec_get_name(enum CodecID id);
+
#if FF_API_GET_PIX_FMT_NAME
/**
* Return the short name for a pixel format.
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
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index ce8c0993a9..1d5ec44d36 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -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;