You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
1.9KB

  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. out="$2"
  22. test -n "$out"
  23. outval=""
  24. add_line () {
  25. outval="$outval$*
  26. "
  27. }
  28. parse_config_h () {
  29. while read define var value; do
  30. case "$define $var $value" in
  31. "#define CONFIG_"*_*" 1") eval "$var=1";;
  32. esac
  33. done
  34. }
  35. define_codecid () {
  36. id="$1"
  37. n=${1#CODEC_ID_}
  38. add_line "case ${id}:"
  39. eval "c=\${CONFIG_${n}_DECODER}:\${CONFIG_${n}_ENCODER}"
  40. case "$c" in
  41. 1:*) s="decoder";;
  42. *:1) s="encoder";;
  43. *) s="";;
  44. esac
  45. case "$s" in
  46. "") add_line " return \"$n\";" ;;
  47. *)
  48. add_line " { extern AVCodec ff_${n}_${s};"
  49. add_line " return ff_${n}_${s}.name; }"
  50. ;;
  51. esac
  52. }
  53. parse_enum_codecid () {
  54. while read line; do
  55. case "$line" in
  56. "};") break;;
  57. *CODEC_ID_FIRST*=*) ;;
  58. CODEC_ID_*) define_codecid ${line%%[=,]*};;
  59. esac
  60. done
  61. }
  62. parse_avcodec_h () {
  63. while read line; do
  64. case "$line" in
  65. "enum CodecID {") parse_enum_codecid; break;;
  66. esac
  67. done
  68. }
  69. parse_config_h < "$config"
  70. parse_avcodec_h # use stdin
  71. sed -e '/case.*:/!y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' \
  72. -e 's/extern avcodec /extern AVCodec /' > "$out" <<EOF
  73. $outval
  74. EOF