print_options.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * Copyright (c) 2012 Anton Khirnov
  3. *
  4. * This file is part of Libav.
  5. *
  6. * Libav 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. * Libav 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 Libav; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. /*
  21. * generate texinfo manpages for avoptions
  22. */
  23. #include <stddef.h>
  24. #include <string.h>
  25. #include <float.h>
  26. #include "libavformat/avformat.h"
  27. #include "libavcodec/avcodec.h"
  28. #include "libavutil/opt.h"
  29. static void print_usage(void)
  30. {
  31. fprintf(stderr, "Usage: enum_options type\n"
  32. "type: format codec\n");
  33. exit(1);
  34. }
  35. static void print_option(const AVOption *opts, const AVOption *o, int per_stream)
  36. {
  37. if (!(o->flags & (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM)))
  38. return;
  39. printf("@item -%s%s @var{", o->name, per_stream ? "[:stream_specifier]" : "");
  40. switch (o->type) {
  41. case AV_OPT_TYPE_BINARY: printf("hexadecimal string"); break;
  42. case AV_OPT_TYPE_STRING: printf("string"); break;
  43. case AV_OPT_TYPE_INT:
  44. case AV_OPT_TYPE_INT64: printf("integer"); break;
  45. case AV_OPT_TYPE_FLOAT:
  46. case AV_OPT_TYPE_DOUBLE: printf("float"); break;
  47. case AV_OPT_TYPE_RATIONAL: printf("rational number"); break;
  48. case AV_OPT_TYPE_FLAGS: printf("flags"); break;
  49. default: printf("value"); break;
  50. }
  51. printf("} (@emph{");
  52. if (o->flags & AV_OPT_FLAG_DECODING_PARAM) {
  53. printf("input");
  54. if (o->flags & AV_OPT_FLAG_ENCODING_PARAM)
  55. printf("/");
  56. }
  57. if (o->flags & AV_OPT_FLAG_ENCODING_PARAM) printf("output");
  58. if (o->flags & AV_OPT_FLAG_AUDIO_PARAM) printf(",audio");
  59. if (o->flags & AV_OPT_FLAG_VIDEO_PARAM) printf(",video");
  60. if (o->flags & AV_OPT_FLAG_SUBTITLE_PARAM) printf(",subtitles");
  61. printf("})\n");
  62. if (o->help)
  63. printf("%s\n", o->help);
  64. if (o->unit) {
  65. const AVOption *u;
  66. printf("\nPossible values:\n@table @samp\n");
  67. for (u = opts; u->name; u++) {
  68. if (u->type == AV_OPT_TYPE_CONST && u->unit && !strcmp(u->unit, o->unit))
  69. printf("@item %s\n%s\n", u->name, u->help ? u->help : "");
  70. }
  71. printf("@end table\n");
  72. }
  73. }
  74. static void show_opts(const AVOption *opts, int per_stream)
  75. {
  76. const AVOption *o;
  77. printf("@table @option\n");
  78. for (o = opts; o->name; o++) {
  79. if (o->type != AV_OPT_TYPE_CONST)
  80. print_option(opts, o, per_stream);
  81. }
  82. printf("@end table\n");
  83. }
  84. static void show_format_opts(void)
  85. {
  86. #include "libavformat/options_table.h"
  87. printf("@section Format AVOptions\n");
  88. show_opts(options, 0);
  89. }
  90. static void show_codec_opts(void)
  91. {
  92. #include "libavcodec/options_table.h"
  93. printf("@section Codec AVOptions\n");
  94. show_opts(options, 1);
  95. }
  96. int main(int argc, char **argv)
  97. {
  98. if (argc < 2)
  99. print_usage();
  100. printf("@c DO NOT EDIT THIS FILE!\n"
  101. "@c It was generated by print_options.\n\n");
  102. if (!strcmp(argv[1], "format"))
  103. show_format_opts();
  104. else if (!strcmp(argv[1], "codec"))
  105. show_codec_opts();
  106. else
  107. print_usage();
  108. return 0;
  109. }