Moved FrameKey to api/video/encoded_frame.h and renamed it to VideoLayerFrameId.

Since we want the VideoStreamDecoder to callback with the last
continuous frame we need to move the FrameKey into the public API.

Bug: webrtc:8909
Change-Id: I39634145d848b8163778e31a1e0d04d91f9bbeb8
Reviewed-on: https://webrtc-review.googlesource.com/60864
Commit-Queue: Philip Eliasson <philipel@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22495}
diff --git a/modules/video_coding/frame_buffer2.cc b/modules/video_coding/frame_buffer2.cc
index b041018..3a3a727 100644
--- a/modules/video_coding/frame_buffer2.cc
+++ b/modules/video_coding/frame_buffer2.cc
@@ -172,8 +172,9 @@
 
       // Sanity check for RTP timestamp monotonicity.
       if (last_decoded_frame_it_ != frames_.end()) {
-        const FrameKey& last_decoded_frame_key = last_decoded_frame_it_->first;
-        const FrameKey& frame_key = next_frame_it_->first;
+        const VideoLayerFrameId& last_decoded_frame_key =
+            last_decoded_frame_it_->first;
+        const VideoLayerFrameId& frame_key = next_frame_it_->first;
 
         const bool frame_is_higher_spatial_layer_of_last_decoded_frame =
             last_decoded_frame_timestamp_ == frame->timestamp &&
@@ -186,8 +187,8 @@
           // these conditions.
           RTC_LOG(LS_WARNING)
               << "Frame with (timestamp:picture_id:spatial_id) ("
-              << frame->timestamp << ":" << frame->picture_id << ":"
-              << static_cast<int>(frame->spatial_layer) << ")"
+              << frame->timestamp << ":" << frame->id.picture_id << ":"
+              << static_cast<int>(frame->id.spatial_layer) << ")"
               << " sent to decoder after frame with"
               << " (timestamp:picture_id:spatial_id) ("
               << last_decoded_frame_timestamp_ << ":"
@@ -263,11 +264,11 @@
 }
 
 bool FrameBuffer::ValidReferences(const EncodedFrame& frame) const {
-  if (frame.picture_id < 0)
+  if (frame.id.picture_id < 0)
     return false;
 
   for (size_t i = 0; i < frame.num_references; ++i) {
-    if (frame.references[i] < 0 || frame.references[i] >= frame.picture_id)
+    if (frame.references[i] < 0 || frame.references[i] >= frame.id.picture_id)
       return false;
 
     for (size_t j = i + 1; j < frame.num_references; ++j) {
@@ -276,7 +277,7 @@
     }
   }
 
-  if (frame.inter_layer_predicted && frame.spatial_layer == 0)
+  if (frame.inter_layer_predicted && frame.id.spatial_layer == 0)
     return false;
 
   return true;
@@ -301,7 +302,7 @@
   if (stats_callback_)
     stats_callback_->OnCompleteFrame(frame->is_keyframe(), frame->size(),
                                      frame->contentType());
-  FrameKey key(frame->picture_id, frame->spatial_layer);
+  const VideoLayerFrameId& id = frame->id;
 
   rtc::CritScope lock(&crit_);
 
@@ -312,8 +313,8 @@
 
   if (!ValidReferences(*frame)) {
     RTC_LOG(LS_WARNING) << "Frame with (picture_id:spatial_id) ("
-                        << key.picture_id << ":"
-                        << static_cast<int>(key.spatial_layer)
+                        << id.picture_id << ":"
+                        << static_cast<int>(id.spatial_layer)
                         << ") has invalid frame references, dropping frame.";
     return last_continuous_picture_id;
   }
@@ -321,15 +322,15 @@
   if (num_frames_buffered_ >= kMaxFramesBuffered) {
     if (frame->is_keyframe()) {
       RTC_LOG(LS_WARNING) << "Inserting keyframe (picture_id:spatial_id) ("
-                          << key.picture_id << ":"
-                          << static_cast<int>(key.spatial_layer)
+                          << id.picture_id << ":"
+                          << static_cast<int>(id.spatial_layer)
                           << ") but buffer is full, clearing"
                           << " buffer and inserting the frame.";
       ClearFramesAndHistory();
     } else {
       RTC_LOG(LS_WARNING) << "Frame with (picture_id:spatial_id) ("
-                          << key.picture_id << ":"
-                          << static_cast<int>(key.spatial_layer)
+                          << id.picture_id << ":"
+                          << static_cast<int>(id.spatial_layer)
                           << ") could not be inserted due to the frame "
                           << "buffer being full, dropping frame.";
       return last_continuous_picture_id;
@@ -337,7 +338,7 @@
   }
 
   if (last_decoded_frame_it_ != frames_.end() &&
-      key <= last_decoded_frame_it_->first) {
+      id <= last_decoded_frame_it_->first) {
     if (AheadOf(frame->timestamp, last_decoded_frame_timestamp_) &&
         frame->is_keyframe()) {
       // If this frame has a newer timestamp but an earlier picture id then we
@@ -351,8 +352,8 @@
       last_continuous_picture_id = -1;
     } else {
       RTC_LOG(LS_WARNING) << "Frame with (picture_id:spatial_id) ("
-                          << key.picture_id << ":"
-                          << static_cast<int>(key.spatial_layer)
+                          << id.picture_id << ":"
+                          << static_cast<int>(id.spatial_layer)
                           << ") inserted after frame ("
                           << last_decoded_frame_it_->first.picture_id << ":"
                           << static_cast<int>(
@@ -365,21 +366,20 @@
   // Test if inserting this frame would cause the order of the frames to become
   // ambiguous (covering more than half the interval of 2^16). This can happen
   // when the picture id make large jumps mid stream.
-  if (!frames_.empty() &&
-      key < frames_.begin()->first &&
-      frames_.rbegin()->first < key) {
+  if (!frames_.empty() && id < frames_.begin()->first &&
+      frames_.rbegin()->first < id) {
     RTC_LOG(LS_WARNING)
         << "A jump in picture id was detected, clearing buffer.";
     ClearFramesAndHistory();
     last_continuous_picture_id = -1;
   }
 
-  auto info = frames_.insert(std::make_pair(key, FrameInfo())).first;
+  auto info = frames_.emplace(id, FrameInfo()).first;
 
   if (info->second.frame) {
     RTC_LOG(LS_WARNING) << "Frame with (picture_id:spatial_id) ("
-                        << key.picture_id << ":"
-                        << static_cast<int>(key.spatial_layer)
+                        << id.picture_id << ":"
+                        << static_cast<int>(id.spatial_layer)
                         << ") already inserted, dropping frame.";
     return last_continuous_picture_id;
   }
@@ -482,7 +482,7 @@
 bool FrameBuffer::UpdateFrameInfoWithIncomingFrame(const EncodedFrame& frame,
                                                    FrameMap::iterator info) {
   TRACE_EVENT0("webrtc", "FrameBuffer::UpdateFrameInfoWithIncomingFrame");
-  FrameKey key(frame.picture_id, frame.spatial_layer);
+  const VideoLayerFrameId& id = frame.id;
   info->second.num_missing_continuous = frame.num_references;
   info->second.num_missing_decodable = frame.num_references;
 
@@ -491,7 +491,7 @@
 
   // Check how many dependencies that have already been fulfilled.
   for (size_t i = 0; i < frame.num_references; ++i) {
-    FrameKey ref_key(frame.references[i], frame.spatial_layer);
+    VideoLayerFrameId ref_key(frame.references[i], frame.id.spatial_layer);
     auto ref_info = frames_.find(ref_key);
 
     // Does |frame| depend on a frame earlier than the last decoded frame?
@@ -501,8 +501,8 @@
         int64_t now_ms = clock_->TimeInMilliseconds();
         if (last_log_non_decoded_ms_ + kLogNonDecodedIntervalMs < now_ms) {
           RTC_LOG(LS_WARNING)
-              << "Frame with (picture_id:spatial_id) (" << key.picture_id << ":"
-              << static_cast<int>(key.spatial_layer)
+              << "Frame with (picture_id:spatial_id) (" << id.picture_id << ":"
+              << static_cast<int>(id.spatial_layer)
               << ") depends on a non-decoded frame more previous than"
               << " the last decoded frame, dropping frame.";
           last_log_non_decoded_ms_ = now_ms;
@@ -522,7 +522,7 @@
       // Add backwards reference so |frame| can be updated when new
       // frames are inserted or decoded.
       ref_info->second.dependent_frames[ref_info->second.num_dependent_frames] =
-          key;
+          id;
       RTC_DCHECK_LT(ref_info->second.num_dependent_frames,
                     (FrameInfo::kMaxNumDependentFrames - 1));
       // TODO(philipel): Look into why this could happen and handle
@@ -541,7 +541,7 @@
     ++info->second.num_missing_continuous;
     ++info->second.num_missing_decodable;
 
-    FrameKey ref_key(frame.picture_id, frame.spatial_layer - 1);
+    VideoLayerFrameId ref_key(frame.id.picture_id, frame.id.spatial_layer - 1);
     // Gets or create the FrameInfo for the referenced frame.
     auto ref_info = frames_.insert(std::make_pair(ref_key, FrameInfo())).first;
     if (ref_info->second.continuous)
@@ -551,7 +551,7 @@
       --info->second.num_missing_decodable;
     } else {
       ref_info->second.dependent_frames[ref_info->second.num_dependent_frames] =
-          key;
+          id;
       ++ref_info->second.num_dependent_frames;
     }
     RTC_DCHECK_LE(ref_info->second.num_missing_continuous,
diff --git a/modules/video_coding/frame_buffer2.h b/modules/video_coding/frame_buffer2.h
index df8d8fe..c05fb8a 100644
--- a/modules/video_coding/frame_buffer2.h
+++ b/modules/video_coding/frame_buffer2.h
@@ -78,23 +78,6 @@
   void UpdateRtt(int64_t rtt_ms);
 
  private:
-  struct FrameKey {
-    FrameKey() : picture_id(-1), spatial_layer(0) {}
-    FrameKey(int64_t picture_id, uint8_t spatial_layer)
-        : picture_id(picture_id), spatial_layer(spatial_layer) {}
-
-    bool operator<(const FrameKey& rhs) const {
-      if (picture_id == rhs.picture_id)
-        return spatial_layer < rhs.spatial_layer;
-      return picture_id < rhs.picture_id;
-    }
-
-    bool operator<=(const FrameKey& rhs) const { return !(rhs < *this); }
-
-    int64_t picture_id;
-    uint8_t spatial_layer;
-  };
-
   struct FrameInfo {
     // The maximum number of frames that can depend on this frame.
     static constexpr size_t kMaxNumDependentFrames = 8;
@@ -103,7 +86,7 @@
     // on this frame.
     // TODO(philipel): Add simple modify/access functions to prevent adding too
     // many |dependent_frames|.
-    FrameKey dependent_frames[kMaxNumDependentFrames];
+    VideoLayerFrameId dependent_frames[kMaxNumDependentFrames];
     size_t num_dependent_frames = 0;
 
     // A frame is continiuous if it has all its referenced/indirectly
@@ -124,7 +107,7 @@
     std::unique_ptr<EncodedFrame> frame;
   };
 
-  using FrameMap = std::map<FrameKey, FrameInfo>;
+  using FrameMap = std::map<VideoLayerFrameId, FrameInfo>;
 
   // Check that the references of |frame| are valid.
   bool ValidReferences(const EncodedFrame& frame) const;
diff --git a/modules/video_coding/frame_buffer2_unittest.cc b/modules/video_coding/frame_buffer2_unittest.cc
index ffc02e8..84682fd 100644
--- a/modules/video_coding/frame_buffer2_unittest.cc
+++ b/modules/video_coding/frame_buffer2_unittest.cc
@@ -160,8 +160,8 @@
         {rtc::checked_cast<uint16_t>(refs)...}};
 
     std::unique_ptr<FrameObjectFake> frame(new FrameObjectFake());
-    frame->picture_id = picture_id;
-    frame->spatial_layer = spatial_layer;
+    frame->id.picture_id = picture_id;
+    frame->id.spatial_layer = spatial_layer;
     frame->timestamp = ts_ms * 90;
     frame->num_references = references.size();
     frame->inter_layer_predicted = inter_layer_predicted;
@@ -193,8 +193,8 @@
     rtc::CritScope lock(&crit_);
     ASSERT_LT(index, frames_.size());
     ASSERT_TRUE(frames_[index]);
-    ASSERT_EQ(picture_id, frames_[index]->picture_id);
-    ASSERT_EQ(spatial_layer, frames_[index]->spatial_layer);
+    ASSERT_EQ(picture_id, frames_[index]->id.picture_id);
+    ASSERT_EQ(spatial_layer, frames_[index]->id.spatial_layer);
   }
 
   void CheckNoFrame(size_t index) {
@@ -269,6 +269,7 @@
 TEST_F(TestFrameBuffer2, SetPlayoutDelay) {
   const PlayoutDelay kPlayoutDelayMs = {123, 321};
   std::unique_ptr<FrameObjectFake> test_frame(new FrameObjectFake());
+  test_frame->id.picture_id = 0;
   test_frame->SetPlayoutDelay(kPlayoutDelayMs);
   buffer_.InsertFrame(std::move(test_frame));
   EXPECT_EQ(kPlayoutDelayMs.min_ms, timing_.min_playout_delay());
@@ -500,8 +501,8 @@
   {
     std::unique_ptr<FrameObjectFake> frame(new FrameObjectFake());
     frame->SetSize(kFrameSize);
-    frame->picture_id = pid;
-    frame->spatial_layer = 0;
+    frame->id.picture_id = pid;
+    frame->id.spatial_layer = 0;
     frame->timestamp = ts;
     frame->num_references = 0;
     frame->inter_layer_predicted = false;
diff --git a/modules/video_coding/packet_buffer.cc b/modules/video_coding/packet_buffer.cc
index 4a8904e..8906041 100644
--- a/modules/video_coding/packet_buffer.cc
+++ b/modules/video_coding/packet_buffer.cc
@@ -430,8 +430,8 @@
     RTC_DCHECK_EQ(data_buffer_[index].seqNum, sequence_buffer_[index].seq_num);
     size_t length = data_buffer_[index].sizeBytes;
     if (destination + length > destination_end) {
-      RTC_LOG(LS_WARNING) << "Frame (" << frame.picture_id << ":"
-                          << static_cast<int>(frame.spatial_layer) << ")"
+      RTC_LOG(LS_WARNING) << "Frame (" << frame.id.picture_id << ":"
+                          << static_cast<int>(frame.id.spatial_layer) << ")"
                           << " bitstream buffer is not large enough.";
       return false;
     }
diff --git a/modules/video_coding/rtp_frame_reference_finder.cc b/modules/video_coding/rtp_frame_reference_finder.cc
index d24bc11..be05e56 100644
--- a/modules/video_coding/rtp_frame_reference_finder.cc
+++ b/modules/video_coding/rtp_frame_reference_finder.cc
@@ -178,9 +178,9 @@
     if (last_unwrap_ == -1)
       last_unwrap_ = picture_id;
 
-    frame->picture_id = unwrapper_.Unwrap(picture_id);
+    frame->id.picture_id = unwrapper_.Unwrap(picture_id);
     frame->num_references = frame->frame_type() == kVideoFrameKey ? 0 : 1;
-    frame->references[0] = frame->picture_id - 1;
+    frame->references[0] = frame->id.picture_id - 1;
     return kHandOff;
   }
 
@@ -229,17 +229,17 @@
 
   // Since keyframes can cause reordering we can't simply assign the
   // picture id according to some incrementing counter.
-  frame->picture_id = frame->last_seq_num();
+  frame->id.picture_id = frame->last_seq_num();
   frame->num_references = frame->frame_type() == kVideoFrameDelta;
   frame->references[0] = generic_unwrapper_.Unwrap(last_picture_id_gop);
-  if (AheadOf<uint16_t>(frame->picture_id, last_picture_id_gop)) {
-    seq_num_it->second.first = frame->picture_id;
-    seq_num_it->second.second = frame->picture_id;
+  if (AheadOf<uint16_t>(frame->id.picture_id, last_picture_id_gop)) {
+    seq_num_it->second.first = frame->id.picture_id;
+    seq_num_it->second.second = frame->id.picture_id;
   }
 
-  last_picture_id_ = frame->picture_id;
-  UpdateLastPictureIdWithPadding(frame->picture_id);
-  frame->picture_id = generic_unwrapper_.Unwrap(frame->picture_id);
+  last_picture_id_ = frame->id.picture_id;
+  UpdateLastPictureIdWithPadding(frame->id.picture_id);
+  frame->id.picture_id = generic_unwrapper_.Unwrap(frame->id.picture_id);
   return kHandOff;
 }
 
@@ -260,21 +260,21 @@
     return ManageFrameGeneric(std::move(frame), codec_header.pictureId);
   }
 
-  frame->picture_id = codec_header.pictureId % kPicIdLength;
+  frame->id.picture_id = codec_header.pictureId % kPicIdLength;
 
   if (last_unwrap_ == -1)
     last_unwrap_ = codec_header.pictureId;
 
   if (last_picture_id_ == -1)
-    last_picture_id_ = frame->picture_id;
+    last_picture_id_ = frame->id.picture_id;
 
   // Find if there has been a gap in fully received frames and save the picture
   // id of those frames in |not_yet_received_frames_|.
-  if (AheadOf<uint16_t, kPicIdLength>(frame->picture_id, last_picture_id_)) {
+  if (AheadOf<uint16_t, kPicIdLength>(frame->id.picture_id, last_picture_id_)) {
     do {
       last_picture_id_ = Add<kPicIdLength>(last_picture_id_, 1);
       not_yet_received_frames_.insert(last_picture_id_);
-    } while (last_picture_id_ != frame->picture_id);
+    } while (last_picture_id_ != frame->id.picture_id);
   }
 
   // Clean up info for base layers that are too old.
@@ -284,7 +284,7 @@
 
   // Clean up info about not yet received frames that are too old.
   uint16_t old_picture_id =
-      Subtract<kPicIdLength>(frame->picture_id, kMaxNotYetReceivedFrames);
+      Subtract<kPicIdLength>(frame->id.picture_id, kMaxNotYetReceivedFrames);
   auto clean_frames_to = not_yet_received_frames_.lower_bound(old_picture_id);
   not_yet_received_frames_.erase(not_yet_received_frames_.begin(),
                                  clean_frames_to);
@@ -339,7 +339,7 @@
     // a layer sync frame has been received after this frame for the same
     // base layer frame, drop this frame.
     if (AheadOf<uint16_t, kPicIdLength>(layer_info_it->second[layer],
-                                        frame->picture_id)) {
+                                        frame->id.picture_id)) {
       return kDrop;
     }
 
@@ -348,14 +348,14 @@
     auto not_received_frame_it =
         not_yet_received_frames_.upper_bound(layer_info_it->second[layer]);
     if (not_received_frame_it != not_yet_received_frames_.end() &&
-        AheadOf<uint16_t, kPicIdLength>(frame->picture_id,
+        AheadOf<uint16_t, kPicIdLength>(frame->id.picture_id,
                                         *not_received_frame_it)) {
       return kStash;
     }
 
-    if (!(AheadOf<uint16_t, kPicIdLength>(frame->picture_id,
+    if (!(AheadOf<uint16_t, kPicIdLength>(frame->id.picture_id,
                                           layer_info_it->second[layer]))) {
-      RTC_LOG(LS_WARNING) << "Frame with picture id " << frame->picture_id
+      RTC_LOG(LS_WARNING) << "Frame with picture id " << frame->id.picture_id
                           << " and packet range [" << frame->first_seq_num()
                           << ", " << frame->last_seq_num()
                           << "] already received, "
@@ -382,17 +382,17 @@
   while (layer_info_it != layer_info_.end()) {
     if (layer_info_it->second[temporal_index] != -1 &&
         AheadOf<uint16_t, kPicIdLength>(layer_info_it->second[temporal_index],
-                                        frame->picture_id)) {
+                                        frame->id.picture_id)) {
       // The frame was not newer, then no subsequent layer info have to be
       // update.
       break;
     }
 
-    layer_info_it->second[codec_header.temporalIdx] = frame->picture_id;
+    layer_info_it->second[codec_header.temporalIdx] = frame->id.picture_id;
     ++tl0_pic_idx;
     layer_info_it = layer_info_.find(tl0_pic_idx);
   }
-  not_yet_received_frames_.erase(frame->picture_id);
+  not_yet_received_frames_.erase(frame->id.picture_id);
 
   UnwrapPictureIds(frame);
 }
@@ -413,21 +413,21 @@
     return ManageFrameGeneric(std::move(frame), codec_header.picture_id);
   }
 
-  frame->spatial_layer = codec_header.spatial_idx;
+  frame->id.spatial_layer = codec_header.spatial_idx;
   frame->inter_layer_predicted = codec_header.inter_layer_predicted;
-  frame->picture_id = codec_header.picture_id % kPicIdLength;
+  frame->id.picture_id = codec_header.picture_id % kPicIdLength;
 
   if (last_unwrap_ == -1)
     last_unwrap_ = codec_header.picture_id;
 
   if (last_picture_id_ == -1)
-    last_picture_id_ = frame->picture_id;
+    last_picture_id_ = frame->id.picture_id;
 
   if (codec_header.flexible_mode) {
     frame->num_references = codec_header.num_ref_pics;
     for (size_t i = 0; i < frame->num_references; ++i) {
-      frame->references[i] =
-          Subtract<kPicIdLength>(frame->picture_id, codec_header.pid_diff[i]);
+      frame->references[i] = Subtract<kPicIdLength>(frame->id.picture_id,
+                                                    codec_header.pid_diff[i]);
     }
 
     UnwrapPictureIds(frame);
@@ -443,10 +443,10 @@
     } else {
       current_ss_idx_ = Add<kMaxGofSaved>(current_ss_idx_, 1);
       scalability_structures_[current_ss_idx_] = codec_header.gof;
-      scalability_structures_[current_ss_idx_].pid_start = frame->picture_id;
+      scalability_structures_[current_ss_idx_].pid_start = frame->id.picture_id;
 
       GofInfo info(&scalability_structures_[current_ss_idx_],
-                   frame->picture_id);
+                   frame->id.picture_id);
       gof_info_.insert(std::make_pair(codec_header.tl0_pic_idx, info));
     }
   }
@@ -463,7 +463,7 @@
 
     frame->num_references = 0;
     GofInfo info = gof_info_.find(codec_header.tl0_pic_idx)->second;
-    FrameReceivedVp9(frame->picture_id, &info);
+    FrameReceivedVp9(frame->id.picture_id, &info);
     UnwrapPictureIds(frame);
     return kHandOff;
   }
@@ -478,16 +478,16 @@
     return kStash;
 
   GofInfo* info = &gof_info_it->second;
-  FrameReceivedVp9(frame->picture_id, info);
+  FrameReceivedVp9(frame->id.picture_id, info);
 
   // Make sure we don't miss any frame that could potentially have the
   // up switch flag set.
-  if (MissingRequiredFrameVp9(frame->picture_id, *info))
+  if (MissingRequiredFrameVp9(frame->id.picture_id, *info))
     return kStash;
 
   if (codec_header.temporal_up_switch) {
     auto pid_tidx =
-        std::make_pair(frame->picture_id, codec_header.temporal_idx);
+        std::make_pair(frame->id.picture_id, codec_header.temporal_idx);
     up_switch_.insert(pid_tidx);
   }
 
@@ -495,28 +495,28 @@
   // then gof info has already been inserted earlier, so we only want to
   // insert if we haven't done so already.
   if (codec_header.temporal_idx == 0 && !codec_header.ss_data_available) {
-    GofInfo new_info(info->gof, frame->picture_id);
+    GofInfo new_info(info->gof, frame->id.picture_id);
     gof_info_.insert(std::make_pair(codec_header.tl0_pic_idx, new_info));
   }
 
   // Clean out old info about up switch frames.
-  uint16_t old_picture_id = Subtract<kPicIdLength>(frame->picture_id, 50);
+  uint16_t old_picture_id = Subtract<kPicIdLength>(frame->id.picture_id, 50);
   auto up_switch_erase_to = up_switch_.lower_bound(old_picture_id);
   up_switch_.erase(up_switch_.begin(), up_switch_erase_to);
 
   size_t diff = ForwardDiff<uint16_t, kPicIdLength>(info->gof->pid_start,
-                                                    frame->picture_id);
+                                                    frame->id.picture_id);
   size_t gof_idx = diff % info->gof->num_frames_in_gof;
 
   // Populate references according to the scalability structure.
   frame->num_references = info->gof->num_ref_pics[gof_idx];
   for (size_t i = 0; i < frame->num_references; ++i) {
     frame->references[i] = Subtract<kPicIdLength>(
-        frame->picture_id, info->gof->pid_diff[gof_idx][i]);
+        frame->id.picture_id, info->gof->pid_diff[gof_idx][i]);
 
     // If this is a reference to a frame earlier than the last up switch point,
     // then ignore this reference.
-    if (UpSwitchInIntervalVp9(frame->picture_id, codec_header.temporal_idx,
+    if (UpSwitchInIntervalVp9(frame->id.picture_id, codec_header.temporal_idx,
                               frame->references[i])) {
       --frame->num_references;
     }
@@ -615,7 +615,7 @@
 void RtpFrameReferenceFinder::UnwrapPictureIds(RtpFrameObject* frame) {
   for (size_t i = 0; i < frame->num_references; ++i)
     frame->references[i] = unwrapper_.Unwrap(frame->references[i]);
-  frame->picture_id = unwrapper_.Unwrap(frame->picture_id);
+  frame->id.picture_id = unwrapper_.Unwrap(frame->id.picture_id);
 }
 
 }  // namespace video_coding
diff --git a/modules/video_coding/rtp_frame_reference_finder_unittest.cc b/modules/video_coding/rtp_frame_reference_finder_unittest.cc
index 0d150ed..7819514 100644
--- a/modules/video_coding/rtp_frame_reference_finder_unittest.cc
+++ b/modules/video_coding/rtp_frame_reference_finder_unittest.cc
@@ -65,8 +65,8 @@
   uint16_t Rand() { return rand_.Rand<uint16_t>(); }
 
   void OnCompleteFrame(std::unique_ptr<EncodedFrame> frame) override {
-    int64_t pid = frame->picture_id;
-    uint16_t sidx = frame->spatial_layer;
+    int64_t pid = frame->id.picture_id;
+    uint16_t sidx = frame->id.spatial_layer;
     auto frame_it = frames_from_callback_.find(std::make_pair(pid, sidx));
     if (frame_it != frames_from_callback_.end()) {
       ADD_FAILURE() << "Already received frame with (pid:sidx): (" << pid << ":"