shithub: libvpx

Download patch

ref: 227deb503e381b86fccae3fd92ee92baacec0948
parent: f6a52bee7db6b54308fa080b84ebfe12977f6b45
author: Jingning Han <jingning@google.com>
date: Mon Oct 15 06:11:57 EDT 2018

Add encoder side frame buffer for tpl model

Add an encoder side reference frame buffer pool to store the
reference frames for tpl model. This servces as an intermediate
step to support multi-layer ARF system. The buffer memory size will
be optimized afterwards.

Change-Id: If2d2f095d4911a4996f6c2a0b0a8e3d235ceadb2

--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -2359,11 +2359,10 @@
   vp9_set_speed_features_framesize_dependent(cpi);
 
   if (cpi->sf.enable_tpl_model) {
+    const int mi_cols = mi_cols_aligned_to_sb(cm->mi_cols);
+    const int mi_rows = mi_cols_aligned_to_sb(cm->mi_rows);
     // TODO(jingning): Reduce the actual memory use for tpl model build up.
     for (frame = 0; frame < MAX_ARF_GOP_SIZE; ++frame) {
-      int mi_cols = mi_cols_aligned_to_sb(cm->mi_cols);
-      int mi_rows = mi_cols_aligned_to_sb(cm->mi_rows);
-
       CHECK_MEM_ERROR(cm, cpi->tpl_stats[frame].tpl_stats_ptr,
                       vpx_calloc(mi_rows * mi_cols,
                                  sizeof(*cpi->tpl_stats[frame].tpl_stats_ptr)));
@@ -2373,6 +2372,11 @@
       cpi->tpl_stats[frame].stride = mi_cols;
       cpi->tpl_stats[frame].mi_rows = cm->mi_rows;
       cpi->tpl_stats[frame].mi_cols = cm->mi_cols;
+    }
+
+    for (frame = 0; frame < REF_FRAMES; ++frame) {
+      cpi->enc_frame_buf[frame].mem_valid = 0;
+      cpi->enc_frame_buf[frame].released = 1;
     }
   }
 
--- a/vp9/encoder/vp9_encoder.h
+++ b/vp9/encoder/vp9_encoder.h
@@ -495,6 +495,12 @@
   struct scale_factors sf;
 } ARNRFilterData;
 
+typedef struct EncFrameBuf {
+  int mem_valid;
+  int released;
+  YV12_BUFFER_CONFIG frame;
+} EncFrameBuf;
+
 // Maximum operating frame buffer size needed for a GOP using ARF reference.
 #define MAX_ARF_GOP_SIZE (2 * MAX_LAG_BUFFERS)
 
@@ -522,7 +528,8 @@
   YV12_BUFFER_CONFIG *raw_source_frame;
 
   TplDepFrame tpl_stats[MAX_ARF_GOP_SIZE];
-  YV12_BUFFER_CONFIG *tpl_recon_frames[REFS_PER_FRAME + 1];
+  YV12_BUFFER_CONFIG *tpl_recon_frames[REF_FRAMES];
+  EncFrameBuf enc_frame_buf[REF_FRAMES];
 
   TileDataEnc *tile_data;
   int allocated_tiles;  // Keep track of memory allocated for tiles.