diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index abdb24b02..5dab7ba28 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -1017,9 +1017,6 @@ VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf) { cm->error.setjmp = 0; -#if CONFIG_TRANSCODE - cm->mi_array_pf = fopen("/usr/local/google/home/jingning/explibvpx-pub/libvpx/build/linuxbuild/mode_info_array.bin", "rb"); -#endif return cpi; } diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c index 72768e11e..7a295e0af 100644 --- a/vp9/vp9_cx_iface.c +++ b/vp9/vp9_cx_iface.c @@ -679,6 +679,17 @@ static vpx_codec_err_t encoder_init(vpx_codec_ctx_t *ctx, res = VPX_CODEC_MEM_ERROR; else ctx->priv->alg_priv->cpi = cpi; + +#if CONFIG_TRANSCODE + if (res == VPX_CODEC_OK) { + cpi->common.mi_array_pf = fopen(ctx->config.enc->mi_fn, "rb"); + if (!cpi->common.mi_array_pf) { + fprintf(stderr, "Unable to open external mode info file %s\n", + ctx->config.enc->mi_fn); + exit(0); + } + } +#endif } } diff --git a/vpx/vpx_encoder.h b/vpx/vpx_encoder.h index 571ad3fc5..63dcf8325 100644 --- a/vpx/vpx_encoder.h +++ b/vpx/vpx_encoder.h @@ -275,7 +275,6 @@ extern "C" { */ unsigned int g_usage; - /*!\brief Maximum number of threads to use * * For multi-threaded implementations, use no more than this number of @@ -667,6 +666,9 @@ extern "C" { * ts_periodicity=8, then ts_layer_id = (0,1,0,1,0,1,0,1). */ unsigned int ts_layer_id[VPX_TS_MAX_PERIODICITY]; + + + const char *mi_fn; } vpx_codec_enc_cfg_t; /**< alias for struct vpx_codec_enc_cfg */ diff --git a/vpxenc.c b/vpxenc.c index d46a83eb0..712a02a04 100644 --- a/vpxenc.c +++ b/vpxenc.c @@ -129,6 +129,12 @@ 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"); + +#if CONFIG_TRANSCODE +static const arg_def_t mode_info_file = ARG_DEF("mi", "modeinfo", 1, + "External mode info filename"); +#endif + 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, @@ -572,6 +578,9 @@ struct stream_config { struct vpx_codec_enc_cfg cfg; const char *out_fn; const char *stats_fn; +#if CONFIG_TRANSCODE + const char *mi_fn; +#endif stereo_format_t stereo_fmt; int arg_ctrls[ARG_CTRL_CNT_MAX][2]; int arg_ctrl_cnt; @@ -823,6 +832,9 @@ static struct stream_state *new_stream(struct VpxEncoderConfig *global, /* Output files must be specified for each stream */ stream->config.out_fn = NULL; +#if CONFIG_TRANSCODE + stream->config.mi_fn = NULL; +#endif stream->next = NULL; return stream; @@ -870,6 +882,10 @@ static int parse_stream_params(struct VpxEncoderConfig *global, if (0) { } else if (arg_match(&arg, &outputfile, argi)) { config->out_fn = arg.val; +#if CONFIG_TRANSCODE + } else if (arg_match(&arg, &mode_info_file, argi)) { + config->mi_fn = arg.val; +#endif } else if (arg_match(&arg, &fpf_name, argi)) { config->stats_fn = arg.val; } else if (arg_match(&arg, &use_ivf, argi)) { @@ -1011,6 +1027,12 @@ static void validate_stream_config(const struct stream_state *stream, fatal("Stream %d: Output file is required (specify with -o)", streami->index); +#if CONFIG_TRANSCODE + if (!streami->config.mi_fn) + fatal("Stream %d: External mode info file is required (specify with -mi)", + streami->index); +#endif + /* Check for two streams outputting to the same file */ if (streami != stream) { const char *a = stream->config.out_fn; @@ -1130,11 +1152,14 @@ static void show_stream_config(struct stream_state *stream, SHOW(kf_max_dist); } - static void open_output_file(struct stream_state *stream, struct VpxEncoderConfig *global) { const char *fn = stream->config.out_fn; - const struct vpx_codec_enc_cfg *const cfg = &stream->config.cfg; + struct vpx_codec_enc_cfg *const cfg = &stream->config.cfg; + +#if CONFIG_TRANSCODE + cfg->mi_fn = stream->config.mi_fn; +#endif if (cfg->g_pass == VPX_RC_FIRST_PASS) return;