codec_names.sh 1.9 KB

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