From 7e665ec96839d33b4943c09f4e4e39962b8afba5 Mon Sep 17 00:00:00 2001 From: Cheng Chen Date: Mon, 17 Feb 2020 16:19:44 -0800 Subject: [PATCH] Add interface for external arf indexes. Pass in external arf indexes to encode command. Change-Id: Ifea5a7d835643760fc5effc594bb448848f6d639 --- vp9/encoder/vp9_encoder.h | 4 ++++ vp9/simple_encode.cc | 10 ++++++++++ vp9/simple_encode.h | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/vp9/encoder/vp9_encoder.h b/vp9/encoder/vp9_encoder.h index 0674e00..35fc62f 100644 --- a/vp9/encoder/vp9_encoder.h +++ b/vp9/encoder/vp9_encoder.h @@ -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 { diff --git a/vp9/simple_encode.cc b/vp9/simple_encode.cc index 56ea65a..1aec7da 100644 --- a/vp9/simple_encode.cc +++ b/vp9/simple_encode.cc @@ -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> 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 = diff --git a/vp9/simple_encode.h b/vp9/simple_encode.h index 0efa27f..9e63e15 100644 --- a/vp9/simple_encode.h +++ b/vp9/simple_encode.h @@ -272,6 +272,14 @@ class SimpleEncode { // values. For details, please check FIRSTPASS_STATS in vp9_firstpass.h std::vector> 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(); -- 2.7.4