Bug 1328142 - Fix VideoConduit warning: Comparison between signed and unsigned ints. r=pkerr
authorAndreas Pehrson <pehrsons@gmail.com>
Tue, 03 Jan 2017 11:54:31 +0100
changeset 377341 15a88f1ebc494d09c895a0125b6a1d669f42454c
parent 377340 8e9b98f6319257c65bfab9974516a13e22032203
child 377342 902f9175ee2b31a41ef997fba56a756d84a16c6b
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspkerr
bugs1328142
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1328142 - Fix VideoConduit warning: Comparison between signed and unsigned ints. r=pkerr MozReview-Commit-ID: IecwaSYvg4z
media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
media/webrtc/signaling/src/media-conduit/VideoConduit.h
--- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
+++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
@@ -73,17 +73,17 @@ static const char* kRedPayloadName = "re
 // Convert (SI) kilobits/sec to (SI) bits/sec
 #define KBPS(kbps) kbps * 1000
 const uint32_t WebrtcVideoConduit::kDefaultMinBitrate_bps =  KBPS(200);
 const uint32_t WebrtcVideoConduit::kDefaultStartBitrate_bps = KBPS(300);
 const uint32_t WebrtcVideoConduit::kDefaultMaxBitrate_bps = KBPS(2000);
 
 // 32 bytes is what WebRTC CodecInst expects
 const unsigned int WebrtcVideoConduit::CODEC_PLNAME_SIZE = 32;
-static const unsigned int kViEMinCodecBitrate = 30;
+static const int kViEMinCodecBitrate = 30;
 
 template<typename T>
 T MinIgnoreZero(const T& a, const T& b)
 {
   return std::min(a? a:b, b? b:a);
 }
 
 void
@@ -1241,20 +1241,20 @@ WebrtcVideoConduit::CreateEncoder(webrtc
     encoder = webrtc::VideoEncoder::Create(aType, enable_simulcast);
   }
 
   return encoder;
 }
 
 struct ResolutionAndBitrateLimits
 {
-  uint32_t resolution_in_mb;
-  uint32_t min_bitrate_bps;
-  uint32_t start_bitrate_bps;
-  uint32_t max_bitrate_bps;
+  int resolution_in_mb;
+  int min_bitrate_bps;
+  int start_bitrate_bps;
+  int max_bitrate_bps;
 };
 
 #define MB_OF(w,h) ((unsigned int)((((w+15)>>4))*((unsigned int)((h+15)>>4))))
 // For now, try to set the max rates well above the knee in the curve.
 // Chosen somewhat arbitrarily; it's hard to find good data oriented for
 // realtime interactive/talking-head recording.  These rates assume
 // 30fps.
 
