/* * Copyright (c) 2010 The WebM project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #include "./vpxenc.h"#include "./vpx_config.h" #include <assert.h>#include <limits.h>#include <math.h>#include <stdarg.h>#include <stdio.h>#include <stdlib.h>#include <string.h> #if CONFIG_LIBYUV#include "third_party/libyuv/include/libyuv/scale.h"#endif #include "vpx/vpx_encoder.h"#if CONFIG_DECODERS#include "vpx/vpx_decoder.h"#endif #include "./args.h"#include "./ivfenc.h"#include "./tools_common.h" #if CONFIG_VP8_ENCODER || CONFIG_VP9_ENCODER#include "vpx/vp8cx.h"#endif#if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER#include "vpx/vp8dx.h"#endif #include "vpx/vpx_integer.h"#include "vpx_ports/mem_ops.h"#include "vpx_ports/vpx_timer.h"#include "./rate_hist.h"#include "./vpxstats.h"#include "./warnings.h"#if CONFIG_WEBM_IO#include "./webmenc.h"#endif#include "./y4minput.h" static size_t wrap_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) { return fwrite(ptr, size, nmemb, stream);}#define fwrite wrap_fwrite static const char *exec_name; static void warn_or_exit_on_errorv(vpx_codec_ctx_t *ctx, int fatal, const char *s, va_list ap) { if (ctx->err) { const char *detail = vpx_codec_error_detail(ctx); vfprintf(stderr, s, ap); fprintf(stderr, ": %s\n", vpx_codec_error(ctx)); if (detail) fprintf(stderr, " %s\n", detail); if (fatal) exit(EXIT_FAILURE); }} static void ctx_exit_on_error(vpx_codec_ctx_t *ctx, const char *s, ...) { va_list ap; va_start(ap, s); warn_or_exit_on_errorv(ctx, 1, s, ap); va_end(ap);} static void warn_or_exit_on_error(vpx_codec_ctx_t *ctx, int fatal, const char *s, ...) { va_list ap; va_start(ap, s); warn_or_exit_on_errorv(ctx, fatal, s, ap); va_end(ap);} static const arg_def_t help = ARG_DEF(NULL, "help", 0, "Show usage options and exit");static const arg_def_t debugmode = ARG_DEF("D", "debug", 0, "Debug mode (makes output deterministic)");static const arg_def_t outputfile = ARG_DEF("o", "output", 1, "Output filename");static const arg_def_t use_nv12 = ARG_DEF(NULL, "nv12", 0, "Input file is NV12 ");static const arg_def_t use_yv12 = ARG_DEF(NULL, "yv12", 0, "Input file is YV12 ");static const arg_def_t use_i420 = ARG_DEF(NULL, "i420", 0, "Input file is I420 (default)");static const arg_def_t use_i422 = ARG_DEF(NULL, "i422", 0, "Input file is I422");static const arg_def_t use_i444 = ARG_DEF(NULL, "i444", 0, "Input file is I444");static const arg_def_t use_i440 = ARG_DEF(NULL, "i440", 0, "Input file is I440");static const arg_def_t codecarg = ARG_DEF(NULL, "codec", 1, "Codec to use");static const arg_def_t passes = ARG_DEF("p", "passes", 1, "Number of passes (1/2)");static const arg_def_t pass_arg = ARG_DEF(NULL, "pass", 1, "Pass to execute (1/2)");static const arg_def_t fpf_name = ARG_DEF(NULL, "fpf", 1, "First pass statistics file name");static const arg_def_t limit = ARG_DEF(NULL, "limit", 1, "Stop encoding after n input frames");static const arg_def_t skip = ARG_DEF(NULL, "skip", 1, "Skip the first n input frames");static const arg_def_t deadline = ARG_DEF("d", "deadline", 1, "Deadline per frame (usec)");static const arg_def_t best_dl = ARG_DEF(NULL, "best", 0, "Use Best Quality Deadline");static const arg_def_t good_dl = ARG_DEF(NULL, "good", 0, "Use Good Quality Deadline");static const arg_def_t rt_dl = ARG_DEF(NULL, "rt", 0, "Use Realtime Quality Deadline");static const arg_def_t quietarg = ARG_DEF("q", "quiet", 0, "Do not print encode progress");static const arg_def_t verbosearg = ARG_DEF("v", "verbose", 0, "Show encoder parameters");static const arg_def_t psnrarg = ARG_DEF(NULL, "psnr", 0, "Show PSNR in status line"); static const struct arg_enum_list test_decode_enum[] = { { "off", TEST_DECODE_OFF }, { "fatal", TEST_DECODE_FATAL }, { "warn", TEST_DECODE_WARN }, { NULL, 0 }};static const arg_def_t recontest = ARG_DEF_ENUM( NULL, "test-decode", 1, "Test encode/decode mismatch", test_decode_enum);static const arg_def_t framerate = ARG_DEF(NULL, "fps", 1, "Stream frame rate (rate/scale)");static const arg_def_t use_webm = ARG_DEF(NULL, "webm", 0, "Output WebM (default when WebM IO is enabled)");static const arg_def_t use_ivf = ARG_DEF(NULL, "ivf", 0, "Output IVF");static const arg_def_t out_part = ARG_DEF("P", "output-partitions", 0, "Makes encoder output partitions. Requires IVF output!");static const arg_def_t q_hist_n = ARG_DEF(NULL, "q-hist", 1, "Show quantizer histogram (n-buckets)");static const arg_def_t rate_hist_n = ARG_DEF(NULL, "rate-hist", 1, "Show rate histogram (n-buckets)");static const arg_def_t disable_warnings = ARG_DEF(NULL, "disable-warnings", 0, "Disable warnings about potentially incorrect encode settings.");static const arg_def_t disable_warning_prompt = ARG_DEF("y", "disable-warning-prompt", 0, "Display warnings, but do not prompt user to continue."); #if CONFIG_VP9_HIGHBITDEPTHstatic const arg_def_t test16bitinternalarg = ARG_DEF( NULL, "test-16bit-internal", 0, "Force use of 16 bit internal buffer");#endif static const arg_def_t *main_args[] = { &help, &debugmode, &outputfile, &codecarg, &passes, &pass_arg, &fpf_name, &limit, &skip, &deadline, &best_dl, &good_dl, &rt_dl, &quietarg, &verbosearg, &psnrarg, &use_webm, &use_ivf, &out_part, &q_hist_n, &rate_hist_n, &disable_warnings, &disable_warning_prompt, &recontest, NULL }; static const arg_def_t usage = ARG_DEF("u", "usage", 1, "Usage profile number to use");static const arg_def_t threads = ARG_DEF("t", "threads", 1, "Max number of threads to use");static const arg_def_t profile = ARG_DEF(NULL, "profile", 1, "Bitstream profile number to use");static const arg_def_t width = ARG_DEF("w", "width", 1, "Frame width");static const arg_def_t height = ARG_DEF("h", "height", 1, "Frame height");#if CONFIG_WEBM_IOstatic const struct arg_enum_list stereo_mode_enum[] = { { "mono", STEREO_FORMAT_MONO }, { "left-right", STEREO_FORMAT_LEFT_RIGHT }, { "bottom-top", STEREO_FORMAT_BOTTOM_TOP }, { "top-bottom", STEREO_FORMAT_TOP_BOTTOM }, { "right-left", STEREO_FORMAT_RIGHT_LEFT }, { NULL, 0 }};static const arg_def_t stereo_mode = ARG_DEF_ENUM( NULL, "stereo-mode", 1, "Stereo 3D video format", stereo_mode_enum);#endifstatic const arg_def_t timebase = ARG_DEF( NULL, "timebase", 1, "Output timestamp precision (fractional seconds)");static const arg_def_t error_resilient = ARG_DEF(NULL, "error-resilient", 1, "Enable error resiliency features");static const arg_def_t lag_in_frames = ARG_DEF(NULL, "lag-in-frames", 1, "Max number of frames to lag"); static const arg_def_t *global_args[] = { &use_nv12, &use_yv12, &use_i420, &use_i422, &use_i444, &use_i440, &usage, &threads, &profile, &width, &height,#if CONFIG_WEBM_IO &stereo_mode,#endif &timebase, &framerate, &error_resilient,#if CONFIG_VP9_HIGHBITDEPTH &test16bitinternalarg,#endif &lag_in_frames, NULL }; static const arg_def_t dropframe_thresh = ARG_DEF(NULL, "drop-frame", 1, "Temporal resampling threshold (buf %)");static const arg_def_t resize_allowed = ARG_DEF(NULL, "resize-allowed", 1, "Spatial resampling enabled (bool)");static const arg_def_t resize_width = ARG_DEF(NULL, "resize-width", 1, "Width of encoded frame");static const arg_def_t resize_height = ARG_DEF(NULL, "resize-height", 1, "Height of encoded frame");static const arg_def_t resize_up_thresh = ARG_DEF(NULL, "resize-up", 1, "Upscale threshold (buf %)");static const arg_def_t resize_down_thresh = ARG_DEF(NULL, "resize-down", 1, "Downscale threshold (buf %)");static const struct arg_enum_list end_usage_enum[] = { { "vbr", VPX_VBR }, { "cbr", VPX_CBR }, { "cq", VPX_CQ }, { "q", VPX_Q }, { NULL, 0 } };static const arg_def_t end_usage = ARG_DEF_ENUM(NULL, "end-usage", 1, "Rate control mode", end_usage_enum);static const arg_def_t target_bitrate = ARG_DEF(NULL, "target-bitrate", 1, "Bitrate (kbps)");static const arg_def_t min_quantizer = ARG_DEF(NULL, "min-q", 1, "Minimum (best) quantizer");static const arg_def_t max_quantizer = ARG_DEF(NULL, "max-q", 1, "Maximum (worst) quantizer");static const arg_def_t undershoot_pct = ARG_DEF(NULL, "undershoot-pct", 1, "Datarate undershoot (min) target (%)");static const arg_def_t overshoot_pct = ARG_DEF(NULL, "overshoot-pct", 1, "Datarate overshoot (max) target (%)");static const arg_def_t buf_sz = ARG_DEF(NULL, "buf-sz", 1, "Client buffer size (ms)");static const arg_def_t buf_initial_sz = ARG_DEF(NULL, "buf-initial-sz", 1, "Client initial buffer size (ms)");static const arg_def_t buf_optimal_sz = ARG_DEF(NULL, "buf-optimal-sz", 1, "Client optimal buffer size (ms)");static const arg_def_t *rc_args[] = { &dropframe_thresh, &resize_allowed, &resize_width, &resize_height, &resize_up_thresh, &resize_down_thresh, &end_usage, &target_bitrate, &min_quantizer, &max_quantizer, &undershoot_pct, &overshoot_pct, &buf_sz, &buf_initial_sz, &buf_optimal_sz, NULL}; #if CONFIG_VP9_ENCODERstatic const arg_def_t use_vizier_rc_params = ARG_DEF(NULL, "use-vizier-rc-params", 1, "Use vizier rc params");static const arg_def_t active_wq_factor = ARG_DEF(NULL, "active-wq-factor", 1, "Active worst quality factor");static const arg_def_t err_per_mb_factor = ARG_DEF(NULL, "err-per-mb-factor", 1, "Error per macroblock factor");static const arg_def_t sr_default_decay_limit = ARG_DEF( NULL, "sr-default-decay-limit", 1, "Second reference default decay limit");static const arg_def_t sr_diff_factor = ARG_DEF(NULL, "sr-diff-factor", 1, "Second reference diff factor");static const arg_def_t kf_err_per_mb_factor = ARG_DEF( NULL, "kf-err-per-mb-factor", 1, "Keyframe error per macroblock factor");static const arg_def_t kf_frame_min_boost_factor = ARG_DEF(NULL, "kf-frame-min-boost-factor", 1, "Keyframe min boost");static const arg_def_t kf_frame_max_boost_first_factor = ARG_DEF(NULL, "kf-frame-max-boost-first-factor", 1, "Max keyframe boost adjustment factor for first frame");static const arg_def_t kf_frame_max_boost_subs_factor = ARG_DEF(NULL, "kf-frame-max-boost-subs-factor", 1, "Max boost adjustment factor for subsequent KFs");static const arg_def_t kf_max_total_boost_factor = ARG_DEF( NULL, "kf-max-total-boost-factor", 1, "Keyframe max total boost factor");static const arg_def_t gf_max_total_boost_factor = ARG_DEF(NULL, "gf-max-total-boost-factor", 1, "Golden frame max total boost factor");static const arg_def_t gf_frame_max_boost_factor = ARG_DEF(NULL, "gf-frame-max-boost-factor", 1, "Golden frame max per frame boost factor");static const arg_def_t zm_factor = ARG_DEF(NULL, "zm-factor", 1, "Zero motion power factor");static const arg_def_t rd_mult_inter_qp_fac = ARG_DEF(NULL, "rd-mult-inter-qp-fac", 1, "RD multiplier adjustment for inter frames");static const arg_def_t rd_mult_arf_qp_fac = ARG_DEF(NULL, "rd-mult-arf-qp-fac", 1, "RD multiplier adjustment for alt-ref frames");static const arg_def_t rd_mult_key_qp_fac = ARG_DEF( NULL, "rd-mult-key-qp-fac", 1, "RD multiplier adjustment for key frames");static const arg_def_t *vizier_rc_args[] = { &use_vizier_rc_params, &active_wq_factor, &err_per_mb_factor, &sr_default_decay_limit, &sr_diff_factor, &kf_err_per_mb_factor, &kf_frame_min_boost_factor, &kf_frame_max_boost_first_factor, &kf_frame_max_boost_subs_factor, &kf_max_total_boost_factor, &gf_max_total_boost_factor, &gf_frame_max_boost_factor, &zm_factor, &rd_mult_inter_qp_fac, &rd_mult_arf_qp_fac, &rd_mult_key_qp_fac, NULL };#endif static const arg_def_t bias_pct = ARG_DEF(NULL, "bias-pct", 1, "CBR/VBR bias (0=CBR, 100=VBR)");static const arg_def_t minsection_pct = ARG_DEF(NULL, "minsection-pct", 1, "GOP min bitrate (% of target)");static const arg_def_t maxsection_pct = ARG_DEF(NULL, "maxsection-pct", 1, "GOP max bitrate (% of target)");static const arg_def_t corpus_complexity = ARG_DEF(NULL, "corpus-complexity", 1, "corpus vbr complexity midpoint");static const arg_def_t *rc_twopass_args[] = { &bias_pct, &minsection_pct, &maxsection_pct, &corpus_complexity, NULL }; static const arg_def_t kf_min_dist = ARG_DEF(NULL, "kf-min-dist", 1, "Minimum keyframe interval (frames)");static const arg_def_t kf_max_dist = ARG_DEF(NULL, "kf-max-dist", 1, "Maximum keyframe interval (frames)");static const arg_def_t kf_disabled = ARG_DEF(NULL, "disable-kf", 0, "Disable keyframe placement");static const arg_def_t *kf_args[] = { &kf_min_dist, &kf_max_dist, &kf_disabled, NULL }; static const arg_def_t noise_sens = ARG_DEF(NULL, "noise-sensitivity", 1, "Noise sensitivity (frames to blur)");static const arg_def_t sharpness = ARG_DEF(NULL, "sharpness", 1, "Increase sharpness at the expense of lower PSNR. (0..7)");static const arg_def_t static_thresh = ARG_DEF(NULL, "static-thresh", 1, "Motion detection threshold");static const arg_def_t arnr_maxframes = ARG_DEF(NULL, "arnr-maxframes", 1, "AltRef max frames (0..15)");static const arg_def_t arnr_strength = ARG_DEF(NULL, "arnr-strength", 1, "AltRef filter strength (0..6)");static const arg_def_t arnr_type = ARG_DEF(NULL, "arnr-type", 1, "AltRef filter type (1..3)");static const struct arg_enum_list tuning_enum[] = { { "psnr", VP8_TUNE_PSNR }, { "ssim", VP8_TUNE_SSIM }, { NULL, 0 } };static const arg_def_t tune_ssim = ARG_DEF_ENUM(NULL, "tune", 1, "Material to favor", tuning_enum);static const arg_def_t cq_level = ARG_DEF(NULL, "cq-level", 1, "Constant/Constrained Quality level");static const arg_def_t max_intra_rate_pct = ARG_DEF(NULL, "max-intra-rate", 1, "Max I-frame bitrate (pct)");static const arg_def_t gf_cbr_boost_pct = ARG_DEF( NULL, "gf-cbr-boost", 1, "Boost for Golden Frame in CBR mode (pct)"); #if CONFIG_VP8_ENCODERstatic const arg_def_t cpu_used_vp8 = ARG_DEF(NULL, "cpu-used", 1, "CPU Used (-16..16)");static const arg_def_t auto_altref_vp8 = ARG_DEF( NULL, "auto-alt-ref", 1, "Enable automatic alt reference frames. (0..1)");static const arg_def_t token_parts = ARG_DEF(NULL, "token-parts", 1, "Number of token partitions to use, log2");static const arg_def_t screen_content_mode = ARG_DEF(NULL, "screen-content-mode", 1, "Screen content mode");static const arg_def_t *vp8_args[] = { &cpu_used_vp8, &auto_altref_vp8, &noise_sens, &sharpness, &static_thresh, &token_parts, &arnr_maxframes, &arnr_strength, &arnr_type, &tune_ssim, &cq_level, &max_intra_rate_pct, &gf_cbr_boost_pct, &screen_content_mode, NULL };static const int vp8_arg_ctrl_map[] = { VP8E_SET_CPUUSED, VP8E_SET_ENABLEAUTOALTREF, VP8E_SET_NOISE_SENSITIVITY, VP8E_SET_SHARPNESS, VP8E_SET_STATIC_THRESHOLD, VP8E_SET_TOKEN_PARTITIONS, VP8E_SET_ARNR_MAXFRAMES, VP8E_SET_ARNR_STRENGTH, VP8E_SET_ARNR_TYPE, VP8E_SET_TUNING, VP8E_SET_CQ_LEVEL, VP8E_SET_MAX_INTRA_BITRATE_PCT, VP8E_SET_GF_CBR_BOOST_PCT, VP8E_SET_SCREEN_CONTENT_MODE, 0 };#endif #if CONFIG_VP9_ENCODERstatic const arg_def_t cpu_used_vp9 = ARG_DEF(NULL, "cpu-used", 1, "CPU Used (-9..9)");static const arg_def_t auto_altref_vp9 = ARG_DEF( NULL, "auto-alt-ref", 1, "Enable automatic alt reference frames, 2+ enables multi-layer. (0..6)");static const arg_def_t tile_cols = ARG_DEF(NULL, "tile-columns", 1, "Number of tile columns to use, log2");static const arg_def_t tile_rows = ARG_DEF(NULL, "tile-rows", 1, "Number of tile rows to use, log2 (set to 0 while threads > 1)"); static const arg_def_t enable_tpl_model = ARG_DEF(NULL, "enable-tpl", 1, "Enable temporal dependency model"); static const arg_def_t lossless = ARG_DEF(NULL, "lossless", 1, "Lossless mode (0: false (default), 1: true)");static const arg_def_t frame_parallel_decoding = ARG_DEF( NULL, "frame-parallel", 1, "Enable frame parallel decodability features");static const arg_def_t aq_mode = ARG_DEF( NULL, "aq-mode", 1, "Adaptive quantization mode (0: off (default), 1: variance 2: complexity, " "3: cyclic refresh, 4: equator360)");static const arg_def_t alt_ref_aq = ARG_DEF(NULL, "alt-ref-aq", 1, "Special adaptive quantization for " "the alternate reference frames.");static const arg_def_t frame_periodic_boost = ARG_DEF(NULL, "frame-boost", 1, "Enable frame periodic boost (0: off (default), 1: on)");static const arg_def_t max_inter_rate_pct = ARG_DEF(NULL, "max-inter-rate", 1, "Max P-frame bitrate (pct)");static const arg_def_t min_gf_interval = ARG_DEF( NULL, "min-gf-interval", 1, "min gf/arf frame interval (default 0, indicating in-built behavior)");static const arg_def_t max_gf_interval = ARG_DEF( NULL, "max-gf-interval", 1, "max gf/arf frame interval (default 0, indicating in-built behavior)"); static const struct arg_enum_list color_space_enum[] = { { "unknown", VPX_CS_UNKNOWN }, { "bt601", VPX_CS_BT_601 }, { "bt709", VPX_CS_BT_709 }, { "smpte170", VPX_CS_SMPTE_170 }, { "smpte240", VPX_CS_SMPTE_240 }, { "bt2020", VPX_CS_BT_2020 }, { "reserved", VPX_CS_RESERVED }, { "sRGB", VPX_CS_SRGB }, { NULL, 0 }}; static const arg_def_t input_color_space = ARG_DEF_ENUM(NULL, "color-space", 1, "The color space of input content:", color_space_enum); #if CONFIG_VP9_HIGHBITDEPTHstatic const struct arg_enum_list bitdepth_enum[] = { { "8", VPX_BITS_8 }, { "10", VPX_BITS_10 }, { "12", VPX_BITS_12 }, { NULL, 0 }}; static const arg_def_t bitdeptharg = ARG_DEF_ENUM( "b", "bit-depth", 1, "Bit depth for codec (8 for version <=1, 10 or 12 for version 2)", bitdepth_enum);static const arg_def_t inbitdeptharg = ARG_DEF(NULL, "input-bit-depth", 1, "Bit depth of input");#endif static const struct arg_enum_list tune_content_enum[] = { { "default", VP9E_CONTENT_DEFAULT }, { "screen", VP9E_CONTENT_SCREEN },Lines 1–500 of 2061. Load more
/* * Copyright (c) 2010 The WebM project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #include "./vpxenc.h" #include "./vpx_config.h" #include <assert.h> #include <limits.h> #include <math.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #if CONFIG_LIBYUV #include "third_party/libyuv/include/libyuv/scale.h" #endif #include "vpx/vpx_encoder.h" #if CONFIG_DECODERS #include "vpx/vpx_decoder.h" #endif #include "./args.h" #include "./ivfenc.h" #include "./tools_common.h" #if CONFIG_VP8_ENCODER || CONFIG_VP9_ENCODER #include "vpx/vp8cx.h" #endif #if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER #include "vpx/vp8dx.h" #endif #include "vpx/vpx_integer.h" #include "vpx_ports/mem_ops.h" #include "vpx_ports/vpx_timer.h" #include "./rate_hist.h" #include "./vpxstats.h" #include "./warnings.h" #if CONFIG_WEBM_IO #include "./webmenc.h" #endif #include "./y4minput.h" static size_t wrap_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) { return fwrite(ptr, size, nmemb, stream); } #define fwrite wrap_fwrite static const char *exec_name; static void warn_or_exit_on_errorv(vpx_codec_ctx_t *ctx, int fatal, const char *s, va_list ap) { if (ctx->err) { const char *detail = vpx_codec_error_detail(ctx); vfprintf(stderr, s, ap); fprintf(stderr, ": %s\n", vpx_codec_error(ctx)); if (detail) fprintf(stderr, " %s\n", detail); if (fatal) exit(EXIT_FAILURE); } } static void ctx_exit_on_error(vpx_codec_ctx_t *ctx, const char *s, ...) { va_list ap; va_start(ap, s); warn_or_exit_on_errorv(ctx, 1, s, ap); va_end(ap); } static void warn_or_exit_on_error(vpx_codec_ctx_t *ctx, int fatal, const char *s, ...) { va_list ap; va_start(ap, s); warn_or_exit_on_errorv(ctx, fatal, s, ap); va_end(ap); } static const arg_def_t help = ARG_DEF(NULL, "help", 0, "Show usage options and exit"); static const arg_def_t debugmode = ARG_DEF("D", "debug", 0, "Debug mode (makes output deterministic)"); static const arg_def_t outputfile = ARG_DEF("o", "output", 1, "Output filename"); static const arg_def_t use_nv12 = ARG_DEF(NULL, "nv12", 0, "Input file is NV12 "); static const arg_def_t use_yv12 = ARG_DEF(NULL, "yv12", 0, "Input file is YV12 "); static const arg_def_t use_i420 = ARG_DEF(NULL, "i420", 0, "Input file is I420 (default)"); static const arg_def_t use_i422 = ARG_DEF(NULL, "i422", 0, "Input file is I422"); static const arg_def_t use_i444 = ARG_DEF(NULL, "i444", 0, "Input file is I444"); static const arg_def_t use_i440 = ARG_DEF(NULL, "i440", 0, "Input file is I440"); static const arg_def_t codecarg = ARG_DEF(NULL, "codec", 1, "Codec to use"); static const arg_def_t passes = ARG_DEF("p", "passes", 1, "Number of passes (1/2)"); static const arg_def_t pass_arg = ARG_DEF(NULL, "pass", 1, "Pass to execute (1/2)"); static const arg_def_t fpf_name = ARG_DEF(NULL, "fpf", 1, "First pass statistics file name"); static const arg_def_t limit = ARG_DEF(NULL, "limit", 1, "Stop encoding after n input frames"); static const arg_def_t skip = ARG_DEF(NULL, "skip", 1, "Skip the first n input frames"); static const arg_def_t deadline = ARG_DEF("d", "deadline", 1, "Deadline per frame (usec)"); static const arg_def_t best_dl = ARG_DEF(NULL, "best", 0, "Use Best Quality Deadline"); static const arg_def_t good_dl = ARG_DEF(NULL, "good", 0, "Use Good Quality Deadline"); static const arg_def_t rt_dl = ARG_DEF(NULL, "rt", 0, "Use Realtime Quality Deadline"); static const arg_def_t quietarg = ARG_DEF("q", "quiet", 0, "Do not print encode progress"); static const arg_def_t verbosearg = ARG_DEF("v", "verbose", 0, "Show encoder parameters"); static const arg_def_t psnrarg = ARG_DEF(NULL, "psnr", 0, "Show PSNR in status line"); static const struct arg_enum_list test_decode_enum[] = { { "off", TEST_DECODE_OFF }, { "fatal", TEST_DECODE_FATAL }, { "warn", TEST_DECODE_WARN }, { NULL, 0 } }; static const arg_def_t recontest = ARG_DEF_ENUM( NULL, "test-decode", 1, "Test encode/decode mismatch", test_decode_enum); static const arg_def_t framerate = ARG_DEF(NULL, "fps", 1, "Stream frame rate (rate/scale)"); static const arg_def_t use_webm = ARG_DEF(NULL, "webm", 0, "Output WebM (default when WebM IO is enabled)"); static const arg_def_t use_ivf = ARG_DEF(NULL, "ivf", 0, "Output IVF"); static const arg_def_t out_part = ARG_DEF("P", "output-partitions", 0, "Makes encoder output partitions. Requires IVF output!"); static const arg_def_t q_hist_n = ARG_DEF(NULL, "q-hist", 1, "Show quantizer histogram (n-buckets)"); static const arg_def_t rate_hist_n = ARG_DEF(NULL, "rate-hist", 1, "Show rate histogram (n-buckets)"); static const arg_def_t disable_warnings = ARG_DEF(NULL, "disable-warnings", 0, "Disable warnings about potentially incorrect encode settings."); static const arg_def_t disable_warning_prompt = ARG_DEF("y", "disable-warning-prompt", 0, "Display warnings, but do not prompt user to continue."); #if CONFIG_VP9_HIGHBITDEPTH static const arg_def_t test16bitinternalarg = ARG_DEF( NULL, "test-16bit-internal", 0, "Force use of 16 bit internal buffer"); #endif static const arg_def_t *main_args[] = { &help, &debugmode, &outputfile, &codecarg, &passes, &pass_arg, &fpf_name, &limit, &skip, &deadline, &best_dl, &good_dl, &rt_dl, &quietarg, &verbosearg, &psnrarg, &use_webm, &use_ivf, &out_part, &q_hist_n, &rate_hist_n, &disable_warnings, &disable_warning_prompt, &recontest, NULL }; static const arg_def_t usage = ARG_DEF("u", "usage", 1, "Usage profile number to use"); static const arg_def_t threads = ARG_DEF("t", "threads", 1, "Max number of threads to use"); static const arg_def_t profile = ARG_DEF(NULL, "profile", 1, "Bitstream profile number to use"); static const arg_def_t width = ARG_DEF("w", "width", 1, "Frame width"); static const arg_def_t height = ARG_DEF("h", "height", 1, "Frame height"); #if CONFIG_WEBM_IO static const struct arg_enum_list stereo_mode_enum[] = { { "mono", STEREO_FORMAT_MONO }, { "left-right", STEREO_FORMAT_LEFT_RIGHT }, { "bottom-top", STEREO_FORMAT_BOTTOM_TOP }, { "top-bottom", STEREO_FORMAT_TOP_BOTTOM }, { "right-left", STEREO_FORMAT_RIGHT_LEFT }, { NULL, 0 } }; static const arg_def_t stereo_mode = ARG_DEF_ENUM( NULL, "stereo-mode", 1, "Stereo 3D video format", stereo_mode_enum); #endif static const arg_def_t timebase = ARG_DEF( NULL, "timebase", 1, "Output timestamp precision (fractional seconds)"); static const arg_def_t error_resilient = ARG_DEF(NULL, "error-resilient", 1, "Enable error resiliency features"); static const arg_def_t lag_in_frames = ARG_DEF(NULL, "lag-in-frames", 1, "Max number of frames to lag"); static const arg_def_t *global_args[] = { &use_nv12, &use_yv12, &use_i420, &use_i422, &use_i444, &use_i440, &usage, &threads, &profile, &width, &height, #if CONFIG_WEBM_IO &stereo_mode, #endif &timebase, &framerate, &error_resilient, #if CONFIG_VP9_HIGHBITDEPTH &test16bitinternalarg, #endif &lag_in_frames, NULL }; static const arg_def_t dropframe_thresh = ARG_DEF(NULL, "drop-frame", 1, "Temporal resampling threshold (buf %)"); static const arg_def_t resize_allowed = ARG_DEF(NULL, "resize-allowed", 1, "Spatial resampling enabled (bool)"); static const arg_def_t resize_width = ARG_DEF(NULL, "resize-width", 1, "Width of encoded frame"); static const arg_def_t resize_height = ARG_DEF(NULL, "resize-height", 1, "Height of encoded frame"); static const arg_def_t resize_up_thresh = ARG_DEF(NULL, "resize-up", 1, "Upscale threshold (buf %)"); static const arg_def_t resize_down_thresh = ARG_DEF(NULL, "resize-down", 1, "Downscale threshold (buf %)"); static const struct arg_enum_list end_usage_enum[] = { { "vbr", VPX_VBR }, { "cbr", VPX_CBR }, { "cq", VPX_CQ }, { "q", VPX_Q }, { NULL, 0 } }; static const arg_def_t end_usage = ARG_DEF_ENUM(NULL, "end-usage", 1, "Rate control mode", end_usage_enum); static const arg_def_t target_bitrate = ARG_DEF(NULL, "target-bitrate", 1, "Bitrate (kbps)"); static const arg_def_t min_quantizer = ARG_DEF(NULL, "min-q", 1, "Minimum (best) quantizer"); static const arg_def_t max_quantizer = ARG_DEF(NULL, "max-q", 1, "Maximum (worst) quantizer"); static const arg_def_t undershoot_pct = ARG_DEF(NULL, "undershoot-pct", 1, "Datarate undershoot (min) target (%)"); static const arg_def_t overshoot_pct = ARG_DEF(NULL, "overshoot-pct", 1, "Datarate overshoot (max) target (%)"); static const arg_def_t buf_sz = ARG_DEF(NULL, "buf-sz", 1, "Client buffer size (ms)"); static const arg_def_t buf_initial_sz = ARG_DEF(NULL, "buf-initial-sz", 1, "Client initial buffer size (ms)"); static const arg_def_t buf_optimal_sz = ARG_DEF(NULL, "buf-optimal-sz", 1, "Client optimal buffer size (ms)"); static const arg_def_t *rc_args[] = { &dropframe_thresh, &resize_allowed, &resize_width, &resize_height, &resize_up_thresh, &resize_down_thresh, &end_usage, &target_bitrate, &min_quantizer, &max_quantizer, &undershoot_pct, &overshoot_pct, &buf_sz, &buf_initial_sz, &buf_optimal_sz, NULL }; #if CONFIG_VP9_ENCODER static const arg_def_t use_vizier_rc_params = ARG_DEF(NULL, "use-vizier-rc-params", 1, "Use vizier rc params"); static const arg_def_t active_wq_factor = ARG_DEF(NULL, "active-wq-factor", 1, "Active worst quality factor"); static const arg_def_t err_per_mb_factor = ARG_DEF(NULL, "err-per-mb-factor", 1, "Error per macroblock factor"); static const arg_def_t sr_default_decay_limit = ARG_DEF( NULL, "sr-default-decay-limit", 1, "Second reference default decay limit"); static const arg_def_t sr_diff_factor = ARG_DEF(NULL, "sr-diff-factor", 1, "Second reference diff factor"); static const arg_def_t kf_err_per_mb_factor = ARG_DEF( NULL, "kf-err-per-mb-factor", 1, "Keyframe error per macroblock factor"); static const arg_def_t kf_frame_min_boost_factor = ARG_DEF(NULL, "kf-frame-min-boost-factor", 1, "Keyframe min boost"); static const arg_def_t kf_frame_max_boost_first_factor = ARG_DEF(NULL, "kf-frame-max-boost-first-factor", 1, "Max keyframe boost adjustment factor for first frame"); static const arg_def_t kf_frame_max_boost_subs_factor = ARG_DEF(NULL, "kf-frame-max-boost-subs-factor", 1, "Max boost adjustment factor for subsequent KFs"); static const arg_def_t kf_max_total_boost_factor = ARG_DEF( NULL, "kf-max-total-boost-factor", 1, "Keyframe max total boost factor"); static const arg_def_t gf_max_total_boost_factor = ARG_DEF(NULL, "gf-max-total-boost-factor", 1, "Golden frame max total boost factor"); static const arg_def_t gf_frame_max_boost_factor = ARG_DEF(NULL, "gf-frame-max-boost-factor", 1, "Golden frame max per frame boost factor"); static const arg_def_t zm_factor = ARG_DEF(NULL, "zm-factor", 1, "Zero motion power factor"); static const arg_def_t rd_mult_inter_qp_fac = ARG_DEF(NULL, "rd-mult-inter-qp-fac", 1, "RD multiplier adjustment for inter frames"); static const arg_def_t rd_mult_arf_qp_fac = ARG_DEF(NULL, "rd-mult-arf-qp-fac", 1, "RD multiplier adjustment for alt-ref frames"); static const arg_def_t rd_mult_key_qp_fac = ARG_DEF( NULL, "rd-mult-key-qp-fac", 1, "RD multiplier adjustment for key frames"); static const arg_def_t *vizier_rc_args[] = { &use_vizier_rc_params, &active_wq_factor, &err_per_mb_factor, &sr_default_decay_limit, &sr_diff_factor, &kf_err_per_mb_factor, &kf_frame_min_boost_factor, &kf_frame_max_boost_first_factor, &kf_frame_max_boost_subs_factor, &kf_max_total_boost_factor, &gf_max_total_boost_factor, &gf_frame_max_boost_factor, &zm_factor, &rd_mult_inter_qp_fac, &rd_mult_arf_qp_fac, &rd_mult_key_qp_fac, NULL }; #endif static const arg_def_t bias_pct = ARG_DEF(NULL, "bias-pct", 1, "CBR/VBR bias (0=CBR, 100=VBR)"); static const arg_def_t minsection_pct = ARG_DEF(NULL, "minsection-pct", 1, "GOP min bitrate (% of target)"); static const arg_def_t maxsection_pct = ARG_DEF(NULL, "maxsection-pct", 1, "GOP max bitrate (% of target)"); static const arg_def_t corpus_complexity = ARG_DEF(NULL, "corpus-complexity", 1, "corpus vbr complexity midpoint"); static const arg_def_t *rc_twopass_args[] = { &bias_pct, &minsection_pct, &maxsection_pct, &corpus_complexity, NULL }; static const arg_def_t kf_min_dist = ARG_DEF(NULL, "kf-min-dist", 1, "Minimum keyframe interval (frames)"); static const arg_def_t kf_max_dist = ARG_DEF(NULL, "kf-max-dist", 1, "Maximum keyframe interval (frames)"); static const arg_def_t kf_disabled = ARG_DEF(NULL, "disable-kf", 0, "Disable keyframe placement"); static const arg_def_t *kf_args[] = { &kf_min_dist, &kf_max_dist, &kf_disabled, NULL }; static const arg_def_t noise_sens = ARG_DEF(NULL, "noise-sensitivity", 1, "Noise sensitivity (frames to blur)"); static const arg_def_t sharpness = ARG_DEF(NULL, "sharpness", 1, "Increase sharpness at the expense of lower PSNR. (0..7)"); static const arg_def_t static_thresh = ARG_DEF(NULL, "static-thresh", 1, "Motion detection threshold"); static const arg_def_t arnr_maxframes = ARG_DEF(NULL, "arnr-maxframes", 1, "AltRef max frames (0..15)"); static const arg_def_t arnr_strength = ARG_DEF(NULL, "arnr-strength", 1, "AltRef filter strength (0..6)"); static const arg_def_t arnr_type = ARG_DEF(NULL, "arnr-type", 1, "AltRef filter type (1..3)"); static const struct arg_enum_list tuning_enum[] = { { "psnr", VP8_TUNE_PSNR }, { "ssim", VP8_TUNE_SSIM }, { NULL, 0 } }; static const arg_def_t tune_ssim = ARG_DEF_ENUM(NULL, "tune", 1, "Material to favor", tuning_enum); static const arg_def_t cq_level = ARG_DEF(NULL, "cq-level", 1, "Constant/Constrained Quality level"); static const arg_def_t max_intra_rate_pct = ARG_DEF(NULL, "max-intra-rate", 1, "Max I-frame bitrate (pct)"); static const arg_def_t gf_cbr_boost_pct = ARG_DEF( NULL, "gf-cbr-boost", 1, "Boost for Golden Frame in CBR mode (pct)"); #if CONFIG_VP8_ENCODER static const arg_def_t cpu_used_vp8 = ARG_DEF(NULL, "cpu-used", 1, "CPU Used (-16..16)"); static const arg_def_t auto_altref_vp8 = ARG_DEF( NULL, "auto-alt-ref", 1, "Enable automatic alt reference frames. (0..1)"); static const arg_def_t token_parts = ARG_DEF(NULL, "token-parts", 1, "Number of token partitions to use, log2"); static const arg_def_t screen_content_mode = ARG_DEF(NULL, "screen-content-mode", 1, "Screen content mode"); static const arg_def_t *vp8_args[] = { &cpu_used_vp8, &auto_altref_vp8, &noise_sens, &sharpness, &static_thresh, &token_parts, &arnr_maxframes, &arnr_strength, &arnr_type, &tune_ssim, &cq_level, &max_intra_rate_pct, &gf_cbr_boost_pct, &screen_content_mode, NULL }; static const int vp8_arg_ctrl_map[] = { VP8E_SET_CPUUSED, VP8E_SET_ENABLEAUTOALTREF, VP8E_SET_NOISE_SENSITIVITY, VP8E_SET_SHARPNESS, VP8E_SET_STATIC_THRESHOLD, VP8E_SET_TOKEN_PARTITIONS, VP8E_SET_ARNR_MAXFRAMES, VP8E_SET_ARNR_STRENGTH, VP8E_SET_ARNR_TYPE, VP8E_SET_TUNING, VP8E_SET_CQ_LEVEL, VP8E_SET_MAX_INTRA_BITRATE_PCT, VP8E_SET_GF_CBR_BOOST_PCT, VP8E_SET_SCREEN_CONTENT_MODE, 0 }; #endif #if CONFIG_VP9_ENCODER static const arg_def_t cpu_used_vp9 = ARG_DEF(NULL, "cpu-used", 1, "CPU Used (-9..9)"); static const arg_def_t auto_altref_vp9 = ARG_DEF( NULL, "auto-alt-ref", 1, "Enable automatic alt reference frames, 2+ enables multi-layer. (0..6)"); static const arg_def_t tile_cols = ARG_DEF(NULL, "tile-columns", 1, "Number of tile columns to use, log2"); static const arg_def_t tile_rows = ARG_DEF(NULL, "tile-rows", 1, "Number of tile rows to use, log2 (set to 0 while threads > 1)"); static const arg_def_t enable_tpl_model = ARG_DEF(NULL, "enable-tpl", 1, "Enable temporal dependency model"); static const arg_def_t lossless = ARG_DEF(NULL, "lossless", 1, "Lossless mode (0: false (default), 1: true)"); static const arg_def_t frame_parallel_decoding = ARG_DEF( NULL, "frame-parallel", 1, "Enable frame parallel decodability features"); static const arg_def_t aq_mode = ARG_DEF( NULL, "aq-mode", 1, "Adaptive quantization mode (0: off (default), 1: variance 2: complexity, " "3: cyclic refresh, 4: equator360)"); static const arg_def_t alt_ref_aq = ARG_DEF(NULL, "alt-ref-aq", 1, "Special adaptive quantization for " "the alternate reference frames."); static const arg_def_t frame_periodic_boost = ARG_DEF(NULL, "frame-boost", 1, "Enable frame periodic boost (0: off (default), 1: on)"); static const arg_def_t max_inter_rate_pct = ARG_DEF(NULL, "max-inter-rate", 1, "Max P-frame bitrate (pct)"); static const arg_def_t min_gf_interval = ARG_DEF( NULL, "min-gf-interval", 1, "min gf/arf frame interval (default 0, indicating in-built behavior)"); static const arg_def_t max_gf_interval = ARG_DEF( NULL, "max-gf-interval", 1, "max gf/arf frame interval (default 0, indicating in-built behavior)"); static const struct arg_enum_list color_space_enum[] = { { "unknown", VPX_CS_UNKNOWN }, { "bt601", VPX_CS_BT_601 }, { "bt709", VPX_CS_BT_709 }, { "smpte170", VPX_CS_SMPTE_170 }, { "smpte240", VPX_CS_SMPTE_240 }, { "bt2020", VPX_CS_BT_2020 }, { "reserved", VPX_CS_RESERVED }, { "sRGB", VPX_CS_SRGB }, { NULL, 0 } }; static const arg_def_t input_color_space = ARG_DEF_ENUM(NULL, "color-space", 1, "The color space of input content:", color_space_enum); #if CONFIG_VP9_HIGHBITDEPTH static const struct arg_enum_list bitdepth_enum[] = { { "8", VPX_BITS_8 }, { "10", VPX_BITS_10 }, { "12", VPX_BITS_12 }, { NULL, 0 } }; static const arg_def_t bitdeptharg = ARG_DEF_ENUM( "b", "bit-depth", 1, "Bit depth for codec (8 for version <=1, 10 or 12 for version 2)", bitdepth_enum); static const arg_def_t inbitdeptharg = ARG_DEF(NULL, "input-bit-depth", 1, "Bit depth of input"); #endif static const struct arg_enum_list tune_content_enum[] = { { "default", VP9E_CONTENT_DEFAULT }, { "screen", VP9E_CONTENT_SCREEN },