Re-work configure interface for encoding based on external mi
This commit refines the configuration interface for encoding process based on external mode info. It allows the vpxenc to read the external file name from command line, and to produce warning message when necessary. Change-Id: I109d02ea9e6e418d00378d512ed9ab9bb0770dbd
This commit is contained in:
@@ -1017,9 +1017,6 @@ VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf) {
|
|||||||
|
|
||||||
cm->error.setjmp = 0;
|
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;
|
return cpi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -679,6 +679,17 @@ static vpx_codec_err_t encoder_init(vpx_codec_ctx_t *ctx,
|
|||||||
res = VPX_CODEC_MEM_ERROR;
|
res = VPX_CODEC_MEM_ERROR;
|
||||||
else
|
else
|
||||||
ctx->priv->alg_priv->cpi = cpi;
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -275,7 +275,6 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
unsigned int g_usage;
|
unsigned int g_usage;
|
||||||
|
|
||||||
|
|
||||||
/*!\brief Maximum number of threads to use
|
/*!\brief Maximum number of threads to use
|
||||||
*
|
*
|
||||||
* For multi-threaded implementations, use no more than this number of
|
* 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).
|
* ts_periodicity=8, then ts_layer_id = (0,1,0,1,0,1,0,1).
|
||||||
*/
|
*/
|
||||||
unsigned int ts_layer_id[VPX_TS_MAX_PERIODICITY];
|
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 */
|
} vpx_codec_enc_cfg_t; /**< alias for struct vpx_codec_enc_cfg */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
29
vpxenc.c
29
vpxenc.c
@@ -129,6 +129,12 @@ static const arg_def_t debugmode = ARG_DEF("D", "debug", 0,
|
|||||||
"Debug mode (makes output deterministic)");
|
"Debug mode (makes output deterministic)");
|
||||||
static const arg_def_t outputfile = ARG_DEF("o", "output", 1,
|
static const arg_def_t outputfile = ARG_DEF("o", "output", 1,
|
||||||
"Output filename");
|
"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,
|
static const arg_def_t use_yv12 = ARG_DEF(NULL, "yv12", 0,
|
||||||
"Input file is YV12 ");
|
"Input file is YV12 ");
|
||||||
static const arg_def_t use_i420 = ARG_DEF(NULL, "i420", 0,
|
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;
|
struct vpx_codec_enc_cfg cfg;
|
||||||
const char *out_fn;
|
const char *out_fn;
|
||||||
const char *stats_fn;
|
const char *stats_fn;
|
||||||
|
#if CONFIG_TRANSCODE
|
||||||
|
const char *mi_fn;
|
||||||
|
#endif
|
||||||
stereo_format_t stereo_fmt;
|
stereo_format_t stereo_fmt;
|
||||||
int arg_ctrls[ARG_CTRL_CNT_MAX][2];
|
int arg_ctrls[ARG_CTRL_CNT_MAX][2];
|
||||||
int arg_ctrl_cnt;
|
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 */
|
/* Output files must be specified for each stream */
|
||||||
stream->config.out_fn = NULL;
|
stream->config.out_fn = NULL;
|
||||||
|
#if CONFIG_TRANSCODE
|
||||||
|
stream->config.mi_fn = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
stream->next = NULL;
|
stream->next = NULL;
|
||||||
return stream;
|
return stream;
|
||||||
@@ -870,6 +882,10 @@ static int parse_stream_params(struct VpxEncoderConfig *global,
|
|||||||
if (0) {
|
if (0) {
|
||||||
} else if (arg_match(&arg, &outputfile, argi)) {
|
} else if (arg_match(&arg, &outputfile, argi)) {
|
||||||
config->out_fn = arg.val;
|
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)) {
|
} else if (arg_match(&arg, &fpf_name, argi)) {
|
||||||
config->stats_fn = arg.val;
|
config->stats_fn = arg.val;
|
||||||
} else if (arg_match(&arg, &use_ivf, argi)) {
|
} 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)",
|
fatal("Stream %d: Output file is required (specify with -o)",
|
||||||
streami->index);
|
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 */
|
/* Check for two streams outputting to the same file */
|
||||||
if (streami != stream) {
|
if (streami != stream) {
|
||||||
const char *a = stream->config.out_fn;
|
const char *a = stream->config.out_fn;
|
||||||
@@ -1130,11 +1152,14 @@ static void show_stream_config(struct stream_state *stream,
|
|||||||
SHOW(kf_max_dist);
|
SHOW(kf_max_dist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void open_output_file(struct stream_state *stream,
|
static void open_output_file(struct stream_state *stream,
|
||||||
struct VpxEncoderConfig *global) {
|
struct VpxEncoderConfig *global) {
|
||||||
const char *fn = stream->config.out_fn;
|
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)
|
if (cfg->g_pass == VPX_RC_FIRST_PASS)
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user