]> git.sesse.net Git - ffmpeg/blob - libavcodec/codec_names.sh
lavc: Check CODEC_CAP_VARIABLE_FRAME_SIZE && !frame
[ffmpeg] / libavcodec / codec_names.sh
1 #!/bin/sh
2
3 # Copyright (c) 2011 Nicolas George
4 #
5 # This file is part of FFmpeg.
6 #
7 # FFmpeg is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
11 #
12 # FFmpeg is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 # Lesser General Public License for more details.
16 #
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with FFmpeg; if not, write to the Free Software Foundation,
19 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
21 set -e
22
23 config="$1"
24 out="$2"
25 test -n "$out"
26
27 outval=""
28
29 add_line () {
30   outval="$outval$*
31 "
32 }
33
34 parse_config_h () {
35   while read define var value; do
36     case "$define $var $value" in
37       "#define CONFIG_"*_*" 1") eval "$var=1";;
38     esac
39   done
40 }
41
42 define_codecid () {
43   id="$1"
44   n=${1#CODEC_ID_}
45   add_line "case ${id}:"
46   eval "c=\${CONFIG_${n}_DECODER}:\${CONFIG_${n}_ENCODER}"
47   case "$c" in
48     1:*) s="decoder";;
49     *:1) s="encoder";;
50     *) s="";;
51   esac
52   case "$s" in
53     "") add_line "    return \"$n\";" ;;
54     *)
55       add_line "    { extern AVCodec ff_${n}_${s};"
56       add_line "      return ff_${n}_${s}.name; }"
57       ;;
58   esac
59 }
60
61 parse_enum_codecid () {
62   while read line; do
63     case "$line" in
64       "};") break;;
65       *CODEC_ID_FIRST*=*) ;;
66       CODEC_ID_*) define_codecid ${line%%[=,]*};;
67     esac
68   done
69 }
70
71 parse_avcodec_h () {
72   while read line; do
73     case "$line" in
74       "enum CodecID {") parse_enum_codecid; break;;
75     esac
76   done
77 }
78
79 parse_config_h  < "$config"
80 parse_avcodec_h # use stdin
81 sed -e '/case.*:/!y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' \
82     -e 's/extern avcodec /extern AVCodec /' > "$out" <<EOF
83 $outval
84 EOF