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

Side by Side Diff: content/common/gpu/media/video_encode_accelerator_unittest.cc

Issue 1324213007: vea_unittest: Fix driver doesn't suppport hole in memory mapped file (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 | « no previous file | no next file » | 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 <inttypes.h> 5 #include <inttypes.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <queue> 8 #include <queue>
9 #include <string> 9 #include <string>
10 10
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 test_stream->mapped_aligned_in_file.IsValid()) 232 test_stream->mapped_aligned_in_file.IsValid())
233 return; 233 return;
234 234
235 // All encoders in multiple encoder test reuse the same test_stream, make 235 // All encoders in multiple encoder test reuse the same test_stream, make
236 // sure they requested the same coded_size 236 // sure they requested the same coded_size
237 ASSERT_TRUE(!test_stream->mapped_aligned_in_file.IsValid() || 237 ASSERT_TRUE(!test_stream->mapped_aligned_in_file.IsValid() ||
238 coded_size == test_stream->coded_size); 238 coded_size == test_stream->coded_size);
239 test_stream->coded_size = coded_size; 239 test_stream->coded_size = coded_size;
240 240
241 size_t num_planes = media::VideoFrame::NumPlanes(kInputFormat); 241 size_t num_planes = media::VideoFrame::NumPlanes(kInputFormat);
242 std::vector<size_t> padding_sizes(num_planes); 242 std::vector<std::vector<uint8>> padding(num_planes);
243 std::vector<size_t> coded_bpl(num_planes); 243 std::vector<size_t> coded_bpl(num_planes);
244 std::vector<size_t> visible_bpl(num_planes); 244 std::vector<size_t> visible_bpl(num_planes);
245 std::vector<size_t> visible_plane_rows(num_planes); 245 std::vector<size_t> visible_plane_rows(num_planes);
246 246
247 // Calculate padding in bytes to be added after each plane required to keep 247 // Calculate padding in bytes to be added after each plane required to keep
248 // starting addresses of all planes at a 64 byte boudnary. This padding will 248 // starting addresses of all planes at a 64 byte boudnary. This padding will
249 // be added after each plane when copying to the temporary file. 249 // be added after each plane when copying to the temporary file.
250 // At the same time we also need to take into account coded_size requested by 250 // At the same time we also need to take into account coded_size requested by
251 // the VEA; each row of visible_bpl bytes in the original file needs to be 251 // the VEA; each row of visible_bpl bytes in the original file needs to be
252 // copied into a row of coded_bpl bytes in the aligned file. 252 // copied into a row of coded_bpl bytes in the aligned file.
253 for (size_t i = 0; i < num_planes; i++) { 253 for (size_t i = 0; i < num_planes; i++) {
254 const size_t size = 254 const size_t size =
255 media::VideoFrame::PlaneSize(kInputFormat, i, coded_size).GetArea(); 255 media::VideoFrame::PlaneSize(kInputFormat, i, coded_size).GetArea();
256 test_stream->aligned_plane_size.push_back(Align64Bytes(size)); 256 test_stream->aligned_plane_size.push_back(Align64Bytes(size));
257 test_stream->aligned_buffer_size += test_stream->aligned_plane_size.back(); 257 test_stream->aligned_buffer_size += test_stream->aligned_plane_size.back();
258 258
259 coded_bpl[i] = 259 coded_bpl[i] =
260 media::VideoFrame::RowBytes(i, kInputFormat, coded_size.width()); 260 media::VideoFrame::RowBytes(i, kInputFormat, coded_size.width());
261 visible_bpl[i] = media::VideoFrame::RowBytes( 261 visible_bpl[i] = media::VideoFrame::RowBytes(
262 i, kInputFormat, test_stream->visible_size.width()); 262 i, kInputFormat, test_stream->visible_size.width());
263 visible_plane_rows[i] = media::VideoFrame::Rows( 263 visible_plane_rows[i] = media::VideoFrame::Rows(
264 i, kInputFormat, test_stream->visible_size.height()); 264 i, kInputFormat, test_stream->visible_size.height());
265 const size_t padding_rows = 265 const size_t padding_rows =
266 media::VideoFrame::Rows(i, kInputFormat, coded_size.height()) - 266 media::VideoFrame::Rows(i, kInputFormat, coded_size.height()) -
267 visible_plane_rows[i]; 267 visible_plane_rows[i];
268 padding_sizes[i] = padding_rows * coded_bpl[i] + Align64Bytes(size) - size; 268 padding[i].resize(padding_rows * coded_bpl[i] + Align64Bytes(size) - size);
269 } 269 }
270 270
271 base::MemoryMappedFile src_file; 271 base::MemoryMappedFile src_file;
272 LOG_ASSERT(src_file.Initialize(base::FilePath(test_stream->in_filename))); 272 LOG_ASSERT(src_file.Initialize(base::FilePath(test_stream->in_filename)));
273 LOG_ASSERT(base::CreateTemporaryFile(&test_stream->aligned_in_file)); 273 LOG_ASSERT(base::CreateTemporaryFile(&test_stream->aligned_in_file));
274 274
275 size_t visible_buffer_size = media::VideoFrame::AllocationSize( 275 size_t visible_buffer_size = media::VideoFrame::AllocationSize(
276 kInputFormat, test_stream->visible_size); 276 kInputFormat, test_stream->visible_size);
277 LOG_ASSERT(src_file.length() % visible_buffer_size == 0U) 277 LOG_ASSERT(src_file.length() % visible_buffer_size == 0U)
278 << "Stream byte size is not a product of calculated frame byte size"; 278 << "Stream byte size is not a product of calculated frame byte size";
(...skipping 13 matching lines...) Expand all
292 for (size_t frame = 0; frame < test_stream->num_frames; frame++) { 292 for (size_t frame = 0; frame < test_stream->num_frames; frame++) {
293 for (size_t i = 0; i < num_planes; i++) { 293 for (size_t i = 0; i < num_planes; i++) {
294 // Assert that each plane of frame starts at 64 byte boundary. 294 // Assert that each plane of frame starts at 64 byte boundary.
295 ASSERT_EQ(dest_offset & 63, 0) 295 ASSERT_EQ(dest_offset & 63, 0)
296 << "Planes of frame should be mapped at a 64 byte boundary"; 296 << "Planes of frame should be mapped at a 64 byte boundary";
297 for (size_t j = 0; j < visible_plane_rows[i]; j++) { 297 for (size_t j = 0; j < visible_plane_rows[i]; j++) {
298 LOG_ASSERT(WriteFile(&dest_file, dest_offset, src, visible_bpl[i])); 298 LOG_ASSERT(WriteFile(&dest_file, dest_offset, src, visible_bpl[i]));
299 src += visible_bpl[i]; 299 src += visible_bpl[i];
300 dest_offset += coded_bpl[i]; 300 dest_offset += coded_bpl[i];
301 } 301 }
302 dest_offset += padding_sizes[i]; 302 if (!padding[i].empty()) {
303 LOG_ASSERT(WriteFile(&dest_file, dest_offset, &padding[i][0],
304 padding[i].size()));
305 dest_offset += padding[i].size();
306 }
303 } 307 }
304 } 308 }
305 LOG_ASSERT(test_stream->mapped_aligned_in_file.Initialize(dest_file.Pass())); 309 LOG_ASSERT(test_stream->mapped_aligned_in_file.Initialize(dest_file.Pass()));
306 // Assert that memory mapped of file starts at 64 byte boundary. So each 310 // Assert that memory mapped of file starts at 64 byte boundary. So each
307 // plane of frames also start at 64 byte boundary. 311 // plane of frames also start at 64 byte boundary.
308 312
309 ASSERT_EQ( 313 ASSERT_EQ(
310 reinterpret_cast<off_t>(test_stream->mapped_aligned_in_file.data()) & 63, 314 reinterpret_cast<off_t>(test_stream->mapped_aligned_in_file.data()) & 63,
311 0) 315 0)
312 << "File should be mapped at a 64 byte boundary"; 316 << "File should be mapped at a 64 byte boundary";
(...skipping 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 1773
1770 content::g_env = 1774 content::g_env =
1771 reinterpret_cast<content::VideoEncodeAcceleratorTestEnvironment*>( 1775 reinterpret_cast<content::VideoEncodeAcceleratorTestEnvironment*>(
1772 testing::AddGlobalTestEnvironment( 1776 testing::AddGlobalTestEnvironment(
1773 new content::VideoEncodeAcceleratorTestEnvironment( 1777 new content::VideoEncodeAcceleratorTestEnvironment(
1774 test_stream_data.Pass(), log_path, run_at_fps, 1778 test_stream_data.Pass(), log_path, run_at_fps,
1775 needs_encode_latency, verify_all_output))); 1779 needs_encode_latency, verify_all_output)));
1776 1780
1777 return RUN_ALL_TESTS(); 1781 return RUN_ALL_TESTS();
1778 } 1782 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698