summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCheng Chen <chengchen@google.com>2020-02-17 16:19:44 -0800
committerCheng Chen <chengchen@google.com>2020-02-24 14:29:51 -0800
commit7e665ec96839d33b4943c09f4e4e39962b8afba5 (patch)
tree7f6b32d619fe9674400a4c3e4437d1d9b120b7aa
parent0484849e8e4fa7c49e415539fae32fa7cb76c9c4 (diff)
downloadlibvpx-7e665ec96839d33b4943c09f4e4e39962b8afba5.tar
libvpx-7e665ec96839d33b4943c09f4e4e39962b8afba5.tar.gz
libvpx-7e665ec96839d33b4943c09f4e4e39962b8afba5.tar.bz2
libvpx-7e665ec96839d33b4943c09f4e4e39962b8afba5.zip
Add interface for external arf indexes.
Pass in external arf indexes to encode command. Change-Id: Ifea5a7d835643760fc5effc594bb448848f6d639
-rw-r--r--vp9/encoder/vp9_encoder.h4
-rw-r--r--vp9/simple_encode.cc10
-rw-r--r--vp9/simple_encode.h8
3 files changed, 22 insertions, 0 deletions
diff --git a/vp9/encoder/vp9_encoder.h b/vp9/encoder/vp9_encoder.h
index 0674e0025..35fc62fdb 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 56ea65a1c..1aec7da4d 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<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 =
diff --git a/vp9/simple_encode.h b/vp9/simple_encode.h
index 0efa27fd2..9e63e15ca 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<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();