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/video_frame_impl.h" |
| 6 |
| 7 #include "base/format_macros.h" |
5 #include "base/string_util.h" | 8 #include "base/string_util.h" |
6 #include "media/base/buffers.h" | 9 #include "media/base/buffers.h" |
7 #include "media/base/mock_filters.h" | 10 #include "media/base/mock_filters.h" |
8 #include "media/base/video_frame_impl.h" | |
9 #include "media/base/yuv_convert.h" | 11 #include "media/base/yuv_convert.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
11 | 13 |
12 namespace media { | 14 namespace media { |
13 | 15 |
14 // Helper function that initializes a YV12 frame with white and black scan | 16 // Helper function that initializes a YV12 frame with white and black scan |
15 // lines based on the |white_to_black| parameter. If 0, then the entire | 17 // lines based on the |white_to_black| parameter. If 0, then the entire |
16 // frame will be black, if 1 then the entire frame will be white. | 18 // frame will be black, if 1 then the entire frame will be white. |
17 void InitializeYV12Frame(VideoFrame* frame, double white_to_black) { | 19 void InitializeYV12Frame(VideoFrame* frame, double white_to_black) { |
18 VideoSurface surface; | 20 VideoSurface surface; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 yuv_surface.strides[VideoSurface::kYPlane], | 79 yuv_surface.strides[VideoSurface::kYPlane], |
78 yuv_surface.strides[VideoSurface::kUPlane], | 80 yuv_surface.strides[VideoSurface::kUPlane], |
79 rgb_surface.strides[VideoSurface::kRGBPlane], | 81 rgb_surface.strides[VideoSurface::kRGBPlane], |
80 media::YV12); | 82 media::YV12); |
81 | 83 |
82 for (size_t row = 0; row < rgb_surface.height; ++row) { | 84 for (size_t row = 0; row < rgb_surface.height; ++row) { |
83 uint32* rgb_row_data = reinterpret_cast<uint32*>( | 85 uint32* rgb_row_data = reinterpret_cast<uint32*>( |
84 rgb_surface.data[VideoSurface::kRGBPlane] + | 86 rgb_surface.data[VideoSurface::kRGBPlane] + |
85 (rgb_surface.strides[VideoSurface::kRGBPlane] * row)); | 87 (rgb_surface.strides[VideoSurface::kRGBPlane] * row)); |
86 for (size_t col = 0; col < rgb_surface.width; ++col) { | 88 for (size_t col = 0; col < rgb_surface.width; ++col) { |
87 SCOPED_TRACE(StringPrintf("Checking (%u, %u)", row, col)); | 89 SCOPED_TRACE(StringPrintf("Checking (%" PRIuS ", %" PRIuS ")", row, col)); |
88 EXPECT_EQ(expect_rgb_color, rgb_row_data[col]); | 90 EXPECT_EQ(expect_rgb_color, rgb_row_data[col]); |
89 } | 91 } |
90 } | 92 } |
91 rgb_frame->Unlock(); | 93 rgb_frame->Unlock(); |
92 yv12_frame->Unlock(); | 94 yv12_frame->Unlock(); |
93 } | 95 } |
94 | 96 |
95 TEST(VideoFrameImpl, CreateFrame) { | 97 TEST(VideoFrameImpl, CreateFrame) { |
96 const size_t kWidth = 64; | 98 const size_t kWidth = 64; |
97 const size_t kHeight = 48; | 99 const size_t kHeight = 48; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 EXPECT_EQ(0, memcmp(kExpectedUVRow, surface.data[VideoSurface::kVPlane], | 178 EXPECT_EQ(0, memcmp(kExpectedUVRow, surface.data[VideoSurface::kVPlane], |
177 arraysize(kExpectedUVRow))); | 179 arraysize(kExpectedUVRow))); |
178 surface.data[VideoSurface::kUPlane] += | 180 surface.data[VideoSurface::kUPlane] += |
179 surface.strides[VideoSurface::kUPlane]; | 181 surface.strides[VideoSurface::kUPlane]; |
180 surface.data[VideoSurface::kVPlane] += | 182 surface.data[VideoSurface::kVPlane] += |
181 surface.strides[VideoSurface::kVPlane]; | 183 surface.strides[VideoSurface::kVPlane]; |
182 } | 184 } |
183 } | 185 } |
184 | 186 |
185 } // namespace media | 187 } // namespace media |
OLD | NEW |