yading@11: /* yading@11: * Copyright (c) 2011 Anton Khirnov yading@11: * yading@11: * This file is part of Libav. yading@11: * yading@11: * Libav is free software; you can redistribute it and/or yading@11: * modify it under the terms of the GNU Lesser General Public yading@11: * License as published by the Free Software Foundation; either yading@11: * version 2.1 of the License, or (at your option) any later version. yading@11: * yading@11: * Libav is distributed in the hope that it will be useful, yading@11: * but WITHOUT ANY WARRANTY; without even the implied warranty of yading@11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yading@11: * Lesser General Public License for more details. yading@11: * yading@11: * You should have received a copy of the GNU Lesser General Public yading@11: * License along with Libav; if not, write to the Free Software yading@11: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA yading@11: */ yading@11: yading@11: /* yading@11: * enumerate avoptions and format them in texinfo format yading@11: */ yading@11: yading@11: #include yading@11: yading@11: #include "libavformat/avformat.h" yading@11: #include "libavcodec/avcodec.h" yading@11: #include "libavutil/log.h" yading@11: #include "libavutil/opt.h" yading@11: yading@11: static void print_usage(void) yading@11: { yading@11: fprintf(stderr, "Usage: enum_options type\n" yading@11: "type: format codec\n"); yading@11: exit(1); yading@11: } yading@11: yading@11: static void print_option(const AVClass *class, const AVOption *o) yading@11: { yading@11: printf("@item -%s @var{", o->name); yading@11: switch (o->type) { yading@11: case FF_OPT_TYPE_BINARY: printf("hexadecimal string"); break; yading@11: case FF_OPT_TYPE_STRING: printf("string"); break; yading@11: case FF_OPT_TYPE_INT: yading@11: case FF_OPT_TYPE_INT64: printf("integer"); break; yading@11: case FF_OPT_TYPE_FLOAT: yading@11: case FF_OPT_TYPE_DOUBLE: printf("float"); break; yading@11: case FF_OPT_TYPE_RATIONAL: printf("rational number"); break; yading@11: case FF_OPT_TYPE_FLAGS: printf("flags"); break; yading@11: default: printf("value"); break; yading@11: } yading@11: printf("} (@emph{"); yading@11: yading@11: if (o->flags & AV_OPT_FLAG_ENCODING_PARAM) { yading@11: printf("input"); yading@11: if (o->flags & AV_OPT_FLAG_ENCODING_PARAM) yading@11: printf("/"); yading@11: } yading@11: if (o->flags & AV_OPT_FLAG_ENCODING_PARAM) yading@11: printf("output"); yading@11: yading@11: printf("})\n"); yading@11: if (o->help) yading@11: printf("%s\n", o->help); yading@11: yading@11: if (o->unit) { yading@11: const AVOption *u = NULL; yading@11: printf("\nPossible values:\n@table @samp\n"); yading@11: yading@11: while ((u = av_next_option(&class, u))) yading@11: if (u->type == FF_OPT_TYPE_CONST && u->unit && !strcmp(u->unit, o->unit)) yading@11: printf("@item %s\n%s\n", u->name, u->help ? u->help : ""); yading@11: printf("@end table\n"); yading@11: } yading@11: } yading@11: yading@11: static void show_opts(const AVClass *class) yading@11: { yading@11: const AVOption *o = NULL; yading@11: yading@11: printf("@table @option\n"); yading@11: while ((o = av_next_option(&class, o))) yading@11: if (o->type != FF_OPT_TYPE_CONST) yading@11: print_option(class, o); yading@11: printf("@end table\n"); yading@11: } yading@11: yading@11: static void show_format_opts(void) yading@11: { yading@11: AVInputFormat *iformat = NULL; yading@11: AVOutputFormat *oformat = NULL; yading@11: yading@11: printf("@section Generic format AVOptions\n"); yading@11: show_opts(avformat_get_class()); yading@11: yading@11: printf("@section Format-specific AVOptions\n"); yading@11: while ((iformat = av_iformat_next(iformat))) { yading@11: if (!iformat->priv_class) yading@11: continue; yading@11: printf("@subsection %s AVOptions\n", iformat->priv_class->class_name); yading@11: show_opts(iformat->priv_class); yading@11: } yading@11: while ((oformat = av_oformat_next(oformat))) { yading@11: if (!oformat->priv_class) yading@11: continue; yading@11: printf("@subsection %s AVOptions\n", oformat->priv_class->class_name); yading@11: show_opts(oformat->priv_class); yading@11: } yading@11: } yading@11: yading@11: static void show_codec_opts(void) yading@11: { yading@11: AVCodec *c = NULL; yading@11: yading@11: printf("@section Generic codec AVOptions\n"); yading@11: show_opts(avcodec_get_class()); yading@11: yading@11: printf("@section Codec-specific AVOptions\n"); yading@11: while ((c = av_codec_next(c))) { yading@11: if (!c->priv_class) yading@11: continue; yading@11: printf("@subsection %s AVOptions\n", c->priv_class->class_name); yading@11: show_opts(c->priv_class); yading@11: } yading@11: } yading@11: yading@11: int main(int argc, char **argv) yading@11: { yading@11: if (argc < 2) yading@11: print_usage(); yading@11: yading@11: av_register_all(); yading@11: yading@11: if (!strcmp(argv[1], "format")) yading@11: show_format_opts(); yading@11: else if (!strcmp(argv[1], "codec")) yading@11: show_codec_opts(); yading@11: else yading@11: print_usage(); yading@11: yading@11: return 0; yading@11: }