]> granicus.if.org Git - libvpx/commitdiff
Add frame pointer to support recon frames in tpl model
authorJingning Han <jingning@google.com>
Fri, 27 Jul 2018 22:08:39 +0000 (15:08 -0700)
committerJingning Han <jingning@google.com>
Tue, 31 Jul 2018 04:13:55 +0000 (21:13 -0700)
Add frame pointer to re-use spare frames to store the reconstructed
frames.

Change-Id: I870aa048fc9b7d8b356aa73df3a92b4670425f95

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

index afe51366de6f6df8dab052cf337c3326da0c7247..c081997853fab9cce09b7220b62fade77a51ee28 100644 (file)
@@ -5496,13 +5496,41 @@ typedef struct GF_PICTURE {
 
 void init_gop_frames(VP9_COMP *cpi, GF_PICTURE *gf_picture,
                      const GF_GROUP *gf_group, int *tpl_group_frames) {
-  int frame_idx, i;
+  VP9_COMMON *cm = &cpi->common;
+  int frame_idx = 0;
+  int i;
   int gld_index = -1;
   int alt_index = -1;
   int lst_index = -1;
   int extend_frame_count = 0;
   int pframe_qindex = cpi->tpl_stats[2].base_qindex;
 
+  RefCntBuffer *frame_bufs = cm->buffer_pool->frame_bufs;
+  int recon_frame_index[REFS_PER_FRAME + 1] = { -1, -1, -1, -1 };
+
+  for (i = 0; i < FRAME_BUFFERS && frame_idx < REFS_PER_FRAME + 1; ++i) {
+    if (frame_bufs[i].ref_count == 0) {
+      alloc_frame_mvs(cm, i);
+      if (vpx_realloc_frame_buffer(&frame_bufs[i].buf, cm->width, cm->height,
+                                   cm->subsampling_x, cm->subsampling_y,
+#if CONFIG_VP9_HIGHBITDEPTH
+                                   cm->use_highbitdepth,
+#endif
+                                   VP9_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
+                                   NULL, NULL, NULL))
+        vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
+                           "Failed to allocate frame buffer");
+
+      recon_frame_index[frame_idx] = i;
+      ++frame_idx;
+    }
+  }
+
+  for (i = 0; i < REFS_PER_FRAME + 1; ++i) {
+    assert(recon_frame_index[i] >= 0);
+    cpi->tpl_recon_frames[i] = &frame_bufs[recon_frame_index[i]].buf;
+  }
+
   *tpl_group_frames = 0;
 
   // Initialize Golden reference frame.
index 0c6375c652a9bbe5515c0be54f0139b1d846eb16..038413a96efe67c4ef15cc6d77d887ad32d70c6c 100644 (file)
@@ -501,6 +501,7 @@ typedef struct VP9_COMP {
   YV12_BUFFER_CONFIG *raw_source_frame;
 
   TplDepFrame tpl_stats[MAX_LAG_BUFFERS];
+  YV12_BUFFER_CONFIG *tpl_recon_frames[REFS_PER_FRAME + 1];
 
   TileDataEnc *tile_data;
   int allocated_tiles;  // Keep track of memory allocated for tiles.