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

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

Issue 2694113002: Delete media/base/yuv_convert and dependents. Prefer libyuv. (Closed)
Patch Set: Fix media_unittests. Created 3 years, 10 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
« no previous file with comments | « media/base/simd/xcode_hack.c ('k') | media/base/video_util.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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/callback_helpers.h" 11 #include "base/callback_helpers.h"
12 #include "base/format_macros.h" 12 #include "base/format_macros.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/aligned_memory.h" 14 #include "base/memory/aligned_memory.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "gpu/command_buffer/common/mailbox_holder.h" 16 #include "gpu/command_buffer/common/mailbox_holder.h"
17 #include "media/base/yuv_convert.h"
18 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "third_party/libyuv/include/libyuv.h"
19 19
20 namespace media { 20 namespace media {
21 21
22 using base::MD5DigestToBase16; 22 using base::MD5DigestToBase16;
23 23
24 // Helper function that initializes a YV12 frame with white and black scan 24 // Helper function that initializes a YV12 frame with white and black scan
25 // lines based on the |white_to_black| parameter. If 0, then the entire 25 // lines based on the |white_to_black| parameter. If 0, then the entire
26 // frame will be black, if 1 then the entire frame will be white. 26 // frame will be black, if 1 then the entire frame will be white.
27 void InitializeYV12Frame(VideoFrame* frame, double white_to_black) { 27 void InitializeYV12Frame(VideoFrame* frame, double white_to_black) {
28 EXPECT_EQ(PIXEL_FORMAT_YV12, frame->format()); 28 EXPECT_EQ(PIXEL_FORMAT_YV12, frame->format());
(...skipping 28 matching lines...) Expand all
57 ASSERT_EQ( 57 ASSERT_EQ(
58 yv12_frame->coded_size().height() & (VideoFrame::kFrameSizeAlignment - 1), 58 yv12_frame->coded_size().height() & (VideoFrame::kFrameSizeAlignment - 1),
59 0); 59 0);
60 60
61 size_t bytes_per_row = yv12_frame->coded_size().width() * 4u; 61 size_t bytes_per_row = yv12_frame->coded_size().width() * 4u;
62 uint8_t* rgb_data = reinterpret_cast<uint8_t*>( 62 uint8_t* rgb_data = reinterpret_cast<uint8_t*>(
63 base::AlignedAlloc(bytes_per_row * yv12_frame->coded_size().height() + 63 base::AlignedAlloc(bytes_per_row * yv12_frame->coded_size().height() +
64 VideoFrame::kFrameSizePadding, 64 VideoFrame::kFrameSizePadding,
65 VideoFrame::kFrameAddressAlignment)); 65 VideoFrame::kFrameAddressAlignment));
66 66
67 media::ConvertYUVToRGB32(yv12_frame->data(VideoFrame::kYPlane), 67 libyuv::I420ToARGB(yv12_frame->data(VideoFrame::kYPlane),
68 yv12_frame->data(VideoFrame::kUPlane), 68 yv12_frame->stride(VideoFrame::kYPlane),
69 yv12_frame->data(VideoFrame::kVPlane), 69 yv12_frame->data(VideoFrame::kUPlane),
70 rgb_data, 70 yv12_frame->stride(VideoFrame::kUPlane),
71 yv12_frame->coded_size().width(), 71 yv12_frame->data(VideoFrame::kVPlane),
72 yv12_frame->coded_size().height(), 72 yv12_frame->stride(VideoFrame::kVPlane), rgb_data,
73 yv12_frame->stride(VideoFrame::kYPlane), 73 bytes_per_row, yv12_frame->coded_size().width(),
74 yv12_frame->stride(VideoFrame::kUPlane), 74 yv12_frame->coded_size().height());
75 bytes_per_row,
76 media::YV12);
77 75
78 for (int row = 0; row < yv12_frame->coded_size().height(); ++row) { 76 for (int row = 0; row < yv12_frame->coded_size().height(); ++row) {
79 uint32_t* rgb_row_data = 77 uint32_t* rgb_row_data =
80 reinterpret_cast<uint32_t*>(rgb_data + (bytes_per_row * row)); 78 reinterpret_cast<uint32_t*>(rgb_data + (bytes_per_row * row));
81 for (int col = 0; col < yv12_frame->coded_size().width(); ++col) { 79 for (int col = 0; col < yv12_frame->coded_size().width(); ++col) {
82 SCOPED_TRACE(base::StringPrintf("Checking (%d, %d)", row, col)); 80 SCOPED_TRACE(base::StringPrintf("Checking (%d, %d)", row, col));
83 EXPECT_EQ(expect_rgb_color, rgb_row_data[col]); 81 EXPECT_EQ(expect_rgb_color, rgb_row_data[col]);
84 } 82 }
85 } 83 }
86 84
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 560
563 for (int i = 0; i < VideoFrameMetadata::NUM_KEYS; ++i) { 561 for (int i = 0; i < VideoFrameMetadata::NUM_KEYS; ++i) {
564 const VideoFrameMetadata::Key key = static_cast<VideoFrameMetadata::Key>(i); 562 const VideoFrameMetadata::Key key = static_cast<VideoFrameMetadata::Key>(i);
565 int value = -1; 563 int value = -1;
566 EXPECT_TRUE(result.GetInteger(key, &value)); 564 EXPECT_TRUE(result.GetInteger(key, &value));
567 EXPECT_EQ(i, value); 565 EXPECT_EQ(i, value);
568 } 566 }
569 } 567 }
570 568
571 } // namespace media 569 } // namespace media
OLDNEW
« no previous file with comments | « media/base/simd/xcode_hack.c ('k') | media/base/video_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698