diff options
author | avi <avi@chromium.org> | 2015-11-24 19:51:14 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-25 03:53:05 +0000 |
commit | b81447781b75fcab4338168b292f01d4c9543892 (patch) | |
tree | f59b6cccd6c36a5cc1df8217cfa4b3071a9d2d94 | |
parent | 50ae488d668dfce2942b868dab6167f7b484399d (diff) | |
download | chromium_src-b81447781b75fcab4338168b292f01d4c9543892.zip chromium_src-b81447781b75fcab4338168b292f01d4c9543892.tar.gz chromium_src-b81447781b75fcab4338168b292f01d4c9543892.tar.bz2 |
Remove kint8min, kint8max, and kint16min.
BUG=138542
Review URL: https://codereview.chromium.org/1475783002
Cr-Commit-Position: refs/heads/master@{#361560}
-rw-r--r-- | base/basictypes.h | 15 | ||||
-rw-r--r-- | media/base/audio_bus.cc | 36 | ||||
-rw-r--r-- | media/base/audio_bus_unittest.cc | 49 |
3 files changed, 56 insertions, 44 deletions
diff --git a/base/basictypes.h b/base/basictypes.h index e167466..e6d6285 100644 --- a/base/basictypes.h +++ b/base/basictypes.h @@ -2,12 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// This file contains definitions of our old basic integral types -// ((u)int{8,16,32,64}) and further includes. I recommend that you use the C99 -// standard types instead, and include <stdint.h>/<stddef.h>/etc. as needed. -// Note that the macros and macro-like constructs that were formerly defined in -// this file are now available separately in base/macros.h. - #ifndef BASE_BASICTYPES_H_ #define BASE_BASICTYPES_H_ @@ -18,7 +12,8 @@ #include "base/macros.h" #include "build/build_config.h" -// DEPRECATED: Please use (u)int{8,16,32,64}_t instead (and include <stdint.h>). +// DEPRECATED: Use (u)int{8,16,32,64}_t instead (and include <stdint.h>). +// http://crbug.com/138542 typedef int8_t int8; typedef uint8_t uint8; typedef int16_t int16; @@ -28,15 +23,13 @@ typedef uint32_t uint32; typedef int64_t int64; typedef uint64_t uint64; -// DEPRECATED: Please use std::numeric_limits (from <limits>) or +// DEPRECATED: Use std::numeric_limits (from <limits>) or // (U)INT{8,16,32,64}_{MIN,MAX} in case of globals (and include <stdint.h>). +// http://crbug.com/138542 const uint8 kuint8max = 0xFF; const uint16 kuint16max = 0xFFFF; const uint32 kuint32max = 0xFFFFFFFF; const uint64 kuint64max = 0xFFFFFFFFFFFFFFFFULL; -const int8 kint8min = -0x7F - 1; -const int8 kint8max = 0x7F; -const int16 kint16min = -0x7FFF - 1; const int16 kint16max = 0x7FFF; const int32 kint32min = -0x7FFFFFFF - 1; const int32 kint32max = 0x7FFFFFFF; diff --git a/media/base/audio_bus.cc b/media/base/audio_bus.cc index 2e34f1e..8466c2a 100644 --- a/media/base/audio_bus.cc +++ b/media/base/audio_bus.cc @@ -4,6 +4,10 @@ #include "media/base/audio_bus.h" +#include <stdint.h> + +#include <limits> + #include "base/logging.h" #include "base/numerics/safe_conversions.h" #include "media/audio/audio_parameters.h" @@ -12,7 +16,7 @@ namespace media { -static const uint8 kUint8Bias = 128; +static const uint8_t kUint8Bias = 128; static bool IsAligned(void* ptr) { return (reinterpret_cast<uintptr_t>(ptr) & @@ -252,19 +256,22 @@ void AudioBus::FromInterleavedPartial(const void* source, int start_frame, CheckOverflow(start_frame, frames, frames_); switch (bytes_per_sample) { case 1: - FromInterleavedInternal<uint8, int16, kUint8Bias>( + FromInterleavedInternal<uint8_t, int16_t, kUint8Bias>( source, start_frame, frames, this, - 1.0f / kint8min, 1.0f / kint8max); + 1.0f / std::numeric_limits<int8_t>::min(), + 1.0f / std::numeric_limits<int8_t>::max()); break; case 2: - FromInterleavedInternal<int16, int16, 0>( + FromInterleavedInternal<int16_t, int16_t, 0>( source, start_frame, frames, this, - 1.0f / kint16min, 1.0f / kint16max); + 1.0f / std::numeric_limits<int16_t>::min(), + 1.0f / std::numeric_limits<int16_t>::max()); break; case 4: - FromInterleavedInternal<int32, int32, 0>( + FromInterleavedInternal<int32_t, int32_t, 0>( source, start_frame, frames, this, - 1.0f / kint32min, 1.0f / kint32max); + 1.0f / std::numeric_limits<int32_t>::min(), + 1.0f / std::numeric_limits<int32_t>::max()); break; default: NOTREACHED() << "Unsupported bytes per sample encountered."; @@ -295,16 +302,19 @@ void AudioBus::ToInterleavedPartial(int start_frame, int frames, CheckOverflow(start_frame, frames, frames_); switch (bytes_per_sample) { case 1: - ToInterleavedInternal<uint8, int16, kUint8Bias>( - this, start_frame, frames, dest, kint8min, kint8max); + ToInterleavedInternal<uint8_t, int16_t, kUint8Bias>( + this, start_frame, frames, dest, std::numeric_limits<int8_t>::min(), + std::numeric_limits<int8_t>::max()); break; case 2: - ToInterleavedInternal<int16, int16, 0>( - this, start_frame, frames, dest, kint16min, kint16max); + ToInterleavedInternal<int16_t, int16_t, 0>( + this, start_frame, frames, dest, std::numeric_limits<int16_t>::min(), + std::numeric_limits<int16_t>::max()); break; case 4: - ToInterleavedInternal<int32, int32, 0>( - this, start_frame, frames, dest, kint32min, kint32max); + ToInterleavedInternal<int32_t, int32_t, 0>( + this, start_frame, frames, dest, std::numeric_limits<int32_t>::min(), + std::numeric_limits<int32_t>::max()); break; default: NOTREACHED() << "Unsupported bytes per sample encountered."; diff --git a/media/base/audio_bus_unittest.cc b/media/base/audio_bus_unittest.cc index ea06f0a..3a3185a 100644 --- a/media/base/audio_bus_unittest.cc +++ b/media/base/audio_bus_unittest.cc @@ -2,6 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stdint.h> + +#include <limits> + #include "base/strings/stringprintf.h" #include "base/time/time.h" #include "build/build_config.h" @@ -247,15 +251,17 @@ TEST_F(AudioBusTest, Zero) { // Each test vector represents two channels of data in the following arbitrary // layout: <min, zero, max, min, max / 2, min / 2, zero, max, zero, zero>. static const int kTestVectorSize = 10; -static const uint8 kTestVectorUint8[kTestVectorSize] = { - 0, -kint8min, kuint8max, 0, kint8max / 2 + 128, kint8min / 2 + 128, - -kint8min, kuint8max, -kint8min, -kint8min }; -static const int16 kTestVectorInt16[kTestVectorSize] = { - kint16min, 0, kint16max, kint16min, kint16max / 2, kint16min / 2, - 0, kint16max, 0, 0 }; -static const int32 kTestVectorInt32[kTestVectorSize] = { - kint32min, 0, kint32max, kint32min, kint32max / 2, kint32min / 2, - 0, kint32max, 0, 0 }; +static const uint8_t kTestVectorUint8[kTestVectorSize] = { + 0, -INT8_MIN, UINT8_MAX, + 0, INT8_MAX / 2 + 128, INT8_MIN / 2 + 128, + -INT8_MIN, UINT8_MAX, -INT8_MIN, + -INT8_MIN}; +static const int16_t kTestVectorInt16[kTestVectorSize] = { + INT16_MIN, 0, INT16_MAX, INT16_MIN, INT16_MAX / 2, + INT16_MIN / 2, 0, INT16_MAX, 0, 0}; +static const int32_t kTestVectorInt32[kTestVectorSize] = { + INT32_MIN, 0, INT32_MAX, INT32_MIN, INT32_MAX / 2, + INT32_MIN / 2, 0, INT32_MAX, 0, 0}; // Expected results. static const int kTestVectorFrames = kTestVectorSize / 2; @@ -278,23 +284,26 @@ TEST_F(AudioBusTest, FromInterleaved) { bus->Zero(); bus->FromInterleaved( kTestVectorUint8, kTestVectorFrames, sizeof(*kTestVectorUint8)); - // Biased uint8 calculations have poor precision, so the epsilon here is - // slightly more permissive than int16 and int32 calculations. - VerifyBusWithEpsilon(bus.get(), expected.get(), 1.0f / (kuint8max - 1)); + // Biased uint8_t calculations have poor precision, so the epsilon here is + // slightly more permissive than int16_t and int32_t calculations. + VerifyBusWithEpsilon(bus.get(), expected.get(), + 1.0f / (std::numeric_limits<uint8_t>::max() - 1)); } { SCOPED_TRACE("int16"); bus->Zero(); bus->FromInterleaved( kTestVectorInt16, kTestVectorFrames, sizeof(*kTestVectorInt16)); - VerifyBusWithEpsilon(bus.get(), expected.get(), 1.0f / (kuint16max + 1.0f)); + VerifyBusWithEpsilon(bus.get(), expected.get(), + 1.0f / (std::numeric_limits<uint16_t>::max() + 1.0f)); } { SCOPED_TRACE("int32"); bus->Zero(); bus->FromInterleaved( kTestVectorInt32, kTestVectorFrames, sizeof(*kTestVectorInt32)); - VerifyBusWithEpsilon(bus.get(), expected.get(), 1.0f / (kuint32max + 1.0f)); + VerifyBusWithEpsilon(bus.get(), expected.get(), + 1.0f / (std::numeric_limits<uint32_t>::max() + 1.0f)); } } @@ -334,28 +343,28 @@ TEST_F(AudioBusTest, ToInterleaved) { } { SCOPED_TRACE("uint8"); - uint8 test_array[arraysize(kTestVectorUint8)]; + uint8_t test_array[arraysize(kTestVectorUint8)]; bus->ToInterleaved(bus->frames(), sizeof(*kTestVectorUint8), test_array); ASSERT_EQ(memcmp( test_array, kTestVectorUint8, sizeof(kTestVectorUint8)), 0); } { SCOPED_TRACE("int16"); - int16 test_array[arraysize(kTestVectorInt16)]; + int16_t test_array[arraysize(kTestVectorInt16)]; bus->ToInterleaved(bus->frames(), sizeof(*kTestVectorInt16), test_array); ASSERT_EQ(memcmp( test_array, kTestVectorInt16, sizeof(kTestVectorInt16)), 0); } { SCOPED_TRACE("int32"); - int32 test_array[arraysize(kTestVectorInt32)]; + int32_t test_array[arraysize(kTestVectorInt32)]; bus->ToInterleaved(bus->frames(), sizeof(*kTestVectorInt32), test_array); // Some compilers get better precision than others on the half-max test, so // let the test pass with an off by one check on the half-max. - int32 fixed_test_array[arraysize(kTestVectorInt32)]; + int32_t fixed_test_array[arraysize(kTestVectorInt32)]; memcpy(fixed_test_array, kTestVectorInt32, sizeof(kTestVectorInt32)); - ASSERT_EQ(fixed_test_array[4], kint32max / 2); + ASSERT_EQ(fixed_test_array[4], std::numeric_limits<int32_t>::max() / 2); fixed_test_array[4]++; ASSERT_TRUE( @@ -378,7 +387,7 @@ TEST_F(AudioBusTest, ToInterleavedPartial) { kTestVectorFrames * sizeof(*expected->channel(ch))); } - int16 test_array[arraysize(kTestVectorInt16)]; + int16_t test_array[arraysize(kTestVectorInt16)]; expected->ToInterleavedPartial( kPartialStart, kPartialFrames, sizeof(*kTestVectorInt16), test_array); ASSERT_EQ(memcmp( |