Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: media/base/audio_bus.cc

Issue 1475783002: Remove kint8min, kint8max, and kint16min. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/basictypes.h ('k') | media/base/audio_bus_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/audio_bus.h" 5 #include "media/base/audio_bus.h"
6 6
7 #include <stdint.h>
8
9 #include <limits>
10
7 #include "base/logging.h" 11 #include "base/logging.h"
8 #include "base/numerics/safe_conversions.h" 12 #include "base/numerics/safe_conversions.h"
9 #include "media/audio/audio_parameters.h" 13 #include "media/audio/audio_parameters.h"
10 #include "media/base/limits.h" 14 #include "media/base/limits.h"
11 #include "media/base/vector_math.h" 15 #include "media/base/vector_math.h"
12 16
13 namespace media { 17 namespace media {
14 18
15 static const uint8 kUint8Bias = 128; 19 static const uint8_t kUint8Bias = 128;
16 20
17 static bool IsAligned(void* ptr) { 21 static bool IsAligned(void* ptr) {
18 return (reinterpret_cast<uintptr_t>(ptr) & 22 return (reinterpret_cast<uintptr_t>(ptr) &
19 (AudioBus::kChannelAlignment - 1)) == 0U; 23 (AudioBus::kChannelAlignment - 1)) == 0U;
20 } 24 }
21 25
22 // Calculates the required size for an AudioBus with the given params, sets 26 // Calculates the required size for an AudioBus with the given params, sets
23 // |aligned_frames| to the actual frame length of each channel array. 27 // |aligned_frames| to the actual frame length of each channel array.
24 static int CalculateMemorySizeInternal(int channels, int frames, 28 static int CalculateMemorySizeInternal(int channels, int frames,
25 int* out_aligned_frames) { 29 int* out_aligned_frames) {
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 for (int i = 0; i < channels; ++i) 249 for (int i = 0; i < channels; ++i)
246 channel_data_.push_back(data + i * aligned_frames); 250 channel_data_.push_back(data + i * aligned_frames);
247 } 251 }
248 252
249 // TODO(dalecurtis): See if intrinsic optimizations help any here. 253 // TODO(dalecurtis): See if intrinsic optimizations help any here.
250 void AudioBus::FromInterleavedPartial(const void* source, int start_frame, 254 void AudioBus::FromInterleavedPartial(const void* source, int start_frame,
251 int frames, int bytes_per_sample) { 255 int frames, int bytes_per_sample) {
252 CheckOverflow(start_frame, frames, frames_); 256 CheckOverflow(start_frame, frames, frames_);
253 switch (bytes_per_sample) { 257 switch (bytes_per_sample) {
254 case 1: 258 case 1:
255 FromInterleavedInternal<uint8, int16, kUint8Bias>( 259 FromInterleavedInternal<uint8_t, int16_t, kUint8Bias>(
256 source, start_frame, frames, this, 260 source, start_frame, frames, this,
257 1.0f / kint8min, 1.0f / kint8max); 261 1.0f / std::numeric_limits<int8_t>::min(),
262 1.0f / std::numeric_limits<int8_t>::max());
258 break; 263 break;
259 case 2: 264 case 2:
260 FromInterleavedInternal<int16, int16, 0>( 265 FromInterleavedInternal<int16_t, int16_t, 0>(
261 source, start_frame, frames, this, 266 source, start_frame, frames, this,
262 1.0f / kint16min, 1.0f / kint16max); 267 1.0f / std::numeric_limits<int16_t>::min(),
268 1.0f / std::numeric_limits<int16_t>::max());
263 break; 269 break;
264 case 4: 270 case 4:
265 FromInterleavedInternal<int32, int32, 0>( 271 FromInterleavedInternal<int32_t, int32_t, 0>(
266 source, start_frame, frames, this, 272 source, start_frame, frames, this,
267 1.0f / kint32min, 1.0f / kint32max); 273 1.0f / std::numeric_limits<int32_t>::min(),
274 1.0f / std::numeric_limits<int32_t>::max());
268 break; 275 break;
269 default: 276 default:
270 NOTREACHED() << "Unsupported bytes per sample encountered."; 277 NOTREACHED() << "Unsupported bytes per sample encountered.";
271 ZeroFramesPartial(start_frame, frames); 278 ZeroFramesPartial(start_frame, frames);
272 return; 279 return;
273 } 280 }
274 281
275 // Don't clear remaining frames if this is a partial deinterleave. 282 // Don't clear remaining frames if this is a partial deinterleave.
276 if (!start_frame) { 283 if (!start_frame) {
277 // Zero any remaining frames. 284 // Zero any remaining frames.
(...skipping 10 matching lines...) Expand all
288 void* dest) const { 295 void* dest) const {
289 ToInterleavedPartial(0, frames, bytes_per_sample, dest); 296 ToInterleavedPartial(0, frames, bytes_per_sample, dest);
290 } 297 }
291 298
292 // TODO(dalecurtis): See if intrinsic optimizations help any here. 299 // TODO(dalecurtis): See if intrinsic optimizations help any here.
293 void AudioBus::ToInterleavedPartial(int start_frame, int frames, 300 void AudioBus::ToInterleavedPartial(int start_frame, int frames,
294 int bytes_per_sample, void* dest) const { 301 int bytes_per_sample, void* dest) const {
295 CheckOverflow(start_frame, frames, frames_); 302 CheckOverflow(start_frame, frames, frames_);
296 switch (bytes_per_sample) { 303 switch (bytes_per_sample) {
297 case 1: 304 case 1:
298 ToInterleavedInternal<uint8, int16, kUint8Bias>( 305 ToInterleavedInternal<uint8_t, int16_t, kUint8Bias>(
299 this, start_frame, frames, dest, kint8min, kint8max); 306 this, start_frame, frames, dest, std::numeric_limits<int8_t>::min(),
307 std::numeric_limits<int8_t>::max());
300 break; 308 break;
301 case 2: 309 case 2:
302 ToInterleavedInternal<int16, int16, 0>( 310 ToInterleavedInternal<int16_t, int16_t, 0>(
303 this, start_frame, frames, dest, kint16min, kint16max); 311 this, start_frame, frames, dest, std::numeric_limits<int16_t>::min(),
312 std::numeric_limits<int16_t>::max());
304 break; 313 break;
305 case 4: 314 case 4:
306 ToInterleavedInternal<int32, int32, 0>( 315 ToInterleavedInternal<int32_t, int32_t, 0>(
307 this, start_frame, frames, dest, kint32min, kint32max); 316 this, start_frame, frames, dest, std::numeric_limits<int32_t>::min(),
317 std::numeric_limits<int32_t>::max());
308 break; 318 break;
309 default: 319 default:
310 NOTREACHED() << "Unsupported bytes per sample encountered."; 320 NOTREACHED() << "Unsupported bytes per sample encountered.";
311 memset(dest, 0, frames * bytes_per_sample); 321 memset(dest, 0, frames * bytes_per_sample);
312 return; 322 return;
313 } 323 }
314 } 324 }
315 325
316 void AudioBus::CopyTo(AudioBus* dest) const { 326 void AudioBus::CopyTo(AudioBus* dest) const {
317 CopyPartialFramesTo(0, frames(), 0, dest); 327 CopyPartialFramesTo(0, frames(), 0, dest);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 return scoped_refptr<AudioBusRefCounted>( 365 return scoped_refptr<AudioBusRefCounted>(
356 new AudioBusRefCounted(channels, frames)); 366 new AudioBusRefCounted(channels, frames));
357 } 367 }
358 368
359 AudioBusRefCounted::AudioBusRefCounted(int channels, int frames) 369 AudioBusRefCounted::AudioBusRefCounted(int channels, int frames)
360 : AudioBus(channels, frames) {} 370 : AudioBus(channels, frames) {}
361 371
362 AudioBusRefCounted::~AudioBusRefCounted() {} 372 AudioBusRefCounted::~AudioBusRefCounted() {}
363 373
364 } // namespace media 374 } // namespace media
OLDNEW
« no previous file with comments | « base/basictypes.h ('k') | media/base/audio_bus_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698