| 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 29 matching lines...) Expand all Loading... |
| 40 } | 40 } |
| 41 | 41 |
| 42 // Given a |yv12_frame| this method converts the YV12 frame to RGBA and | 42 // Given a |yv12_frame| this method converts the YV12 frame to RGBA and |
| 43 // makes sure that all the pixels of the RBG frame equal |expect_rgb_color|. | 43 // makes sure that all the pixels of the RBG frame equal |expect_rgb_color|. |
| 44 void ExpectFrameColor(media::VideoFrame* yv12_frame, uint32 expect_rgb_color) { | 44 void ExpectFrameColor(media::VideoFrame* yv12_frame, uint32 expect_rgb_color) { |
| 45 ASSERT_EQ(VideoFrame::YV12, yv12_frame->format()); | 45 ASSERT_EQ(VideoFrame::YV12, yv12_frame->format()); |
| 46 ASSERT_EQ(yv12_frame->stride(VideoFrame::kUPlane), | 46 ASSERT_EQ(yv12_frame->stride(VideoFrame::kUPlane), |
| 47 yv12_frame->stride(VideoFrame::kVPlane)); | 47 yv12_frame->stride(VideoFrame::kVPlane)); |
| 48 | 48 |
| 49 scoped_refptr<media::VideoFrame> rgb_frame; | 49 scoped_refptr<media::VideoFrame> rgb_frame; |
| 50 rgb_frame = media::VideoFrame::CreateFrame(VideoFrame::RGBA, | 50 rgb_frame = media::VideoFrame::CreateFrame(VideoFrame::RGB32, |
| 51 yv12_frame->width(), | 51 yv12_frame->width(), |
| 52 yv12_frame->height(), | 52 yv12_frame->height(), |
| 53 yv12_frame->GetTimestamp(), | 53 yv12_frame->GetTimestamp(), |
| 54 yv12_frame->GetDuration()); | 54 yv12_frame->GetDuration()); |
| 55 | 55 |
| 56 ASSERT_EQ(yv12_frame->width(), rgb_frame->width()); | 56 ASSERT_EQ(yv12_frame->width(), rgb_frame->width()); |
| 57 ASSERT_EQ(yv12_frame->height(), rgb_frame->height()); | 57 ASSERT_EQ(yv12_frame->height(), rgb_frame->height()); |
| 58 | 58 |
| 59 media::ConvertYUVToRGB32(yv12_frame->data(VideoFrame::kYPlane), | 59 media::ConvertYUVToRGB32(yv12_frame->data(VideoFrame::kYPlane), |
| 60 yv12_frame->data(VideoFrame::kUPlane), | 60 yv12_frame->data(VideoFrame::kUPlane), |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 } | 195 } |
| 196 } | 196 } |
| 197 | 197 |
| 198 // Ensure each frame is properly sized and allocated. Will trigger OOB reads | 198 // Ensure each frame is properly sized and allocated. Will trigger OOB reads |
| 199 // and writes as well as incorrect frame hashes otherwise. | 199 // and writes as well as incorrect frame hashes otherwise. |
| 200 TEST(VideoFrame, CheckFrameExtents) { | 200 TEST(VideoFrame, CheckFrameExtents) { |
| 201 // Each call consists of a VideoFrame::Format, # of planes, bytes per pixel, | 201 // Each call consists of a VideoFrame::Format, # of planes, bytes per pixel, |
| 202 // and the expected hash of all planes if filled with kFillByte (defined in | 202 // and the expected hash of all planes if filled with kFillByte (defined in |
| 203 // ExpectFrameExtents). | 203 // ExpectFrameExtents). |
| 204 ExpectFrameExtents( | 204 ExpectFrameExtents( |
| 205 VideoFrame::RGB555, 1, 2, "31f7739efc76b5d9cb51361ba82533fa"); | |
| 206 ExpectFrameExtents( | |
| 207 VideoFrame::RGB565, 1, 2, "31f7739efc76b5d9cb51361ba82533fa"); | |
| 208 ExpectFrameExtents( | |
| 209 VideoFrame::RGB24, 1, 3, "84361ae9d4b6d4641a11474b3a7a2260"); | |
| 210 ExpectFrameExtents( | |
| 211 VideoFrame::RGB32, 1, 4, "de6d3d567e282f6a38d478f04fc81fb0"); | 205 VideoFrame::RGB32, 1, 4, "de6d3d567e282f6a38d478f04fc81fb0"); |
| 212 ExpectFrameExtents( | 206 ExpectFrameExtents( |
| 213 VideoFrame::RGBA, 1, 4, "de6d3d567e282f6a38d478f04fc81fb0"); | |
| 214 ExpectFrameExtents( | |
| 215 VideoFrame::YV12, 3, 1, "71113bdfd4c0de6cf62f48fb74f7a0b1"); | 207 VideoFrame::YV12, 3, 1, "71113bdfd4c0de6cf62f48fb74f7a0b1"); |
| 216 ExpectFrameExtents( | 208 ExpectFrameExtents( |
| 217 VideoFrame::YV16, 3, 1, "9bb99ac3ff350644ebff4d28dc01b461"); | 209 VideoFrame::YV16, 3, 1, "9bb99ac3ff350644ebff4d28dc01b461"); |
| 218 } | 210 } |
| 219 | 211 |
| 220 } // namespace media | 212 } // namespace media |
| OLD | NEW |