shithub: libvpx

Download patch

ref: 7e665ec96839d33b4943c09f4e4e39962b8afba5
parent: 0484849e8e4fa7c49e415539fae32fa7cb76c9c4
author: Cheng Chen <chengchen@google.com>
date: Mon Feb 17 11:19:44 EST 2020

Add interface for external arf indexes.

Pass in external arf indexes to encode command.

Change-Id: Ifea5a7d835643760fc5effc594bb448848f6d639

--- a/vp9/encoder/vp9_encoder.h
+++ b/vp9/encoder/vp9_encoder.h
@@ -521,6 +521,10 @@
 typedef struct ENCODE_COMMAND {
   int use_external_quantize_index;
   int external_quantize_index;
+  int use_external_arf;
+  // A list of binary flags set from the external controller.
+  // Each binary flag indicates whether the frame is an arf or not.
+  const int *external_arf_indexes;
 } ENCODE_COMMAND;
 
 typedef struct PARTITION_INFO {
--- a/vp9/simple_encode.cc
+++ b/vp9/simple_encode.cc
@@ -573,6 +573,9 @@
   }
 }
 
+// Gets group of picture information from VP9's decision, and update
+// |group_of_picture| accordingly.
+// This is called at the starting of encoding of each group of picture.
 static void UpdateGroupOfPicture(const VP9_COMP *cpi, int start_coding_index,
                                  GroupOfPicture *group_of_picture) {
   int first_is_key_frame;
@@ -601,6 +604,7 @@
   num_frames_ = num_frames;
   frame_coding_index_ = 0;
   // TODO(angirbid): Should we keep a file pointer here or keep the file_path?
+  assert(infile_path != nullptr);
   in_file_ = fopen(infile_path, "r");
   if (outfile_path != nullptr) {
     out_file_ = fopen(outfile_path, "w");
@@ -685,6 +689,12 @@
     output_stats.push_back(this_stats);
   }
   return output_stats;
+}
+
+void SimpleEncode::SetExternalGroupOfPicture(const bool use_external_arf,
+                                             const int *external_arf_indexes) {
+  impl_ptr_->cpi->encode_command.use_external_arf = use_external_arf;
+  impl_ptr_->cpi->encode_command.external_arf_indexes = external_arf_indexes;
 }
 
 void SimpleEncode::StartEncode() {
--- a/vp9/simple_encode.h
+++ b/vp9/simple_encode.h
@@ -272,6 +272,14 @@
   // values. For details, please check FIRSTPASS_STATS in vp9_firstpass.h
   std::vector<std::vector<double>> ObserveFirstPassStats();
 
+  // Sets arf indexes for the video from external input.
+  // The arf index determines whether a frame is arf or not.
+  // Therefore it also determines the group of picture size.
+  // If set, VP9 will use the external arf index to make decision.
+  // This function is called only once before StartEncde().
+  void SetExternalGroupOfPicture(bool use_external_arf,
+                                 const int *external_arf_indexes);
+
   // Initializes the encoder for actual encoding.
   // This function should be called after ComputeFirstPassStats().
   void StartEncode();