Bug 1069047: don't recount delta/keyframes stats for each H.264 NAL r=pkerr
authorRandell Jesup <rjesup@jesup.org>
Tue, 14 Oct 2014 19:24:44 -0400
changeset 210469 556ad64e03e280103424754e404cc402b775dc3a
parent 210468 fb08ab7ef68ef659b6b80f45e86a1c6c14e1ff42
child 210470 782a7f579e7b1d5144a84fb83c12cb28af71c512
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerspkerr
bugs1069047
milestone36.0a1
Bug 1069047: don't recount delta/keyframes stats for each H.264 NAL r=pkerr
media/webrtc/trunk/webrtc/modules/video_coding/main/source/media_optimization.cc
--- a/media/webrtc/trunk/webrtc/modules/video_coding/main/source/media_optimization.cc
+++ b/media/webrtc/trunk/webrtc/modules/video_coding/main/source/media_optimization.cc
@@ -365,33 +365,38 @@ VCMFrameCount MediaOptimization::SentFra
   count.numKeyFrames = key_frame_cnt_;
   return count;
 }
 
 int32_t MediaOptimization::UpdateWithEncodedData(int encoded_length,
                                                  uint32_t timestamp,
                                                  FrameType encoded_frame_type) {
   const int64_t now_ms = clock_->TimeInMilliseconds();
+  bool same_frame;
   PurgeOldFrameSamples(now_ms);
   if (encoded_frame_samples_.size() > 0 &&
       encoded_frame_samples_.back().timestamp == timestamp) {
     // Frames having the same timestamp are generated from the same input
     // frame. We don't want to double count them, but only increment the
     // size_bytes.
     encoded_frame_samples_.back().size_bytes += encoded_length;
     encoded_frame_samples_.back().time_complete_ms = now_ms;
+    same_frame = true;
   } else {
     encoded_frame_samples_.push_back(
         EncodedFrameSample(encoded_length, timestamp, now_ms));
+    same_frame = false;
   }
   UpdateSentBitrate(now_ms);
   UpdateSentFramerate();
   if (encoded_length > 0) {
     const bool delta_frame = (encoded_frame_type != kVideoFrameKey);
 
+    // XXX TODO(jesup): if same_frame is true, we should be considering it a single
+    // frame here.
     frame_dropper_->Fill(encoded_length, delta_frame);
     if (max_payload_size_ > 0 && encoded_length > 0) {
       const float min_packets_per_frame =
           encoded_length / static_cast<float>(max_payload_size_);
       if (delta_frame) {
         loss_prot_logic_->UpdatePacketsPerFrame(min_packets_per_frame,
                                                 clock_->TimeInMilliseconds());
       } else {
@@ -404,20 +409,22 @@ int32_t MediaOptimization::UpdateWithEnc
         qm_resolution_->UpdateEncodedSize(encoded_length, encoded_frame_type);
       }
     }
     if (!delta_frame && encoded_length > 0) {
       loss_prot_logic_->UpdateKeyFrameSize(static_cast<float>(encoded_length));
     }
 
     // Updating counters.
-    if (delta_frame) {
-      delta_frame_cnt_++;
-    } else {
-      key_frame_cnt_++;
+    if (!same_frame) {
+      if (delta_frame) {
+        delta_frame_cnt_++;
+      } else {
+        key_frame_cnt_++;
+      }
     }
   }
 
   return VCM_OK;
 }
 
 void MediaOptimization::EnableQM(bool enable) { enable_qm_ = enable; }