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

Side by Side Diff: media/cast/test/utility/generate_timecode_audio.cc

Issue 1477533002: Remove kint16max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kint8max
Patch Set: includes 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 | « media/base/audio_buffer_unittest.cc ('k') | net/disk_cache/blockfile/addr.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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>
6
5 #include <algorithm> 7 #include <algorithm>
6 #include <cstdio> 8 #include <cstdio>
7 #include <cstdlib> 9 #include <cstdlib>
10 #include <limits>
8 #include <vector> 11 #include <vector>
9 12
10 #include "base/basictypes.h"
11 #include "base/logging.h" 13 #include "base/logging.h"
12 #include "media/cast/test/utility/audio_utility.h" 14 #include "media/cast/test/utility/audio_utility.h"
13 15
14 const size_t kSamplingFrequency = 48000; 16 const size_t kSamplingFrequency = 48000;
15 17
16 int main(int argc, char **argv) { 18 int main(int argc, char **argv) {
17 if (argc < 3) { 19 if (argc < 3) {
18 fprintf(stderr, "Usage: %s <fps> <frames> >output.s16le\n", argv[0]); 20 fprintf(stderr, "Usage: %s <fps> <frames> >output.s16le\n", argv[0]);
19 exit(1); 21 exit(1);
20 } 22 }
21 int fps = atoi(argv[1]); 23 int fps = atoi(argv[1]);
22 const uint32 frames = static_cast<uint32>(std::max(0, atoi(argv[2]))); 24 const uint32_t frames = static_cast<uint32_t>(std::max(0, atoi(argv[2])));
23 std::vector<float> samples(kSamplingFrequency / fps); 25 std::vector<float> samples(kSamplingFrequency / fps);
24 size_t num_samples = 0; 26 size_t num_samples = 0;
25 for (uint32 frame_id = 1; frame_id <= frames; frame_id++) { 27 for (uint32_t frame_id = 1; frame_id <= frames; frame_id++) {
26 CHECK(media::cast::EncodeTimestamp( 28 CHECK(media::cast::EncodeTimestamp(
27 frame_id, num_samples, samples.size(), &samples.front())); 29 frame_id, num_samples, samples.size(), &samples.front()));
28 num_samples += samples.size(); 30 num_samples += samples.size();
29 for (size_t i = 0; i < samples.size(); ++i) { 31 for (size_t i = 0; i < samples.size(); ++i) {
30 const int16 sample_s16 = static_cast<int16>(samples[i] * kint16max); 32 const int16_t sample_s16 = static_cast<int16_t>(
33 samples[i] * std::numeric_limits<int16_t>::max());
31 putchar(sample_s16 & 0xff); 34 putchar(sample_s16 & 0xff);
32 putchar(sample_s16 >> 8); 35 putchar(sample_s16 >> 8);
33 putchar(sample_s16 & 0xff); 36 putchar(sample_s16 & 0xff);
34 putchar(sample_s16 >> 8); 37 putchar(sample_s16 >> 8);
35 } 38 }
36 } 39 }
37 } 40 }
OLDNEW
« no previous file with comments | « media/base/audio_buffer_unittest.cc ('k') | net/disk_cache/blockfile/addr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698