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

Unified Diff: media/base/video_frame_unittest.cc

Issue 56713002: Remove RGB32 from VideoFrame::Format. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@vframe_invalid
Patch Set: Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/video_frame.cc ('k') | media/filters/video_renderer_base_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/video_frame_unittest.cc
diff --git a/media/base/video_frame_unittest.cc b/media/base/video_frame_unittest.cc
index b88d20c363973e9a1937a640829a5edca79d561b..2e4f4191037164364479bad7744882d489ce6067 100644
--- a/media/base/video_frame_unittest.cc
+++ b/media/base/video_frame_unittest.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/format_macros.h"
+#include "base/memory/aligned_memory.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/stringprintf.h"
#include "media/base/buffers.h"
@@ -17,6 +18,12 @@ namespace media {
using base::MD5DigestToBase16;
+static inline size_t RoundUp(size_t value, size_t alignment) {
rileya (GONE FROM CHROMIUM) 2013/11/04 19:25:53 This was copied from video_frame.cc... in the inte
scherkus (not reviewing) 2013/11/04 22:54:34 either: 1) dump this in media/base/video_util.h
rileya (GONE FROM CHROMIUM) 2013/11/04 23:51:41 Alright, I did 2).
+ // Check that |alignment| is a power of 2.
+ DCHECK((alignment + (alignment - 1)) == (alignment | (alignment - 1)));
+ return ((value + (alignment - 1)) & ~(alignment-1));
+}
+
// Helper function that initializes a YV12 frame with white and black scan
// lines based on the |white_to_black| parameter. If 0, then the entire
// frame will be black, if 1 then the entire frame will be white.
@@ -47,39 +54,36 @@ void ExpectFrameColor(media::VideoFrame* yv12_frame, uint32 expect_rgb_color) {
ASSERT_EQ(yv12_frame->stride(VideoFrame::kUPlane),
yv12_frame->stride(VideoFrame::kVPlane));
- scoped_refptr<media::VideoFrame> rgb_frame;
- rgb_frame = media::VideoFrame::CreateFrame(VideoFrame::RGB32,
- yv12_frame->coded_size(),
- yv12_frame->visible_rect(),
- yv12_frame->natural_size(),
- yv12_frame->GetTimestamp());
-
- ASSERT_EQ(yv12_frame->coded_size().width(),
- rgb_frame->coded_size().width());
- ASSERT_EQ(yv12_frame->coded_size().height(),
- rgb_frame->coded_size().height());
+ size_t bytes_per_row = RoundUp(yv12_frame->coded_size().width(),
+ VideoFrame::kFrameSizeAlignment) * 4u;
+ size_t aligned_height = RoundUp(yv12_frame->coded_size().height(),
+ VideoFrame::kFrameSizeAlignment);
+ uint8* data = reinterpret_cast<uint8*>(base::AlignedAlloc(
scherkus (not reviewing) 2013/11/04 22:54:34 s/data/rgb_data/
rileya (GONE FROM CHROMIUM) 2013/11/04 23:51:41 Done.
+ bytes_per_row * aligned_height + VideoFrame::kFrameSizePadding,
+ VideoFrame::kFrameAddressAlignment));
media::ConvertYUVToRGB32(yv12_frame->data(VideoFrame::kYPlane),
yv12_frame->data(VideoFrame::kUPlane),
yv12_frame->data(VideoFrame::kVPlane),
- rgb_frame->data(VideoFrame::kRGBPlane),
- rgb_frame->coded_size().width(),
- rgb_frame->coded_size().height(),
+ data,
+ yv12_frame->coded_size().width(),
+ yv12_frame->coded_size().height(),
yv12_frame->stride(VideoFrame::kYPlane),
yv12_frame->stride(VideoFrame::kUPlane),
- rgb_frame->stride(VideoFrame::kRGBPlane),
+ bytes_per_row,
media::YV12);
- for (int row = 0; row < rgb_frame->coded_size().height(); ++row) {
+ for (int row = 0; row < yv12_frame->coded_size().height(); ++row) {
uint32* rgb_row_data = reinterpret_cast<uint32*>(
- rgb_frame->data(VideoFrame::kRGBPlane) +
- (rgb_frame->stride(VideoFrame::kRGBPlane) * row));
- for (int col = 0; col < rgb_frame->coded_size().width(); ++col) {
+ data + (bytes_per_row * row));
+ for (int col = 0; col < yv12_frame->coded_size().width(); ++col) {
SCOPED_TRACE(
base::StringPrintf("Checking (%d, %d)", row, col));
EXPECT_EQ(expect_rgb_color, rgb_row_data[col]);
}
}
+
+ base::AlignedFree(data);
}
// Fill each plane to its reported extents and verify accessors report non
@@ -204,8 +208,6 @@ TEST(VideoFrame, CheckFrameExtents) {
// and the expected hash of all planes if filled with kFillByte (defined in
// ExpectFrameExtents).
ExpectFrameExtents(
- VideoFrame::RGB32, 1, 4, "de6d3d567e282f6a38d478f04fc81fb0");
- ExpectFrameExtents(
VideoFrame::YV12, 3, 1, "71113bdfd4c0de6cf62f48fb74f7a0b1");
ExpectFrameExtents(
VideoFrame::YV16, 3, 1, "9bb99ac3ff350644ebff4d28dc01b461");
« no previous file with comments | « media/base/video_frame.cc ('k') | media/filters/video_renderer_base_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698