Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

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