summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJingning Han <jingning@google.com>2018-10-22 14:21:48 -0700
committerJingning Han <jingning@google.com>2018-10-23 10:34:58 -0700
commit9f02ba36847738ebf824a6dcd609d354c08859ed (patch)
tree9dcad137ef37a99a85d69f03a4e9fdfdffdbc3f7
parentb77291abc9dc2884103c1846f3fc1a0395dd9e67 (diff)
downloadlibvpx-9f02ba36847738ebf824a6dcd609d354c08859ed.tar
libvpx-9f02ba36847738ebf824a6dcd609d354c08859ed.tar.gz
libvpx-9f02ba36847738ebf824a6dcd609d354c08859ed.tar.bz2
libvpx-9f02ba36847738ebf824a6dcd609d354c08859ed.zip
Fix frame offset computation for GOP extension
Properly compute the extended GOP frames' buffer offsets. Change-Id: I9aed14f4b8d623f1832e782828dce07aa546507d
-rw-r--r--vp9/encoder/vp9_encoder.c11
-rw-r--r--vp9/encoder/vp9_ratectrl.c2
2 files changed, 8 insertions, 5 deletions
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index b31f180bb..b5f04e3bb 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -5382,6 +5382,7 @@ void init_gop_frames(VP9_COMP *cpi, GF_PICTURE *gf_picture,
int arf_stack_size = 0;
int extend_frame_count = 0;
int pframe_qindex = cpi->tpl_stats[2].base_qindex;
+ int frame_gop_offset = 0;
RefCntBuffer *frame_bufs = cm->buffer_pool->frame_bufs;
int8_t recon_frame_index[REFS_PER_FRAME + MAX_ARF_LAYERS];
@@ -5435,9 +5436,9 @@ void init_gop_frames(VP9_COMP *cpi, GF_PICTURE *gf_picture,
// Initialize P frames
for (frame_idx = 2; frame_idx < MAX_ARF_GOP_SIZE; ++frame_idx) {
- const int frame_gop_offset = gf_group->frame_gop_index[frame_idx];
- struct lookahead_entry *buf =
- vp9_lookahead_peek(cpi->lookahead, frame_gop_offset - 1);
+ struct lookahead_entry *buf;
+ frame_gop_offset = gf_group->frame_gop_index[frame_idx];
+ buf = vp9_lookahead_peek(cpi->lookahead, frame_gop_offset - 1);
if (buf == NULL) break;
@@ -5476,11 +5477,12 @@ void init_gop_frames(VP9_COMP *cpi, GF_PICTURE *gf_picture,
alt_index = -1;
++frame_idx;
+ ++frame_gop_offset;
// Extend two frames outside the current gf group.
for (; frame_idx < MAX_LAG_BUFFERS && extend_frame_count < 2; ++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;
@@ -5493,6 +5495,7 @@ void init_gop_frames(VP9_COMP *cpi, GF_PICTURE *gf_picture,
lst_index = frame_idx;
++*tpl_group_frames;
++extend_frame_count;
+ ++frame_gop_offset;
}
}
diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c
index 81cf8858a..e0d71900e 100644
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -1486,7 +1486,7 @@ void vp9_estimate_qp_gop(VP9_COMP *cpi) {
int idx;
const int gf_index = cpi->twopass.gf_group.index;
- for (idx = 1; idx < gop_length; ++idx) {
+ for (idx = 1; idx <= gop_length; ++idx) {
TplDepFrame *tpl_frame = &cpi->tpl_stats[idx];
int target_rate = cpi->twopass.gf_group.bit_allocation[idx];
cpi->twopass.gf_group.index = idx;