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.

131 lines
3.7KB

  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 <stdio.h>
  25. #include <string.h>
  26. #include <float.h>
  27. #include "libavutil/attributes.h"
  28. #include "libavutil/opt.h"
  29. /* Forcibly turn off deprecation warnings, which just add noise here. */
  30. #undef attribute_deprecated
  31. #define attribute_deprecated
  32. #include "libavcodec/options_table.h"
  33. #include "libavformat/options_table.h"
  34. static void print_usage(void)
  35. {
  36. fprintf(stderr, "Usage: enum_options type\n"
  37. "type: format codec\n");
  38. exit(1);
  39. }
  40. static void print_option(const AVOption *opts, const AVOption *o, int per_stream)
  41. {
  42. if (!(o->flags & (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM)))
  43. return;
  44. printf("@item -%s%s @var{", o->name, per_stream ? "[:stream_specifier]" : "");
  45. switch (o->type) {
  46. case AV_OPT_TYPE_BINARY: printf("hexadecimal string"); break;
  47. case AV_OPT_TYPE_STRING: printf("string"); break;
  48. case AV_OPT_TYPE_INT:
  49. case AV_OPT_TYPE_INT64: printf("integer"); break;
  50. case AV_OPT_TYPE_FLOAT:
  51. case AV_OPT_TYPE_DOUBLE: printf("float"); break;
  52. case AV_OPT_TYPE_RATIONAL: printf("rational number"); break;
  53. case AV_OPT_TYPE_FLAGS: printf("flags"); break;
  54. default: printf("value"); break;
  55. }
  56. printf("} (@emph{");
  57. if (o->flags & AV_OPT_FLAG_DECODING_PARAM) {
  58. printf("input");
  59. if (o->flags & AV_OPT_FLAG_ENCODING_PARAM)
  60. printf("/");
  61. }
  62. if (o->flags & AV_OPT_FLAG_ENCODING_PARAM) printf("output");
  63. if (o->flags & AV_OPT_FLAG_AUDIO_PARAM) printf(",audio");
  64. if (o->flags & AV_OPT_FLAG_VIDEO_PARAM) printf(",video");
  65. if (o->flags & AV_OPT_FLAG_SUBTITLE_PARAM) printf(",subtitles");
  66. printf("})\n");
  67. if (o->help)
  68. printf("%s\n", o->help);
  69. if (o->unit) {
  70. const AVOption *u;
  71. printf("\nPossible values:\n@table @samp\n");
  72. for (u = opts; u->name; u++) {
  73. if (u->type == AV_OPT_TYPE_CONST && u->unit && !strcmp(u->unit, o->unit))
  74. printf("@item %s\n%s\n", u->name, u->help ? u->help : "");
  75. }
  76. printf("@end table\n");
  77. }
  78. }
  79. static void show_opts(const AVOption *opts, int per_stream)
  80. {
  81. const AVOption *o;
  82. printf("@table @option\n");
  83. for (o = opts; o->name; o++) {
  84. if (o->type != AV_OPT_TYPE_CONST)
  85. print_option(opts, o, per_stream);
  86. }
  87. printf("@end table\n");
  88. }
  89. static void show_format_opts(void)
  90. {
  91. printf("@section Format AVOptions\n");
  92. show_opts(avformat_options, 0);
  93. }
  94. static void show_codec_opts(void)
  95. {
  96. printf("@section Codec AVOptions\n");
  97. show_opts(avcodec_options, 1);
  98. }
  99. int main(int argc, char **argv)
  100. {
  101. if (argc < 2)
  102. print_usage();
  103. if (!strcmp(argv[1], "format"))
  104. show_format_opts();
  105. else if (!strcmp(argv[1], "codec"))
  106. show_codec_opts();
  107. else
  108. print_usage();
  109. return 0;
  110. }