Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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; |
| 108 std::string out_filename; | 111 std::string out_filename; |
| 109 unsigned int requested_bitrate; | 112 unsigned int requested_bitrate; |
| 110 unsigned int requested_framerate; | 113 unsigned int requested_framerate; |
| 111 unsigned int requested_subsequent_bitrate; | 114 unsigned int requested_subsequent_bitrate; |
| 112 unsigned int requested_subsequent_framerate; | 115 unsigned int requested_subsequent_framerate; |
| 113 }; | 116 }; |
| 114 | 117 |
| 118 // ARM performs CPU cache management with CPU cache line granularity. We thus | |
| 119 // need to ensure our buffers are CPU cache line-aligned (64 byte-aligned). | |
| 120 // Otherwise newer kernels will refuse to accept them, and on older kernels | |
| 121 // we'll be treating ourselves to random corruption. | |
| 122 // Since we are just mmapping and passing chunks of the input file, to ensure | |
| 123 // alignment, if the starting virtual addresses of YUV planes of the frames | |
| 124 // in it were not 64 byte-aligned, we'd have to prepare a memory with 64 | |
| 125 // byte-aligned starting address and make sure the addresses of YUV planes of | |
| 126 // each frame are 64 byte-aligned before sending to the encoder. | |
| 127 // Now we test resolutions different from coded size and prepare chunks before | |
| 128 // encoding to avoid performance impact. | |
| 129 // Use |visible_size| and |coded_size| to copy YUV data into memory from | |
| 130 // |in_filename|. The copied result will be saved in |input_file|. Also | |
| 131 // calculate the byte size of an input frame and set it to |coded_buffer_size|. | |
| 132 static void PrepareInputBuffers(const gfx::Size& visible_size, | |
| 133 const gfx::Size& coded_size, | |
| 134 const std::string in_filename, | |
| 135 base::MemoryMappedFile* input_file, | |
| 136 size_t* coded_buffer_size) { | |
| 137 base::FilePath temp_file; | |
| 138 size_t input_num_planes = media::VideoFrame::NumPlanes(kInputFormat); | |
| 139 std::vector<size_t> padding_sizes(input_num_planes); | |
| 140 std::vector<size_t> coded_bpl(input_num_planes); | |
| 141 std::vector<size_t> visible_bpl(input_num_planes); | |
| 142 std::vector<size_t> visible_plane_rows(input_num_planes); | |
| 143 | |
| 144 // YUV plane starting address should be 64 bytes alignment. | |
| 145 // Calculate padding size for each plane, and frame allocation size for | |
|
wuchengli
2014/08/28 10:17:48
80 char aligned. Move this with the previous line.
henryhsu
2014/08/29 06:36:41
Done.
| |
| 146 // coded size. And also store bytes per line information of coded size and | |
|
wuchengli
2014/08/28 10:17:48
s/And also/Also/
henryhsu
2014/08/29 06:36:41
Done.
| |
| 147 // visible size. | |
| 148 *coded_buffer_size = 0; | |
| 149 for (off_t i = 0; i < input_num_planes; i++) { | |
| 150 size_t size = | |
| 151 media::VideoFrame::PlaneAllocationSize(kInputFormat, i, coded_size); | |
| 152 size_t padding_bytes = ALIGN_64_BYTES(size) - size; | |
| 153 | |
| 154 coded_bpl[i] = | |
| 155 media::VideoFrame::RowBytes(i, kInputFormat, coded_size.width()); | |
| 156 visible_bpl[i] = | |
| 157 media::VideoFrame::RowBytes(i, kInputFormat, visible_size.width()); | |
| 158 visible_plane_rows[i] = | |
| 159 media::VideoFrame::Rows(i, kInputFormat, visible_size.height()); | |
| 160 size_t padding_rows = | |
| 161 media::VideoFrame::Rows(i, kInputFormat, coded_size.height()) - | |
| 162 visible_plane_rows[i]; | |
| 163 padding_sizes[i] = padding_rows * coded_bpl[i] + padding_bytes; | |
| 164 *coded_buffer_size += ALIGN_64_BYTES(size); | |
|
wuchengli
2014/08/28 10:17:48
Move this after padding_bytes so the use of |size|
henryhsu
2014/08/29 06:36:41
Done.
| |
| 165 } | |
| 166 | |
| 167 // Test case may have many encoders and memory should be prepared once. | |
| 168 if (input_file->IsValid()) | |
| 169 return; | |
| 170 | |
| 171 base::MemoryMappedFile src_file; | |
| 172 CHECK(base::CreateTemporaryFile(&temp_file)); | |
| 173 CHECK(src_file.Initialize(base::FilePath(in_filename))); | |
| 174 | |
| 175 size_t visible_buffer_size = | |
| 176 media::VideoFrame::AllocationSize(kInputFormat, visible_size); | |
| 177 size_t num_frames = src_file.length() / visible_buffer_size; | |
| 178 uint32 flags = base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE | | |
| 179 base::File::FLAG_READ; | |
| 180 | |
| 181 // Create a temporary file with coded_size length. | |
| 182 base::File file(base::FilePath(temp_file), flags); | |
| 183 file.Write(*coded_buffer_size * num_frames - 1, ".", 1); | |
|
wuchengli
2014/08/28 10:17:48
Can we use SetLength for this? Is SetLength fast?
henryhsu
2014/08/29 06:36:41
Done.
| |
| 184 CHECK(input_file->Initialize(file.Pass(), true)); | |
| 185 | |
| 186 off_t src_offset = 0, dest_offset = 0; | |
| 187 while (src_offset < static_cast<off_t>(src_file.length())) { | |
| 188 for (off_t i = 0; i < input_num_planes; i++) { | |
| 189 #if defined(ARCH_CPU_ARMEL) | |
| 190 // Assert that each plane of frame starts at 64-byte boundary. | |
| 191 const uint8* ptr = input_file->data() + dest_offset; | |
| 192 ASSERT_EQ(reinterpret_cast<off_t>(ptr) & 63, 0) | |
| 193 << "Planes of frame should be mapped at a 64 byte boundary"; | |
| 194 #endif | |
| 195 for (off_t j = 0; j < visible_plane_rows[i]; j++) { | |
| 196 const uint8* src = src_file.data() + src_offset; | |
| 197 uint8* dest = const_cast<uint8*>(input_file->data() + dest_offset); | |
|
wuchengli
2014/08/28 10:17:48
We should not return a const and access it. Maybe
henryhsu
2014/08/29 06:36:41
Done.
| |
| 198 memcpy(dest, src, visible_bpl[i]); | |
| 199 src_offset += visible_bpl[i]; | |
| 200 dest_offset += coded_bpl[i]; | |
| 201 } | |
| 202 dest_offset += padding_sizes[i]; | |
| 203 } | |
| 204 } | |
| 205 base::DeleteFile(temp_file, false); | |
| 206 } | |
| 207 | |
| 115 // Parse |data| into its constituent parts, set the various output fields | 208 // Parse |data| into its constituent parts, set the various output fields |
| 116 // accordingly, read in video stream, and store them to |test_streams|. | 209 // accordingly, read in video stream, and store them to |test_streams|. |
| 117 static void ParseAndReadTestStreamData(const base::FilePath::StringType& data, | 210 static void ParseAndReadTestStreamData(const base::FilePath::StringType& data, |
| 118 ScopedVector<TestStream>* test_streams) { | 211 ScopedVector<TestStream>* test_streams) { |
| 119 // Split the string to individual test stream data. | 212 // Split the string to individual test stream data. |
| 120 std::vector<base::FilePath::StringType> test_streams_data; | 213 std::vector<base::FilePath::StringType> test_streams_data; |
| 121 base::SplitString(data, ';', &test_streams_data); | 214 base::SplitString(data, ';', &test_streams_data); |
| 122 CHECK_GE(test_streams_data.size(), 1U) << data; | 215 CHECK_GE(test_streams_data.size(), 1U) << data; |
| 123 | 216 |
| 124 // Parse each test stream data and read the input file. | 217 // Parse each test stream data and read the input file. |
| 125 for (size_t index = 0; index < test_streams_data.size(); ++index) { | 218 for (size_t index = 0; index < test_streams_data.size(); ++index) { |
| 126 std::vector<base::FilePath::StringType> fields; | 219 std::vector<base::FilePath::StringType> fields; |
| 127 base::SplitString(test_streams_data[index], ':', &fields); | 220 base::SplitString(test_streams_data[index], ':', &fields); |
| 128 CHECK_GE(fields.size(), 4U) << data; | 221 CHECK_GE(fields.size(), 4U) << data; |
| 129 CHECK_LE(fields.size(), 9U) << data; | 222 CHECK_LE(fields.size(), 9U) << data; |
| 130 TestStream* test_stream = new TestStream(); | 223 TestStream* test_stream = new TestStream(); |
| 131 | 224 |
| 132 base::FilePath::StringType filename = fields[0]; | 225 test_stream->in_filename = fields[0]; |
| 133 int width, height; | 226 int width, height; |
| 134 CHECK(base::StringToInt(fields[1], &width)); | 227 CHECK(base::StringToInt(fields[1], &width)); |
| 135 CHECK(base::StringToInt(fields[2], &height)); | 228 CHECK(base::StringToInt(fields[2], &height)); |
| 136 test_stream->size = gfx::Size(width, height); | 229 test_stream->size = gfx::Size(width, height); |
| 137 CHECK(!test_stream->size.IsEmpty()); | 230 CHECK(!test_stream->size.IsEmpty()); |
| 138 int profile; | 231 int profile; |
| 139 CHECK(base::StringToInt(fields[3], &profile)); | 232 CHECK(base::StringToInt(fields[3], &profile)); |
| 140 CHECK_GT(profile, media::VIDEO_CODEC_PROFILE_UNKNOWN); | 233 CHECK_GT(profile, media::VIDEO_CODEC_PROFILE_UNKNOWN); |
| 141 CHECK_LE(profile, media::VIDEO_CODEC_PROFILE_MAX); | 234 CHECK_LE(profile, media::VIDEO_CODEC_PROFILE_MAX); |
| 142 test_stream->requested_profile = | 235 test_stream->requested_profile = |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 154 if (fields.size() >= 8 && !fields[7].empty()) { | 247 if (fields.size() >= 8 && !fields[7].empty()) { |
| 155 CHECK(base::StringToUint(fields[7], | 248 CHECK(base::StringToUint(fields[7], |
| 156 &test_stream->requested_subsequent_bitrate)); | 249 &test_stream->requested_subsequent_bitrate)); |
| 157 } | 250 } |
| 158 | 251 |
| 159 if (fields.size() >= 9 && !fields[8].empty()) { | 252 if (fields.size() >= 9 && !fields[8].empty()) { |
| 160 CHECK(base::StringToUint(fields[8], | 253 CHECK(base::StringToUint(fields[8], |
| 161 &test_stream->requested_subsequent_framerate)); | 254 &test_stream->requested_subsequent_framerate)); |
| 162 } | 255 } |
| 163 | 256 |
| 164 CHECK(test_stream->input_file.Initialize(base::FilePath(filename))); | |
| 165 test_streams->push_back(test_stream); | 257 test_streams->push_back(test_stream); |
| 166 } | 258 } |
| 167 } | 259 } |
| 168 | 260 |
| 169 // Set default parameters of |test_streams| and update the parameters according | 261 // Set default parameters of |test_streams| and update the parameters according |
| 170 // to |mid_stream_bitrate_switch| and |mid_stream_framerate_switch|. | 262 // to |mid_stream_bitrate_switch| and |mid_stream_framerate_switch|. |
| 171 static void UpdateTestStreamData(bool mid_stream_bitrate_switch, | 263 static void UpdateTestStreamData(bool mid_stream_bitrate_switch, |
| 172 bool mid_stream_framerate_switch, | 264 bool mid_stream_framerate_switch, |
| 173 ScopedVector<TestStream>* test_streams) { | 265 ScopedVector<TestStream>* test_streams) { |
| 174 for (size_t i = 0; i < test_streams->size(); i++) { | 266 for (size_t i = 0; i < test_streams->size(); i++) { |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 545 CHECK(validator_.get()); | 637 CHECK(validator_.get()); |
| 546 | 638 |
| 547 if (save_to_file_) { | 639 if (save_to_file_) { |
| 548 CHECK(!test_stream_.out_filename.empty()); | 640 CHECK(!test_stream_.out_filename.empty()); |
| 549 base::FilePath out_filename(test_stream_.out_filename); | 641 base::FilePath out_filename(test_stream_.out_filename); |
| 550 // This creates or truncates out_filename. | 642 // This creates or truncates out_filename. |
| 551 // Without it, AppendToFile() will not work. | 643 // Without it, AppendToFile() will not work. |
| 552 EXPECT_EQ(0, base::WriteFile(out_filename, NULL, 0)); | 644 EXPECT_EQ(0, base::WriteFile(out_filename, NULL, 0)); |
| 553 } | 645 } |
| 554 | 646 |
| 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(); | 647 thread_checker_.DetachFromThread(); |
| 579 } | 648 } |
| 580 | 649 |
| 581 VEAClient::~VEAClient() { CHECK(!has_encoder()); } | 650 VEAClient::~VEAClient() { CHECK(!has_encoder()); } |
| 582 | 651 |
| 583 void VEAClient::CreateEncoder() { | 652 void VEAClient::CreateEncoder() { |
| 584 DCHECK(thread_checker_.CalledOnValidThread()); | 653 DCHECK(thread_checker_.CalledOnValidThread()); |
| 585 CHECK(!has_encoder()); | 654 CHECK(!has_encoder()); |
| 586 | 655 |
| 587 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 656 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 622 return num_encoded_frames_ / duration.InSecondsF(); | 691 return num_encoded_frames_ / duration.InSecondsF(); |
| 623 } | 692 } |
| 624 | 693 |
| 625 void VEAClient::RequireBitstreamBuffers(unsigned int input_count, | 694 void VEAClient::RequireBitstreamBuffers(unsigned int input_count, |
| 626 const gfx::Size& input_coded_size, | 695 const gfx::Size& input_coded_size, |
| 627 size_t output_size) { | 696 size_t output_size) { |
| 628 DCHECK(thread_checker_.CalledOnValidThread()); | 697 DCHECK(thread_checker_.CalledOnValidThread()); |
| 629 ASSERT_EQ(state_, CS_INITIALIZED); | 698 ASSERT_EQ(state_, CS_INITIALIZED); |
| 630 SetState(CS_ENCODING); | 699 SetState(CS_ENCODING); |
| 631 | 700 |
| 632 // TODO(posciak): For now we only support input streams that meet encoder | 701 PrepareInputBuffers( |
| 633 // size requirements exactly (i.e. coded size == visible size), so that we | 702 test_stream_.size, |
| 634 // can simply mmap the stream file and feed the encoder directly with chunks | 703 input_coded_size, |
| 635 // of that, instead of memcpying from mmapped file into a separate set of | 704 test_stream_.in_filename, |
| 636 // input buffers that would meet the coded size and alignment requirements. | 705 const_cast<base::MemoryMappedFile*>(&test_stream_.input_file), |
|
wuchengli
2014/08/28 10:17:48
We should remove the const of test_stream_ because
henryhsu
2014/08/29 06:36:41
Done.
| |
| 637 // If/when this is changed, the ARM-specific alignment check below should be | 706 &input_buffer_size_); |
| 638 // redone as well. | 707 CHECK_GT(input_buffer_size_, 0UL); |
| 708 | |
| 709 // Calculate the number of frames in the input stream by dividing its length | |
| 710 // in bytes by frame size in bytes. | |
| 711 CHECK_EQ(test_stream_.input_file.length() % input_buffer_size_, 0U) | |
| 712 << "Stream byte size is not a product of calculated frame byte size"; | |
| 713 num_frames_in_stream_ = test_stream_.input_file.length() / input_buffer_size_; | |
| 714 CHECK_GT(num_frames_in_stream_, 0UL); | |
| 715 CHECK_LE(num_frames_in_stream_, kMaxFrameNum); | |
| 716 | |
| 717 // We may need to loop over the stream more than once if more frames than | |
| 718 // provided is required for bitrate tests. | |
| 719 if (force_bitrate_ && num_frames_in_stream_ < kMinFramesForBitrateTests) { | |
| 720 DVLOG(1) << "Stream too short for bitrate test (" << num_frames_in_stream_ | |
| 721 << " frames), will loop it to reach " << kMinFramesForBitrateTests | |
| 722 << " frames"; | |
| 723 num_frames_to_encode_ = kMinFramesForBitrateTests; | |
| 724 } else { | |
| 725 num_frames_to_encode_ = num_frames_in_stream_; | |
| 726 } | |
| 727 | |
| 639 input_coded_size_ = input_coded_size; | 728 input_coded_size_ = input_coded_size; |
| 640 ASSERT_EQ(input_coded_size_, test_stream_.size); | |
| 641 #if defined(ARCH_CPU_ARMEL) | |
| 642 // 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). | |
| 644 // Otherwise newer kernels will refuse to accept them, and on older kernels | |
| 645 // we'll be treating ourselves to random corruption. | |
| 646 // 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 | |
| 648 // 64 byte-aligned, we'd have to use a separate set of input buffers and copy | |
| 649 // the frames into them before sending to the encoder. It would have been an | |
| 650 // overkill here though, because, for now at least, we only test resolutions | |
| 651 // that result in proper alignment, and it would have also interfered with | |
| 652 // performance testing. So just assert that the frame size is a multiple of | |
| 653 // 64 bytes. This ensures all frames start at 64-byte boundary, because | |
| 654 // MemoryMappedFile should be mmapp()ed at virtual page start as well. | |
| 655 ASSERT_EQ(input_buffer_size_ & 63, 0u) | |
| 656 << "Frame size has to be a multiple of 64 bytes"; | |
| 657 ASSERT_EQ(reinterpret_cast<off_t>(test_stream_.input_file.data()) & 63, 0) | |
| 658 << "Mapped file should be mapped at a 64 byte boundary"; | |
| 659 #endif | |
| 660 | |
| 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 |
| 664 output_buffer_size_ = output_size; | 732 output_buffer_size_ = output_size; |
| 665 ASSERT_GT(output_buffer_size_, 0UL); | 733 ASSERT_GT(output_buffer_size_, 0UL); |
| 666 | 734 |
| 667 for (unsigned int i = 0; i < kNumOutputBuffers; ++i) { | 735 for (unsigned int i = 0; i < kNumOutputBuffers; ++i) { |
| 668 base::SharedMemory* shm = new base::SharedMemory(); | 736 base::SharedMemory* shm = new base::SharedMemory(); |
| 669 CHECK(shm->CreateAndMapAnonymous(output_buffer_size_)); | 737 CHECK(shm->CreateAndMapAnonymous(output_buffer_size_)); |
| 670 output_shms_.push_back(shm); | 738 output_shms_.push_back(shm); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 = | |
| 817 frame_data_y + ALIGN_64_BYTES(media::VideoFrame::PlaneAllocationSize( | |
| 818 kInputFormat, 0, input_coded_size_)); | |
| 819 uint8* frame_data_v = | |
| 820 frame_data_u + 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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1054 test_stream_data->assign(it->second.c_str()); | 1128 test_stream_data->assign(it->second.c_str()); |
| 1055 continue; | 1129 continue; |
| 1056 } | 1130 } |
| 1057 if (it->first == "v" || it->first == "vmodule") | 1131 if (it->first == "v" || it->first == "vmodule") |
| 1058 continue; | 1132 continue; |
| 1059 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; | 1133 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; |
| 1060 } | 1134 } |
| 1061 | 1135 |
| 1062 return RUN_ALL_TESTS(); | 1136 return RUN_ALL_TESTS(); |
| 1063 } | 1137 } |
| OLD | NEW |