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 1789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1800 std::unique_ptr<const cricket::VideoFrame> target; | 1800 std::unique_ptr<const cricket::VideoFrame> target; |
1801 ASSERT_TRUE(LoadFrameNoRepeat(source.get())); | 1801 ASSERT_TRUE(LoadFrameNoRepeat(source.get())); |
1802 target.reset(source->Copy()); | 1802 target.reset(source->Copy()); |
1803 EXPECT_TRUE(IsEqual(*source, *target, 0)); | 1803 EXPECT_TRUE(IsEqual(*source, *target, 0)); |
1804 const T* const_source = source.get(); | 1804 const T* const_source = source.get(); |
1805 EXPECT_EQ(const_source->GetYPlane(), target->GetYPlane()); | 1805 EXPECT_EQ(const_source->GetYPlane(), target->GetYPlane()); |
1806 EXPECT_EQ(const_source->GetUPlane(), target->GetUPlane()); | 1806 EXPECT_EQ(const_source->GetUPlane(), target->GetUPlane()); |
1807 EXPECT_EQ(const_source->GetVPlane(), target->GetVPlane()); | 1807 EXPECT_EQ(const_source->GetVPlane(), target->GetVPlane()); |
1808 } | 1808 } |
1809 | 1809 |
1810 void MakeExclusive() { | |
1811 std::unique_ptr<T> source(new T); | |
1812 std::unique_ptr<cricket::VideoFrame> target; | |
1813 ASSERT_TRUE(LoadFrameNoRepeat(source.get())); | |
1814 target.reset(source->Copy()); | |
1815 EXPECT_TRUE(target->MakeExclusive()); | |
1816 EXPECT_TRUE(IsEqual(*source, *target, 0)); | |
1817 EXPECT_NE(target->GetYPlane(), source->GetYPlane()); | |
1818 EXPECT_NE(target->GetUPlane(), source->GetUPlane()); | |
1819 EXPECT_NE(target->GetVPlane(), source->GetVPlane()); | |
1820 } | |
1821 | |
1822 void CopyToFrame() { | |
1823 T source; | |
1824 std::unique_ptr<rtc::MemoryStream> ms( | |
1825 LoadSample(kImageFilename)); | |
1826 ASSERT_TRUE(ms.get() != NULL); | |
1827 ASSERT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_I420, kWidth, kHeight, | |
1828 &source)); | |
1829 | |
1830 // Create the target frame by loading from a file. | |
1831 T target; | |
1832 ASSERT_TRUE(LoadFrameNoRepeat(&target)); | |
1833 EXPECT_FALSE(IsBlack(target)); | |
1834 | |
1835 // Stretch and check if the stretched target is black. | |
1836 source.CopyToFrame(&target); | |
1837 | |
1838 EXPECT_TRUE(IsEqual(source, target, 0)); | |
1839 } | |
1840 | |
1841 void StretchToFrame() { | 1810 void StretchToFrame() { |
1842 // Create the source frame as a black frame. | 1811 // Create the source frame as a black frame. |
1843 T source; | 1812 T source; |
1844 EXPECT_TRUE(source.InitToBlack(kWidth * 2, kHeight * 2, 0)); | 1813 EXPECT_TRUE(source.InitToBlack(kWidth * 2, kHeight * 2, 0)); |
1845 EXPECT_TRUE(IsSize(source, kWidth * 2, kHeight * 2)); | 1814 EXPECT_TRUE(IsSize(source, kWidth * 2, kHeight * 2)); |
1846 | 1815 |
1847 // Create the target frame by loading from a file. | 1816 // Create the target frame by loading from a file. |
1848 T target1; | 1817 T target1; |
1849 ASSERT_TRUE(LoadFrameNoRepeat(&target1)); | 1818 ASSERT_TRUE(LoadFrameNoRepeat(&target1)); |
1850 EXPECT_FALSE(IsBlack(target1)); | 1819 EXPECT_FALSE(IsBlack(target1)); |
1851 | 1820 |
1852 // Stretch and check if the stretched target is black. | 1821 // Stretch and check if the stretched target is black. |
1853 source.StretchToFrame(&target1, true, false); | 1822 source.StretchToFrame(&target1, true, false); |
1854 EXPECT_TRUE(IsBlack(target1)); | 1823 EXPECT_TRUE(IsBlack(target1)); |
1855 | 1824 |
1856 // Crop and stretch and check if the stretched target is black. | 1825 // Crop and stretch and check if the stretched target is black. |
1857 T target2; | 1826 T target2; |
1858 ASSERT_TRUE(LoadFrameNoRepeat(&target2)); | 1827 ASSERT_TRUE(LoadFrameNoRepeat(&target2)); |
1859 source.StretchToFrame(&target2, true, true); | 1828 source.StretchToFrame(&target2, true, true); |
1860 EXPECT_TRUE(IsBlack(target2)); | 1829 EXPECT_TRUE(IsBlack(target2)); |
1861 EXPECT_EQ(source.GetTimeStamp(), target2.GetTimeStamp()); | 1830 EXPECT_EQ(source.GetTimeStamp(), target2.GetTimeStamp()); |
1862 } | 1831 } |
1863 | 1832 |
1864 int repeat_; | 1833 int repeat_; |
1865 }; | 1834 }; |
1866 | 1835 |
1867 #endif // WEBRTC_MEDIA_BASE_VIDEOFRAME_UNITTEST_H_ | 1836 #endif // WEBRTC_MEDIA_BASE_VIDEOFRAME_UNITTEST_H_ |
OLD | NEW |