clang-tidy: apply readability-static-accessed-through-instance once
this generally produces too many false positives, in particular for ArrayView, doing it once produced some useful results.
drive-by: fix double typo "ConvertsToTimeDela" to "ConvertToTimeDelta".
Bug: webrtc:424706384
Change-Id: I7f05f1985b5778fcaef6317984602ebcd75f430d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/403508
Commit-Queue: Philipp Hancke <phancke@meta.com>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45334}
diff --git a/.clang-tidy b/.clang-tidy
index 8470f6b..42ad6ca 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -8,6 +8,7 @@
readability-static-definition-in-anonymous-namespace,
readability-redundant-smartptr-get,
readability-redundant-declaration'
+ # readability-static-accessed-through-instance is generally useful but produces too many false positives.
CheckOptions:
# The default threshold gives false positives in test data
modernize-use-std-numbers.DiffThreshold: 0.00001
diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc
index adecc36..90d3c70 100644
--- a/audio/channel_receive.cc
+++ b/audio/channel_receive.cc
@@ -494,7 +494,7 @@
if (packet_info.absolute_capture_time().has_value()) {
MutexLock lock(&ts_stats_lock_);
new_packet_info.set_local_capture_clock_offset(
- capture_clock_offset_updater_.ConvertsToTimeDela(
+ CaptureClockOffsetUpdater::ConvertToTimeDelta(
capture_clock_offset_updater_.AdjustEstimatedCaptureClockOffset(
packet_info.absolute_capture_time()
->estimated_capture_clock_offset)));
diff --git a/common_audio/resampler/sinc_resampler_unittest.cc b/common_audio/resampler/sinc_resampler_unittest.cc
index 8fbe0d8..d6aeb45 100644
--- a/common_audio/resampler/sinc_resampler_unittest.cc
+++ b/common_audio/resampler/sinc_resampler_unittest.cc
@@ -136,7 +136,7 @@
// Use a kernel from SincResampler as input and kernel data, this has the
// benefit of already being properly sized and aligned for Convolve_SSE().
- double result = resampler.Convolve_C(
+ double result = SincResampler::Convolve_C(
resampler.kernel_storage_.get(), resampler.kernel_storage_.get(),
resampler.kernel_storage_.get(), kKernelInterpolationFactor);
double result2 = resampler.convolve_proc_(
@@ -145,7 +145,7 @@
EXPECT_NEAR(result2, result, kEpsilon);
// Test Convolve() w/ unaligned input pointer.
- result = resampler.Convolve_C(
+ result = SincResampler::Convolve_C(
resampler.kernel_storage_.get() + 1, resampler.kernel_storage_.get(),
resampler.kernel_storage_.get(), kKernelInterpolationFactor);
result2 = resampler.convolve_proc_(
@@ -172,7 +172,7 @@
// Benchmark Convolve_C().
int64_t start = TimeNanos();
for (int i = 0; i < kConvolveIterations; ++i) {
- resampler.Convolve_C(
+ SincResampler::Convolve_C(
resampler.kernel_storage_.get(), resampler.kernel_storage_.get(),
resampler.kernel_storage_.get(), kKernelInterpolationFactor);
}
diff --git a/common_video/h265/h265_bitstream_parser_unittest.cc b/common_video/h265/h265_bitstream_parser_unittest.cc
index ec629ea..7cfa1ea 100644
--- a/common_video/h265/h265_bitstream_parser_unittest.cc
+++ b/common_video/h265/h265_bitstream_parser_unittest.cc
@@ -165,10 +165,9 @@
}
TEST(H265BitstreamParserTest, PpsIdFromSlice) {
- H265BitstreamParser h265_parser;
std::optional<uint32_t> pps_id =
- h265_parser.ParsePpsIdFromSliceSegmentLayerRbsp(kH265SliceChunk,
- H265::NaluType::kTrailR);
+ H265BitstreamParser::ParsePpsIdFromSliceSegmentLayerRbsp(
+ kH265SliceChunk, H265::NaluType::kTrailR);
ASSERT_TRUE(pps_id);
EXPECT_EQ(1u, *pps_id);
}
diff --git a/media/engine/webrtc_voice_engine.cc b/media/engine/webrtc_voice_engine.cc
index 6d996f1..cc011a1 100644
--- a/media/engine/webrtc_voice_engine.cc
+++ b/media/engine/webrtc_voice_engine.cc
@@ -732,10 +732,10 @@
apm_config.gain_controller1.enabled = enabled;
#if defined(WEBRTC_IOS) || defined(WEBRTC_ANDROID)
apm_config.gain_controller1.mode =
- apm_config.gain_controller1.kFixedDigital;
+ AudioProcessing::Config::GainController1::kFixedDigital;
#else
apm_config.gain_controller1.mode =
- apm_config.gain_controller1.kAdaptiveAnalog;
+ AudioProcessing::Config::GainController1::kAdaptiveAnalog;
#endif
}
diff --git a/modules/audio_processing/agc/agc_manager_direct_unittest.cc b/modules/audio_processing/agc/agc_manager_direct_unittest.cc
index 742472d..259592d 100644
--- a/modules/audio_processing/agc/agc_manager_direct_unittest.cc
+++ b/modules/audio_processing/agc/agc_manager_direct_unittest.cc
@@ -256,7 +256,8 @@
// in the PCM file if `num_frames` is too large - i.e., does not loop.
void Feed(int num_frames, int gain_db, AgcManagerDirect& agc) {
float gain = std::pow(10.0f, gain_db / 20.0f); // From dB to linear gain.
- is_.seekg(0, is_.beg); // Start from the beginning of the PCM file.
+ is_.seekg(0,
+ std::ifstream::beg); // Start from the beginning of the PCM file.
// Read and feed frames.
for (int i = 0; i < num_frames; ++i) {
@@ -290,7 +291,8 @@
std::optional<float> speech_level_override,
AgcManagerDirect& agc) {
float gain = std::pow(10.0f, gain_db / 20.0f); // From dB to linear gain.
- is_.seekg(0, is_.beg); // Start from the beginning of the PCM file.
+ is_.seekg(0,
+ std::ifstream::beg); // Start from the beginning of the PCM file.
// Read and feed frames.
for (int i = 0; i < num_frames; ++i) {
diff --git a/modules/audio_processing/agc2/input_volume_controller_unittest.cc b/modules/audio_processing/agc2/input_volume_controller_unittest.cc
index 7502467..f31fae1 100644
--- a/modules/audio_processing/agc2/input_volume_controller_unittest.cc
+++ b/modules/audio_processing/agc2/input_volume_controller_unittest.cc
@@ -165,7 +165,8 @@
RTC_DCHECK(controller.capture_output_used());
float gain = std::pow(10.0f, gain_db / 20.0f); // From dB to linear gain.
- is_.seekg(0, is_.beg); // Start from the beginning of the PCM file.
+ is_.seekg(0,
+ std::ifstream::beg); // Start from the beginning of the PCM file.
// Read and feed frames.
for (int i = 0; i < num_frames; ++i) {
diff --git a/modules/audio_processing/agc2/rnn_vad/test_utils.cc b/modules/audio_processing/agc2/rnn_vad/test_utils.cc
index 4fb11ce..fd6c2c3 100644
--- a/modules/audio_processing/agc2/rnn_vad/test_utils.cc
+++ b/modules/audio_processing/agc2/rnn_vad/test_utils.cc
@@ -62,8 +62,10 @@
return is_.gcount() == bytes_to_read;
}
bool ReadValue(float& dst) override { return ReadChunk({&dst, 1}); }
- void SeekForward(int hop) override { is_.seekg(hop * sizeof(T), is_.cur); }
- void SeekBeginning() override { is_.seekg(0, is_.beg); }
+ void SeekForward(int hop) override {
+ is_.seekg(hop * sizeof(T), std::ifstream::cur);
+ }
+ void SeekBeginning() override { is_.seekg(0, std::ifstream::beg); }
private:
std::ifstream is_;
diff --git a/modules/audio_processing/audio_processing_unittest.cc b/modules/audio_processing/audio_processing_unittest.cc
index 61f00de..49b7131 100644
--- a/modules/audio_processing/audio_processing_unittest.cc
+++ b/modules/audio_processing/audio_processing_unittest.cc
@@ -811,7 +811,8 @@
// Testing number of invalid and valid channels.
Init(16000, 16000, 16000, 4, 4, 4, false);
- TestChangingChannelsInt16Interface(0, apm_->kBadNumberChannelsError);
+ TestChangingChannelsInt16Interface(0,
+ AudioProcessing::kBadNumberChannelsError);
for (size_t i = 1; i < 4; i++) {
TestChangingChannelsInt16Interface(i, AudioProcessing::kNoError);
@@ -823,8 +824,8 @@
// Testing number of invalid and valid channels.
Init(16000, 16000, 16000, 4, 4, 4, false);
- TestChangingForwardChannels(0, 1, apm_->kBadNumberChannelsError);
- TestChangingReverseChannels(0, apm_->kBadNumberChannelsError);
+ TestChangingForwardChannels(0, 1, AudioProcessing::kBadNumberChannelsError);
+ TestChangingReverseChannels(0, AudioProcessing::kBadNumberChannelsError);
for (size_t i = 1; i < 4; ++i) {
for (size_t j = 0; j < 1; ++j) {
@@ -2741,7 +2742,7 @@
// Fill the audio frame with a sawtooth pattern.
int16_t* ptr = frame.data.data();
- for (size_t i = 0; i < frame.kMaxDataSizeSamples; i++) {
+ for (size_t i = 0; i < Int16FrameData::kMaxDataSizeSamples; i++) {
ptr[i] = 10000 * ((i % 3) - 1);
}
@@ -2790,7 +2791,7 @@
// Fill the audio frame with a sawtooth pattern.
int16_t* ptr = frame.data.data();
- for (size_t i = 0; i < frame.kMaxDataSizeSamples; i++) {
+ for (size_t i = 0; i < Int16FrameData::kMaxDataSizeSamples; i++) {
ptr[i] = 10000 * ((i % 3) - 1);
}
@@ -2837,7 +2838,7 @@
// Fill the audio frame with a sawtooth pattern.
int16_t* ptr = frame.data.data();
- for (size_t i = 0; i < frame.kMaxDataSizeSamples; i++) {
+ for (size_t i = 0; i < Int16FrameData::kMaxDataSizeSamples; i++) {
ptr[i] = 10000 * ((i % 3) - 1);
}
diff --git a/modules/rtp_rtcp/source/capture_clock_offset_updater.cc b/modules/rtp_rtcp/source/capture_clock_offset_updater.cc
index 861f177..4a8cb83 100644
--- a/modules/rtp_rtcp/source/capture_clock_offset_updater.cc
+++ b/modules/rtp_rtcp/source/capture_clock_offset_updater.cc
@@ -31,7 +31,7 @@
static_cast<uint64_t>(*remote_to_local_clock_offset_);
}
-std::optional<TimeDelta> CaptureClockOffsetUpdater::ConvertsToTimeDela(
+std::optional<TimeDelta> CaptureClockOffsetUpdater::ConvertToTimeDelta(
std::optional<int64_t> q32x32) {
if (q32x32 == std::nullopt) {
return std::nullopt;
diff --git a/modules/rtp_rtcp/source/capture_clock_offset_updater.h b/modules/rtp_rtcp/source/capture_clock_offset_updater.h
index 5bae8b8..b85f5eb 100644
--- a/modules/rtp_rtcp/source/capture_clock_offset_updater.h
+++ b/modules/rtp_rtcp/source/capture_clock_offset_updater.h
@@ -45,7 +45,7 @@
void SetRemoteToLocalClockOffset(std::optional<int64_t> offset_q32x32);
// Converts a signed Q32.32-formatted fixed-point to a TimeDelta.
- static std::optional<TimeDelta> ConvertsToTimeDela(
+ static std::optional<TimeDelta> ConvertToTimeDelta(
std::optional<int64_t> q32x32);
private:
diff --git a/modules/rtp_rtcp/source/capture_clock_offset_updater_unittest.cc b/modules/rtp_rtcp/source/capture_clock_offset_updater_unittest.cc
index 1723f8e..6c9da46 100644
--- a/modules/rtp_rtcp/source/capture_clock_offset_updater_unittest.cc
+++ b/modules/rtp_rtcp/source/capture_clock_offset_updater_unittest.cc
@@ -68,16 +68,16 @@
kPositive.ms() * (NtpTime::kFractionsPerSecond / 1000);
constexpr TimeDelta kEpsilon = TimeDelta::Millis(1);
std::optional<TimeDelta> converted =
- CaptureClockOffsetUpdater::ConvertsToTimeDela(kNegativeQ32x32);
+ CaptureClockOffsetUpdater::ConvertToTimeDelta(kNegativeQ32x32);
EXPECT_GT(converted, kNegative - kEpsilon);
EXPECT_LT(converted, kNegative + kEpsilon);
- converted = CaptureClockOffsetUpdater::ConvertsToTimeDela(kPositiveQ32x32);
+ converted = CaptureClockOffsetUpdater::ConvertToTimeDelta(kPositiveQ32x32);
EXPECT_GT(converted, kPositive - kEpsilon);
EXPECT_LT(converted, kPositive + kEpsilon);
EXPECT_FALSE(
- CaptureClockOffsetUpdater::ConvertsToTimeDela(std::nullopt).has_value());
+ CaptureClockOffsetUpdater::ConvertToTimeDelta(std::nullopt).has_value());
}
} // namespace webrtc
diff --git a/modules/rtp_rtcp/source/ulpfec_generator.cc b/modules/rtp_rtcp/source/ulpfec_generator.cc
index 56c8ee3..5ef7f6f 100644
--- a/modules/rtp_rtcp/source/ulpfec_generator.cc
+++ b/modules/rtp_rtcp/source/ulpfec_generator.cc
@@ -253,8 +253,8 @@
int UlpfecGenerator::Overhead() const {
RTC_DCHECK_RUNS_SERIALIZED(&race_checker_);
RTC_DCHECK(!media_packets_.empty());
- int num_fec_packets =
- fec_->NumFecPackets(media_packets_.size(), CurrentParams().fec_rate);
+ int num_fec_packets = ForwardErrorCorrection::NumFecPackets(
+ media_packets_.size(), CurrentParams().fec_rate);
// Return the overhead in Q8.
return (num_fec_packets << 8) / media_packets_.size();
diff --git a/system_wrappers/source/field_trial.cc b/system_wrappers/source/field_trial.cc
index b426f42..1d15e85 100644
--- a/system_wrappers/source/field_trial.cc
+++ b/system_wrappers/source/field_trial.cc
@@ -47,11 +47,12 @@
std::map<absl::string_view, absl::string_view> field_trials;
while (next_item < trials.length()) {
size_t name_end = trials.find(kPersistentStringSeparator, next_item);
- if (name_end == trials.npos || next_item == name_end)
+ if (name_end == absl::string_view::npos || next_item == name_end)
return false;
size_t group_name_end =
trials.find(kPersistentStringSeparator, name_end + 1);
- if (group_name_end == trials.npos || name_end + 1 == group_name_end)
+ if (group_name_end == absl::string_view::npos ||
+ name_end + 1 == group_name_end)
return false;
absl::string_view name = trials.substr(next_item, name_end - next_item);
absl::string_view group_name =
diff --git a/video/rtp_streams_synchronizer2.cc b/video/rtp_streams_synchronizer2.cc
index 2019ec3..a7b655e 100644
--- a/video/rtp_streams_synchronizer2.cc
+++ b/video/rtp_streams_synchronizer2.cc
@@ -125,8 +125,8 @@
int relative_delay_ms;
// Calculate how much later or earlier the audio stream is compared to video.
- if (!sync_->ComputeRelativeDelay(audio_measurement_, video_measurement_,
- &relative_delay_ms)) {
+ if (!StreamSynchronization::ComputeRelativeDelay(
+ audio_measurement_, video_measurement_, &relative_delay_ms)) {
return;
}
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index ef79a69..072823b 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -62,6 +62,7 @@
#include "modules/rtp_rtcp/include/rtcp_statistics.h"
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "modules/rtp_rtcp/source/absolute_capture_time_interpolator.h"
+#include "modules/rtp_rtcp/source/capture_clock_offset_updater.h"
#include "modules/rtp_rtcp/source/corruption_detection_extension.h"
#include "modules/rtp_rtcp/source/create_video_rtp_depacketizer.h"
#include "modules/rtp_rtcp/source/frame_object.h"
@@ -596,7 +597,7 @@
rtp_packet.GetExtension<AbsoluteCaptureTimeExtension>()));
if (packet_info.absolute_capture_time().has_value()) {
packet_info.set_local_capture_clock_offset(
- capture_clock_offset_updater_.ConvertsToTimeDela(
+ CaptureClockOffsetUpdater::ConvertToTimeDelta(
capture_clock_offset_updater_.AdjustEstimatedCaptureClockOffset(
packet_info.absolute_capture_time()
->estimated_capture_clock_offset)));