Bug 1069646 - Scale frame rate initialization in webrtc media_opimization. r=gcp, a=sledru
authorRandell Jesup <rjesup@jesup.org>
Mon, 22 Sep 2014 23:35:58 -0400
changeset 216881 bc5451d18901
parent 216880 dabbfa2c0eac
child 216882 0780dce35e25
push id3952
push userryanvm@gmail.com
push date2014-09-29 21:31 +0000
treeherdermozilla-beta@0780dce35e25 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgcp, sledru
bugs1069646
milestone33.0
Bug 1069646 - Scale frame rate initialization in webrtc media_opimization. r=gcp, a=sledru
media/webrtc/trunk/webrtc/modules/video_coding/main/source/content_metrics_processing.cc
media/webrtc/trunk/webrtc/modules/video_coding/main/source/content_metrics_processing.h
media/webrtc/trunk/webrtc/modules/video_coding/main/source/media_optimization.cc
--- a/media/webrtc/trunk/webrtc/modules/video_coding/main/source/content_metrics_processing.cc
+++ b/media/webrtc/trunk/webrtc/modules/video_coding/main/source/content_metrics_processing.cc
@@ -16,17 +16,17 @@
 #include "webrtc/modules/video_coding/main/interface/video_coding_defines.h"
 
 namespace webrtc {
 //////////////////////////////////
 /// VCMContentMetricsProcessing //
 //////////////////////////////////
 
 VCMContentMetricsProcessing::VCMContentMetricsProcessing()
-    : recursive_avg_factor_(1 / 150.0f),  // matched to  30fps.
+    : recursive_avg_factor_(1 / 150.0f),  // matched to  15fps.
       frame_cnt_uniform_avg_(0),
       avg_motion_level_(0.0f),
       avg_spatial_level_(0.0f) {
   recursive_avg_ = new VideoContentMetrics();
   uniform_avg_ = new VideoContentMetrics();
 }
 
 VCMContentMetricsProcessing::~VCMContentMetricsProcessing() {
@@ -38,17 +38,17 @@ int VCMContentMetricsProcessing::Reset()
   recursive_avg_->Reset();
   uniform_avg_->Reset();
   frame_cnt_uniform_avg_ = 0;
   avg_motion_level_  = 0.0f;
   avg_spatial_level_ = 0.0f;
   return VCM_OK;
 }
 
-void VCMContentMetricsProcessing::UpdateFrameRate(uint32_t frameRate) {
+void VCMContentMetricsProcessing::UpdateFrameRate(float frameRate) {
   // Update factor for recursive averaging.
   recursive_avg_factor_ = static_cast<float> (1000.0f) /
       static_cast<float>(frameRate *  kQmMinIntervalMs);
 }
 
 VideoContentMetrics* VCMContentMetricsProcessing::LongTermAvgData() {
   return recursive_avg_;
 }
--- a/media/webrtc/trunk/webrtc/modules/video_coding/main/source/content_metrics_processing.h
+++ b/media/webrtc/trunk/webrtc/modules/video_coding/main/source/content_metrics_processing.h
@@ -40,17 +40,17 @@ class VCMContentMetricsProcessing {
 
   // Reset the short-term averaged content data.
   void ResetShortTermAvgData();
 
   // Initialize.
   int Reset();
 
   // Inform class of current frame rate.
-  void UpdateFrameRate(uint32_t frameRate);
+  void UpdateFrameRate(float frameRate);
 
   // Returns the long-term averaged content data: recursive average over longer
   // time scale.
   VideoContentMetrics* LongTermAvgData();
 
   // Returns the short-term averaged content data: uniform average over
   // shorter time scalE.
   VideoContentMetrics* ShortTermAvgData();
--- 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
@@ -133,42 +133,42 @@ void MediaOptimization::Reset() {
   last_qm_update_time_ = 0;
   last_change_time_ = 0;
   encoded_frame_samples_.clear();
   avg_sent_bit_rate_bps_ = 0;
   num_layers_ = 1;
 }
 
 void MediaOptimization::SetEncodingData(VideoCodecType send_codec_type,
-                                        int32_t max_bit_rate,
-                                        uint32_t frame_rate,
-                                        uint32_t target_bitrate,
+                                        int32_t max_bit_rate,    // in bits/s
+                                        uint32_t frame_rate,     // in fps*1000
+                                        uint32_t target_bitrate, // in bits/s
                                         uint16_t width,
                                         uint16_t height,
                                         int num_layers,
                                         int32_t mtu) {
   // Everything codec specific should be reset here since this means the codec
   // has changed. If native dimension values have changed, then either user
   // initiated change, or QM initiated change. Will be able to determine only
   // after the processing of the first frame.
   last_change_time_ = clock_->TimeInMilliseconds();
   content_->Reset();
-  content_->UpdateFrameRate(frame_rate);
+  content_->UpdateFrameRate(static_cast<float>(frame_rate) / 1000.0f);
 
   max_bit_rate_ = max_bit_rate;
   send_codec_type_ = send_codec_type;
   target_bit_rate_ = target_bitrate;
   float target_bitrate_kbps = static_cast<float>(target_bitrate) / 1000.0f;
   loss_prot_logic_->UpdateBitRate(target_bitrate_kbps);
-  loss_prot_logic_->UpdateFrameRate(static_cast<float>(frame_rate));
+  loss_prot_logic_->UpdateFrameRate(static_cast<float>(frame_rate) / 1000.0f);
   loss_prot_logic_->UpdateFrameSize(width, height);
   loss_prot_logic_->UpdateNumLayers(num_layers);
   frame_dropper_->Reset();
-  frame_dropper_->SetRates(target_bitrate_kbps, static_cast<float>(frame_rate));
-  user_frame_rate_ = static_cast<float>(frame_rate);
+  frame_dropper_->SetRates(target_bitrate_kbps, static_cast<float>(frame_rate) / 1000.0f);
+  user_frame_rate_ = static_cast<float>(frame_rate)/1000.0f;
   codec_width_ = width;
   codec_height_ = height;
   num_layers_ = (num_layers <= 1) ? 1 : num_layers;  // Can also be zero.
   max_payload_size_ = mtu;
   qm_resolution_->Initialize(target_bitrate_kbps,
                              user_frame_rate_,
                              codec_width_,
                              codec_height_,