| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/base/buffers.h" | 5 #include "media/base/buffers.h" |
| 6 #include "media/base/mock_filters.h" | 6 #include "media/base/mock_filters.h" |
| 7 #include "media/base/video_frame_impl.h" | 7 #include "media/base/video_frame_impl.h" |
| 8 #include "media/base/yuv_convert.h" | 8 #include "media/base/yuv_convert.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 InitializeYV12Frame(frame, 0.0f); | 123 InitializeYV12Frame(frame, 0.0f); |
| 124 ExpectFrameColor(frame, 0xFF000000); | 124 ExpectFrameColor(frame, 0xFF000000); |
| 125 InitializeYV12Frame(frame, 1.0f); | 125 InitializeYV12Frame(frame, 1.0f); |
| 126 ExpectFrameColor(frame, 0xFFFFFFFF); | 126 ExpectFrameColor(frame, 0xFFFFFFFF); |
| 127 | 127 |
| 128 // Test an empty frame. | 128 // Test an empty frame. |
| 129 VideoFrameImpl::CreateEmptyFrame(&frame); | 129 VideoFrameImpl::CreateEmptyFrame(&frame); |
| 130 EXPECT_TRUE(frame->IsEndOfStream()); | 130 EXPECT_TRUE(frame->IsEndOfStream()); |
| 131 } | 131 } |
| 132 | 132 |
| 133 TEST(VideoFrameImpl, CreateBlackFrame) { |
| 134 const size_t kWidth = 2; |
| 135 const size_t kHeight = 2; |
| 136 const uint8 kExpectedYRow[] = { 0, 0 }; |
| 137 const uint8 kExpectedUVRow[] = { 128 }; |
| 138 |
| 139 scoped_refptr<media::VideoFrame> frame; |
| 140 VideoFrameImpl::CreateBlackFrame(kWidth, kHeight, &frame); |
| 141 ASSERT_TRUE(frame); |
| 142 |
| 143 // Test basic properties. |
| 144 EXPECT_EQ(0, frame->GetTimestamp().InMicroseconds()); |
| 145 EXPECT_EQ(0, frame->GetDuration().InMicroseconds()); |
| 146 EXPECT_FALSE(frame->IsEndOfStream()); |
| 147 |
| 148 // Test surface properties. |
| 149 VideoSurface surface; |
| 150 EXPECT_TRUE(frame->Lock(&surface)); |
| 151 EXPECT_EQ(VideoSurface::YV12, surface.format); |
| 152 EXPECT_EQ(kWidth, surface.width); |
| 153 EXPECT_EQ(kHeight, surface.height); |
| 154 EXPECT_EQ(3u, surface.planes); |
| 155 |
| 156 // Test surfaces themselves. |
| 157 for (size_t y = 0; y < surface.height; ++y) { |
| 158 EXPECT_EQ(0, memcmp(kExpectedYRow, surface.data[VideoSurface::kYPlane], |
| 159 arraysize(kExpectedYRow))); |
| 160 surface.data[VideoSurface::kYPlane] += |
| 161 surface.strides[VideoSurface::kYPlane]; |
| 162 } |
| 163 for (size_t y = 0; y < surface.height / 2; ++y) { |
| 164 EXPECT_EQ(0, memcmp(kExpectedUVRow, surface.data[VideoSurface::kUPlane], |
| 165 arraysize(kExpectedUVRow))); |
| 166 EXPECT_EQ(0, memcmp(kExpectedUVRow, surface.data[VideoSurface::kVPlane], |
| 167 arraysize(kExpectedUVRow))); |
| 168 surface.data[VideoSurface::kUPlane] += |
| 169 surface.strides[VideoSurface::kUPlane]; |
| 170 surface.data[VideoSurface::kVPlane] += |
| 171 surface.strides[VideoSurface::kVPlane]; |
| 172 } |
| 173 } |
| 174 |
| 133 } // namespace media | 175 } // namespace media |
| OLD | NEW |