]> granicus.if.org Git - libvpx/commitdiff
Add encoder side frame buffer for tpl model
authorJingning Han <jingning@google.com>
Mon, 15 Oct 2018 17:11:57 +0000 (10:11 -0700)
committerJingning Han <jingning@google.com>
Mon, 15 Oct 2018 21:57:05 +0000 (14:57 -0700)
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

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

index 21decd52664ee8aad5b82b3efa1b678ebf34a67b..7c9d61ab2232d6f6521a5d0929e6577e31b7bbae 100644 (file)
@@ -2359,11 +2359,10 @@ VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf,
   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)));
@@ -2374,6 +2373,11 @@ VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf,
       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;
+    }
   }
 
   // Allocate memory to store variances for a frame.
index 45cc973152b3b65993e071aaa94d8893b844806d..79346ed09e051c06d1eed2ae514071d920dbb158 100644 (file)
@@ -495,6 +495,12 @@ typedef struct ARNRFilterData {
   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 @@ typedef struct VP9_COMP {
   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.