Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(588)

Side by Side Diff: media/base/video_frame_unittest.cc

Issue 10832087: Remove VideoDecoderConfig.frame_rate_xxx() & VideoFrame:Get/SetDuration() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address more CR comments. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/video_frame.cc ('k') | media/base/video_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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->GetTimestamp(), 52 yv12_frame->GetTimestamp());
53 yv12_frame->GetDuration());
54 53
55 ASSERT_EQ(yv12_frame->width(), rgb_frame->width()); 54 ASSERT_EQ(yv12_frame->width(), rgb_frame->width());
56 ASSERT_EQ(yv12_frame->height(), rgb_frame->height()); 55 ASSERT_EQ(yv12_frame->height(), rgb_frame->height());
57 56
58 media::ConvertYUVToRGB32(yv12_frame->data(VideoFrame::kYPlane), 57 media::ConvertYUVToRGB32(yv12_frame->data(VideoFrame::kYPlane),
59 yv12_frame->data(VideoFrame::kUPlane), 58 yv12_frame->data(VideoFrame::kUPlane),
60 yv12_frame->data(VideoFrame::kVPlane), 59 yv12_frame->data(VideoFrame::kVPlane),
61 rgb_frame->data(VideoFrame::kRGBPlane), 60 rgb_frame->data(VideoFrame::kRGBPlane),
62 rgb_frame->width(), 61 rgb_frame->width(),
63 rgb_frame->height(), 62 rgb_frame->height(),
(...skipping 16 matching lines...) Expand all
80 79
81 // Fill each plane to its reported extents and verify accessors report non 80 // Fill each plane to its reported extents and verify accessors report non
82 // zero values. Additionally, for the first plane verify the rows and 81 // zero values. Additionally, for the first plane verify the rows and
83 // row_bytes values are correct. 82 // row_bytes values are correct.
84 void ExpectFrameExtents(VideoFrame::Format format, int planes, 83 void ExpectFrameExtents(VideoFrame::Format format, int planes,
85 int bytes_per_pixel, const char* expected_hash) { 84 int bytes_per_pixel, const char* expected_hash) {
86 const unsigned char kFillByte = 0x80; 85 const unsigned char kFillByte = 0x80;
87 const size_t kWidth = 61; 86 const size_t kWidth = 61;
88 const size_t kHeight = 31; 87 const size_t kHeight = 31;
89 const base::TimeDelta kTimestamp = base::TimeDelta::FromMicroseconds(1337); 88 const base::TimeDelta kTimestamp = base::TimeDelta::FromMicroseconds(1337);
90 const base::TimeDelta kDuration = base::TimeDelta::FromMicroseconds(1667);
91 89
92 scoped_refptr<VideoFrame> frame = VideoFrame::CreateFrame( 90 scoped_refptr<VideoFrame> frame = VideoFrame::CreateFrame(
93 format, kWidth, kHeight, kTimestamp, kDuration); 91 format, kWidth, kHeight, kTimestamp);
94 ASSERT_TRUE(frame); 92 ASSERT_TRUE(frame);
95 93
96 for(int plane = 0; plane < planes; plane++) { 94 for(int plane = 0; plane < planes; plane++) {
97 SCOPED_TRACE(base::StringPrintf("Checking plane %d", plane)); 95 SCOPED_TRACE(base::StringPrintf("Checking plane %d", plane));
98 EXPECT_TRUE(frame->data(plane)); 96 EXPECT_TRUE(frame->data(plane));
99 EXPECT_TRUE(frame->stride(plane)); 97 EXPECT_TRUE(frame->stride(plane));
100 EXPECT_TRUE(frame->rows(plane)); 98 EXPECT_TRUE(frame->rows(plane));
101 EXPECT_TRUE(frame->row_bytes(plane)); 99 EXPECT_TRUE(frame->row_bytes(plane));
102 100
103 if (plane == 0) { 101 if (plane == 0) {
(...skipping 10 matching lines...) Expand all
114 frame->HashFrameForTesting(&context); 112 frame->HashFrameForTesting(&context);
115 base::MD5Digest digest; 113 base::MD5Digest digest;
116 base::MD5Final(&digest, &context); 114 base::MD5Final(&digest, &context);
117 EXPECT_EQ(MD5DigestToBase16(digest), expected_hash); 115 EXPECT_EQ(MD5DigestToBase16(digest), expected_hash);
118 } 116 }
119 117
120 TEST(VideoFrame, CreateFrame) { 118 TEST(VideoFrame, CreateFrame) {
121 const size_t kWidth = 64; 119 const size_t kWidth = 64;
122 const size_t kHeight = 48; 120 const size_t kHeight = 48;
123 const base::TimeDelta kTimestamp = base::TimeDelta::FromMicroseconds(1337); 121 const base::TimeDelta kTimestamp = base::TimeDelta::FromMicroseconds(1337);
124 const base::TimeDelta kDuration = base::TimeDelta::FromMicroseconds(1667);
125 122
126 // Create a YV12 Video Frame. 123 // Create a YV12 Video Frame.
127 scoped_refptr<media::VideoFrame> frame = 124 scoped_refptr<media::VideoFrame> frame =
128 VideoFrame::CreateFrame(media::VideoFrame::YV12, kWidth, kHeight, 125 VideoFrame::CreateFrame(media::VideoFrame::YV12, kWidth, kHeight,
129 kTimestamp, kDuration); 126 kTimestamp);
130 ASSERT_TRUE(frame); 127 ASSERT_TRUE(frame);
131 128
132 // Test VideoFrame implementation. 129 // Test VideoFrame implementation.
133 EXPECT_EQ(media::VideoFrame::YV12, frame->format()); 130 EXPECT_EQ(media::VideoFrame::YV12, frame->format());
134 { 131 {
135 SCOPED_TRACE(""); 132 SCOPED_TRACE("");
136 InitializeYV12Frame(frame, 0.0f); 133 InitializeYV12Frame(frame, 0.0f);
137 ExpectFrameColor(frame, 0xFF000000); 134 ExpectFrameColor(frame, 0xFF000000);
138 } 135 }
139 base::MD5Digest digest; 136 base::MD5Digest digest;
(...skipping 22 matching lines...) Expand all
162 const size_t kHeight = 2; 159 const size_t kHeight = 2;
163 const uint8 kExpectedYRow[] = { 0, 0 }; 160 const uint8 kExpectedYRow[] = { 0, 0 };
164 const uint8 kExpectedUVRow[] = { 128 }; 161 const uint8 kExpectedUVRow[] = { 128 };
165 162
166 scoped_refptr<media::VideoFrame> frame = 163 scoped_refptr<media::VideoFrame> frame =
167 VideoFrame::CreateBlackFrame(kWidth, kHeight); 164 VideoFrame::CreateBlackFrame(kWidth, kHeight);
168 ASSERT_TRUE(frame); 165 ASSERT_TRUE(frame);
169 166
170 // Test basic properties. 167 // Test basic properties.
171 EXPECT_EQ(0, frame->GetTimestamp().InMicroseconds()); 168 EXPECT_EQ(0, frame->GetTimestamp().InMicroseconds());
172 EXPECT_EQ(0, frame->GetDuration().InMicroseconds());
173 EXPECT_FALSE(frame->IsEndOfStream()); 169 EXPECT_FALSE(frame->IsEndOfStream());
174 170
175 // Test |frame| properties. 171 // Test |frame| properties.
176 EXPECT_EQ(VideoFrame::YV12, frame->format()); 172 EXPECT_EQ(VideoFrame::YV12, frame->format());
177 EXPECT_EQ(kWidth, frame->width()); 173 EXPECT_EQ(kWidth, frame->width());
178 EXPECT_EQ(kHeight, frame->height()); 174 EXPECT_EQ(kHeight, frame->height());
179 175
180 // Test frames themselves. 176 // Test frames themselves.
181 uint8* y_plane = frame->data(VideoFrame::kYPlane); 177 uint8* y_plane = frame->data(VideoFrame::kYPlane);
182 for (size_t y = 0; y < frame->height(); ++y) { 178 for (size_t y = 0; y < frame->height(); ++y) {
(...skipping 19 matching lines...) Expand all
202 // ExpectFrameExtents). 198 // ExpectFrameExtents).
203 ExpectFrameExtents( 199 ExpectFrameExtents(
204 VideoFrame::RGB32, 1, 4, "de6d3d567e282f6a38d478f04fc81fb0"); 200 VideoFrame::RGB32, 1, 4, "de6d3d567e282f6a38d478f04fc81fb0");
205 ExpectFrameExtents( 201 ExpectFrameExtents(
206 VideoFrame::YV12, 3, 1, "71113bdfd4c0de6cf62f48fb74f7a0b1"); 202 VideoFrame::YV12, 3, 1, "71113bdfd4c0de6cf62f48fb74f7a0b1");
207 ExpectFrameExtents( 203 ExpectFrameExtents(
208 VideoFrame::YV16, 3, 1, "9bb99ac3ff350644ebff4d28dc01b461"); 204 VideoFrame::YV16, 3, 1, "9bb99ac3ff350644ebff4d28dc01b461");
209 } 205 }
210 206
211 } // namespace media 207 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_frame.cc ('k') | media/base/video_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698