print_options.c 4.0 KB

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