Skip to content

Commit

Permalink
vp9: set kf_max_dist to a reasonable default (128)
Browse files Browse the repository at this point in the history
the same as vp8, with the same reasoning from:
2a0d7b1 Reduce the default kf_max_dist to 128.

see also:
https://trac.ffmpeg.org/ticket/4904
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=815673

+ restore vpxenc behavior of taking the library default rather than
  forcing 5s

This change also exposes an issue with one-pass svc in cbr mode, keep
the old default in datarate_test.cc for now.

Change-Id: Id6d1244f42490b06fefc1a7b4e12a423a1f83e88
  • Loading branch information
jzern committed Feb 25, 2016
1 parent 784eebb commit 14828e7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Next Release
- Incompatible changes:
The VP9 encoder's default keyframe interval changed to 128 from 9999.

2015-11-09 v1.5.0 "Javan Whistling Duck"
This release improves upon the VP9 encoder and speeds up the encoding and
decoding processes.
Expand Down
3 changes: 3 additions & 0 deletions test/datarate_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,9 @@ TEST_P(DatarateOnePassCbrSvc, OnePassCbrSvc) {
svc_params_.scaling_factor_num[1] = 288;
svc_params_.scaling_factor_den[1] = 288;
cfg_.rc_dropframe_thresh = 10;
// TODO(marpan): another test should be added for default/small kf_max_dist
// once https://bugs.chromium.org/p/webm/issues/detail?id=1150 is fixed.
cfg_.kf_max_dist = 9999;
::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
30, 1, 0, 200);
// TODO(wonkap/marpan): Check that effective_datarate for each layer hits the
Expand Down
2 changes: 1 addition & 1 deletion vp9/vp9_cx_iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,7 @@ static vpx_codec_enc_cfg_map_t encoder_usage_cfg_map[] = {
// keyframing settings (kf)
VPX_KF_AUTO, // g_kfmode
0, // kf_min_dist
9999, // kf_max_dist
128, // kf_max_dist

VPX_SS_DEFAULT_LAYERS, // ss_number_layers
{0},
Expand Down
17 changes: 0 additions & 17 deletions vpxenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,6 @@ struct stream_config {
int arg_ctrls[ARG_CTRL_CNT_MAX][2];
int arg_ctrl_cnt;
int write_webm;
int have_kf_max_dist;
#if CONFIG_VP9_HIGHBITDEPTH
// whether to use 16bit internal buffers
int use_16bit_internal;
Expand Down Expand Up @@ -1224,7 +1223,6 @@ static int parse_stream_params(struct VpxEncoderConfig *global,
config->cfg.kf_min_dist = arg_parse_uint(&arg);
} else if (arg_match(&arg, &kf_max_dist, argi)) {
config->cfg.kf_max_dist = arg_parse_uint(&arg);
config->have_kf_max_dist = 1;
} else if (arg_match(&arg, &kf_disabled, argi)) {
config->cfg.kf_mode = VPX_KF_DISABLED;
#if CONFIG_VP9_HIGHBITDEPTH
Expand Down Expand Up @@ -1352,19 +1350,6 @@ static void set_stream_dimensions(struct stream_state *stream,
}
}


static void set_default_kf_interval(struct stream_state *stream,
struct VpxEncoderConfig *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 = (unsigned int)(5.0 * framerate);
}
}

static const char* file_type_to_string(enum VideoFileType t) {
switch (t) {
case FILE_TYPE_RAW: return "RAW";
Expand Down Expand Up @@ -2086,8 +2071,6 @@ int main(int argc, const char **argv_) {
stream->config.cfg.g_timebase.num = global.framerate.den);
}

FOREACH_STREAM(set_default_kf_interval(stream, &global));

/* Show configuration */
if (global.verbose && pass == 0)
FOREACH_STREAM(show_stream_config(stream, &global, &input));
Expand Down

0 comments on commit 14828e7

Please sign in to comment.