Have vpxenc use a default kf_max_rate of 5 seconds.

Rather than using the static default maximum keyframe spacing
provided by vpx_codec_enc_config_default() set the default
value to 5 times the frame rate. Five seconds is too long for
live streaming applications, but is a compromise between seek
efficiency and giving the encoder freedom to choose keyframe
locations.

The five second value is from James Zern's suggestion in
http://article.gmane.org/gmane.comp.multimedia.webm.user/2945

Change-Id: Ib7274dc248589c433c06e68ca07232e97f7ce17f
This commit is contained in:
Ralph Giles 2012-01-05 15:05:05 -06:00 коммит произвёл John Koleszar
Родитель 1b27e93cd1
Коммит 061a16d96e
1 изменённых файлов: 21 добавлений и 0 удалений

Просмотреть файл

@ -1517,6 +1517,7 @@ struct stream_config
int arg_ctrls[ARG_CTRL_CNT_MAX][2]; int arg_ctrls[ARG_CTRL_CNT_MAX][2];
int arg_ctrl_cnt; int arg_ctrl_cnt;
int write_webm; int write_webm;
int have_kf_max_dist;
}; };
@ -1883,7 +1884,10 @@ static int parse_stream_params(struct global_config *global,
else if (arg_match(&arg, &kf_min_dist, argi)) else if (arg_match(&arg, &kf_min_dist, argi))
config->cfg.kf_min_dist = arg_parse_uint(&arg); config->cfg.kf_min_dist = arg_parse_uint(&arg);
else if (arg_match(&arg, &kf_max_dist, argi)) else if (arg_match(&arg, &kf_max_dist, argi))
{
config->cfg.kf_max_dist = arg_parse_uint(&arg); config->cfg.kf_max_dist = arg_parse_uint(&arg);
config->have_kf_max_dist = 1;
}
else if (arg_match(&arg, &kf_disabled, argi)) else if (arg_match(&arg, &kf_disabled, argi))
config->cfg.kf_mode = VPX_KF_DISABLED; config->cfg.kf_mode = VPX_KF_DISABLED;
else else
@ -1986,6 +1990,21 @@ static void set_stream_dimensions(struct stream_state *stream,
} }
static void set_default_kf_interval(struct stream_state *stream,
struct global_config *global)
{
/* Use a max keyframe interval of 5 seconds, if none was
* specified on the command line.
*/
if (!stream->config.have_kf_max_dist)
{
double framerate = (double)global->framerate.num/global->framerate.den;
if (framerate > 0.0)
stream->config.cfg.kf_max_dist = 5.0*framerate;
}
}
static void show_stream_config(struct stream_state *stream, static void show_stream_config(struct stream_state *stream,
struct global_config *global, struct global_config *global,
struct input_state *input) struct input_state *input)
@ -2401,6 +2420,8 @@ int main(int argc, const char **argv_)
if (!global.have_framerate) if (!global.have_framerate)
global.framerate = input.framerate; global.framerate = input.framerate;
FOREACH_STREAM(set_default_kf_interval(stream, &global));
/* Show configuration */ /* Show configuration */
if (global.verbose && pass == 0) if (global.verbose && pass == 0)
FOREACH_STREAM(show_stream_config(stream, &global, &input)); FOREACH_STREAM(show_stream_config(stream, &global, &input));