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

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 review comments of patch set 7 and 8 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;
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 use a separate set of input
wuchengli 2014/08/28 08:33:00 Please remove "use a separate set of input buffers
henryhsu 2014/08/28 09:36:45 Done.
125 // buffers and copy the frames into them before sending to the encoder.
126 // Now we test resolutions different from coded size and prepare chunks before
127 // testing to avoid performance impact.
wuchengli 2014/08/28 08:33:01 s/testing/encoding/
henryhsu 2014/08/28 09:36:44 Done.
128 // Use |coded_size| to copy YUV data into memory from |test_stream| input file.
129 // The copyied result will be saved in test_stream->input_file.
wuchengli 2014/08/28 08:33:01 s/copyied/copied/
henryhsu 2014/08/28 09:36:45 Done.
130 // Also calculate the byte size of an input frame and set it to
131 // |input_buffer_size|.
132 static void PrepareInputMemory(const gfx::Size& coded_size,
133 TestStream* test_stream,
wuchengli 2014/08/28 08:33:01 It is clearer to pass test_stream->size, test_stre
henryhsu 2014/08/28 09:36:44 Done.
134 size_t* input_buffer_size) {
135 base::FilePath temp_file;
136 size_t input_num_planes = media::VideoFrame::NumPlanes(kInputFormat);
137 std::vector<size_t> padding_sizes(input_num_planes);
138 std::vector<size_t> coded_bpl(input_num_planes);
139 std::vector<size_t> visible_bpl(input_num_planes);
140 std::vector<size_t> visible_plane_rows(input_num_planes);
141 size_t visible_frame_size =
wuchengli 2014/08/28 08:33:01 I think it's easier to understand to s/visible_fra
henryhsu 2014/08/28 09:36:45 Done.
142 media::VideoFrame::AllocationSize(kInputFormat, test_stream->size);
143
144 // YUV plane starting address should be 64 bytes alignment.
145 // Calculate padding size for each plane, and frame size for visible size
wuchengli 2014/08/28 08:33:00 s/frame size/frame allocation size/. Remove visibl
henryhsu 2014/08/28 09:36:44 Done.
146 // and coded size.
147 *input_buffer_size = 0;
148 for (off_t i = 0; i < input_num_planes; i++) {
149 size_t size =
150 media::VideoFrame::PlaneAllocationSize(kInputFormat, i, coded_size);
151 size_t padding_bytes = ALIGN_64_BYTES(size) - size;
152
153 coded_bpl[i] =
154 media::VideoFrame::RowBytes(i, kInputFormat, coded_size.width());
155 visible_bpl[i] =
156 media::VideoFrame::RowBytes(i, kInputFormat, test_stream->size.width());
157 visible_plane_rows[i] =
158 media::VideoFrame::Rows(i, kInputFormat, test_stream->size.height());
159 size_t padding_rows =
160 media::VideoFrame::Rows(i, kInputFormat, coded_size.height()) -
161 visible_plane_rows[i];
162 padding_sizes[i] = padding_rows * coded_bpl[i] + padding_bytes;
163 *input_buffer_size += ALIGN_64_BYTES(size);
164 }
165
166 // Test case may have many encoders and memory should be prepared once.
167 if (test_stream->input_file.IsValid())
168 return;
169
170 base::MemoryMappedFile input_file;
171 CHECK(base::CreateTemporaryFile(&temp_file));
172 CHECK(input_file.Initialize(base::FilePath(test_stream->in_filename)));
173
174 size_t num_frames = input_file.length() / visible_frame_size;
175 uint32 flags = base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE |
176 base::File::FLAG_READ;
177
178 // Create a temporary file with coded_size length.
179 base::File file(base::FilePath(temp_file), flags);
180 file.Write(*input_buffer_size * num_frames - 1, ".", 1);
181 CHECK(test_stream->input_file.Initialize(file.Pass()));
182
183 #if defined(ARCH_CPU_ARMEL)
184 // Assert that the frame size is a multiple of 64 bytes. This ensures all
185 // frames start at 64-byte boundary, because MemoryMappedFile should be
186 // mmap()ed at virtual page start as well.
187 ASSERT_EQ(*input_buffer_size & 63, 0u)
wuchengli 2014/08/28 08:33:01 This can be removed. The above for loop ensured it
henryhsu 2014/08/28 09:36:44 Done.
188 << "Frame size has to be a multiple of 64 bytes";
189 ASSERT_EQ(reinterpret_cast<off_t>(test_stream->input_file.data()) & 63, 0)
wuchengli 2014/08/28 08:33:01 This can be removed. The first time of ASSERT_EQ b
henryhsu 2014/08/28 09:36:44 Done.
190 << "Mapped file should be mapped at a 64 byte boundary";
191 #endif
192
193 off_t src_offset = 0, dest_offset = 0;
194 while (src_offset < static_cast<off_t>(input_file.length())) {
195 for (off_t i = 0; i < input_num_planes; i++) {
196 #if defined(ARCH_CPU_ARMEL)
197 // Assert that each plane of frame starts at 64-byte boundary.
198 uint8* ptr =
199 const_cast<uint8*>(test_stream->input_file.data() + dest_offset);
200 ASSERT_EQ(reinterpret_cast<off_t>(ptr) & 63, 0)
201 << "Planes of frame should be mapped at a 64 byte boundary";
202 #endif
203 for (off_t j = 0; j < visible_plane_rows[i]; j++) {
204 uint8* src = const_cast<uint8*>(input_file.data() + src_offset);
wuchengli 2014/08/28 08:33:01 nit: |src| can be const and the casting can be rem
henryhsu 2014/08/28 09:36:45 Done.
205 uint8* dest =
206 const_cast<uint8*>(test_stream->input_file.data() + dest_offset);
207 memcpy(dest, src, visible_bpl[i]);
208 src_offset += visible_bpl[i];
209 dest_offset += coded_bpl[i];
210 }
211 dest_offset += padding_sizes[i];
212 }
213 }
214 base::DeleteFile(temp_file, false);
wuchengli 2014/08/28 08:33:00 Can we delete the file and still access it from te
henryhsu 2014/08/28 09:36:44 Yes, I tried this and encoded results are correct.
wuchengli 2014/08/28 10:17:48 This doesn't make sense. Why we can access the map
henryhsu 2014/08/29 06:36:40 Not sure. But for safety, we can rollback to origi
215 }
216
115 // Parse |data| into its constituent parts, set the various output fields 217 // Parse |data| into its constituent parts, set the various output fields
116 // accordingly, read in video stream, and store them to |test_streams|. 218 // accordingly, read in video stream, and store them to |test_streams|.
117 static void ParseAndReadTestStreamData(const base::FilePath::StringType& data, 219 static void ParseAndReadTestStreamData(const base::FilePath::StringType& data,
118 ScopedVector<TestStream>* test_streams) { 220 ScopedVector<TestStream>* test_streams) {
119 // Split the string to individual test stream data. 221 // Split the string to individual test stream data.
120 std::vector<base::FilePath::StringType> test_streams_data; 222 std::vector<base::FilePath::StringType> test_streams_data;
121 base::SplitString(data, ';', &test_streams_data); 223 base::SplitString(data, ';', &test_streams_data);
122 CHECK_GE(test_streams_data.size(), 1U) << data; 224 CHECK_GE(test_streams_data.size(), 1U) << data;
123 225
124 // Parse each test stream data and read the input file. 226 // Parse each test stream data and read the input file.
125 for (size_t index = 0; index < test_streams_data.size(); ++index) { 227 for (size_t index = 0; index < test_streams_data.size(); ++index) {
126 std::vector<base::FilePath::StringType> fields; 228 std::vector<base::FilePath::StringType> fields;
127 base::SplitString(test_streams_data[index], ':', &fields); 229 base::SplitString(test_streams_data[index], ':', &fields);
128 CHECK_GE(fields.size(), 4U) << data; 230 CHECK_GE(fields.size(), 4U) << data;
129 CHECK_LE(fields.size(), 9U) << data; 231 CHECK_LE(fields.size(), 9U) << data;
130 TestStream* test_stream = new TestStream(); 232 TestStream* test_stream = new TestStream();
131 233
132 base::FilePath::StringType filename = fields[0]; 234 test_stream->in_filename = fields[0];
133 int width, height; 235 int width, height;
134 CHECK(base::StringToInt(fields[1], &width)); 236 CHECK(base::StringToInt(fields[1], &width));
135 CHECK(base::StringToInt(fields[2], &height)); 237 CHECK(base::StringToInt(fields[2], &height));
136 test_stream->size = gfx::Size(width, height); 238 test_stream->size = gfx::Size(width, height);
137 CHECK(!test_stream->size.IsEmpty()); 239 CHECK(!test_stream->size.IsEmpty());
138 int profile; 240 int profile;
139 CHECK(base::StringToInt(fields[3], &profile)); 241 CHECK(base::StringToInt(fields[3], &profile));
140 CHECK_GT(profile, media::VIDEO_CODEC_PROFILE_UNKNOWN); 242 CHECK_GT(profile, media::VIDEO_CODEC_PROFILE_UNKNOWN);
141 CHECK_LE(profile, media::VIDEO_CODEC_PROFILE_MAX); 243 CHECK_LE(profile, media::VIDEO_CODEC_PROFILE_MAX);
142 test_stream->requested_profile = 244 test_stream->requested_profile =
(...skipping 11 matching lines...) Expand all
154 if (fields.size() >= 8 && !fields[7].empty()) { 256 if (fields.size() >= 8 && !fields[7].empty()) {
155 CHECK(base::StringToUint(fields[7], 257 CHECK(base::StringToUint(fields[7],
156 &test_stream->requested_subsequent_bitrate)); 258 &test_stream->requested_subsequent_bitrate));
157 } 259 }
158 260
159 if (fields.size() >= 9 && !fields[8].empty()) { 261 if (fields.size() >= 9 && !fields[8].empty()) {
160 CHECK(base::StringToUint(fields[8], 262 CHECK(base::StringToUint(fields[8],
161 &test_stream->requested_subsequent_framerate)); 263 &test_stream->requested_subsequent_framerate));
162 } 264 }
163 265
164 CHECK(test_stream->input_file.Initialize(base::FilePath(filename)));
165 test_streams->push_back(test_stream); 266 test_streams->push_back(test_stream);
166 } 267 }
167 } 268 }
168 269
169 // Set default parameters of |test_streams| and update the parameters according 270 // Set default parameters of |test_streams| and update the parameters according
170 // to |mid_stream_bitrate_switch| and |mid_stream_framerate_switch|. 271 // to |mid_stream_bitrate_switch| and |mid_stream_framerate_switch|.
171 static void UpdateTestStreamData(bool mid_stream_bitrate_switch, 272 static void UpdateTestStreamData(bool mid_stream_bitrate_switch,
172 bool mid_stream_framerate_switch, 273 bool mid_stream_framerate_switch,
173 ScopedVector<TestStream>* test_streams) { 274 ScopedVector<TestStream>* test_streams) {
174 for (size_t i = 0; i < test_streams->size(); i++) { 275 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()); 646 CHECK(validator_.get());
546 647
547 if (save_to_file_) { 648 if (save_to_file_) {
548 CHECK(!test_stream_.out_filename.empty()); 649 CHECK(!test_stream_.out_filename.empty());
549 base::FilePath out_filename(test_stream_.out_filename); 650 base::FilePath out_filename(test_stream_.out_filename);
550 // This creates or truncates out_filename. 651 // This creates or truncates out_filename.
551 // Without it, AppendToFile() will not work. 652 // Without it, AppendToFile() will not work.
552 EXPECT_EQ(0, base::WriteFile(out_filename, NULL, 0)); 653 EXPECT_EQ(0, base::WriteFile(out_filename, NULL, 0));
553 } 654 }
554 655
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(); 656 thread_checker_.DetachFromThread();
579 } 657 }
580 658
581 VEAClient::~VEAClient() { CHECK(!has_encoder()); } 659 VEAClient::~VEAClient() { CHECK(!has_encoder()); }
582 660
583 void VEAClient::CreateEncoder() { 661 void VEAClient::CreateEncoder() {
584 DCHECK(thread_checker_.CalledOnValidThread()); 662 DCHECK(thread_checker_.CalledOnValidThread());
585 CHECK(!has_encoder()); 663 CHECK(!has_encoder());
586 664
587 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) 665 #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(); 700 return num_encoded_frames_ / duration.InSecondsF();
623 } 701 }
624 702
625 void VEAClient::RequireBitstreamBuffers(unsigned int input_count, 703 void VEAClient::RequireBitstreamBuffers(unsigned int input_count,
626 const gfx::Size& input_coded_size, 704 const gfx::Size& input_coded_size,
627 size_t output_size) { 705 size_t output_size) {
628 DCHECK(thread_checker_.CalledOnValidThread()); 706 DCHECK(thread_checker_.CalledOnValidThread());
629 ASSERT_EQ(state_, CS_INITIALIZED); 707 ASSERT_EQ(state_, CS_INITIALIZED);
630 SetState(CS_ENCODING); 708 SetState(CS_ENCODING);
631 709
632 // TODO(posciak): For now we only support input streams that meet encoder 710 PrepareInputMemory(input_coded_size,
wuchengli 2014/08/28 08:33:01 s/PrepareInputMemory/PrepareInputBuffers/ to be co
henryhsu 2014/08/28 09:36:44 Done.
633 // size requirements exactly (i.e. coded size == visible size), so that we 711 const_cast<TestStream*>(&test_stream_),
634 // can simply mmap the stream file and feed the encoder directly with chunks 712 &input_buffer_size_);
635 // of that, instead of memcpying from mmapped file into a separate set of 713 CHECK_GT(input_buffer_size_, 0UL);
636 // input buffers that would meet the coded size and alignment requirements. 714
637 // If/when this is changed, the ARM-specific alignment check below should be 715 // Calculate the number of frames in the input stream by dividing its length
638 // redone as well. 716 // in bytes by frame size in bytes.
717 CHECK_EQ(test_stream_.input_file.length() % input_buffer_size_, 0U)
718 << "Stream byte size is not a product of calculated frame byte size";
719 num_frames_in_stream_ = test_stream_.input_file.length() / input_buffer_size_;
720 CHECK_GT(num_frames_in_stream_, 0UL);
721 CHECK_LE(num_frames_in_stream_, kMaxFrameNum);
722
723 // We may need to loop over the stream more than once if more frames than
724 // provided is required for bitrate tests.
725 if (force_bitrate_ && num_frames_in_stream_ < kMinFramesForBitrateTests) {
726 DVLOG(1) << "Stream too short for bitrate test (" << num_frames_in_stream_
727 << " frames), will loop it to reach " << kMinFramesForBitrateTests
728 << " frames";
729 num_frames_to_encode_ = kMinFramesForBitrateTests;
730 } else {
731 num_frames_to_encode_ = num_frames_in_stream_;
732 }
733
639 input_coded_size_ = input_coded_size; 734 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; 735 num_required_input_buffers_ = input_count;
662 ASSERT_GT(num_required_input_buffers_, 0UL); 736 ASSERT_GT(num_required_input_buffers_, 0UL);
663 737
664 output_buffer_size_ = output_size; 738 output_buffer_size_ = output_size;
665 ASSERT_GT(output_buffer_size_, 0UL); 739 ASSERT_GT(output_buffer_size_, 0UL);
666 740
667 for (unsigned int i = 0; i < kNumOutputBuffers; ++i) { 741 for (unsigned int i = 0; i < kNumOutputBuffers; ++i) {
668 base::SharedMemory* shm = new base::SharedMemory(); 742 base::SharedMemory* shm = new base::SharedMemory();
669 CHECK(shm->CreateAndMapAnonymous(output_buffer_size_)); 743 CHECK(shm->CreateAndMapAnonymous(output_buffer_size_));
670 output_shms_.push_back(shm); 744 output_shms_.push_back(shm);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 void VEAClient::InputNoLongerNeededCallback(int32 input_id) { 810 void VEAClient::InputNoLongerNeededCallback(int32 input_id) {
737 std::set<int32>::iterator it = inputs_at_client_.find(input_id); 811 std::set<int32>::iterator it = inputs_at_client_.find(input_id);
738 ASSERT_NE(it, inputs_at_client_.end()); 812 ASSERT_NE(it, inputs_at_client_.end());
739 inputs_at_client_.erase(it); 813 inputs_at_client_.erase(it);
740 FeedEncoderWithInputs(); 814 FeedEncoderWithInputs();
741 } 815 }
742 816
743 scoped_refptr<media::VideoFrame> VEAClient::PrepareInputFrame(off_t position) { 817 scoped_refptr<media::VideoFrame> VEAClient::PrepareInputFrame(off_t position) {
744 CHECK_LE(position + input_buffer_size_, test_stream_.input_file.length()); 818 CHECK_LE(position + input_buffer_size_, test_stream_.input_file.length());
745 819
746 uint8* frame_data = 820 uint8* frame_data_y =
747 const_cast<uint8*>(test_stream_.input_file.data() + position); 821 const_cast<uint8*>(test_stream_.input_file.data() + position);
822 uint8* frame_data_u =
823 frame_data_y + ALIGN_64_BYTES(media::VideoFrame::PlaneAllocationSize(
824 kInputFormat, 0, input_coded_size_));
825 uint8* frame_data_v =
826 frame_data_u + ALIGN_64_BYTES(media::VideoFrame::PlaneAllocationSize(
827 kInputFormat, 1, input_coded_size_));
748 828
749 CHECK_GT(current_framerate_, 0U); 829 CHECK_GT(current_framerate_, 0U);
750 scoped_refptr<media::VideoFrame> frame = 830 scoped_refptr<media::VideoFrame> frame =
751 media::VideoFrame::WrapExternalYuvData( 831 media::VideoFrame::WrapExternalYuvData(
752 kInputFormat, 832 kInputFormat,
753 input_coded_size_, 833 input_coded_size_,
754 gfx::Rect(test_stream_.size), 834 gfx::Rect(test_stream_.size),
755 test_stream_.size, 835 test_stream_.size,
756 input_coded_size_.width(), 836 input_coded_size_.width(),
757 input_coded_size_.width() / 2, 837 input_coded_size_.width() / 2,
758 input_coded_size_.width() / 2, 838 input_coded_size_.width() / 2,
759 frame_data, 839 frame_data_y,
760 frame_data + input_coded_size_.GetArea(), 840 frame_data_u,
761 frame_data + (input_coded_size_.GetArea() * 5 / 4), 841 frame_data_v,
762 base::TimeDelta().FromMilliseconds( 842 base::TimeDelta().FromMilliseconds(
763 next_input_id_ * base::Time::kMillisecondsPerSecond / 843 next_input_id_ * base::Time::kMillisecondsPerSecond /
764 current_framerate_), 844 current_framerate_),
765 media::BindToCurrentLoop( 845 media::BindToCurrentLoop(
766 base::Bind(&VEAClient::InputNoLongerNeededCallback, 846 base::Bind(&VEAClient::InputNoLongerNeededCallback,
767 base::Unretained(this), 847 base::Unretained(this),
768 next_input_id_))); 848 next_input_id_)));
769 849
770 CHECK(inputs_at_client_.insert(next_input_id_).second); 850 CHECK(inputs_at_client_.insert(next_input_id_).second);
771 ++next_input_id_; 851 ++next_input_id_;
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 test_stream_data->assign(it->second.c_str()); 1134 test_stream_data->assign(it->second.c_str());
1055 continue; 1135 continue;
1056 } 1136 }
1057 if (it->first == "v" || it->first == "vmodule") 1137 if (it->first == "v" || it->first == "vmodule")
1058 continue; 1138 continue;
1059 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; 1139 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second;
1060 } 1140 }
1061 1141
1062 return RUN_ALL_TESTS(); 1142 return RUN_ALL_TESTS();
1063 } 1143 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698