ref: ec12c265e970b220b914587aaf7f26871860e538
parent: 9a95f27563f7e01f8d6b2c4616558645bacb0960
parent: 0d7a05ae0bda703fd00e2580f86966a9efe0a1cc
author: Jingning Han <jingning@google.com>
date: Wed Nov 7 13:21:38 EST 2018
Merge "Unify GOP structure layout setup"
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -2183,10 +2183,9 @@
RATE_CONTROL *const rc = &cpi->rc;
TWO_PASS *const twopass = &cpi->twopass;
GF_GROUP *const gf_group = &twopass->gf_group;
- int i;
int frame_index = 0;
int key_frame;
- int normal_frames;
+ int layer_depth = 1;
key_frame = cpi->common.frame_type == KEY_FRAME;
@@ -2193,6 +2192,7 @@
gf_group->frame_start = cpi->common.current_video_frame;
gf_group->frame_end = gf_group->frame_start + rc->baseline_gf_interval;
gf_group->max_layer_depth = 0;
+ gf_group->allowed_max_layer_depth = 0;
// For key frames the frame target rate is already set and it
// is also the golden frame.
@@ -2206,51 +2206,24 @@
if (rc->source_alt_ref_pending) {
gf_group->update_type[frame_index] = ARF_UPDATE;
gf_group->rf_level[frame_index] = GF_ARF_STD;
- gf_group->layer_depth[frame_index] = 1;
+ gf_group->layer_depth[frame_index] = layer_depth;
gf_group->arf_src_offset[frame_index] =
(unsigned char)(rc->baseline_gf_interval - 1);
gf_group->frame_gop_index[frame_index] = rc->baseline_gf_interval;
gf_group->max_layer_depth = 1;
++frame_index;
- }
-
- if (rc->source_alt_ref_pending && cpi->multi_layer_arf) {
+ ++layer_depth;
gf_group->allowed_max_layer_depth = cpi->oxcf.enable_auto_arf;
- find_arf_order(cpi, gf_group, &frame_index, 2, 1, rc->baseline_gf_interval);
-
- set_gf_overlay_frame_type(gf_group, frame_index,
- rc->source_alt_ref_pending);
-
- gf_group->arf_src_offset[frame_index] = 0;
- gf_group->frame_gop_index[frame_index] = rc->baseline_gf_interval;
-
- gf_group->gf_group_size = frame_index;
- return;
}
- normal_frames =
- rc->baseline_gf_interval - (key_frame || rc->source_alt_ref_pending);
+ find_arf_order(cpi, gf_group, &frame_index, layer_depth, 1,
+ rc->baseline_gf_interval);
- for (i = 0; i < normal_frames; ++i) {
- if (twopass->stats_in >= twopass->stats_in_end) break;
-
- gf_group->update_type[frame_index] = LF_UPDATE;
- gf_group->rf_level[frame_index] = INTER_NORMAL;
- gf_group->arf_src_offset[frame_index] = 0;
- gf_group->frame_gop_index[frame_index] = i + 1;
- gf_group->layer_depth[frame_index] = MAX_ARF_LAYERS - 1;
-
- ++frame_index;
- }
-
- // Note:
- // We need to configure the frame at the end of the sequence + 1 that will be
- // the start frame for the next group. Otherwise prior to the call to
- // vp9_rc_get_second_pass_params() the data will be undefined.
set_gf_overlay_frame_type(gf_group, frame_index, rc->source_alt_ref_pending);
gf_group->arf_src_offset[frame_index] = 0;
gf_group->frame_gop_index[frame_index] = rc->baseline_gf_interval;
+ // Set the frame ops number.
gf_group->gf_group_size = frame_index;
}