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

Side by Side Diff: media/formats/mp2t/timestamp_unroller_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 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> 5 #include <stdint.h>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/test/perf_test_suite.h" 9 #include "base/test/perf_test_suite.h"
10 #include "media/formats/mp2t/timestamp_unroller.h" 10 #include "media/formats/mp2t/timestamp_unroller.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace media { 13 namespace media {
14 namespace mp2t { 14 namespace mp2t {
15 15
16 static std::vector<int64> TruncateTimestamps( 16 static std::vector<int64_t> TruncateTimestamps(
17 const std::vector<int64>& timestamps) { 17 const std::vector<int64_t>& timestamps) {
18 const int nbits = 33; 18 const int nbits = 33;
19 int64 truncate_mask = (INT64_C(1) << nbits) - 1; 19 int64_t truncate_mask = (INT64_C(1) << nbits) - 1;
20 std::vector<int64> truncated_timestamps(timestamps.size()); 20 std::vector<int64_t> truncated_timestamps(timestamps.size());
21 for (size_t k = 0; k < timestamps.size(); k++) 21 for (size_t k = 0; k < timestamps.size(); k++)
22 truncated_timestamps[k] = timestamps[k] & truncate_mask; 22 truncated_timestamps[k] = timestamps[k] & truncate_mask;
23 return truncated_timestamps; 23 return truncated_timestamps;
24 } 24 }
25 25
26 static void RunUnrollTest(const std::vector<int64>& timestamps) { 26 static void RunUnrollTest(const std::vector<int64_t>& timestamps) {
27 std::vector<int64> truncated_timestamps = TruncateTimestamps(timestamps); 27 std::vector<int64_t> truncated_timestamps = TruncateTimestamps(timestamps);
28 28
29 TimestampUnroller timestamp_unroller; 29 TimestampUnroller timestamp_unroller;
30 for (size_t k = 0; k < timestamps.size(); k++) { 30 for (size_t k = 0; k < timestamps.size(); k++) {
31 int64 unrolled_timestamp = 31 int64_t unrolled_timestamp =
32 timestamp_unroller.GetUnrolledTimestamp(truncated_timestamps[k]); 32 timestamp_unroller.GetUnrolledTimestamp(truncated_timestamps[k]);
33 EXPECT_EQ(timestamps[k], unrolled_timestamp); 33 EXPECT_EQ(timestamps[k], unrolled_timestamp);
34 } 34 }
35 } 35 }
36 36
37 TEST(TimestampUnrollerTest, SingleStream) { 37 TEST(TimestampUnrollerTest, SingleStream) {
38 // Array of 64 bit timestamps. 38 // Array of 64 bit timestamps.
39 // This is the expected result from unrolling these timestamps 39 // This is the expected result from unrolling these timestamps
40 // truncated to 33 bits. 40 // truncated to 33 bits.
41 int64 timestamps[] = { 41 int64_t timestamps[] = {
42 INT64_C(0x0000000000000000), 42 INT64_C(0x0000000000000000),
43 INT64_C(-190), // - 190 43 INT64_C(-190), // - 190
44 INT64_C(0x00000000aaaaa9ed), // + 0xaaaaaaab 44 INT64_C(0x00000000aaaaa9ed), // + 0xaaaaaaab
45 INT64_C(0x0000000155555498), // + 0xaaaaaaab 45 INT64_C(0x0000000155555498), // + 0xaaaaaaab
46 INT64_C(0x00000001ffffff43), // + 0xaaaaaaab 46 INT64_C(0x00000001ffffff43), // + 0xaaaaaaab
47 INT64_C(0x00000002aaaaa9ee), // + 0xaaaaaaab 47 INT64_C(0x00000002aaaaa9ee), // + 0xaaaaaaab
48 INT64_C(0x0000000355555499), // + 0xaaaaaaab 48 INT64_C(0x0000000355555499), // + 0xaaaaaaab
49 INT64_C(0x00000003ffffff44), // + 0xaaaaaaab 49 INT64_C(0x00000003ffffff44), // + 0xaaaaaaab
50 }; 50 };
51 51
52 std::vector<int64> timestamps_vector( 52 std::vector<int64_t> timestamps_vector(timestamps,
53 timestamps, timestamps + arraysize(timestamps)); 53 timestamps + arraysize(timestamps));
54 RunUnrollTest(timestamps_vector); 54 RunUnrollTest(timestamps_vector);
55 } 55 }
56 56
57 } // namespace mp2t 57 } // namespace mp2t
58 } // namespace media 58 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698