summaryrefslogtreecommitdiff
path: root/vp9/simple_encode.cc
diff options
context:
space:
mode:
authorangiebird <angiebird@google.com>2020-05-27 00:30:11 -0700
committerangiebird <angiebird@google.com>2020-05-28 18:07:12 -0700
commit34034789d758440415306a637e6aea57f34e1a4c (patch)
treec5cbcd5772ba90ffec9226cb3cecfd4c3a234be8 /vp9/simple_encode.cc
parent9c7e04a159f79994f0a19c1b0407cb3f029080fc (diff)
downloadlibvpx-34034789d758440415306a637e6aea57f34e1a4c.tar.gz
Add extra check / unit test to SetExternalGroupOfPicturesMap()
Let SetExternalGroupOfPicturesMap() modify the gop_map_ to satisfy the following constraints. 1) Each key frame position should be at the start of a gop. 2) The last gop should not use an alt ref. Add unit test for SetExternalGroupOfPicturesMap() Change-Id: Iee9bd238ad0fc5c2ccbf2fbd065a280c854cd718
Diffstat (limited to 'vp9/simple_encode.cc')
-rw-r--r--vp9/simple_encode.cc32
1 files changed, 31 insertions, 1 deletions
diff --git a/vp9/simple_encode.cc b/vp9/simple_encode.cc
index f52c18015..9d62d26e1 100644
--- a/vp9/simple_encode.cc
+++ b/vp9/simple_encode.cc
@@ -806,8 +806,36 @@ std::vector<std::vector<double>> SimpleEncode::ObserveFirstPassStats() {
return output_stats;
}
-void SimpleEncode::SetExternalGroupOfPicture(std::vector<int> gop_map) {
+void SimpleEncode::SetExternalGroupOfPicturesMap(std::vector<int> gop_map) {
gop_map_ = gop_map;
+ // The following will check and modify gop_map_ to make sure the
+ // gop_map_ satisfies the constraints.
+ // 1) Each key frame position should be at the start of a gop.
+ // 2) The last gop should not use an alt ref.
+ assert(gop_map_.size() == key_frame_map_.size());
+ int last_gop_start = 0;
+ for (int i = 0; static_cast<size_t>(i) < gop_map_.size(); ++i) {
+ if (key_frame_map_[i] == 1 && gop_map_[i] == 0) {
+ fprintf(stderr, "Add an extra gop start at show_idx %d\n", i);
+ // Insert a gop start at key frame location.
+ gop_map_[i] |= kGopMapFlagStart;
+ gop_map_[i] |= kGopMapFlagUseAltRef;
+ }
+ if (gop_map_[i] & kGopMapFlagStart) {
+ last_gop_start = i;
+ }
+ }
+ if (gop_map_[last_gop_start] & kGopMapFlagUseAltRef) {
+ fprintf(stderr,
+ "Last group of pictures starting at show_idx %d shouldn't use alt "
+ "ref\n",
+ last_gop_start);
+ gop_map_[last_gop_start] &= ~kGopMapFlagUseAltRef;
+ }
+}
+
+std::vector<int> SimpleEncode::ObserveExternalGroupOfPicturesMap() {
+ return gop_map_;
}
template <typename T>
@@ -867,6 +895,8 @@ void SimpleEncode::StartEncode() {
UpdateKeyFrameGroup(show_frame_count_);
+ const GOP_COMMAND gop_command = GetGopCommand(gop_map_, show_frame_count_);
+ encode_command_set_gop_command(&impl_ptr_->cpi->encode_command, gop_command);
UpdateGroupOfPicture(impl_ptr_->cpi, frame_coding_index_, ref_frame_info_,
&group_of_picture_);
rewind(in_file_);