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

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

Issue 1267003004: Revert to zero-initializing buffers for FFmpegVideoDecoder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Zero initialize only the planes. Created 5 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
« no previous file with comments | « media/base/video_frame_pool.cc ('k') | media/filters/ffmpeg_video_decoder.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_pool.h" 5 #include "media/base/video_frame_pool.h"
6 #include "testing/gmock/include/gmock/gmock.h" 6 #include "testing/gmock/include/gmock/gmock.h"
7 7
8 namespace media { 8 namespace media {
9 9
10 class VideoFramePoolTest : public ::testing::Test { 10 class VideoFramePoolTest : public ::testing::Test {
(...skipping 21 matching lines...) Expand all
32 } 32 }
33 33
34 void CheckPoolSize(size_t size) const { 34 void CheckPoolSize(size_t size) const {
35 EXPECT_EQ(size, pool_->GetPoolSizeForTesting()); 35 EXPECT_EQ(size, pool_->GetPoolSizeForTesting());
36 } 36 }
37 37
38 protected: 38 protected:
39 scoped_ptr<VideoFramePool> pool_; 39 scoped_ptr<VideoFramePool> pool_;
40 }; 40 };
41 41
42 TEST_F(VideoFramePoolTest, FrameInitializedAndZeroed) {
43 scoped_refptr<VideoFrame> frame = CreateFrame(PIXEL_FORMAT_YV12, 10);
44
45 // Verify that frame is initialized with zeros.
46 for (size_t i = 0; i < VideoFrame::NumPlanes(frame->format()); ++i)
47 EXPECT_EQ(0, frame->data(i)[0]);
48 }
49
42 TEST_F(VideoFramePoolTest, SimpleFrameReuse) { 50 TEST_F(VideoFramePoolTest, SimpleFrameReuse) {
43 scoped_refptr<VideoFrame> frame = CreateFrame(PIXEL_FORMAT_YV12, 10); 51 scoped_refptr<VideoFrame> frame = CreateFrame(PIXEL_FORMAT_YV12, 10);
44 const uint8* old_y_data = frame->data(VideoFrame::kYPlane); 52 const uint8* old_y_data = frame->data(VideoFrame::kYPlane);
45 53
46 // Clear frame reference to return the frame to the pool. 54 // Clear frame reference to return the frame to the pool.
47 frame = NULL; 55 frame = NULL;
48 56
49 // Verify that the next frame from the pool uses the same memory. 57 // Verify that the next frame from the pool uses the same memory.
50 scoped_refptr<VideoFrame> new_frame = CreateFrame(PIXEL_FORMAT_YV12, 20); 58 scoped_refptr<VideoFrame> new_frame = CreateFrame(PIXEL_FORMAT_YV12, 20);
51 EXPECT_EQ(old_y_data, new_frame->data(VideoFrame::kYPlane)); 59 EXPECT_EQ(old_y_data, new_frame->data(VideoFrame::kYPlane));
(...skipping 22 matching lines...) Expand all
74 // Destroy the pool. 82 // Destroy the pool.
75 pool_.reset(); 83 pool_.reset();
76 84
77 // Write to the Y plane. The memory tools should detect a 85 // Write to the Y plane. The memory tools should detect a
78 // use-after-free if the storage was actually removed by pool destruction. 86 // use-after-free if the storage was actually removed by pool destruction.
79 memset(frame->data(VideoFrame::kYPlane), 0xff, 87 memset(frame->data(VideoFrame::kYPlane), 0xff,
80 frame->rows(VideoFrame::kYPlane) * frame->stride(VideoFrame::kYPlane)); 88 frame->rows(VideoFrame::kYPlane) * frame->stride(VideoFrame::kYPlane));
81 } 89 }
82 90
83 } // namespace media 91 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_frame_pool.cc ('k') | media/filters/ffmpeg_video_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698