OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "media/base/buffers.h" | 10 #include "media/base/buffers.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 // makes sure that all the pixels of the RBG frame equal |expect_rgb_color|. | 42 // makes sure that all the pixels of the RBG frame equal |expect_rgb_color|. |
43 void ExpectFrameColor(media::VideoFrame* yv12_frame, uint32 expect_rgb_color) { | 43 void ExpectFrameColor(media::VideoFrame* yv12_frame, uint32 expect_rgb_color) { |
44 ASSERT_EQ(VideoFrame::YV12, yv12_frame->format()); | 44 ASSERT_EQ(VideoFrame::YV12, yv12_frame->format()); |
45 ASSERT_EQ(yv12_frame->stride(VideoFrame::kUPlane), | 45 ASSERT_EQ(yv12_frame->stride(VideoFrame::kUPlane), |
46 yv12_frame->stride(VideoFrame::kVPlane)); | 46 yv12_frame->stride(VideoFrame::kVPlane)); |
47 | 47 |
48 scoped_refptr<media::VideoFrame> rgb_frame; | 48 scoped_refptr<media::VideoFrame> rgb_frame; |
49 rgb_frame = media::VideoFrame::CreateFrame(VideoFrame::RGB32, | 49 rgb_frame = media::VideoFrame::CreateFrame(VideoFrame::RGB32, |
50 yv12_frame->width(), | 50 yv12_frame->width(), |
51 yv12_frame->height(), | 51 yv12_frame->height(), |
| 52 yv12_frame->natural_size(), |
52 yv12_frame->GetTimestamp()); | 53 yv12_frame->GetTimestamp()); |
53 | 54 |
54 ASSERT_EQ(yv12_frame->width(), rgb_frame->width()); | 55 ASSERT_EQ(yv12_frame->width(), rgb_frame->width()); |
55 ASSERT_EQ(yv12_frame->height(), rgb_frame->height()); | 56 ASSERT_EQ(yv12_frame->height(), rgb_frame->height()); |
56 | 57 |
57 media::ConvertYUVToRGB32(yv12_frame->data(VideoFrame::kYPlane), | 58 media::ConvertYUVToRGB32(yv12_frame->data(VideoFrame::kYPlane), |
58 yv12_frame->data(VideoFrame::kUPlane), | 59 yv12_frame->data(VideoFrame::kUPlane), |
59 yv12_frame->data(VideoFrame::kVPlane), | 60 yv12_frame->data(VideoFrame::kVPlane), |
60 rgb_frame->data(VideoFrame::kRGBPlane), | 61 rgb_frame->data(VideoFrame::kRGBPlane), |
61 rgb_frame->width(), | 62 rgb_frame->width(), |
(...skipping 19 matching lines...) Expand all Loading... |
81 // zero values. Additionally, for the first plane verify the rows and | 82 // zero values. Additionally, for the first plane verify the rows and |
82 // row_bytes values are correct. | 83 // row_bytes values are correct. |
83 void ExpectFrameExtents(VideoFrame::Format format, int planes, | 84 void ExpectFrameExtents(VideoFrame::Format format, int planes, |
84 int bytes_per_pixel, const char* expected_hash) { | 85 int bytes_per_pixel, const char* expected_hash) { |
85 const unsigned char kFillByte = 0x80; | 86 const unsigned char kFillByte = 0x80; |
86 const size_t kWidth = 61; | 87 const size_t kWidth = 61; |
87 const size_t kHeight = 31; | 88 const size_t kHeight = 31; |
88 const base::TimeDelta kTimestamp = base::TimeDelta::FromMicroseconds(1337); | 89 const base::TimeDelta kTimestamp = base::TimeDelta::FromMicroseconds(1337); |
89 | 90 |
90 scoped_refptr<VideoFrame> frame = VideoFrame::CreateFrame( | 91 scoped_refptr<VideoFrame> frame = VideoFrame::CreateFrame( |
91 format, kWidth, kHeight, kTimestamp); | 92 format, kWidth, kHeight, gfx::Size(kWidth, kHeight), kTimestamp); |
92 ASSERT_TRUE(frame); | 93 ASSERT_TRUE(frame); |
93 | 94 |
94 for(int plane = 0; plane < planes; plane++) { | 95 for(int plane = 0; plane < planes; plane++) { |
95 SCOPED_TRACE(base::StringPrintf("Checking plane %d", plane)); | 96 SCOPED_TRACE(base::StringPrintf("Checking plane %d", plane)); |
96 EXPECT_TRUE(frame->data(plane)); | 97 EXPECT_TRUE(frame->data(plane)); |
97 EXPECT_TRUE(frame->stride(plane)); | 98 EXPECT_TRUE(frame->stride(plane)); |
98 EXPECT_TRUE(frame->rows(plane)); | 99 EXPECT_TRUE(frame->rows(plane)); |
99 EXPECT_TRUE(frame->row_bytes(plane)); | 100 EXPECT_TRUE(frame->row_bytes(plane)); |
100 | 101 |
101 if (plane == 0) { | 102 if (plane == 0) { |
(...skipping 14 matching lines...) Expand all Loading... |
116 } | 117 } |
117 | 118 |
118 TEST(VideoFrame, CreateFrame) { | 119 TEST(VideoFrame, CreateFrame) { |
119 const size_t kWidth = 64; | 120 const size_t kWidth = 64; |
120 const size_t kHeight = 48; | 121 const size_t kHeight = 48; |
121 const base::TimeDelta kTimestamp = base::TimeDelta::FromMicroseconds(1337); | 122 const base::TimeDelta kTimestamp = base::TimeDelta::FromMicroseconds(1337); |
122 | 123 |
123 // Create a YV12 Video Frame. | 124 // Create a YV12 Video Frame. |
124 scoped_refptr<media::VideoFrame> frame = | 125 scoped_refptr<media::VideoFrame> frame = |
125 VideoFrame::CreateFrame(media::VideoFrame::YV12, kWidth, kHeight, | 126 VideoFrame::CreateFrame(media::VideoFrame::YV12, kWidth, kHeight, |
126 kTimestamp); | 127 gfx::Size(kWidth, kHeight), kTimestamp); |
127 ASSERT_TRUE(frame); | 128 ASSERT_TRUE(frame); |
128 | 129 |
129 // Test VideoFrame implementation. | 130 // Test VideoFrame implementation. |
130 EXPECT_EQ(media::VideoFrame::YV12, frame->format()); | 131 EXPECT_EQ(media::VideoFrame::YV12, frame->format()); |
131 { | 132 { |
132 SCOPED_TRACE(""); | 133 SCOPED_TRACE(""); |
133 InitializeYV12Frame(frame, 0.0f); | 134 InitializeYV12Frame(frame, 0.0f); |
134 ExpectFrameColor(frame, 0xFF000000); | 135 ExpectFrameColor(frame, 0xFF000000); |
135 } | 136 } |
136 base::MD5Digest digest; | 137 base::MD5Digest digest; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 // ExpectFrameExtents). | 199 // ExpectFrameExtents). |
199 ExpectFrameExtents( | 200 ExpectFrameExtents( |
200 VideoFrame::RGB32, 1, 4, "de6d3d567e282f6a38d478f04fc81fb0"); | 201 VideoFrame::RGB32, 1, 4, "de6d3d567e282f6a38d478f04fc81fb0"); |
201 ExpectFrameExtents( | 202 ExpectFrameExtents( |
202 VideoFrame::YV12, 3, 1, "71113bdfd4c0de6cf62f48fb74f7a0b1"); | 203 VideoFrame::YV12, 3, 1, "71113bdfd4c0de6cf62f48fb74f7a0b1"); |
203 ExpectFrameExtents( | 204 ExpectFrameExtents( |
204 VideoFrame::YV16, 3, 1, "9bb99ac3ff350644ebff4d28dc01b461"); | 205 VideoFrame::YV16, 3, 1, "9bb99ac3ff350644ebff4d28dc01b461"); |
205 } | 206 } |
206 | 207 |
207 } // namespace media | 208 } // namespace media |
OLD | NEW |