-static int opt_audio_qscale(OptionsContext *o, const char *opt, const char *arg)
-{
- return parse_option(o, "q:a", arg, options);
-}
-
-static void show_usage(void)
-{
- printf("Hyper fast Audio and Video encoder\n");
- printf("usage: %s [options] [[infile options] -i infile]... {[outfile options] outfile}...\n", program_name);
- printf("\n");
-}
-
-static void show_help(void)
-{
- int flags = AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM;
- av_log_set_callback(log_callback_help);
- show_usage();
- show_help_options(options, "Main options:\n",
- OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE | OPT_GRAB, 0);
- show_help_options(options, "\nAdvanced options:\n",
- OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE | OPT_GRAB,
- OPT_EXPERT);
- show_help_options(options, "\nVideo options:\n",
- OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_GRAB,
- OPT_VIDEO);
- show_help_options(options, "\nAdvanced Video options:\n",
- OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_GRAB,
- OPT_VIDEO | OPT_EXPERT);
- show_help_options(options, "\nAudio options:\n",
- OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_GRAB,
- OPT_AUDIO);
- show_help_options(options, "\nAdvanced Audio options:\n",
- OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_GRAB,
- OPT_AUDIO | OPT_EXPERT);
- show_help_options(options, "\nSubtitle options:\n",
- OPT_SUBTITLE | OPT_GRAB,
- OPT_SUBTITLE);
- show_help_options(options, "\nAudio/Video grab options:\n",
- OPT_GRAB,
- OPT_GRAB);
- printf("\n");
- show_help_children(avcodec_get_class(), flags);
- show_help_children(avformat_get_class(), flags);
- show_help_children(sws_get_class(), flags);
-}
-
-static int opt_target(OptionsContext *o, const char *opt, const char *arg)
-{
- enum { PAL, NTSC, FILM, UNKNOWN } norm = UNKNOWN;
- static const char *const frame_rates[] = { "25", "30000/1001", "24000/1001" };
-
- if (!strncmp(arg, "pal-", 4)) {
- norm = PAL;
- arg += 4;
- } else if (!strncmp(arg, "ntsc-", 5)) {
- norm = NTSC;
- arg += 5;
- } else if (!strncmp(arg, "film-", 5)) {
- norm = FILM;
- arg += 5;
- } else {
- /* Try to determine PAL/NTSC by peeking in the input files */
- if (nb_input_files) {
- int i, j, fr;
- for (j = 0; j < nb_input_files; j++) {
- for (i = 0; i < input_files[j].nb_streams; i++) {
- AVCodecContext *c = input_files[j].ctx->streams[i]->codec;
- if (c->codec_type != AVMEDIA_TYPE_VIDEO)
- continue;
- fr = c->time_base.den * 1000 / c->time_base.num;
- if (fr == 25000) {
- norm = PAL;
- break;
- } else if ((fr == 29970) || (fr == 23976)) {
- norm = NTSC;
- break;
- }
- }
- if (norm != UNKNOWN)
- break;
- }
- }
- if (norm != UNKNOWN)
- av_log(NULL, AV_LOG_INFO, "Assuming %s for target.\n", norm == PAL ? "PAL" : "NTSC");
- }
-
- if (norm == UNKNOWN) {
- av_log(NULL, AV_LOG_FATAL, "Could not determine norm (PAL/NTSC/NTSC-Film) for target.\n");
- av_log(NULL, AV_LOG_FATAL, "Please prefix target with \"pal-\", \"ntsc-\" or \"film-\",\n");
- av_log(NULL, AV_LOG_FATAL, "or set a framerate with \"-r xxx\".\n");
- exit_program(1);
- }
-
- if (!strcmp(arg, "vcd")) {
- opt_video_codec(o, "c:v", "mpeg1video");
- opt_audio_codec(o, "c:a", "mp2");
- parse_option(o, "f", "vcd", options);
-
- parse_option(o, "s", norm == PAL ? "352x288" : "352x240", options);
- parse_option(o, "r", frame_rates[norm], options);
- opt_default("g", norm == PAL ? "15" : "18");
-
- opt_default("b", "1150000");
- opt_default("maxrate", "1150000");
- opt_default("minrate", "1150000");
- opt_default("bufsize", "327680"); // 40*1024*8;
-
- opt_default("b:a", "224000");
- parse_option(o, "ar", "44100", options);
- parse_option(o, "ac", "2", options);
-
- opt_default("packetsize", "2324");
- opt_default("muxrate", "1411200"); // 2352 * 75 * 8;
-
- /* We have to offset the PTS, so that it is consistent with the SCR.
- SCR starts at 36000, but the first two packs contain only padding
- and the first pack from the other stream, respectively, may also have
- been written before.
- So the real data starts at SCR 36000+3*1200. */
- o->mux_preload = (36000 + 3 * 1200) / 90000.0; // 0.44
- } else if (!strcmp(arg, "svcd")) {
-
- opt_video_codec(o, "c:v", "mpeg2video");
- opt_audio_codec(o, "c:a", "mp2");
- parse_option(o, "f", "svcd", options);
-
- parse_option(o, "s", norm == PAL ? "480x576" : "480x480", options);
- parse_option(o, "r", frame_rates[norm], options);
- opt_default("g", norm == PAL ? "15" : "18");
-
- opt_default("b", "2040000");
- opt_default("maxrate", "2516000");
- opt_default("minrate", "0"); // 1145000;
- opt_default("bufsize", "1835008"); // 224*1024*8;
- opt_default("flags", "+scan_offset");
-
-
- opt_default("b:a", "224000");
- parse_option(o, "ar", "44100", options);
-
- opt_default("packetsize", "2324");
-
- } else if (!strcmp(arg, "dvd")) {
-
- opt_video_codec(o, "c:v", "mpeg2video");
- opt_audio_codec(o, "c:a", "ac3");
- parse_option(o, "f", "dvd", options);
-
- parse_option(o, "s", norm == PAL ? "720x576" : "720x480", options);
- parse_option(o, "r", frame_rates[norm], options);
- opt_default("g", norm == PAL ? "15" : "18");
-
- opt_default("b", "6000000");
- opt_default("maxrate", "9000000");
- opt_default("minrate", "0"); // 1500000;
- opt_default("bufsize", "1835008"); // 224*1024*8;
-
- opt_default("packetsize", "2048"); // from www.mpucoder.com: DVD sectors contain 2048 bytes of data, this is also the size of one pack.
- opt_default("muxrate", "10080000"); // from mplex project: data_rate = 1260000. mux_rate = data_rate * 8
-
- opt_default("b:a", "448000");
- parse_option(o, "ar", "48000", options);
-
- } else if (!strncmp(arg, "dv", 2)) {
-
- parse_option(o, "f", "dv", options);
-
- parse_option(o, "s", norm == PAL ? "720x576" : "720x480", options);
- parse_option(o, "pix_fmt", !strncmp(arg, "dv50", 4) ? "yuv422p" :
- norm == PAL ? "yuv420p" : "yuv411p", options);
- parse_option(o, "r", frame_rates[norm], options);
-
- parse_option(o, "ar", "48000", options);
- parse_option(o, "ac", "2", options);
-
- } else {
- av_log(NULL, AV_LOG_ERROR, "Unknown target: %s\n", arg);
- return AVERROR(EINVAL);
- }
- return 0;
-}
-
-static int opt_vstats_file(const char *opt, const char *arg)
-{
- av_free (vstats_filename);
- vstats_filename = av_strdup (arg);
- return 0;
-}
-
-static int opt_vstats(const char *opt, const char *arg)
-{
- char filename[40];
- time_t today2 = time(NULL);
- struct tm *today = localtime(&today2);
-
- snprintf(filename, sizeof(filename), "vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
- today->tm_sec);
- return opt_vstats_file(opt, filename);
-}
-
-static int opt_video_frames(OptionsContext *o, const char *opt, const char *arg)
-{
- return parse_option(o, "frames:v", arg, options);
-}
-
-static int opt_audio_frames(OptionsContext *o, const char *opt, const char *arg)
-{
- return parse_option(o, "frames:a", arg, options);
-}
-
-static int opt_data_frames(OptionsContext *o, const char *opt, const char *arg)
-{
- return parse_option(o, "frames:d", arg, options);
-}
-
-static int opt_video_tag(OptionsContext *o, const char *opt, const char *arg)
-{
- return parse_option(o, "tag:v", arg, options);
-}
-
-static int opt_audio_tag(OptionsContext *o, const char *opt, const char *arg)
-{
- return parse_option(o, "tag:a", arg, options);
-}
-
-static int opt_subtitle_tag(OptionsContext *o, const char *opt, const char *arg)
-{
- return parse_option(o, "tag:s", arg, options);
-}
-
-static int opt_video_filters(OptionsContext *o, const char *opt, const char *arg)
-{
- return parse_option(o, "filter:v", arg, options);
-}
-
-static int opt_vsync(const char *opt, const char *arg)
-{
- if (!av_strcasecmp(arg, "cfr")) video_sync_method = VSYNC_CFR;
- else if (!av_strcasecmp(arg, "vfr")) video_sync_method = VSYNC_VFR;
- else if (!av_strcasecmp(arg, "passthrough")) video_sync_method = VSYNC_PASSTHROUGH;
-
- if (video_sync_method == VSYNC_AUTO)
- video_sync_method = parse_number_or_die("vsync", arg, OPT_INT, VSYNC_AUTO, VSYNC_VFR);
- return 0;
-}
-
-static int opt_deinterlace(const char *opt, const char *arg)
-{
- av_log(NULL, AV_LOG_WARNING, "-%s is deprecated, use -filter:v yadif instead\n", opt);
- do_deinterlace = 1;
- return 0;
-}
-
-static int opt_cpuflags(const char *opt, const char *arg)
-{
-#define CPUFLAG_MMX2 (AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMX2)
-#define CPUFLAG_3DNOW (AV_CPU_FLAG_3DNOW | AV_CPU_FLAG_MMX)
-#define CPUFLAG_3DNOWEXT (AV_CPU_FLAG_3DNOWEXT | CPUFLAG_3DNOW)
-#define CPUFLAG_SSE (AV_CPU_FLAG_SSE | CPUFLAG_MMX2)
-#define CPUFLAG_SSE2 (AV_CPU_FLAG_SSE2 | CPUFLAG_SSE)
-#define CPUFLAG_SSE2SLOW (AV_CPU_FLAG_SSE2SLOW | CPUFLAG_SSE2)
-#define CPUFLAG_SSE3 (AV_CPU_FLAG_SSE3 | CPUFLAG_SSE2)
-#define CPUFLAG_SSE3SLOW (AV_CPU_FLAG_SSE3SLOW | CPUFLAG_SSE3)
-#define CPUFLAG_SSSE3 (AV_CPU_FLAG_SSSE3 | CPUFLAG_SSE3)
-#define CPUFLAG_SSE4 (AV_CPU_FLAG_SSE4 | CPUFLAG_SSSE3)
-#define CPUFLAG_SSE42 (AV_CPU_FLAG_SSE42 | CPUFLAG_SSE4)
-#define CPUFLAG_AVX (AV_CPU_FLAG_AVX | CPUFLAG_SSE42)
-#define CPUFLAG_XOP (AV_CPU_FLAG_XOP | CPUFLAG_AVX)
-#define CPUFLAG_FMA4 (AV_CPU_FLAG_FMA4 | CPUFLAG_AVX)
- static const AVOption cpuflags_opts[] = {
- { "flags" , NULL, 0, AV_OPT_TYPE_FLAGS, { 0 }, INT64_MIN, INT64_MAX, .unit = "flags" },
- { "altivec" , NULL, 0, AV_OPT_TYPE_CONST, { AV_CPU_FLAG_ALTIVEC }, .unit = "flags" },
- { "mmx" , NULL, 0, AV_OPT_TYPE_CONST, { AV_CPU_FLAG_MMX }, .unit = "flags" },
- { "mmx2" , NULL, 0, AV_OPT_TYPE_CONST, { CPUFLAG_MMX2 }, .unit = "flags" },
- { "sse" , NULL, 0, AV_OPT_TYPE_CONST, { CPUFLAG_SSE }, .unit = "flags" },
- { "sse2" , NULL, 0, AV_OPT_TYPE_CONST, { CPUFLAG_SSE2 }, .unit = "flags" },
- { "sse2slow", NULL, 0, AV_OPT_TYPE_CONST, { CPUFLAG_SSE2SLOW }, .unit = "flags" },
- { "sse3" , NULL, 0, AV_OPT_TYPE_CONST, { CPUFLAG_SSE3 }, .unit = "flags" },
- { "sse3slow", NULL, 0, AV_OPT_TYPE_CONST, { CPUFLAG_SSE3SLOW }, .unit = "flags" },
- { "ssse3" , NULL, 0, AV_OPT_TYPE_CONST, { CPUFLAG_SSSE3 }, .unit = "flags" },
- { "atom" , NULL, 0, AV_OPT_TYPE_CONST, { AV_CPU_FLAG_ATOM }, .unit = "flags" },
- { "sse4.1" , NULL, 0, AV_OPT_TYPE_CONST, { CPUFLAG_SSE4 }, .unit = "flags" },
- { "sse4.2" , NULL, 0, AV_OPT_TYPE_CONST, { CPUFLAG_SSE42 }, .unit = "flags" },
- { "avx" , NULL, 0, AV_OPT_TYPE_CONST, { CPUFLAG_AVX }, .unit = "flags" },
- { "xop" , NULL, 0, AV_OPT_TYPE_CONST, { CPUFLAG_XOP }, .unit = "flags" },
- { "fma4" , NULL, 0, AV_OPT_TYPE_CONST, { CPUFLAG_FMA4 }, .unit = "flags" },
- { "3dnow" , NULL, 0, AV_OPT_TYPE_CONST, { CPUFLAG_3DNOW }, .unit = "flags" },
- { "3dnowext", NULL, 0, AV_OPT_TYPE_CONST, { CPUFLAG_3DNOWEXT }, .unit = "flags" },
- { NULL },
- };
- static const AVClass class = {
- .class_name = "cpuflags",
- .item_name = av_default_item_name,
- .option = cpuflags_opts,
- .version = LIBAVUTIL_VERSION_INT,
- };
-
- int flags = 0, ret;
- const AVClass *pclass = &class;
-
- if ((ret = av_opt_eval_flags(&pclass, &cpuflags_opts[0], arg, &flags)) < 0)
- return ret;
-
- av_set_cpu_flags_mask(flags);
- return 0;
-}
-