Add interface for external arf indexes.
authorCheng Chen <chengchen@google.com>
Tue, 18 Feb 2020 00:19:44 +0000 (16:19 -0800)
committerCheng Chen <chengchen@google.com>
Mon, 24 Feb 2020 22:29:51 +0000 (14:29 -0800)
Pass in external arf indexes to encode command.

Change-Id: Ifea5a7d835643760fc5effc594bb448848f6d639

vp9/encoder/vp9_encoder.h
vp9/simple_encode.cc
vp9/simple_encode.h

index 0674e00..35fc62f 100644 (file)
@@ -521,6 +521,10 @@ typedef struct KMEANS_DATA {
 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 {
index 56ea65a..1aec7da 100644 (file)
@@ -573,6 +573,9 @@ static void SetGroupOfPicture(int first_is_key_frame, int use_alt_ref,
   }
 }
 
+// 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 @@ SimpleEncode::SimpleEncode(int frame_width, int frame_height,
   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");
@@ -687,6 +691,12 @@ std::vector<std::vector<double>> SimpleEncode::ObserveFirstPassStats() {
   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() {
   assert(impl_ptr_->first_pass_stats.size() > 0);
   vpx_rational_t frame_rate =
index 0efa27f..9e63e15 100644 (file)
@@ -272,6 +272,14 @@ class SimpleEncode {
   // 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();