|
| 1 | +#pragma once |
| 2 | + |
| 3 | +extern"C" { |
| 4 | +#include "cmdutils.h" |
| 5 | +#include "libavutil/opt.h" |
| 6 | +} |
| 7 | + |
| 8 | +#include <SDL.h> |
| 9 | + |
| 10 | +//#include "VideoState.h" |
| 11 | + |
| 12 | +//#define CO ((CommandOptions*)command_options) |
| 13 | + |
| 14 | +enum ShowMode { |
| 15 | + SHOW_MODE_NONE = -1, |
| 16 | + SHOW_MODE_VIDEO = 0, |
| 17 | + SHOW_MODE_RDFT, |
| 18 | + SHOW_MODE_NB |
| 19 | +}; |
| 20 | + |
| 21 | +enum SyncMode { |
| 22 | + AV_SYNC_AUDIO_MASTER, // default choice |
| 23 | + AV_SYNC_VIDEO_MASTER, |
| 24 | + AV_SYNC_EXTERNAL_CLOCK, // synchronize to an external clock |
| 25 | +}; |
| 26 | + |
| 27 | + |
| 28 | +#define SAMPLE_ARRAY_SIZE (8 * 65536) |
| 29 | +#define USE_ONEPASS_SUBTITLE_RENDER 1 |
| 30 | +#define SDL_AUDIO_MIN_BUFFER_SIZE 512 |
| 31 | +#define SDL_AUDIO_MAX_CALLBACKS_PER_SEC 30 |
| 32 | +#define AUDIO_DIFF_AVG_NB 20 |
| 33 | +#define SAMPLE_CORRECTION_PERCENT_MAX 10 |
| 34 | +#define EXTERNAL_CLOCK_MIN_FRAMES 2 |
| 35 | +#define EXTERNAL_CLOCK_MAX_FRAMES 10 |
| 36 | +#define EXTERNAL_CLOCK_SPEED_MIN 0.900 |
| 37 | +#define EXTERNAL_CLOCK_SPEED_MAX 1.010 |
| 38 | +#define EXTERNAL_CLOCK_SPEED_STEP 0.001 |
| 39 | + |
| 40 | +class CommandOptions |
| 41 | +{ |
| 42 | +public: |
| 43 | + CommandOptions(); |
| 44 | + |
| 45 | + static void show_usage(void); |
| 46 | + |
| 47 | + static int opt_frame_size(void* optctx, const char* opt, const char* arg); |
| 48 | + static int opt_width(void* optctx, const char* opt, const char* arg); |
| 49 | + static int opt_height(void* optctx, const char* opt, const char* arg); |
| 50 | + static int opt_format(void* optctx, const char* opt, const char* arg); |
| 51 | + static int opt_frame_pix_fmt(void* optctx, const char* opt, const char* arg); |
| 52 | + static int opt_sync(void* optctx, const char* opt, const char* arg); |
| 53 | + static int opt_seek(void* optctx, const char* opt, const char* arg); |
| 54 | + static int opt_duration(void* optctx, const char* opt, const char* arg); |
| 55 | + static int opt_show_mode(void* optctx, const char* opt, const char* arg); |
| 56 | + static void opt_input_file(void* optctx, const char* filename); |
| 57 | + static int opt_codec(void* optctx, const char* opt, const char* arg); |
| 58 | + |
| 59 | +#if CONFIG_AVFILTER |
| 60 | + static int opt_add_vfilter(void* optctx, const char* opt, const char* arg); |
| 61 | +#endif |
| 62 | + |
| 63 | + inline static int dummy; |
| 64 | + |
| 65 | + inline static AVInputFormat* file_iformat; |
| 66 | + inline static const char* input_filename; |
| 67 | + inline static const char* window_title; |
| 68 | + inline static int default_width = 640; |
| 69 | + inline static int default_height = 480; |
| 70 | + inline static int screen_width = 0; |
| 71 | + inline static int screen_height = 0; |
| 72 | + inline static int screen_left = SDL_WINDOWPOS_CENTERED; |
| 73 | + inline static int screen_top = SDL_WINDOWPOS_CENTERED; |
| 74 | + inline static int audio_disable; |
| 75 | + inline static int video_disable; |
| 76 | + inline static int subtitle_disable; |
| 77 | + inline static const char* wanted_stream_spec[AVMEDIA_TYPE_NB] = { 0 }; |
| 78 | + inline static int seek_by_bytes = -1; |
| 79 | + inline static float seek_interval = 10; |
| 80 | + inline static int display_disable; |
| 81 | + inline static int borderless; |
| 82 | + inline static int startup_volume = 100; |
| 83 | + inline static int show_status = 1; |
| 84 | + inline static int av_sync_type = AV_SYNC_AUDIO_MASTER; |
| 85 | + inline static int64_t start_time = AV_NOPTS_VALUE; |
| 86 | + inline static int64_t duration = AV_NOPTS_VALUE; |
| 87 | + inline static int fast = 0; |
| 88 | + inline static int genpts = 0; |
| 89 | + inline static int lowres = 0; |
| 90 | + inline static int decoder_reorder_pts = -1; |
| 91 | + inline static int autoexit; |
| 92 | + inline static int exit_on_keydown; |
| 93 | + inline static int exit_on_mousedown; |
| 94 | + inline static int loop = 1; |
| 95 | + inline static int framedrop = -1; |
| 96 | + inline static int infinite_buffer = -1; |
| 97 | + inline static enum ShowMode show_mode = SHOW_MODE_NONE; |
| 98 | + inline static const char* audio_codec_name; |
| 99 | + inline static const char* subtitle_codec_name; |
| 100 | + inline static const char* video_codec_name; |
| 101 | + inline static double rdftspeed = 0.02; |
| 102 | + inline static int64_t cursor_last_shown; |
| 103 | + inline static int cursor_hidden = 0; |
| 104 | +#if CONFIG_AVFILTER |
| 105 | + inline static const char** vfilters_list = NULL; |
| 106 | + inline static int nb_vfilters = 0; |
| 107 | + inline static char* afilters = NULL; |
| 108 | +#endif |
| 109 | + inline static int autorotate = 1; |
| 110 | + inline static int find_stream_info = 1; |
| 111 | + inline static int filter_nbthreads = 0; |
| 112 | + |
| 113 | + /* current context */ |
| 114 | + inline static int is_full_screen; |
| 115 | + inline static int64_t audio_callback_time; |
| 116 | + |
| 117 | + |
| 118 | + inline static const OptionDef options[] = { |
| 119 | + CMDUTILS_COMMON_OPTIONS |
| 120 | + { "x", HAS_ARG, {.func_arg = opt_width }, "force displayed width", "width" }, |
| 121 | + { "y", HAS_ARG, {.func_arg = opt_height }, "force displayed height", "height" }, |
| 122 | + { "s", HAS_ARG | OPT_VIDEO, {.func_arg = opt_frame_size }, "set frame size (WxH or abbreviation)", "size" }, |
| 123 | + { "fs", OPT_BOOL, { &is_full_screen }, "force full screen" }, |
| 124 | + { "an", OPT_BOOL, { &audio_disable }, "disable audio" }, |
| 125 | + { "vn", OPT_BOOL, { &video_disable }, "disable video" }, |
| 126 | + { "sn", OPT_BOOL, { &subtitle_disable }, "disable subtitling" }, |
| 127 | + { "ast", OPT_STRING | HAS_ARG | OPT_EXPERT, { &wanted_stream_spec[AVMEDIA_TYPE_AUDIO] }, "select desired audio stream", "stream_specifier" }, |
| 128 | + { "vst", OPT_STRING | HAS_ARG | OPT_EXPERT, { &wanted_stream_spec[AVMEDIA_TYPE_VIDEO] }, "select desired video stream", "stream_specifier" }, |
| 129 | + { "sst", OPT_STRING | HAS_ARG | OPT_EXPERT, { &wanted_stream_spec[AVMEDIA_TYPE_SUBTITLE] }, "select desired subtitle stream", "stream_specifier" }, |
| 130 | + { "ss", HAS_ARG, {.func_arg = opt_seek }, "seek to a given position in seconds", "pos" }, |
| 131 | + { "t", HAS_ARG, {.func_arg = opt_duration }, "play \"duration\" seconds of audio/video", "duration" }, |
| 132 | + { "bytes", OPT_INT | HAS_ARG, { &seek_by_bytes }, "seek by bytes 0=off 1=on -1=auto", "val" }, |
| 133 | + { "seek_interval", OPT_FLOAT | HAS_ARG, { &seek_interval }, "set seek interval for left/right keys, in seconds", "seconds" }, |
| 134 | + { "nodisp", OPT_BOOL, { &display_disable }, "disable graphical display" }, |
| 135 | + { "noborder", OPT_BOOL, { &borderless }, "borderless window" }, |
| 136 | + { "volume", OPT_INT | HAS_ARG, { &startup_volume}, "set startup volume 0=min 100=max", "volume" }, |
| 137 | + { "f", HAS_ARG, {.func_arg = opt_format }, "force format", "fmt" }, |
| 138 | + { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {.func_arg = opt_frame_pix_fmt }, "set pixel format", "format" }, |
| 139 | + { "stats", OPT_BOOL | OPT_EXPERT, { &show_status }, "show status", "" }, |
| 140 | + { "fast", OPT_BOOL | OPT_EXPERT, { &fast }, "non spec compliant optimizations", "" }, |
| 141 | + { "genpts", OPT_BOOL | OPT_EXPERT, { &genpts }, "generate pts", "" }, |
| 142 | + { "drp", OPT_INT | HAS_ARG | OPT_EXPERT, { &decoder_reorder_pts }, "let decoder reorder pts 0=off 1=on -1=auto", ""}, |
| 143 | + { "lowres", OPT_INT | HAS_ARG | OPT_EXPERT, { &lowres }, "", "" }, |
| 144 | + { "sync", HAS_ARG | OPT_EXPERT, {.func_arg = opt_sync }, "set audio-video sync. type (type=audio/video/ext)", "type" }, |
| 145 | + { "autoexit", OPT_BOOL | OPT_EXPERT, { &autoexit }, "exit at the end", "" }, |
| 146 | + { "exitonkeydown", OPT_BOOL | OPT_EXPERT, { &exit_on_keydown }, "exit on key down", "" }, |
| 147 | + { "exitonmousedown", OPT_BOOL | OPT_EXPERT, { &exit_on_mousedown }, "exit on mouse down", "" }, |
| 148 | + { "loop", OPT_INT | HAS_ARG | OPT_EXPERT, { &loop }, "set number of times the playback shall be looped", "loop count" }, |
| 149 | + { "framedrop", OPT_BOOL | OPT_EXPERT, { &framedrop }, "drop frames when cpu is too slow", "" }, |
| 150 | + { "infbuf", OPT_BOOL | OPT_EXPERT, { &infinite_buffer }, "don't limit the input buffer size (useful with realtime streams)", "" }, |
| 151 | + { "window_title", OPT_STRING | HAS_ARG, { &window_title }, "set window title", "window title" }, |
| 152 | + { "left", OPT_INT | HAS_ARG | OPT_EXPERT, { &screen_left }, "set the x position for the left of the window", "x pos" }, |
| 153 | + { "top", OPT_INT | HAS_ARG | OPT_EXPERT, { &screen_top }, "set the y position for the top of the window", "y pos" }, |
| 154 | +#if CONFIG_AVFILTER |
| 155 | + { "vf", OPT_EXPERT | HAS_ARG, {.func_arg = opt_add_vfilter }, "set video filters", "filter_graph" }, |
| 156 | + { "af", OPT_STRING | HAS_ARG, { &afilters }, "set audio filters", "filter_graph" }, |
| 157 | +#endif |
| 158 | + //{ "rdftspeed", OPT_INT | HAS_ARG | OPT_AUDIO | OPT_EXPERT, { &rdftspeed }, "rdft speed", "msecs" }, |
| 159 | + { "showmode", HAS_ARG, {.func_arg = opt_show_mode}, "select show mode (0 = video, 1 = waves, 2 = RDFT)", "mode" }, |
| 160 | + { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {.func_arg = opt_default }, "generic catch all option", "" }, |
| 161 | + { "i", OPT_BOOL, { &dummy}, "read specified file", "input_file"}, |
| 162 | + { "codec", HAS_ARG, {.func_arg = opt_codec}, "force decoder", "decoder_name" }, |
| 163 | + { "acodec", HAS_ARG | OPT_STRING | OPT_EXPERT, { &audio_codec_name }, "force audio decoder", "decoder_name" }, |
| 164 | + { "scodec", HAS_ARG | OPT_STRING | OPT_EXPERT, { &subtitle_codec_name }, "force subtitle decoder", "decoder_name" }, |
| 165 | + { "vcodec", HAS_ARG | OPT_STRING | OPT_EXPERT, { &video_codec_name }, "force video decoder", "decoder_name" }, |
| 166 | + { "autorotate", OPT_BOOL, { &autorotate }, "automatically rotate video", "" }, |
| 167 | + { "find_stream_info", OPT_BOOL | OPT_INPUT | OPT_EXPERT, { &find_stream_info }, |
| 168 | + "read and decode the streams to fill missing information with heuristics" }, |
| 169 | + { "filter_threads", HAS_ARG | OPT_INT | OPT_EXPERT, { &filter_nbthreads }, "number of filter threads per graph" }, |
| 170 | + { NULL, }, |
| 171 | + }; |
| 172 | +}; |
| 173 | + |
0 commit comments