@@ -1266,61 +1266,61 @@ static ResolutionAndBitrateLimits kResol
   {MB_OF(800, 480), KBPS(600), KBPS(800), KBPS(2500)}, // HD ~720
   {tl::Max<MB_OF(400, 240), MB_OF(352, 288)>::value, KBPS(200), KBPS(300), KBPS(1300)}, // VGA, WVGA
   {MB_OF(176, 144), KBPS(100), KBPS(150), KBPS(500)}, // WQVGA, CIF
   {0 , KBPS(40), KBPS(80), KBPS(250)} // QCIF and below
 };
 
 void
 WebrtcVideoConduit::SelectBitrates(
-  unsigned short width, unsigned short height, uint32_t cap,
+  unsigned short width, unsigned short height, int cap,
   int32_t aLastFramerateTenths,
   webrtc::VideoStream& aVideoStream)
 {
   int& out_min = aVideoStream.min_bitrate_bps;
   int& out_start = aVideoStream.target_bitrate_bps;
   int& out_max = aVideoStream.max_bitrate_bps;
   // max bandwidth should be proportional (not linearly!) to resolution, and
   // proportional (perhaps linearly, or close) to current frame rate.
-  unsigned int fs = MB_OF(width, height);
+  int fs = MB_OF(width, height);
 
   for (ResolutionAndBitrateLimits resAndLimits : kResolutionAndBitrateLimits) {
     if (fs > resAndLimits.resolution_in_mb &&
         // pick the highest range where at least start rate is within cap
         // (or if we're at the end of the array).
         (!cap || resAndLimits.start_bitrate_bps <= cap ||
          resAndLimits.resolution_in_mb == 0)) {
-      out_min = static_cast<int>(MinIgnoreZero(resAndLimits.min_bitrate_bps, cap));
-      out_start = static_cast<int>(MinIgnoreZero(resAndLimits.start_bitrate_bps, cap));
-      out_max = static_cast<int>(MinIgnoreZero(resAndLimits.max_bitrate_bps, cap));
+      out_min = MinIgnoreZero(resAndLimits.min_bitrate_bps, cap);
+      out_start = MinIgnoreZero(resAndLimits.start_bitrate_bps, cap);
+      out_max = MinIgnoreZero(resAndLimits.max_bitrate_bps, cap);
       break;
     }
   }
 
   // mLastFramerateTenths is scaled by *10
   double framerate = std::min((aLastFramerateTenths / 10.), 60.0);
   MOZ_ASSERT(framerate > 0);
   // Now linear reduction/increase based on fps (max 60fps i.e. doubling)
   if (framerate >= 10) {
     out_min = out_min * (framerate / 30);
     out_start = out_start * (framerate / 30);
-    out_max = std::max(static_cast<unsigned int>(out_max * (framerate / 30)), cap);
+    out_max = std::max(static_cast<int>(out_max * (framerate / 30)), cap);
   } else {
     // At low framerates, don't reduce bandwidth as much - cut slope to 1/2.
     // Mostly this would be ultra-low-light situations/mobile or screensharing.
     out_min = out_min * ((10 - (framerate / 2)) / 30);
     out_start = out_start * ((10 - (framerate / 2)) / 30);
-    out_max = std::max(static_cast<unsigned int>(out_max * ((10 - (framerate / 2)) / 30)), cap);
+    out_max = std::max(static_cast<int>(out_max * ((10 - (framerate / 2)) / 30)), cap);
   }
 
   if (mMinBitrate && mMinBitrate > out_min) {
     out_min = mMinBitrate;
   }
   // If we try to set a minimum bitrate that is too low, ViE will reject it.
-  out_min = std::max(static_cast<int>(kViEMinCodecBitrate), out_min);
+  out_min = std::max(kViEMinCodecBitrate, out_min);
   if (mStartBitrate && mStartBitrate > out_start) {
     out_start = mStartBitrate;
   }
   out_start = std::max(out_start, out_min);
 
   // Note: mNegotiatedMaxBitrate is the max transport bitrate - it applies to
   // a single codec encoding, but should also apply to the sum of all
   // simulcast layers in this encoding!  So sum(layers.maxBitrate) <=
--- a/media/webrtc/signaling/src/media-conduit/VideoConduit.h
+++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.h
@@ -154,17 +154,17 @@ public:
    * Function to set the encoding bitrate limits based on incoming frame size and rate
    * @param width, height: dimensions of the frame
    * @param cap: user-enforced max bitrate, or 0
    * @param aLastFramerateTenths: holds the current input framerate
    * @param aVideoStream stream to apply bitrates to
    */
   void SelectBitrates(unsigned short width,
                       unsigned short height,
-                      unsigned int cap,
+                      int cap,
                       int32_t aLastFramerateTenths,
                       webrtc::VideoStream& aVideoStream);
 
   /**
    * Function to select and change the encoding resolution based on incoming frame size
    * and current available bandwidth.
    * @param width, height: dimensions of the frame
    * @param frame: optional frame to submit for encoding after reconfig
@@ -458,21 +458,21 @@ private:
   unsigned short mReceivingWidth;
   unsigned short mReceivingHeight;
   unsigned int   mSendingFramerate;
   // scaled by *10 because Atomic<double/float> isn't supported
   mozilla::Atomic<int32_t, mozilla::Relaxed> mLastFramerateTenths;
   unsigned short mNumReceivingStreams;
   bool mVideoLatencyTestEnable;
   uint64_t mVideoLatencyAvg;
-  uint32_t mMinBitrate;
-  uint32_t mStartBitrate;
-  uint32_t mPrefMaxBitrate;
-  uint32_t mNegotiatedMaxBitrate;
-  uint32_t mMinBitrateEstimate;
+  int mMinBitrate;
+  int mStartBitrate;
+  int mPrefMaxBitrate;
+  int mMinBitrateEstimate;
+  int mNegotiatedMaxBitrate;
 
   bool mRtpStreamIdEnabled;
   uint8_t mRtpStreamIdExtId;
 
   static const unsigned int sAlphaNum = 7;
   static const unsigned int sAlphaDen = 8;
   static const unsigned int sRoundingPadding = 1024;