ref: 4d3275f865488bb6dc4c7a25e12cc6efa358ef7b
parent: 227deb503e381b86fccae3fd92ee92baacec0948
author: Jingning Han <jingning@google.com>
date: Mon Oct 15 07:48:39 EDT 2018
Add frame_gop_index to GF_GROUP Add frame_gop_index to track the frame offset within a group of picture. This reworks the GOP frame offset calculation and use case. The coding stats remain identical. Change-Id: I94d0957bcc327f6bbeac6e84157635663c36b953
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -5416,8 +5416,9 @@
// Initialize P frames
for (frame_idx = 2; frame_idx < MAX_LAG_BUFFERS; ++frame_idx) {
+ const int frame_gop_offset = gf_group->frame_gop_index[frame_idx];
struct lookahead_entry *buf =
- vp9_lookahead_peek(cpi->lookahead, frame_idx - 2);
+ vp9_lookahead_peek(cpi->lookahead, frame_gop_offset - 1);
if (buf == NULL) break;
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -2124,6 +2124,7 @@
for (idx = start; idx < end; ++idx) {
gf_group->update_type[*index_counter] = LF_UPDATE;
gf_group->arf_src_offset[*index_counter] = 0;
+ gf_group->frame_gop_index[*index_counter] = idx;
gf_group->rf_level[*index_counter] = INTER_NORMAL;
gf_group->layer_depth[*index_counter] = depth;
++(*index_counter);
@@ -2137,6 +2138,7 @@
gf_group->layer_depth[*index_counter] = depth;
gf_group->update_type[*index_counter] = ARF_UPDATE;
gf_group->arf_src_offset[*index_counter] = mid - start;
+ gf_group->frame_gop_index[*index_counter] = mid;
gf_group->rf_level[*index_counter] = GF_ARF_LOW;
for (idx = 0; idx <= mid; ++idx)
@@ -2153,6 +2155,7 @@
gf_group->update_type[*index_counter] = USE_BUF_FRAME;
gf_group->arf_src_offset[*index_counter] = 0;
+ gf_group->frame_gop_index[*index_counter] = mid;
gf_group->rf_level[*index_counter] = INTER_NORMAL;
gf_group->layer_depth[*index_counter] = depth;
++(*index_counter);
@@ -2203,17 +2206,18 @@
gf_group->layer_depth[frame_index] = 1;
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;
++frame_index;
}
if (rc->source_alt_ref_pending && cpi->multi_layer_arf) {
- find_arf_order(cpi, gf_group, &frame_index, 2, 0,
- rc->baseline_gf_interval - 1);
+ 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;
return frame_index;
}
@@ -2227,6 +2231,7 @@
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;
@@ -2247,6 +2252,7 @@
gf_group->rf_level[frame_index] = GF_ARF_STD;
}
gf_group->arf_src_offset[frame_index] = 0;
+ gf_group->frame_gop_index[frame_index] = rc->baseline_gf_interval;
return frame_index;
}
--- a/vp9/encoder/vp9_firstpass.h
+++ b/vp9/encoder/vp9_firstpass.h
@@ -129,6 +129,7 @@
FRAME_UPDATE_TYPE update_type[MAX_STATIC_GF_GROUP_LENGTH + 2];
unsigned char arf_src_offset[MAX_STATIC_GF_GROUP_LENGTH + 2];
unsigned char layer_depth[MAX_STATIC_GF_GROUP_LENGTH + 2];
+ unsigned char frame_gop_index[MAX_STATIC_GF_GROUP_LENGTH + 2];
int bit_allocation[MAX_STATIC_GF_GROUP_LENGTH + 2];
int gfu_boost[MAX_STATIC_GF_GROUP_LENGTH + 2];