OLD | NEW |
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 "media/formats/webm/webm_cluster_parser.h" | 5 #include "media/formats/webm/webm_cluster_parser.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 | 1059 |
1060 int block_count = arraysize(kBlockInfo); | 1060 int block_count = arraysize(kBlockInfo); |
1061 std::unique_ptr<Cluster> cluster(CreateCluster(0, kBlockInfo, block_count)); | 1061 std::unique_ptr<Cluster> cluster(CreateCluster(0, kBlockInfo, block_count)); |
1062 int result = parser_->Parse(cluster->data(), cluster->size()); | 1062 int result = parser_->Parse(cluster->data(), cluster->size()); |
1063 EXPECT_EQ(cluster->size(), result); | 1063 EXPECT_EQ(cluster->size(), result); |
1064 ASSERT_TRUE(VerifyBuffers(parser_, kBlockInfo, block_count)); | 1064 ASSERT_TRUE(VerifyBuffers(parser_, kBlockInfo, block_count)); |
1065 } | 1065 } |
1066 | 1066 |
1067 TEST_F(WebMClusterParserTest, ReadOpusDurationsSimpleBlockAtEndOfCluster) { | 1067 TEST_F(WebMClusterParserTest, ReadOpusDurationsSimpleBlockAtEndOfCluster) { |
1068 int loop_count = 0; | 1068 int loop_count = 0; |
1069 for (const auto* packet_ptr : BuildAllOpusPackets()) { | 1069 for (const auto& packet_ptr : BuildAllOpusPackets()) { |
1070 InSequence s; | 1070 InSequence s; |
1071 | 1071 |
1072 // Get a new parser each iteration to prevent exceeding the media log cap. | 1072 // Get a new parser each iteration to prevent exceeding the media log cap. |
1073 parser_.reset(CreateParserWithKeyIdsAndAudioCodec( | 1073 parser_.reset(CreateParserWithKeyIdsAndAudioCodec( |
1074 std::string(), std::string(), kCodecOpus)); | 1074 std::string(), std::string(), kCodecOpus)); |
1075 | 1075 |
1076 const BlockInfo kBlockInfo[] = {{kAudioTrackNum, | 1076 const BlockInfo kBlockInfo[] = {{kAudioTrackNum, |
1077 0, | 1077 0, |
1078 packet_ptr->duration_ms(), | 1078 packet_ptr->duration_ms(), |
1079 true, // Make it a SimpleBlock. | 1079 true, // Make it a SimpleBlock. |
(...skipping 16 matching lines...) Expand all Loading... |
1096 | 1096 |
1097 loop_count++; | 1097 loop_count++; |
1098 } | 1098 } |
1099 | 1099 |
1100 // Test should minimally cover all the combinations of config and frame count. | 1100 // Test should minimally cover all the combinations of config and frame count. |
1101 ASSERT_GE(loop_count, kNumPossibleOpusConfigs * kMaxOpusPacketFrameCount); | 1101 ASSERT_GE(loop_count, kNumPossibleOpusConfigs * kMaxOpusPacketFrameCount); |
1102 } | 1102 } |
1103 | 1103 |
1104 TEST_F(WebMClusterParserTest, PreferOpusDurationsOverBlockDurations) { | 1104 TEST_F(WebMClusterParserTest, PreferOpusDurationsOverBlockDurations) { |
1105 int loop_count = 0; | 1105 int loop_count = 0; |
1106 for (const auto* packet_ptr : BuildAllOpusPackets()) { | 1106 for (const auto& packet_ptr : BuildAllOpusPackets()) { |
1107 InSequence s; | 1107 InSequence s; |
1108 | 1108 |
1109 // Get a new parser each iteration to prevent exceeding the media log cap. | 1109 // Get a new parser each iteration to prevent exceeding the media log cap. |
1110 parser_.reset(CreateParserWithKeyIdsAndAudioCodec( | 1110 parser_.reset(CreateParserWithKeyIdsAndAudioCodec( |
1111 std::string(), std::string(), kCodecOpus)); | 1111 std::string(), std::string(), kCodecOpus)); |
1112 | 1112 |
1113 // Setting BlockDuration != Opus duration to see which one the parser uses. | 1113 // Setting BlockDuration != Opus duration to see which one the parser uses. |
1114 int block_duration_ms = packet_ptr->duration_ms() + 10; | 1114 int block_duration_ms = packet_ptr->duration_ms() + 10; |
1115 if (packet_ptr->duration_ms() > 120) { | 1115 if (packet_ptr->duration_ms() > 120) { |
1116 EXPECT_MEDIA_LOG(OpusPacketDurationTooHigh(packet_ptr->duration_ms())); | 1116 EXPECT_MEDIA_LOG(OpusPacketDurationTooHigh(packet_ptr->duration_ms())); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 int block_count = arraysize(kBlockInfo); | 1170 int block_count = arraysize(kBlockInfo); |
1171 std::unique_ptr<Cluster> cluster(CreateCluster(0, kBlockInfo, block_count)); | 1171 std::unique_ptr<Cluster> cluster(CreateCluster(0, kBlockInfo, block_count)); |
1172 int result = parser_->Parse(cluster->data(), cluster->size()); | 1172 int result = parser_->Parse(cluster->data(), cluster->size()); |
1173 EXPECT_EQ(cluster->size(), result); | 1173 EXPECT_EQ(cluster->size(), result); |
1174 | 1174 |
1175 // Will verify that duration of buffer matches that of BlockDuration. | 1175 // Will verify that duration of buffer matches that of BlockDuration. |
1176 ASSERT_TRUE(VerifyBuffers(parser_, kBlockInfo, block_count)); | 1176 ASSERT_TRUE(VerifyBuffers(parser_, kBlockInfo, block_count)); |
1177 } | 1177 } |
1178 | 1178 |
1179 } // namespace media | 1179 } // namespace media |
OLD | NEW |