Bug 1069047: don't recount delta/keyframes stats for each H.264 NAL r=pkerr
--- 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; }