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

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

Issue 430583005: Make VEA test support videos with different coded size and visible size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address rvargas review comments Created 6 years, 3 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 "base/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/memory_mapped_file.h" 9 #include "base/files/memory_mapped_file.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 15 matching lines...) Expand all
26 #endif 26 #endif
27 27
28 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) 28 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
29 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h" 29 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h"
30 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) 30 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11)
31 #include "content/common/gpu/media/vaapi_video_encode_accelerator.h" 31 #include "content/common/gpu/media/vaapi_video_encode_accelerator.h"
32 #else 32 #else
33 #error The VideoEncodeAcceleratorUnittest is not supported on this platform. 33 #error The VideoEncodeAcceleratorUnittest is not supported on this platform.
34 #endif 34 #endif
35 35
36 #define ALIGN_64_BYTES(x) (((x) + 63) & ~63)
37
36 using media::VideoEncodeAccelerator; 38 using media::VideoEncodeAccelerator;
37 39
38 namespace content { 40 namespace content {
39 namespace { 41 namespace {
40 42
41 const media::VideoFrame::Format kInputFormat = media::VideoFrame::I420; 43 const media::VideoFrame::Format kInputFormat = media::VideoFrame::I420;
42 44
43 // Arbitrarily chosen to add some depth to the pipeline. 45 // Arbitrarily chosen to add some depth to the pipeline.
44 const unsigned int kNumOutputBuffers = 4; 46 const unsigned int kNumOutputBuffers = 4;
45 const unsigned int kNumExtraInputFrames = 4; 47 const unsigned int kNumExtraInputFrames = 4;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 98
97 struct TestStream { 99 struct TestStream {
98 TestStream() 100 TestStream()
99 : requested_bitrate(0), 101 : requested_bitrate(0),
100 requested_framerate(0), 102 requested_framerate(0),
101 requested_subsequent_bitrate(0), 103 requested_subsequent_bitrate(0),
102 requested_subsequent_framerate(0) {} 104 requested_subsequent_framerate(0) {}
103 ~TestStream() {} 105 ~TestStream() {}
104 106
105 gfx::Size size; 107 gfx::Size size;
108 std::string in_filename;
106 base::MemoryMappedFile input_file; 109 base::MemoryMappedFile input_file;
107 media::VideoCodecProfile requested_profile; 110 media::VideoCodecProfile requested_profile;
111 base::FilePath temp_file;
wuchengli 2014/08/27 05:46:24 Add comments for this variable. It's not obvious w
henryhsu 2014/08/27 10:07:28 Done.
108 std::string out_filename; 112 std::string out_filename;
109 unsigned int requested_bitrate; 113 unsigned int requested_bitrate;
110 unsigned int requested_framerate; 114 unsigned int requested_framerate;
111 unsigned int requested_subsequent_bitrate; 115 unsigned int requested_subsequent_bitrate;
112 unsigned int requested_subsequent_framerate; 116 unsigned int requested_subsequent_framerate;
113 }; 117 };
114 118
119 // Use |coded_size| to copy YUV data into memory from |test_stream| input file.
wuchengli 2014/08/27 05:46:24 Explain the result is saved back to test_stream->i
henryhsu 2014/08/27 10:07:27 Done.
120 // Also calculate |input_buffer_size| frame size value.
wuchengli 2014/08/27 05:46:24 Too many sizes here. It's confusing to see "frame
henryhsu 2014/08/27 10:07:27 Done.
121 static bool PrepareAlignedTempFile(const gfx::Size& coded_size,
wuchengli 2014/08/27 05:46:24 Return value not used. Remove. Change the functio
henryhsu 2014/08/27 10:07:28 Done.
122 TestStream* test_stream,
123 size_t* input_buffer_size) {
124 size_t input_num_planes = media::VideoFrame::NumPlanes(kInputFormat);
125 size_t* padding_size = new size_t[input_num_planes];
wuchengli 2014/08/27 05:46:23 nit: I'd use a vector. Up to you. s/padding_size/
henryhsu 2014/08/27 10:07:28 Done.
126 size_t visible_frame_size = 0;
wuchengli 2014/08/27 05:46:24 Just use VideoFrame::AllocationSize.
henryhsu 2014/08/27 10:07:28 Done.
127
128 // YUV plane starting address should be 64 bytes alignment.
129 // Calculate padding size for each plane, and frame size for visible size
130 // and coded size.
131 *input_buffer_size = 0;
132 for (off_t i = 0; i < input_num_planes; i++) {
133 size_t size = media::VideoFrame::PlaneAllocationSize(
134 kInputFormat, i, coded_size);
135 padding_size[i] = ALIGN_64_BYTES(size) - size;
136 visible_frame_size += media::VideoFrame::PlaneAllocationSize(
137 kInputFormat, i, test_stream->size);
138 *input_buffer_size += ALIGN_64_BYTES(size);
139 }
140
141 // Test case may have many encoders and memory should be prepared once.
142 if (!test_stream->input_file.IsValid()) {
wuchengli 2014/08/27 05:46:24 nit: I'd return here to avoid a huge if clause.
henryhsu 2014/08/27 10:07:28 Done.
143 base::MemoryMappedFile input_file;
144 CHECK(base::CreateTemporaryFile(&test_stream->temp_file));
145 CHECK(input_file.Initialize(
146 base::File(base::FilePath(test_stream->in_filename),
147 base::File::FLAG_OPEN |
148 base::File::FLAG_WRITE |
149 base::File::FLAG_READ).Pass()));
150
151 size_t num_frames = input_file.length() / visible_frame_size;
152 uint32 flags = base::File::FLAG_CREATE_ALWAYS |
153 base::File::FLAG_WRITE |
154 base::File::FLAG_READ;
155
156 // Create a temporary file with coded_size length
wuchengli 2014/08/27 05:46:24 add period for consistency
157 base::File file(base::FilePath(test_stream->temp_file), flags);
158 file.Write(*input_buffer_size * num_frames - 1, ".", 1);
wuchengli 2014/08/27 05:46:24 Why do we need to minus one here? Just curious. W
henryhsu 2014/08/27 10:07:27 Because first parameter is offset. We write one by
wuchengli 2014/08/28 08:33:00 Can we use SetLength for this? Is SetLength fast?
159 CHECK(test_stream->input_file.Initialize(file.Pass()));
160
161 off_t src_offset = 0, dest_offset = 0;
162 while (src_offset < static_cast<off_t>(input_file.length())) {
163 for (off_t i = 0; i < input_num_planes; i++) {
164 size_t coded_bpl =
165 media::VideoFrame::RowBytes(i, kInputFormat, coded_size.width());
166 size_t visible_bpl =
167 media::VideoFrame::RowBytes(i, kInputFormat,
168 test_stream->size.width());
169 off_t rows = media::VideoFrame::Rows(i, kInputFormat,
wuchengli 2014/08/27 05:46:25 coded_bpl, visible_bpl, and rows are similar to pa
henryhsu 2014/08/27 10:07:28 Done.
170 test_stream->size.height());
wuchengli 2014/08/27 05:46:24 run git cl format
henryhsu 2014/08/27 10:07:28 Done.
171 for (off_t j = 0; j < rows; j++) {
172 char *src = reinterpret_cast<char*>(
wuchengli 2014/08/27 05:46:24 Use uint8* to avoid both castings? s/char */char*
henryhsu 2014/08/27 10:07:28 Done.
173 const_cast<uint8*>(input_file.data() + src_offset));
174 char *dest = reinterpret_cast<char*>(
175 const_cast<uint8*>(test_stream->input_file.data() + dest_offset));
wuchengli 2014/08/27 05:46:24 Why we do need to cast twice? Can we just use rein
henryhsu 2014/08/27 10:07:28 input_file.data() will return const variable. Use
176 memcpy(dest, src, visible_bpl);
177 src_offset += visible_bpl;
178 dest_offset += coded_bpl;
179 }
180 off_t padding_rows =
181 media::VideoFrame::Rows(i, kInputFormat, coded_size.height()) -
182 rows;
183 dest_offset += padding_rows * coded_bpl + padding_size[i];
wuchengli 2014/08/27 05:46:24 Can we precalculate padding_rows * coded_bpl + pad
henryhsu 2014/08/27 10:07:28 Done.
184 }
185 }
186 }
187 delete[] padding_size;
wuchengli 2014/08/27 05:46:24 Are we done with the temp_file here? If yes, delet
henryhsu 2014/08/27 10:07:28 Done.
188 return true;
189 }
190
115 // Parse |data| into its constituent parts, set the various output fields 191 // Parse |data| into its constituent parts, set the various output fields
116 // accordingly, read in video stream, and store them to |test_streams|. 192 // accordingly, read in video stream, and store them to |test_streams|.
117 static void ParseAndReadTestStreamData(const base::FilePath::StringType& data, 193 static void ParseAndReadTestStreamData(const base::FilePath::StringType& data,
118 ScopedVector<TestStream>* test_streams) { 194 ScopedVector<TestStream>* test_streams) {
119 // Split the string to individual test stream data. 195 // Split the string to individual test stream data.
120 std::vector<base::FilePath::StringType> test_streams_data; 196 std::vector<base::FilePath::StringType> test_streams_data;
121 base::SplitString(data, ';', &test_streams_data); 197 base::SplitString(data, ';', &test_streams_data);
122 CHECK_GE(test_streams_data.size(), 1U) << data; 198 CHECK_GE(test_streams_data.size(), 1U) << data;
123 199
124 // Parse each test stream data and read the input file. 200 // Parse each test stream data and read the input file.
125 for (size_t index = 0; index < test_streams_data.size(); ++index) { 201 for (size_t index = 0; index < test_streams_data.size(); ++index) {
126 std::vector<base::FilePath::StringType> fields; 202 std::vector<base::FilePath::StringType> fields;
127 base::SplitString(test_streams_data[index], ':', &fields); 203 base::SplitString(test_streams_data[index], ':', &fields);
128 CHECK_GE(fields.size(), 4U) << data; 204 CHECK_GE(fields.size(), 4U) << data;
129 CHECK_LE(fields.size(), 9U) << data; 205 CHECK_LE(fields.size(), 9U) << data;
130 TestStream* test_stream = new TestStream(); 206 TestStream* test_stream = new TestStream();
131 207
132 base::FilePath::StringType filename = fields[0]; 208 test_stream->in_filename = fields[0];
133 int width, height; 209 int width, height;
134 CHECK(base::StringToInt(fields[1], &width)); 210 CHECK(base::StringToInt(fields[1], &width));
135 CHECK(base::StringToInt(fields[2], &height)); 211 CHECK(base::StringToInt(fields[2], &height));
136 test_stream->size = gfx::Size(width, height); 212 test_stream->size = gfx::Size(width, height);
137 CHECK(!test_stream->size.IsEmpty()); 213 CHECK(!test_stream->size.IsEmpty());
138 int profile; 214 int profile;
139 CHECK(base::StringToInt(fields[3], &profile)); 215 CHECK(base::StringToInt(fields[3], &profile));
140 CHECK_GT(profile, media::VIDEO_CODEC_PROFILE_UNKNOWN); 216 CHECK_GT(profile, media::VIDEO_CODEC_PROFILE_UNKNOWN);
141 CHECK_LE(profile, media::VIDEO_CODEC_PROFILE_MAX); 217 CHECK_LE(profile, media::VIDEO_CODEC_PROFILE_MAX);
142 test_stream->requested_profile = 218 test_stream->requested_profile =
(...skipping 11 matching lines...) Expand all
154 if (fields.size() >= 8 && !fields[7].empty()) { 230 if (fields.size() >= 8 && !fields[7].empty()) {
155 CHECK(base::StringToUint(fields[7], 231 CHECK(base::StringToUint(fields[7],
156 &test_stream->requested_subsequent_bitrate)); 232 &test_stream->requested_subsequent_bitrate));
157 } 233 }
158 234
159 if (fields.size() >= 9 && !fields[8].empty()) { 235 if (fields.size() >= 9 && !fields[8].empty()) {
160 CHECK(base::StringToUint(fields[8], 236 CHECK(base::StringToUint(fields[8],
161 &test_stream->requested_subsequent_framerate)); 237 &test_stream->requested_subsequent_framerate));
162 } 238 }
163 239
164 CHECK(test_stream->input_file.Initialize(base::FilePath(filename)));
165 test_streams->push_back(test_stream); 240 test_streams->push_back(test_stream);
166 } 241 }
167 } 242 }
168 243
169 // Set default parameters of |test_streams| and update the parameters according 244 // Set default parameters of |test_streams| and update the parameters according
170 // to |mid_stream_bitrate_switch| and |mid_stream_framerate_switch|. 245 // to |mid_stream_bitrate_switch| and |mid_stream_framerate_switch|.
171 static void UpdateTestStreamData(bool mid_stream_bitrate_switch, 246 static void UpdateTestStreamData(bool mid_stream_bitrate_switch,
172 bool mid_stream_framerate_switch, 247 bool mid_stream_framerate_switch,
173 ScopedVector<TestStream>* test_streams) { 248 ScopedVector<TestStream>* test_streams) {
174 for (size_t i = 0; i < test_streams->size(); i++) { 249 for (size_t i = 0; i < test_streams->size(); i++) {
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 CHECK(validator_.get()); 620 CHECK(validator_.get());
546 621
547 if (save_to_file_) { 622 if (save_to_file_) {
548 CHECK(!test_stream_.out_filename.empty()); 623 CHECK(!test_stream_.out_filename.empty());
549 base::FilePath out_filename(test_stream_.out_filename); 624 base::FilePath out_filename(test_stream_.out_filename);
550 // This creates or truncates out_filename. 625 // This creates or truncates out_filename.
551 // Without it, AppendToFile() will not work. 626 // Without it, AppendToFile() will not work.
552 EXPECT_EQ(0, base::WriteFile(out_filename, NULL, 0)); 627 EXPECT_EQ(0, base::WriteFile(out_filename, NULL, 0));
553 } 628 }
554 629
555 input_buffer_size_ =
556 media::VideoFrame::AllocationSize(kInputFormat, test_stream.size);
557 CHECK_GT(input_buffer_size_, 0UL);
558
559 // Calculate the number of frames in the input stream by dividing its length
560 // in bytes by frame size in bytes.
561 CHECK_EQ(test_stream_.input_file.length() % input_buffer_size_, 0U)
562 << "Stream byte size is not a product of calculated frame byte size";
563 num_frames_in_stream_ = test_stream_.input_file.length() / input_buffer_size_;
564 CHECK_GT(num_frames_in_stream_, 0UL);
565 CHECK_LE(num_frames_in_stream_, kMaxFrameNum);
566
567 // We may need to loop over the stream more than once if more frames than
568 // provided is required for bitrate tests.
569 if (force_bitrate_ && num_frames_in_stream_ < kMinFramesForBitrateTests) {
570 DVLOG(1) << "Stream too short for bitrate test (" << num_frames_in_stream_
571 << " frames), will loop it to reach " << kMinFramesForBitrateTests
572 << " frames";
573 num_frames_to_encode_ = kMinFramesForBitrateTests;
574 } else {
575 num_frames_to_encode_ = num_frames_in_stream_;
576 }
577
578 thread_checker_.DetachFromThread(); 630 thread_checker_.DetachFromThread();
579 } 631 }
580 632
581 VEAClient::~VEAClient() { CHECK(!has_encoder()); } 633 VEAClient::~VEAClient() { CHECK(!has_encoder()); }
582 634
583 void VEAClient::CreateEncoder() { 635 void VEAClient::CreateEncoder() {
584 DCHECK(thread_checker_.CalledOnValidThread()); 636 DCHECK(thread_checker_.CalledOnValidThread());
585 CHECK(!has_encoder()); 637 CHECK(!has_encoder());
586 638
587 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) 639 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 return num_encoded_frames_ / duration.InSecondsF(); 674 return num_encoded_frames_ / duration.InSecondsF();
623 } 675 }
624 676
625 void VEAClient::RequireBitstreamBuffers(unsigned int input_count, 677 void VEAClient::RequireBitstreamBuffers(unsigned int input_count,
626 const gfx::Size& input_coded_size, 678 const gfx::Size& input_coded_size,
627 size_t output_size) { 679 size_t output_size) {
628 DCHECK(thread_checker_.CalledOnValidThread()); 680 DCHECK(thread_checker_.CalledOnValidThread());
629 ASSERT_EQ(state_, CS_INITIALIZED); 681 ASSERT_EQ(state_, CS_INITIALIZED);
630 SetState(CS_ENCODING); 682 SetState(CS_ENCODING);
631 683
632 // TODO(posciak): For now we only support input streams that meet encoder 684 PrepareAlignedTempFile(input_coded_size,
633 // size requirements exactly (i.e. coded size == visible size), so that we 685 const_cast<TestStream*>(&test_stream_),
634 // can simply mmap the stream file and feed the encoder directly with chunks 686 &input_buffer_size_);
635 // of that, instead of memcpying from mmapped file into a separate set of 687 CHECK_GT(input_buffer_size_, 0UL);
636 // input buffers that would meet the coded size and alignment requirements. 688
637 // If/when this is changed, the ARM-specific alignment check below should be 689 // Calculate the number of frames in the input stream by dividing its length
638 // redone as well. 690 // in bytes by frame size in bytes.
691 CHECK_EQ(test_stream_.input_file.length() % input_buffer_size_, 0U)
692 << "Stream byte size is not a product of calculated frame byte size";
693 num_frames_in_stream_ = test_stream_.input_file.length() / input_buffer_size_;
694 CHECK_GT(num_frames_in_stream_, 0UL);
695 CHECK_LE(num_frames_in_stream_, kMaxFrameNum);
696
697 // We may need to loop over the stream more than once if more frames than
698 // provided is required for bitrate tests.
699 if (force_bitrate_ && num_frames_in_stream_ < kMinFramesForBitrateTests) {
700 DVLOG(1) << "Stream too short for bitrate test (" << num_frames_in_stream_
701 << " frames), will loop it to reach " << kMinFramesForBitrateTests
702 << " frames";
703 num_frames_to_encode_ = kMinFramesForBitrateTests;
704 } else {
705 num_frames_to_encode_ = num_frames_in_stream_;
706 }
707
639 input_coded_size_ = input_coded_size; 708 input_coded_size_ = input_coded_size;
640 ASSERT_EQ(input_coded_size_, test_stream_.size);
641 #if defined(ARCH_CPU_ARMEL) 709 #if defined(ARCH_CPU_ARMEL)
wuchengli 2014/08/27 05:46:24 I think this paragraph should be moved to the func
henryhsu 2014/08/27 10:07:28 Done.
642 // ARM performs CPU cache management with CPU cache line granularity. We thus 710 // ARM performs CPU cache management with CPU cache line granularity. We thus
643 // need to ensure our buffers are CPU cache line-aligned (64 byte-aligned). 711 // need to ensure our buffers are CPU cache line-aligned (64 byte-aligned).
644 // Otherwise newer kernels will refuse to accept them, and on older kernels 712 // Otherwise newer kernels will refuse to accept them, and on older kernels
645 // we'll be treating ourselves to random corruption. 713 // we'll be treating ourselves to random corruption.
646 // Since we are just mmapping and passing chunks of the input file, to ensure 714 // Since we are just mmapping and passing chunks of the input file, to ensure
647 // alignment, if the starting virtual addresses of the frames in it were not 715 // alignment, if the starting virtual addresses of YUV planes of the frames
648 // 64 byte-aligned, we'd have to use a separate set of input buffers and copy 716 // in it were not 64 byte-aligned, we'd have to use a separate set of input
649 // the frames into them before sending to the encoder. It would have been an 717 // buffers and copy the frames into them before sending to the encoder.
650 // overkill here though, because, for now at least, we only test resolutions 718 // Now we test resolutions differ from coded size and prepare chunks before
wuchengli 2014/08/27 05:46:24 s/differ/different/. Differ is a verb.
henryhsu 2014/08/27 10:07:28 Done.
651 // that result in proper alignment, and it would have also interfered with 719 // testing to avoid performance impact.
652 // performance testing. So just assert that the frame size is a multiple of 720 // So just assert that the frame size is a multiple of 64 bytes.
wuchengli 2014/08/27 05:46:24 Do you intend to make this a paragraph? If not, th
henryhsu 2014/08/27 10:07:27 Done.
653 // 64 bytes. This ensures all frames start at 64-byte boundary, because 721 // This ensures all frames start at 64-byte boundary, because
wuchengli 2014/08/27 05:46:24 80 chars alignment. This should be in the previous
henryhsu 2014/08/27 10:07:28 Done.
654 // MemoryMappedFile should be mmapp()ed at virtual page start as well. 722 // MemoryMappedFile should be mmapp()ed at virtual page start as well.
655 ASSERT_EQ(input_buffer_size_ & 63, 0u) 723 ASSERT_EQ(input_buffer_size_ & 63, 0u)
656 << "Frame size has to be a multiple of 64 bytes"; 724 << "Frame size has to be a multiple of 64 bytes";
657 ASSERT_EQ(reinterpret_cast<off_t>(test_stream_.input_file.data()) & 63, 0) 725 ASSERT_EQ(reinterpret_cast<off_t>(test_stream_.input_file.data()) & 63, 0)
658 << "Mapped file should be mapped at a 64 byte boundary"; 726 << "Mapped file should be mapped at a 64 byte boundary";
659 #endif 727 #endif
660 728
661 num_required_input_buffers_ = input_count; 729 num_required_input_buffers_ = input_count;
662 ASSERT_GT(num_required_input_buffers_, 0UL); 730 ASSERT_GT(num_required_input_buffers_, 0UL);
663 731
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 void VEAClient::InputNoLongerNeededCallback(int32 input_id) { 804 void VEAClient::InputNoLongerNeededCallback(int32 input_id) {
737 std::set<int32>::iterator it = inputs_at_client_.find(input_id); 805 std::set<int32>::iterator it = inputs_at_client_.find(input_id);
738 ASSERT_NE(it, inputs_at_client_.end()); 806 ASSERT_NE(it, inputs_at_client_.end());
739 inputs_at_client_.erase(it); 807 inputs_at_client_.erase(it);
740 FeedEncoderWithInputs(); 808 FeedEncoderWithInputs();
741 } 809 }
742 810
743 scoped_refptr<media::VideoFrame> VEAClient::PrepareInputFrame(off_t position) { 811 scoped_refptr<media::VideoFrame> VEAClient::PrepareInputFrame(off_t position) {
744 CHECK_LE(position + input_buffer_size_, test_stream_.input_file.length()); 812 CHECK_LE(position + input_buffer_size_, test_stream_.input_file.length());
745 813
746 uint8* frame_data = 814 uint8* frame_data_y =
747 const_cast<uint8*>(test_stream_.input_file.data() + position); 815 const_cast<uint8*>(test_stream_.input_file.data() + position);
816 uint8* frame_data_u = frame_data_y +
817 ALIGN_64_BYTES(media::VideoFrame::PlaneAllocationSize(
818 kInputFormat, 0, input_coded_size_));
819 uint8* frame_data_v = frame_data_u +
820 ALIGN_64_BYTES(media::VideoFrame::PlaneAllocationSize(
821 kInputFormat, 1, input_coded_size_));
748 822
749 CHECK_GT(current_framerate_, 0U); 823 CHECK_GT(current_framerate_, 0U);
750 scoped_refptr<media::VideoFrame> frame = 824 scoped_refptr<media::VideoFrame> frame =
751 media::VideoFrame::WrapExternalYuvData( 825 media::VideoFrame::WrapExternalYuvData(
752 kInputFormat, 826 kInputFormat,
753 input_coded_size_, 827 input_coded_size_,
754 gfx::Rect(test_stream_.size), 828 gfx::Rect(test_stream_.size),
755 test_stream_.size, 829 test_stream_.size,
756 input_coded_size_.width(), 830 input_coded_size_.width(),
757 input_coded_size_.width() / 2, 831 input_coded_size_.width() / 2,
758 input_coded_size_.width() / 2, 832 input_coded_size_.width() / 2,
759 frame_data, 833 frame_data_y,
760 frame_data + input_coded_size_.GetArea(), 834 frame_data_u,
761 frame_data + (input_coded_size_.GetArea() * 5 / 4), 835 frame_data_v,
762 base::TimeDelta().FromMilliseconds( 836 base::TimeDelta().FromMilliseconds(
763 next_input_id_ * base::Time::kMillisecondsPerSecond / 837 next_input_id_ * base::Time::kMillisecondsPerSecond /
764 current_framerate_), 838 current_framerate_),
765 media::BindToCurrentLoop( 839 media::BindToCurrentLoop(
766 base::Bind(&VEAClient::InputNoLongerNeededCallback, 840 base::Bind(&VEAClient::InputNoLongerNeededCallback,
767 base::Unretained(this), 841 base::Unretained(this),
768 next_input_id_))); 842 next_input_id_)));
769 843
770 CHECK(inputs_at_client_.insert(next_input_id_).second); 844 CHECK(inputs_at_client_.insert(next_input_id_).second);
771 ++next_input_id_; 845 ++next_input_id_;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 for (size_t state_no = 0; state_no < arraysize(state_transitions); ++state_no) 1040 for (size_t state_no = 0; state_no < arraysize(state_transitions); ++state_no)
967 for (size_t i = 0; i < num_concurrent_encoders; i++) 1041 for (size_t i = 0; i < num_concurrent_encoders; i++)
968 ASSERT_EQ(notes[i]->Wait(), state_transitions[state_no]); 1042 ASSERT_EQ(notes[i]->Wait(), state_transitions[state_no]);
969 1043
970 for (size_t i = 0; i < num_concurrent_encoders; ++i) { 1044 for (size_t i = 0; i < num_concurrent_encoders; ++i) {
971 encoder_thread.message_loop()->PostTask( 1045 encoder_thread.message_loop()->PostTask(
972 FROM_HERE, 1046 FROM_HERE,
973 base::Bind(&VEAClient::DestroyEncoder, base::Unretained(clients[i]))); 1047 base::Bind(&VEAClient::DestroyEncoder, base::Unretained(clients[i])));
974 } 1048 }
975 1049
1050 // Delete temporary files when test finished.
1051 for (size_t i = 0; i < test_streams.size(); i++)
1052 base::DeleteFile(test_streams[i]->temp_file, false);
1053
976 // This ensures all tasks have finished. 1054 // This ensures all tasks have finished.
977 encoder_thread.Stop(); 1055 encoder_thread.Stop();
978 } 1056 }
979 1057
980 INSTANTIATE_TEST_CASE_P( 1058 INSTANTIATE_TEST_CASE_P(
981 SimpleEncode, 1059 SimpleEncode,
982 VideoEncodeAcceleratorTest, 1060 VideoEncodeAcceleratorTest,
983 ::testing::Values(MakeTuple(1, true, 0, false, false, false, false))); 1061 ::testing::Values(MakeTuple(1, true, 0, false, false, false, false)));
984 1062
985 INSTANTIATE_TEST_CASE_P( 1063 INSTANTIATE_TEST_CASE_P(
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 test_stream_data->assign(it->second.c_str()); 1132 test_stream_data->assign(it->second.c_str());
1055 continue; 1133 continue;
1056 } 1134 }
1057 if (it->first == "v" || it->first == "vmodule") 1135 if (it->first == "v" || it->first == "vmodule")
1058 continue; 1136 continue;
1059 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; 1137 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second;
1060 } 1138 }
1061 1139
1062 return RUN_ALL_TESTS(); 1140 return RUN_ALL_TESTS();
1063 } 1141 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698