OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "media/formats/ac3/ac3_util.h" |
| 6 |
| 7 #include "base/files/file_util.h" |
| 8 #include "media/base/test_data_util.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 |
| 11 namespace media { |
| 12 |
| 13 namespace { |
| 14 |
| 15 struct Ac3StreamInfo { |
| 16 size_t size; |
| 17 int pcm_frame_count; |
| 18 }; |
| 19 |
| 20 } // namespace anonymous |
| 21 |
| 22 TEST(Ac3UtilTest, ParseTotalAc3SampleCount) { |
| 23 char buffer[8192]; |
| 24 const int buffer_size = sizeof(buffer); |
| 25 const Ac3StreamInfo ac3StreamInfo[] = { |
| 26 {834, 1 * 1536}, {1670, 2 * 1536}, {2506, 3 * 1536}, |
| 27 }; |
| 28 |
| 29 for (const Ac3StreamInfo& info : ac3StreamInfo) { |
| 30 memset(buffer, 0, buffer_size); |
| 31 int data_size = |
| 32 base::ReadFile(GetTestDataFilePath("bear.ac3"), buffer, info.size); |
| 33 |
| 34 EXPECT_EQ(info.pcm_frame_count, |
| 35 ::media::Ac3Util::ParseTotalAc3SampleCount( |
| 36 reinterpret_cast<const uint8_t*>(buffer), data_size)); |
| 37 } |
| 38 } |
| 39 |
| 40 TEST(Ac3UtilTest, ParseTotalEac3SampleCount) { |
| 41 char buffer[8192]; |
| 42 const int buffer_size = sizeof(buffer); |
| 43 const Ac3StreamInfo ac3StreamInfo[] = { |
| 44 {870, 1 * 1536}, {1742, 2 * 1536}, {2612, 3 * 1536}, |
| 45 }; |
| 46 |
| 47 for (const Ac3StreamInfo& info : ac3StreamInfo) { |
| 48 memset(buffer, 0, buffer_size); |
| 49 int data_size = |
| 50 base::ReadFile(GetTestDataFilePath("bear.eac3"), buffer, info.size); |
| 51 |
| 52 EXPECT_EQ(info.pcm_frame_count, |
| 53 ::media::Ac3Util::ParseTotalEac3SampleCount( |
| 54 reinterpret_cast<const uint8_t*>(buffer), data_size)); |
| 55 } |
| 56 } |
| 57 |
| 58 } // namespace media |
OLD | NEW |