From 96e82a5598c63a1fdb42f9b31028c18baaa5722f Mon Sep 17 00:00:00 2001 From: Miguel Casas Date: Tue, 1 Oct 2024 10:30:58 -0700 Subject: [PATCH] starboard/types.h: Replace kSbInt16Min/Max with std::numeric_limits equivalents (#4177) As said this CL replaces kSbInt16Min/Max with their std::numeric_limits<> equivalent, and removes kSbUInt16Max entirely because it's unused. Verified bya local x64x11 build. [1] https://source.corp.google.com/search?q=kSb.%3FInt(16)&sq=&ss=h%2Flbshell-internal%2Fcobalt_src%2F%2B%2Frefs%2Fheads%2FCOBALT b/366064934 --- .../filter/audio_channel_layout_mixer_impl.cc | 9 +++++---- .../testing/audio_channel_layout_mixer_test.cc | 13 ++++++++----- starboard/types.h | 4 ---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/starboard/shared/starboard/player/filter/audio_channel_layout_mixer_impl.cc b/starboard/shared/starboard/player/filter/audio_channel_layout_mixer_impl.cc index 0f09fa0da62e..df1a8894ab03 100644 --- a/starboard/shared/starboard/player/filter/audio_channel_layout_mixer_impl.cc +++ b/starboard/shared/starboard/player/filter/audio_channel_layout_mixer_impl.cc @@ -14,6 +14,7 @@ #include "starboard/shared/starboard/player/filter/audio_channel_layout_mixer.h" +#include #include #include "starboard/common/log.h" @@ -213,11 +214,11 @@ float ClipSample(float sample) { template <> int16_t ClipSample(float sample) { - if (sample > kSbInt16Max) { - return kSbInt16Max; + if (sample > std::numeric_limits::max()) { + return std::numeric_limits::max(); } - if (sample < kSbInt16Min) { - return kSbInt16Min; + if (sample < std::numeric_limits::min()) { + return std::numeric_limits::min(); } return sample; } diff --git a/starboard/shared/starboard/player/filter/testing/audio_channel_layout_mixer_test.cc b/starboard/shared/starboard/player/filter/testing/audio_channel_layout_mixer_test.cc index 2c9b4e512f11..d5e51f37c9cc 100644 --- a/starboard/shared/starboard/player/filter/testing/audio_channel_layout_mixer_test.cc +++ b/starboard/shared/starboard/player/filter/testing/audio_channel_layout_mixer_test.cc @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -104,7 +105,8 @@ class AudioChannelLayoutMixerTest if (storage_type_ == kSbMediaAudioFrameStorageTypePlanar) { src_index = i % kInputFrames * num_of_channels + i / kInputFrames; } - dest_buffer[i] = data_buffer[src_index] * kSbInt16Max; + dest_buffer[i] = + data_buffer[src_index] * std::numeric_limits::max(); } } return decoded_audio; @@ -146,10 +148,11 @@ class AudioChannelLayoutMixerTest src_index = i % output->frames() * output_num_of_channels + i / output->frames(); } - ASSERT_LE(fabs(expected_output[src_index] - - static_cast(output_buffer[i]) / - static_cast(kSbInt16Max)), - 0.001f); + ASSERT_LE( + fabs(expected_output[src_index] - + static_cast(output_buffer[i]) / + static_cast(std::numeric_limits::max())), + 0.001f); } } } diff --git a/starboard/types.h b/starboard/types.h index f8af0615249b..70f3e1dfe22c 100644 --- a/starboard/types.h +++ b/starboard/types.h @@ -57,10 +57,6 @@ typedef int64_t ssize_t; // Simulate needed portions of limits.h for platforms that don't provide it. -static const int16_t kSbInt16Min = ((int16_t)0x8000); -static const int16_t kSbInt16Max = ((int16_t)0x7FFF); -static const uint16_t kSbUInt16Max = ((uint16_t)0xFFFF); - #define kSbInt32Min ((int32_t)0x80000000) static const int32_t kSbInt32Max = ((int32_t)0x7FFFFFFF); static const uint32_t kSbUInt32Max = ((uint32_t)0xFFFFFFFF);