| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } else { | 118 } else { |
| 119 // Only process audio/video. | 119 // Only process audio/video. |
| 120 continue; | 120 continue; |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 | 123 |
| 124 ASSERT_TRUE(found_audio); | 124 ASSERT_TRUE(found_audio); |
| 125 ASSERT_TRUE(found_video); | 125 ASSERT_TRUE(found_video); |
| 126 } | 126 } |
| 127 | 127 |
| 128 TEST_F(FFmpegCommonTest, AVStreamToAudioDecoderConfig_OpusAmbisonics_4ch) { |
| 129 base::MemoryMappedFile file; |
| 130 file.Initialize( |
| 131 GetTestDataFilePath("bear-opus-end-trimming-4ch-channelmapping2.webm")); |
| 132 InMemoryUrlProtocol protocol(file.data(), file.length(), false); |
| 133 FFmpegGlue glue(&protocol); |
| 134 ASSERT_TRUE(glue.OpenContext()); |
| 135 |
| 136 AVFormatContext* format_context = glue.format_context(); |
| 137 EXPECT_EQ(static_cast<unsigned int>(1), format_context->nb_streams); |
| 138 AVStream* stream = format_context->streams[0]; |
| 139 |
| 140 AVCodecParameters* codec_parameters = stream->codecpar; |
| 141 EXPECT_EQ(AVMEDIA_TYPE_AUDIO, codec_parameters->codec_type); |
| 142 |
| 143 AudioDecoderConfig audio_config; |
| 144 ASSERT_TRUE(AVStreamToAudioDecoderConfig(stream, &audio_config)); |
| 145 |
| 146 EXPECT_EQ(kCodecOpus, audio_config.codec()); |
| 147 EXPECT_EQ(CHANNEL_LAYOUT_QUAD, audio_config.channel_layout()); |
| 148 EXPECT_EQ(4, audio_config.channels()); |
| 149 } |
| 150 |
| 151 TEST_F(FFmpegCommonTest, AVStreamToAudioDecoderConfig_OpusAmbisonics_11ch) { |
| 152 base::MemoryMappedFile file; |
| 153 file.Initialize( |
| 154 GetTestDataFilePath("bear-opus-end-trimming-11ch-channelmapping2.webm")); |
| 155 InMemoryUrlProtocol protocol(file.data(), file.length(), false); |
| 156 FFmpegGlue glue(&protocol); |
| 157 ASSERT_TRUE(glue.OpenContext()); |
| 158 |
| 159 AVFormatContext* format_context = glue.format_context(); |
| 160 EXPECT_EQ(static_cast<unsigned int>(1), format_context->nb_streams); |
| 161 AVStream* stream = format_context->streams[0]; |
| 162 |
| 163 AVCodecParameters* codec_parameters = stream->codecpar; |
| 164 EXPECT_EQ(AVMEDIA_TYPE_AUDIO, codec_parameters->codec_type); |
| 165 |
| 166 AudioDecoderConfig audio_config; |
| 167 ASSERT_TRUE(AVStreamToAudioDecoderConfig(stream, &audio_config)); |
| 168 |
| 169 EXPECT_EQ(kCodecOpus, audio_config.codec()); |
| 170 EXPECT_EQ(CHANNEL_LAYOUT_DISCRETE, audio_config.channel_layout()); |
| 171 EXPECT_EQ(11, audio_config.channels()); |
| 172 } |
| 173 |
| 128 TEST_F(FFmpegCommonTest, TimeBaseConversions) { | 174 TEST_F(FFmpegCommonTest, TimeBaseConversions) { |
| 129 const int64_t test_data[][5] = { | 175 const int64_t test_data[][5] = { |
| 130 {1, 2, 1, 500000, 1}, {1, 3, 1, 333333, 1}, {1, 3, 2, 666667, 2}, | 176 {1, 2, 1, 500000, 1}, {1, 3, 1, 333333, 1}, {1, 3, 2, 666667, 2}, |
| 131 }; | 177 }; |
| 132 | 178 |
| 133 for (size_t i = 0; i < arraysize(test_data); ++i) { | 179 for (size_t i = 0; i < arraysize(test_data); ++i) { |
| 134 SCOPED_TRACE(i); | 180 SCOPED_TRACE(i); |
| 135 | 181 |
| 136 AVRational time_base; | 182 AVRational time_base; |
| 137 time_base.num = static_cast<int>(test_data[i][0]); | 183 time_base.num = static_cast<int>(test_data[i][0]); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 // values; diff should verify. | 243 // values; diff should verify. |
| 198 #if 0 | 244 #if 0 |
| 199 printf("<enum name=\"FFmpegCodecHashes\" type=\"int\">\n"); | 245 printf("<enum name=\"FFmpegCodecHashes\" type=\"int\">\n"); |
| 200 for (const auto& kv : sorted_hashes) | 246 for (const auto& kv : sorted_hashes) |
| 201 printf(" <int value=\"%d\" label=\"%s\"/>\n", kv.first, kv.second); | 247 printf(" <int value=\"%d\" label=\"%s\"/>\n", kv.first, kv.second); |
| 202 printf("</enum>\n"); | 248 printf("</enum>\n"); |
| 203 #endif | 249 #endif |
| 204 } | 250 } |
| 205 | 251 |
| 206 } // namespace media | 252 } // namespace media |
| OLD | NEW |