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

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

Issue 1476523005: Verify returned frames from media::VideoFrame::Wrap*() methods (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 11 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
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 #include <stddef.h> 6 #include <stddef.h>
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <queue> 9 #include <queue>
10 #include <string> 10 #include <string>
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 FeedEncoderWithOneInput(); 1314 FeedEncoderWithOneInput();
1315 } 1315 }
1316 1316
1317 scoped_refptr<media::VideoFrame> VEAClient::CreateFrame(off_t position) { 1317 scoped_refptr<media::VideoFrame> VEAClient::CreateFrame(off_t position) {
1318 uint8_t* frame_data_y = const_cast<uint8_t*>( 1318 uint8_t* frame_data_y = const_cast<uint8_t*>(
1319 test_stream_->mapped_aligned_in_file.data() + position); 1319 test_stream_->mapped_aligned_in_file.data() + position);
1320 uint8_t* frame_data_u = frame_data_y + test_stream_->aligned_plane_size[0]; 1320 uint8_t* frame_data_u = frame_data_y + test_stream_->aligned_plane_size[0];
1321 uint8_t* frame_data_v = frame_data_u + test_stream_->aligned_plane_size[1]; 1321 uint8_t* frame_data_v = frame_data_u + test_stream_->aligned_plane_size[1];
1322 CHECK_GT(current_framerate_, 0U); 1322 CHECK_GT(current_framerate_, 0U);
1323 1323
1324 return media::VideoFrame::WrapExternalYuvData( 1324 scoped_refptr<media::VideoFrame> video_frame =
1325 kInputFormat, input_coded_size_, gfx::Rect(test_stream_->visible_size), 1325 media::VideoFrame::WrapExternalYuvData(
1326 test_stream_->visible_size, input_coded_size_.width(), 1326 kInputFormat, input_coded_size_,
1327 input_coded_size_.width() / 2, input_coded_size_.width() / 2, 1327 gfx::Rect(test_stream_->visible_size), test_stream_->visible_size,
1328 frame_data_y, frame_data_u, frame_data_v, 1328 input_coded_size_.width(), input_coded_size_.width() / 2,
1329 base::TimeDelta().FromMilliseconds(next_input_id_ * 1329 input_coded_size_.width() / 2, frame_data_y, frame_data_u,
1330 base::Time::kMillisecondsPerSecond / 1330 frame_data_v,
1331 current_framerate_)); 1331 base::TimeDelta().FromMilliseconds(
1332 next_input_id_ * base::Time::kMillisecondsPerSecond /
1333 current_framerate_));
1334 EXPECT_NE(video_frame.get(), nullptr);
mcasas 2016/01/12 17:46:16 nit: Same here, ASSERT(video_frame) for tests.
emircan 2016/01/14 23:07:40 ASSERT has the same problem as above.
1335 return video_frame;
1332 } 1336 }
1333 1337
1334 scoped_refptr<media::VideoFrame> VEAClient::PrepareInputFrame( 1338 scoped_refptr<media::VideoFrame> VEAClient::PrepareInputFrame(
1335 off_t position, 1339 off_t position,
1336 int32_t* input_id) { 1340 int32_t* input_id) {
1337 CHECK_LE(position + test_stream_->aligned_buffer_size, 1341 CHECK_LE(position + test_stream_->aligned_buffer_size,
1338 test_stream_->mapped_aligned_in_file.length()); 1342 test_stream_->mapped_aligned_in_file.length());
1339 1343
1340 scoped_refptr<media::VideoFrame> frame = CreateFrame(position); 1344 scoped_refptr<media::VideoFrame> frame = CreateFrame(position);
1345 EXPECT_NE(frame.get(), nullptr);
1341 frame->AddDestructionObserver( 1346 frame->AddDestructionObserver(
1342 media::BindToCurrentLoop( 1347 media::BindToCurrentLoop(
1343 base::Bind(&VEAClient::InputNoLongerNeededCallback, 1348 base::Bind(&VEAClient::InputNoLongerNeededCallback,
1344 base::Unretained(this), 1349 base::Unretained(this),
1345 next_input_id_))); 1350 next_input_id_)));
1346 1351
1347 LOG_ASSERT(inputs_at_client_.insert(next_input_id_).second); 1352 LOG_ASSERT(inputs_at_client_.insert(next_input_id_).second);
1348 1353
1349 *input_id = next_input_id_++; 1354 *input_id = next_input_id_++;
1350 return frame; 1355 return frame;
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1778 1783
1779 content::g_env = 1784 content::g_env =
1780 reinterpret_cast<content::VideoEncodeAcceleratorTestEnvironment*>( 1785 reinterpret_cast<content::VideoEncodeAcceleratorTestEnvironment*>(
1781 testing::AddGlobalTestEnvironment( 1786 testing::AddGlobalTestEnvironment(
1782 new content::VideoEncodeAcceleratorTestEnvironment( 1787 new content::VideoEncodeAcceleratorTestEnvironment(
1783 std::move(test_stream_data), log_path, run_at_fps, 1788 std::move(test_stream_data), log_path, run_at_fps,
1784 needs_encode_latency, verify_all_output))); 1789 needs_encode_latency, verify_all_output)));
1785 1790
1786 return RUN_ALL_TESTS(); 1791 return RUN_ALL_TESTS();
1787 } 1792 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698