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

Unified Diff: media/base/video_frame_unittest.cc

Issue 178133005: Audit/fix use of media::VideoFrame::coded_size() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 2121885f Rebase. Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: media/base/video_frame_unittest.cc
diff --git a/media/base/video_frame_unittest.cc b/media/base/video_frame_unittest.cc
index 967d37653c49ef469f1fd841fd45c3547635447d..9229b6a4d17c803764a4ff87a80fded935d0f70b 100644
--- a/media/base/video_frame_unittest.cc
+++ b/media/base/video_frame_unittest.cc
@@ -88,8 +88,7 @@ void ExpectFrameColor(media::VideoFrame* yv12_frame, uint32 expect_rgb_color) {
// Fill each plane to its reported extents and verify accessors report non
// zero values. Additionally, for the first plane verify the rows and
// row_bytes values are correct.
-void ExpectFrameExtents(VideoFrame::Format format, int planes,
- int bytes_per_pixel, const char* expected_hash) {
+void ExpectFrameExtents(VideoFrame::Format format, const char* expected_hash) {
const unsigned char kFillByte = 0x80;
const int kWidth = 61;
const int kHeight = 31;
@@ -100,18 +99,14 @@ void ExpectFrameExtents(VideoFrame::Format format, int planes,
format, size, gfx::Rect(size), size, kTimestamp);
ASSERT_TRUE(frame.get());
- for(int plane = 0; plane < planes; plane++) {
+ int planes = VideoFrame::NumPlanes(format);
+ for (int plane = 0; plane < planes; plane++) {
SCOPED_TRACE(base::StringPrintf("Checking plane %d", plane));
EXPECT_TRUE(frame->data(plane));
EXPECT_TRUE(frame->stride(plane));
EXPECT_TRUE(frame->rows(plane));
EXPECT_TRUE(frame->row_bytes(plane));
- if (plane == 0) {
- EXPECT_EQ(frame->rows(plane), kHeight);
- EXPECT_EQ(frame->row_bytes(plane), kWidth * bytes_per_pixel);
- }
-
memset(frame->data(plane), kFillByte,
frame->stride(plane) * frame->rows(plane));
}
@@ -239,13 +234,10 @@ TEST(VideoFrame, WrapVideoFrame) {
// Ensure each frame is properly sized and allocated. Will trigger OOB reads
// and writes as well as incorrect frame hashes otherwise.
TEST(VideoFrame, CheckFrameExtents) {
- // Each call consists of a VideoFrame::Format, # of planes, bytes per pixel,
- // and the expected hash of all planes if filled with kFillByte (defined in
- // ExpectFrameExtents).
- ExpectFrameExtents(
- VideoFrame::YV12, 3, 1, "71113bdfd4c0de6cf62f48fb74f7a0b1");
- ExpectFrameExtents(
- VideoFrame::YV16, 3, 1, "9bb99ac3ff350644ebff4d28dc01b461");
+ // Each call consists of a VideoFrame::Format and the expected hash of all
+ // planes if filled with kFillByte (defined in ExpectFrameExtents).
+ ExpectFrameExtents(VideoFrame::YV12, "8e5d54cb23cd0edca111dd35ffb6ff05");
+ ExpectFrameExtents(VideoFrame::YV16, "cce408a044b212db42a10dfec304b3ef");
}
static void TextureCallback(uint32* called_sync_point,

Powered by Google App Engine
This is Rietveld 408576698