#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 "third_party/libyuv/include/libyuv/scale.h"
#include "./args.h"
#include "./ivfenc.h"
#include "./tools_common.h"
"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 codecarg = ARG_DEF(NULL, "codec", 1,
"Codec to use");
static const arg_def_t passes = ARG_DEF("p", "passes", 1,
"Pass to execute (1/2)");
static const arg_def_t fpf_name = ARG_DEF(NULL, "fpf", 1,
"First pass statistics file name");
+#if CONFIG_FP_MB_STATS
+static const arg_def_t fpmbf_name = ARG_DEF(NULL, "fpmbf", 1,
+ "First pass block statistics file name");
+#endif
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,
"Max number of frames to lag");
static const arg_def_t *global_args[] = {
- &use_yv12, &use_i420, &usage, &threads, &profile,
+ &use_yv12, &use_i420, &use_i422, &use_i444,
+ &usage, &threads, &profile,
&width, &height,
#if CONFIG_WEBM_IO
&stereo_mode,
NULL, "frame_boost", 1,
"Enable frame periodic boost (0: off (default), 1: on)");
+static const struct arg_enum_list tune_content_enum[] = {
+ {"default", VP9E_CONTENT_DEFAULT},
+ {"screen", VP9E_CONTENT_SCREEN},
+ {NULL, 0}
+};
+
+static const arg_def_t tune_content = ARG_DEF_ENUM(
+ NULL, "tune-content", 1, "Tune content type", tune_content_enum);
+
static const arg_def_t *vp9_args[] = {
&cpu_used, &auto_altref, &noise_sens, &sharpness, &static_thresh,
&tile_cols, &tile_rows, &arnr_maxframes, &arnr_strength, &arnr_type,
&tune_ssim, &cq_level, &max_intra_rate_pct, &lossless,
- &frame_parallel_decoding, &aq_mode, &frame_periodic_boost,
+ &frame_parallel_decoding, &aq_mode, &frame_periodic_boost, &tune_content,
NULL
};
static const int vp9_arg_ctrl_map[] = {
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,
VP9E_SET_LOSSLESS, VP9E_SET_FRAME_PARALLEL_DECODING, VP9E_SET_AQ_MODE,
- VP9E_SET_FRAME_PERIODIC_BOOST,
+ VP9E_SET_FRAME_PERIODIC_BOOST, VP9E_SET_TUNE_CONTENT,
0
};
#endif
for (i = 0; i < get_vpx_encoder_count(); ++i) {
const VpxInterface *const encoder = get_vpx_encoder_by_index(i);
fprintf(stderr, " %-6s - %s\n",
- encoder->name, vpx_codec_iface_name(encoder->interface()));
+ encoder->name, vpx_codec_iface_name(encoder->codec_interface()));
}
exit(EXIT_FAILURE);
struct vpx_codec_enc_cfg cfg;
const char *out_fn;
const char *stats_fn;
+#if CONFIG_FP_MB_STATS
+ const char *fpmb_stats_fn;
+#endif
stereo_format_t stereo_fmt;
int arg_ctrls[ARG_CTRL_CNT_MAX][2];
int arg_ctrl_cnt;
uint64_t cx_time;
size_t nbytes;
stats_io_t stats;
+#if CONFIG_FP_MB_STATS
+ stats_io_t fpmb_stats;
+#endif
struct vpx_image *img;
vpx_codec_ctx_t decoder;
int mismatch_seen;
memset(global, 0, sizeof(*global));
global->codec = get_vpx_encoder_by_index(0);
global->passes = 0;
- global->use_i420 = 1;
+ global->color_type = I420;
/* Assign default deadline to good quality */
global->deadline = VPX_DL_GOOD_QUALITY;
else if (arg_match(&arg, &rt_dl, argi))
global->deadline = VPX_DL_REALTIME;
else if (arg_match(&arg, &use_yv12, argi))
- global->use_i420 = 0;
+ global->color_type = YV12;
else if (arg_match(&arg, &use_i420, argi))
- global->use_i420 = 1;
+ global->color_type = I420;
+ else if (arg_match(&arg, &use_i422, argi))
+ global->color_type = I422;
+ else if (arg_match(&arg, &use_i444, argi))
+ global->color_type = I444;
else if (arg_match(&arg, &quietarg, argi))
global->quiet = 1;
else if (arg_match(&arg, &verbosearg, argi))
vpx_codec_err_t res;
/* Populate encoder configuration */
- res = vpx_codec_enc_config_default(global->codec->interface(),
+ res = vpx_codec_enc_config_default(global->codec->codec_interface(),
&stream->config.cfg,
global->usage);
if (res)
config->out_fn = arg.val;
} else if (arg_match(&arg, &fpf_name, argi)) {
config->stats_fn = arg.val;
+#if CONFIG_FP_MB_STATS
+ } else if (arg_match(&arg, &fpmbf_name, argi)) {
+ config->fpmb_stats_fn = arg.val;
+#endif
} else if (arg_match(&arg, &use_ivf, argi)) {
config->write_webm = 0;
} else if (arg_match(&arg, &threads, argi)) {
break;
/* Update/insert */
- assert(j < ARG_CTRL_CNT_MAX);
- if (j < ARG_CTRL_CNT_MAX) {
+ assert(j < (int)ARG_CTRL_CNT_MAX);
+ if (j < (int)ARG_CTRL_CNT_MAX) {
config->arg_ctrls[j][0] = ctrl_args_map[i];
config->arg_ctrls[j][1] = arg_parse_enum_or_int(&arg);
if (j == config->arg_ctrl_cnt)
fatal("Stream %d: duplicate stats file (from stream %d)",
streami->index, stream->index);
}
+
+#if CONFIG_FP_MB_STATS
+ /* Check for two streams sharing a mb stats file. */
+ if (streami != stream) {
+ const char *a = stream->config.fpmb_stats_fn;
+ const char *b = streami->config.fpmb_stats_fn;
+ if (a && b && !strcmp(a, b))
+ fatal("Stream %d: duplicate mb stats file (from stream %d)",
+ streami->index, stream->index);
+ }
+#endif
}
}
if (stream->index == 0) {
fprintf(stderr, "Codec: %s\n",
- vpx_codec_iface_name(global->codec->interface()));
+ vpx_codec_iface_name(global->codec->codec_interface()));
fprintf(stderr, "Source file: %s File Type: %s Format: %s\n",
input->filename,
file_type_to_string(input->file_type),
fatal("Failed to open statistics store");
}
+#if CONFIG_FP_MB_STATS
+ if (stream->config.fpmb_stats_fn) {
+ if (!stats_open_file(&stream->fpmb_stats,
+ stream->config.fpmb_stats_fn, pass))
+ fatal("Failed to open mb statistics store");
+ } else {
+ if (!stats_open_mem(&stream->fpmb_stats, pass))
+ fatal("Failed to open mb statistics store");
+ }
+#endif
+
stream->config.cfg.g_pass = global->passes == 2
? pass ? VPX_RC_LAST_PASS : VPX_RC_FIRST_PASS
: VPX_RC_ONE_PASS;
- if (pass)
+ if (pass) {
stream->config.cfg.rc_twopass_stats_in = stats_get(&stream->stats);
+#if CONFIG_FP_MB_STATS
+ stream->config.cfg.rc_firstpass_mb_stats_in =
+ stats_get(&stream->fpmb_stats);
+#endif
+ }
stream->cx_time = 0;
stream->nbytes = 0;
flags |= global->out_part ? VPX_CODEC_USE_OUTPUT_PARTITION : 0;
/* Construct Encoder Context */
- vpx_codec_enc_init(&stream->encoder, global->codec->interface(),
+ vpx_codec_enc_init(&stream->encoder, global->codec->codec_interface(),
&stream->config.cfg, flags);
ctx_exit_on_error(&stream->encoder, "Failed to initialize encoder");
#if CONFIG_DECODERS
if (global->test_decode != TEST_DECODE_OFF) {
const VpxInterface *decoder = get_vpx_decoder_by_name(global->codec->name);
- vpx_codec_dec_init(&stream->decoder, decoder->interface(), NULL, 0);
+ vpx_codec_dec_init(&stream->decoder, decoder->codec_interface(), NULL, 0);
}
#endif
}
pkt->data.twopass_stats.sz);
stream->nbytes += pkt->data.raw.sz;
break;
+#if CONFIG_FP_MB_STATS
+ case VPX_CODEC_FPMB_STATS_PKT:
+ stats_write(&stream->fpmb_stats,
+ pkt->data.firstpass_mb_stats.buf,
+ pkt->data.firstpass_mb_stats.sz);
+ stream->nbytes += pkt->data.raw.sz;
+ break;
+#endif
case VPX_CODEC_PSNR_PKT:
if (global->show_psnr) {
vpx_image_t raw;
int frame_avail, got_data;
- struct VpxInputContext input = {0};
+ struct VpxInputContext input;
struct VpxEncoderConfig global;
struct stream_state *streams = NULL;
char **argv, **argi;
int stream_cnt = 0;
int res = 0;
+ memset(&input, 0, sizeof(input));
exec_name = argv_[0];
if (argc < 3)
argv = argv_dup(argc - 1, argv_ + 1);
parse_global_config(&global, argv);
- input.fmt = global.use_i420 ? VPX_IMG_FMT_I420 : VPX_IMG_FMT_YV12;
+ switch (global.color_type) {
+ case I420:
+ input.fmt = VPX_IMG_FMT_I420;
+ break;
+ case I422:
+ input.fmt = VPX_IMG_FMT_I422;
+ break;
+ case I444:
+ input.fmt = VPX_IMG_FMT_I444;
+ break;
+ case YV12:
+ input.fmt = VPX_IMG_FMT_YV12;
+ break;
+ }
{
/* Now parse each stream's parameters. Using a local scope here
fps >= 1.0 ? fps : fps * 60,
fps >= 1.0 ? "fps" : "fpm");
print_time("ETA", estimated_time_left);
- fprintf(stderr, "\033[K");
}
} else
}
fflush(stdout);
+ if (!global.quiet)
+ fprintf(stderr, "\033[K");
}
if (stream_cnt > 1)
FOREACH_STREAM(stats_close(&stream->stats, global.passes - 1));
+#if CONFIG_FP_MB_STATS
+ FOREACH_STREAM(stats_close(&stream->fpmb_stats, global.passes - 1));
+#endif
+
if (global.pass)
break;
}