Fix two UBSan warnings in NetEq

Both were related to very large jumps in RTP timestamps.

BUG=webrtc:5488

Review URL: https://codereview.webrtc.org/1685103002

Cr-Commit-Position: refs/heads/master@{#11569}
diff --git a/webrtc/modules/audio_coding/neteq/delay_manager.cc b/webrtc/modules/audio_coding/neteq/delay_manager.cc
index 806d02b..af49f00 100644
--- a/webrtc/modules/audio_coding/neteq/delay_manager.cc
+++ b/webrtc/modules/audio_coding/neteq/delay_manager.cc
@@ -15,6 +15,7 @@
 
 #include <algorithm>  // max, min
 
+#include "webrtc/base/safe_conversions.h"
 #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
 #include "webrtc/modules/audio_coding/neteq/delay_peak_detector.h"
 #include "webrtc/modules/include/module_common_types.h"
@@ -93,10 +94,11 @@
     packet_len_ms = packet_len_ms_;
   } else {
     // Calculate timestamps per packet and derive packet length in ms.
-    int packet_len_samp =
+    int64_t packet_len_samp =
         static_cast<uint32_t>(timestamp - last_timestamp_) /
         static_cast<uint16_t>(sequence_number - last_seq_no_);
-    packet_len_ms = (1000 * packet_len_samp) / sample_rate_hz;
+    packet_len_ms =
+        rtc::checked_cast<int>(1000 * packet_len_samp / sample_rate_hz);
   }
 
   if (packet_len_ms > 0) {
diff --git a/webrtc/modules/audio_coding/neteq/timestamp_scaler.cc b/webrtc/modules/audio_coding/neteq/timestamp_scaler.cc
index c1abdc3..b228e01 100644
--- a/webrtc/modules/audio_coding/neteq/timestamp_scaler.cc
+++ b/webrtc/modules/audio_coding/neteq/timestamp_scaler.cc
@@ -75,7 +75,7 @@
       internal_ref_ = external_timestamp;
       first_packet_received_ = true;
     }
-    int32_t external_diff = external_timestamp - external_ref_;
+    int64_t external_diff = external_timestamp - external_ref_;
     assert(denominator_ > 0);  // Should not be possible.
     external_ref_ = external_timestamp;
     internal_ref_ += (external_diff * numerator_) / denominator_;
@@ -92,7 +92,7 @@
     // Not initialized, or scale factor is 1.
     return internal_timestamp;
   } else {
-    int32_t internal_diff = internal_timestamp - internal_ref_;
+    int64_t internal_diff = internal_timestamp - internal_ref_;
     assert(numerator_ > 0);  // Should not be possible.
     // Do not update references in this method.
     // Switch |denominator_| and |numerator_| to convert the other way.