Bug 1577236 - clang-10: Fix -Wimplicit-int-float-conversion warnings in dom/media r=jya
authorSylvestre Ledru <sledru@mozilla.com>
Fri, 30 Aug 2019 05:44:13 +0000
changeset 551342 127fb176c0238abd4df5e721e843e5ad4bf7e7ff
parent 551341 6eb3bfbbad0888b343bce4ea3f696c7b979c3f45
child 551343 a4c348d431167134bb73c3aa1a45293c489dead8
push id11865
push userbtara@mozilla.com
push dateMon, 02 Sep 2019 08:54:37 +0000
treeherdermozilla-beta@37f59c4671b3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1577236
milestone70.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 1577236 - clang-10: Fix -Wimplicit-int-float-conversion warnings in dom/media r=jya Depends on D43776 Differential Revision: https://phabricator.services.mozilla.com/D43778
dom/media/VideoUtils.cpp
dom/media/platforms/agnostic/bytestreams/H264.cpp
dom/media/webaudio/DelayBuffer.h
--- a/dom/media/VideoUtils.cpp
+++ b/dom/media/VideoUtils.cpp
@@ -73,26 +73,27 @@ CheckedInt64 UsecsToFrames(int64_t aUsec
 
 // Format TimeUnit as number of frames at given rate.
 CheckedInt64 TimeUnitToFrames(const TimeUnit& aTime, uint32_t aRate) {
   return aTime.IsValid() ? UsecsToFrames(aTime.ToMicroseconds(), aRate)
                          : CheckedInt64(INT64_MAX) + 1;
 }
 
 nsresult SecondsToUsecs(double aSeconds, int64_t& aOutUsecs) {
-  if (aSeconds * double(USECS_PER_S) > INT64_MAX) {
+  if (aSeconds * double(USECS_PER_S) > double(INT64_MAX)) {
     return NS_ERROR_FAILURE;
   }
   aOutUsecs = int64_t(aSeconds * double(USECS_PER_S));
   return NS_OK;
 }
 
 static int32_t ConditionDimension(float aValue) {
   // This will exclude NaNs and too-big values.
-  if (aValue > 1.0 && aValue <= INT32_MAX) return int32_t(NS_round(aValue));
+  if (aValue > 1.0 && aValue <= float(INT32_MAX))
+    return int32_t(NS_round(aValue));
   return 0;
 }
 
 void ScaleDisplayByAspectRatio(gfx::IntSize& aDisplay, float aAspectRatio) {
   if (aAspectRatio > 1.0) {
     // Increase the intrinsic width
     aDisplay.width = ConditionDimension(aAspectRatio * aDisplay.width);
   } else {
--- a/dom/media/platforms/agnostic/bytestreams/H264.cpp
+++ b/dom/media/platforms/agnostic/bytestreams/H264.cpp
@@ -529,17 +529,17 @@ class SPSNALIterator {
     }
     rbsp->AppendElement(val);
   }
   return rbsp.forget();
 }
 
 static int32_t ConditionDimension(float aValue) {
   // This will exclude NaNs and too-big values.
-  if (aValue > 1.0 && aValue <= INT32_MAX / 2) {
+  if (aValue > 1.0 && aValue <= float(INT32_MAX) / 2) {
     return int32_t(aValue);
   }
   return 0;
 }
 
 /* static */
 bool H264::DecodeSPS(const mozilla::MediaByteBuffer* aSPS, SPSData& aDest) {
   if (!aSPS) {
--- a/dom/media/webaudio/DelayBuffer.h
+++ b/dom/media/webaudio/DelayBuffer.h
@@ -27,17 +27,17 @@ class DelayBuffer final {
         ,
         mHaveWrittenBlock(false)
 #endif
   {
     // The 180 second limit in AudioContext::CreateDelay() and the
     // 1 << MEDIA_TIME_FRAC_BITS limit on sample rate provide a limit on the
     // maximum delay.
     MOZ_ASSERT(aMaxDelayTicks <=
-               std::numeric_limits<decltype(mMaxDelayTicks)>::max());
+               float(std::numeric_limits<decltype(mMaxDelayTicks)>::max()));
   }
 
   // Write a WEBAUDIO_BLOCK_SIZE block for aChannelCount channels.
   void Write(const AudioBlock& aInputChunk);
 
   // Read a block with an array of delays, in ticks, for each sample frame.
   // Each delay should be >= 0 and <= MaxDelayTicks().
   void Read(const float aPerFrameDelays[WEBAUDIO_BLOCK_SIZE],