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

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

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "media/base/audio_buffer.h" 9 #include "media/base/audio_buffer.h"
10 #include "media/base/audio_bus.h" 10 #include "media/base/audio_bus.h"
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 static void ReadFramesInterleavedS32Test(SampleFormat sample_format) { 472 static void ReadFramesInterleavedS32Test(SampleFormat sample_format) {
473 const ChannelLayout channel_layout = CHANNEL_LAYOUT_4_0; 473 const ChannelLayout channel_layout = CHANNEL_LAYOUT_4_0;
474 const int channels = ChannelLayoutToChannelCount(channel_layout); 474 const int channels = ChannelLayoutToChannelCount(channel_layout);
475 const int frames = kSampleRate / 100; 475 const int frames = kSampleRate / 100;
476 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(10); 476 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(10);
477 scoped_refptr<AudioBuffer> buffer = MakeReadFramesInterleavedTestBuffer( 477 scoped_refptr<AudioBuffer> buffer = MakeReadFramesInterleavedTestBuffer(
478 sample_format, kSampleRate, channel_layout, channels, frames); 478 sample_format, kSampleRate, channel_layout, channels, frames);
479 EXPECT_EQ(frames, buffer->frame_count()); 479 EXPECT_EQ(frames, buffer->frame_count());
480 EXPECT_EQ(duration, buffer->duration()); 480 EXPECT_EQ(duration, buffer->duration());
481 481
482 int32* dest = new int32[frames * channels]; 482 int32_t* dest = new int32_t[frames * channels];
483 buffer->ReadFramesInterleavedS32(frames, dest); 483 buffer->ReadFramesInterleavedS32(frames, dest);
484 484
485 int count = 0; 485 int count = 0;
486 for (int i = 0; i < frames; ++i) { 486 for (int i = 0; i < frames; ++i) {
487 for (int ch = 0; ch < channels; ++ch) { 487 for (int ch = 0; ch < channels; ++ch) {
488 EXPECT_EQ(dest[count++], (frames * ch + i) << 16); 488 EXPECT_EQ(dest[count++], (frames * ch + i) << 16);
489 } 489 }
490 } 490 }
491 delete[] dest; 491 delete[] dest;
492 } 492 }
(...skipping 21 matching lines...) Expand all
514 static void ReadFramesInterleavedS16Test(SampleFormat sample_format) { 514 static void ReadFramesInterleavedS16Test(SampleFormat sample_format) {
515 const ChannelLayout channel_layout = CHANNEL_LAYOUT_4_0; 515 const ChannelLayout channel_layout = CHANNEL_LAYOUT_4_0;
516 const int channels = ChannelLayoutToChannelCount(channel_layout); 516 const int channels = ChannelLayoutToChannelCount(channel_layout);
517 const int frames = kSampleRate / 100; 517 const int frames = kSampleRate / 100;
518 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(10); 518 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(10);
519 scoped_refptr<AudioBuffer> buffer = MakeReadFramesInterleavedTestBuffer( 519 scoped_refptr<AudioBuffer> buffer = MakeReadFramesInterleavedTestBuffer(
520 sample_format, kSampleRate, channel_layout, channels, frames); 520 sample_format, kSampleRate, channel_layout, channels, frames);
521 EXPECT_EQ(frames, buffer->frame_count()); 521 EXPECT_EQ(frames, buffer->frame_count());
522 EXPECT_EQ(duration, buffer->duration()); 522 EXPECT_EQ(duration, buffer->duration());
523 523
524 int16* dest = new int16[frames * channels]; 524 int16_t* dest = new int16_t[frames * channels];
525 buffer->ReadFramesInterleavedS16(frames, dest); 525 buffer->ReadFramesInterleavedS16(frames, dest);
526 526
527 int count = 0; 527 int count = 0;
528 for (int i = 0; i < frames; ++i) { 528 for (int i = 0; i < frames; ++i) {
529 for (int ch = 0; ch < channels; ++ch) { 529 for (int ch = 0; ch < channels; ++ch) {
530 EXPECT_EQ(dest[count++], (frames * ch + i)); 530 EXPECT_EQ(dest[count++], (frames * ch + i));
531 } 531 }
532 } 532 }
533 delete[] dest; 533 delete[] dest;
534 } 534 }
(...skipping 12 matching lines...) Expand all
547 547
548 TEST(AudioBufferTest, ReadFramesInterleavedS16FromPlanarS16) { 548 TEST(AudioBufferTest, ReadFramesInterleavedS16FromPlanarS16) {
549 ReadFramesInterleavedS16Test(kSampleFormatPlanarS16); 549 ReadFramesInterleavedS16Test(kSampleFormatPlanarS16);
550 } 550 }
551 551
552 TEST(AudioBufferTest, ReadFramesInterleavedS16FromPlanarF32) { 552 TEST(AudioBufferTest, ReadFramesInterleavedS16FromPlanarF32) {
553 ReadFramesInterleavedS16Test(kSampleFormatPlanarF32); 553 ReadFramesInterleavedS16Test(kSampleFormatPlanarF32);
554 } 554 }
555 555
556 } // namespace media 556 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698