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 "media/base/video_frame.h" | 5 #include "media/base/video_frame.h" |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/string_util.h" | 9 #include "base/stringprintf.h" |
10 #include "media/base/buffers.h" | 10 #include "media/base/buffers.h" |
11 #include "media/base/mock_filters.h" | 11 #include "media/base/mock_filters.h" |
12 #include "media/base/yuv_convert.h" | 12 #include "media/base/yuv_convert.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace media { | 15 namespace media { |
16 | 16 |
17 // Helper function that initializes a YV12 frame with white and black scan | 17 // Helper function that initializes a YV12 frame with white and black scan |
18 // lines based on the |white_to_black| parameter. If 0, then the entire | 18 // lines based on the |white_to_black| parameter. If 0, then the entire |
19 // frame will be black, if 1 then the entire frame will be white. | 19 // frame will be black, if 1 then the entire frame will be white. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 yv12_frame->stride(VideoFrame::kYPlane), | 72 yv12_frame->stride(VideoFrame::kYPlane), |
73 yv12_frame->stride(VideoFrame::kUPlane), | 73 yv12_frame->stride(VideoFrame::kUPlane), |
74 rgb_frame->stride(VideoFrame::kRGBPlane), | 74 rgb_frame->stride(VideoFrame::kRGBPlane), |
75 media::YV12); | 75 media::YV12); |
76 | 76 |
77 for (size_t row = 0; row < rgb_frame->height(); ++row) { | 77 for (size_t row = 0; row < rgb_frame->height(); ++row) { |
78 uint32* rgb_row_data = reinterpret_cast<uint32*>( | 78 uint32* rgb_row_data = reinterpret_cast<uint32*>( |
79 rgb_frame->data(VideoFrame::kRGBPlane) + | 79 rgb_frame->data(VideoFrame::kRGBPlane) + |
80 (rgb_frame->stride(VideoFrame::kRGBPlane) * row)); | 80 (rgb_frame->stride(VideoFrame::kRGBPlane) * row)); |
81 for (size_t col = 0; col < rgb_frame->width(); ++col) { | 81 for (size_t col = 0; col < rgb_frame->width(); ++col) { |
82 SCOPED_TRACE(StringPrintf("Checking (%" PRIuS ", %" PRIuS ")", | 82 SCOPED_TRACE( |
83 row, col)); | 83 base::StringPrintf("Checking (%" PRIuS ", %" PRIuS ")", row, col)); |
84 EXPECT_EQ(expect_rgb_color, rgb_row_data[col]); | 84 EXPECT_EQ(expect_rgb_color, rgb_row_data[col]); |
85 } | 85 } |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 TEST(VideoFrame, CreateFrame) { | 89 TEST(VideoFrame, CreateFrame) { |
90 const size_t kWidth = 64; | 90 const size_t kWidth = 64; |
91 const size_t kHeight = 48; | 91 const size_t kHeight = 48; |
92 const base::TimeDelta kTimestampA = base::TimeDelta::FromMicroseconds(1337); | 92 const base::TimeDelta kTimestampA = base::TimeDelta::FromMicroseconds(1337); |
93 const base::TimeDelta kDurationA = base::TimeDelta::FromMicroseconds(1667); | 93 const base::TimeDelta kDurationA = base::TimeDelta::FromMicroseconds(1667); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // Test frame properties. | 187 // Test frame properties. |
188 EXPECT_EQ(1, frame->stride(VideoFrame::kRGBPlane)); | 188 EXPECT_EQ(1, frame->stride(VideoFrame::kRGBPlane)); |
189 EXPECT_EQ(memory.get(), frame->data(VideoFrame::kRGBPlane)); | 189 EXPECT_EQ(memory.get(), frame->data(VideoFrame::kRGBPlane)); |
190 | 190 |
191 // Delete |memory| and then |frame|. | 191 // Delete |memory| and then |frame|. |
192 memory.reset(); | 192 memory.reset(); |
193 frame = NULL; | 193 frame = NULL; |
194 } | 194 } |
195 | 195 |
196 } // namespace media | 196 } // namespace media |
OLD | NEW |