OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1364 EXPECT_TRUE(ConvertRgb(ms.get(), cricket::FOURCC_ARGB, | 1364 EXPECT_TRUE(ConvertRgb(ms.get(), cricket::FOURCC_ARGB, |
1365 kOddWidth + i, kOddHeight + j, | 1365 kOddWidth + i, kOddHeight + j, |
1366 &frame1)); | 1366 &frame1)); |
1367 EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_ARGB, | 1367 EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_ARGB, |
1368 kOddWidth + i, kOddHeight + j, &frame2)); | 1368 kOddWidth + i, kOddHeight + j, &frame2)); |
1369 EXPECT_TRUE(IsEqual(frame1, frame2, 64)); | 1369 EXPECT_TRUE(IsEqual(frame1, frame2, 64)); |
1370 } | 1370 } |
1371 } | 1371 } |
1372 } | 1372 } |
1373 | 1373 |
1374 // Tests re-initing an existing image. | |
1375 void Reset(webrtc::VideoRotation rotation, bool apply_rotation) { | |
1376 T frame1, frame2; | |
1377 std::unique_ptr<rtc::MemoryStream> ms( | |
1378 LoadSample(kImageFilename)); | |
1379 ASSERT_TRUE(ms.get() != NULL); | |
1380 size_t data_size; | |
1381 ms->GetSize(&data_size); | |
1382 EXPECT_TRUE(frame1.InitToBlack(kWidth, kHeight, 0)); | |
1383 EXPECT_TRUE(frame2.InitToBlack(kWidth, kHeight, 0)); | |
1384 EXPECT_TRUE(IsBlack(frame1)); | |
1385 EXPECT_TRUE(IsEqual(frame1, frame2, 0)); | |
1386 EXPECT_TRUE(frame1.Reset(cricket::FOURCC_I420, kWidth, kHeight, kWidth, | |
1387 kHeight, | |
1388 reinterpret_cast<uint8_t*>(ms->GetBuffer()), | |
1389 data_size, 0, rotation, apply_rotation)); | |
1390 if (apply_rotation) | |
1391 EXPECT_EQ(webrtc::kVideoRotation_0, frame1.GetVideoRotation()); | |
1392 else | |
1393 EXPECT_EQ(rotation, frame1.GetVideoRotation()); | |
1394 | |
1395 // Swapp width and height if the frame is rotated 90 or 270 degrees. | |
1396 if (apply_rotation && (rotation == webrtc::kVideoRotation_90 | |
1397 || rotation == webrtc::kVideoRotation_270)) { | |
1398 EXPECT_TRUE(kHeight == frame1.width()); | |
1399 EXPECT_TRUE(kWidth == frame1.height()); | |
1400 } else { | |
1401 EXPECT_TRUE(kWidth == frame1.width()); | |
1402 EXPECT_TRUE(kHeight == frame1.height()); | |
1403 } | |
1404 EXPECT_FALSE(IsBlack(frame1)); | |
1405 EXPECT_FALSE(IsEqual(frame1, frame2, 0)); | |
1406 } | |
1407 | |
1408 void ResetAndApplyRotation() { | |
1409 Reset(webrtc::kVideoRotation_90, true); | |
1410 } | |
1411 | |
1412 void ResetAndDontApplyRotation() { | |
1413 Reset(webrtc::kVideoRotation_90, false); | |
1414 } | |
1415 | |
1416 ////////////////////// | 1374 ////////////////////// |
1417 // Conversion tests // | 1375 // Conversion tests // |
1418 ////////////////////// | 1376 ////////////////////// |
1419 | 1377 |
1420 enum ToFrom { TO, FROM }; | 1378 enum ToFrom { TO, FROM }; |
1421 | 1379 |
1422 // Helper function for test converting from I420 to packed formats. | 1380 // Helper function for test converting from I420 to packed formats. |
1423 inline void ConvertToBuffer(int bpp, | 1381 inline void ConvertToBuffer(int bpp, |
1424 int rowpad, | 1382 int rowpad, |
1425 bool invert, | 1383 bool invert, |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1826 ASSERT_TRUE(LoadFrameNoRepeat(&target2)); | 1784 ASSERT_TRUE(LoadFrameNoRepeat(&target2)); |
1827 source.StretchToFrame(&target2, true, true); | 1785 source.StretchToFrame(&target2, true, true); |
1828 EXPECT_TRUE(IsBlack(target2)); | 1786 EXPECT_TRUE(IsBlack(target2)); |
1829 EXPECT_EQ(source.GetTimeStamp(), target2.GetTimeStamp()); | 1787 EXPECT_EQ(source.GetTimeStamp(), target2.GetTimeStamp()); |
1830 } | 1788 } |
1831 | 1789 |
1832 int repeat_; | 1790 int repeat_; |
1833 }; | 1791 }; |
1834 | 1792 |
1835 #endif // WEBRTC_MEDIA_BASE_VIDEOFRAME_UNITTEST_H_ | 1793 #endif // WEBRTC_MEDIA_BASE_VIDEOFRAME_UNITTEST_H_ |
OLD | NEW |