]> granicus.if.org Git - libvpx/commitdiff
Update frame index per buffer at encoder
authorJingning Han <jingning@google.com>
Mon, 17 Sep 2018 21:17:36 +0000 (14:17 -0700)
committerJingning Han <jingning@google.com>
Tue, 18 Sep 2018 03:58:14 +0000 (20:58 -0700)
Update the frame index counting from key frame offset for all
the processed frames at the encoder. This would allow encoder to
automatically decide frame sign bias next.

Change-Id: Ibbdc2a29b7245be27422272e1fb539596eed63d1

vp9/encoder/vp9_encoder.c
vp9/encoder/vp9_encoder.h

index 2de85e735994a40a45ee10733392a2797f93c1ec..f50022dba02cdc521d38510abf3f7592ec3fb4bb 100644 (file)
@@ -4587,6 +4587,16 @@ static void vp9_try_disable_lookahead_aq(VP9_COMP *cpi, size_t *size,
     }
 }
 
+static void set_frame_index(VP9_COMP *cpi, VP9_COMMON *cm) {
+  RefCntBuffer *const ref_buffer = get_ref_cnt_buffer(cm, cm->new_fb_idx);
+
+  if (ref_buffer) {
+    const GF_GROUP *const gf_group = &cpi->twopass.gf_group;
+    ref_buffer->frame_index =
+        cm->current_video_frame + gf_group->arf_src_offset[gf_group->index];
+  }
+}
+
 static void encode_frame_to_data_rate(VP9_COMP *cpi, size_t *size,
                                       uint8_t *dest,
                                       unsigned int *frame_flags) {
@@ -4751,6 +4761,9 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, size_t *size,
   // build the bitstream
   vp9_pack_bitstream(cpi, dest, size);
 
+  // Update frame index
+  set_frame_index(cpi, cm);
+
   if (cm->seg.update_map) update_reference_segmentation_map(cpi);
 
   if (frame_is_intra_only(cm) == 0) {
index 4034fe42c69098cfcd415382c2219de4b2516837..192668225889b829e01fdcf9078f22205e12e5ee 100644 (file)
@@ -858,6 +858,10 @@ static INLINE int get_ref_frame_buf_idx(const VP9_COMP *const cpi,
   return (map_idx != INVALID_IDX) ? cm->ref_frame_map[map_idx] : INVALID_IDX;
 }
 
+static INLINE RefCntBuffer *get_ref_cnt_buffer(VP9_COMMON *cm, int fb_idx) {
+  return fb_idx != INVALID_IDX ? &cm->buffer_pool->frame_bufs[fb_idx] : NULL;
+}
+
 static INLINE YV12_BUFFER_CONFIG *get_ref_frame_buffer(
     VP9_COMP *cpi, MV_REFERENCE_FRAME ref_frame) {
   VP9_COMMON *const cm = &cpi->common;