| 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 <cstring> | 5 #include <cstring> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/memory_mapped_file.h" | 8 #include "base/files/memory_mapped_file.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 EXPECT_EQ(time_delta.InMicroseconds(), test_data[i][3]); | 155 EXPECT_EQ(time_delta.InMicroseconds(), test_data[i][3]); |
| 156 EXPECT_EQ(ConvertToTimeBase(time_base, time_delta), test_data[i][4]); | 156 EXPECT_EQ(ConvertToTimeBase(time_base, time_delta), test_data[i][4]); |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 | 159 |
| 160 TEST_F(FFmpegCommonTest, VerifyFormatSizes) { | 160 TEST_F(FFmpegCommonTest, VerifyFormatSizes) { |
| 161 for (AVSampleFormat format = AV_SAMPLE_FMT_NONE; | 161 for (AVSampleFormat format = AV_SAMPLE_FMT_NONE; |
| 162 format < AV_SAMPLE_FMT_NB; | 162 format < AV_SAMPLE_FMT_NB; |
| 163 format = static_cast<AVSampleFormat>(format + 1)) { | 163 format = static_cast<AVSampleFormat>(format + 1)) { |
| 164 SampleFormat sample_format = AVSampleFormatToSampleFormat(format); | 164 std::vector<AVCodecID> codec_ids(1, AV_CODEC_ID_NONE); |
| 165 if (sample_format == kUnknownSampleFormat) { | 165 if (format == AV_SAMPLE_FMT_S32) |
| 166 // This format not supported, so skip it. | 166 codec_ids.push_back(AV_CODEC_ID_PCM_S24LE); |
| 167 continue; | 167 for (const auto& codec_id : codec_ids) { |
| 168 SampleFormat sample_format = |
| 169 AVSampleFormatToSampleFormat(format, codec_id); |
| 170 if (sample_format == kUnknownSampleFormat) { |
| 171 // This format not supported, so skip it. |
| 172 continue; |
| 173 } |
| 174 |
| 175 // Have FFMpeg compute the size of a buffer of 1 channel / 1 frame |
| 176 // with 1 byte alignment to make sure the sizes match. |
| 177 int single_buffer_size = |
| 178 av_samples_get_buffer_size(NULL, 1, 1, format, 1); |
| 179 int bytes_per_channel = SampleFormatToBytesPerChannel(sample_format); |
| 180 EXPECT_EQ(bytes_per_channel, single_buffer_size); |
| 168 } | 181 } |
| 169 | |
| 170 // Have FFMpeg compute the size of a buffer of 1 channel / 1 frame | |
| 171 // with 1 byte alignment to make sure the sizes match. | |
| 172 int single_buffer_size = av_samples_get_buffer_size(NULL, 1, 1, format, 1); | |
| 173 int bytes_per_channel = SampleFormatToBytesPerChannel(sample_format); | |
| 174 EXPECT_EQ(bytes_per_channel, single_buffer_size); | |
| 175 } | 182 } |
| 176 } | 183 } |
| 177 | 184 |
| 178 TEST_F(FFmpegCommonTest, UTCDateToTime_Valid) { | 185 TEST_F(FFmpegCommonTest, UTCDateToTime_Valid) { |
| 179 base::Time result; | 186 base::Time result; |
| 180 EXPECT_TRUE(FFmpegUTCDateToTime("2012-11-10 12:34:56", &result)); | 187 EXPECT_TRUE(FFmpegUTCDateToTime("2012-11-10 12:34:56", &result)); |
| 181 | 188 |
| 182 base::Time::Exploded exploded; | 189 base::Time::Exploded exploded; |
| 183 result.UTCExplode(&exploded); | 190 result.UTCExplode(&exploded); |
| 184 EXPECT_TRUE(exploded.HasValidValues()); | 191 EXPECT_TRUE(exploded.HasValidValues()); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 // values; diff should verify. | 262 // values; diff should verify. |
| 256 #if 0 | 263 #if 0 |
| 257 printf("<enum name=\"FFmpegCodecHashes\" type=\"int\">\n"); | 264 printf("<enum name=\"FFmpegCodecHashes\" type=\"int\">\n"); |
| 258 for (const auto& kv : sorted_hashes) | 265 for (const auto& kv : sorted_hashes) |
| 259 printf(" <int value=\"%d\" label=\"%s\"/>\n", kv.first, kv.second); | 266 printf(" <int value=\"%d\" label=\"%s\"/>\n", kv.first, kv.second); |
| 260 printf("</enum>\n"); | 267 printf("</enum>\n"); |
| 261 #endif | 268 #endif |
| 262 } | 269 } |
| 263 | 270 |
| 264 } // namespace media | 271 } // namespace media |
| OLD | NEW |