OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
wuchengli
2015/11/19 03:33:40
There was only subject in the change description.
kcwu
2015/11/20 10:04:06
Done.
| |
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 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 // sure they requested the same coded_size | 218 // sure they requested the same coded_size |
219 ASSERT_TRUE(!test_stream->mapped_aligned_in_file.IsValid() || | 219 ASSERT_TRUE(!test_stream->mapped_aligned_in_file.IsValid() || |
220 coded_size == test_stream->coded_size); | 220 coded_size == test_stream->coded_size); |
221 test_stream->coded_size = coded_size; | 221 test_stream->coded_size = coded_size; |
222 | 222 |
223 size_t num_planes = media::VideoFrame::NumPlanes(kInputFormat); | 223 size_t num_planes = media::VideoFrame::NumPlanes(kInputFormat); |
224 std::vector<size_t> padding_sizes(num_planes); | 224 std::vector<size_t> padding_sizes(num_planes); |
225 std::vector<size_t> coded_bpl(num_planes); | 225 std::vector<size_t> coded_bpl(num_planes); |
226 std::vector<size_t> visible_bpl(num_planes); | 226 std::vector<size_t> visible_bpl(num_planes); |
227 std::vector<size_t> visible_plane_rows(num_planes); | 227 std::vector<size_t> visible_plane_rows(num_planes); |
228 std::vector<std::vector<uint8>> padding(num_planes); | |
228 | 229 |
229 // Calculate padding in bytes to be added after each plane required to keep | 230 // Calculate padding in bytes to be added after each plane required to keep |
230 // starting addresses of all planes at a 64 byte boudnary. This padding will | 231 // starting addresses of all planes at a 64 byte boudnary. This padding will |
231 // be added after each plane when copying to the temporary file. | 232 // be added after each plane when copying to the temporary file. |
232 // At the same time we also need to take into account coded_size requested by | 233 // At the same time we also need to take into account coded_size requested by |
233 // the VEA; each row of visible_bpl bytes in the original file needs to be | 234 // the VEA; each row of visible_bpl bytes in the original file needs to be |
234 // copied into a row of coded_bpl bytes in the aligned file. | 235 // copied into a row of coded_bpl bytes in the aligned file. |
235 for (size_t i = 0; i < num_planes; i++) { | 236 for (size_t i = 0; i < num_planes; i++) { |
236 const size_t size = | 237 const size_t size = |
237 media::VideoFrame::PlaneSize(kInputFormat, i, coded_size).GetArea(); | 238 media::VideoFrame::PlaneSize(kInputFormat, i, coded_size).GetArea(); |
238 test_stream->aligned_plane_size.push_back(Align64Bytes(size)); | 239 test_stream->aligned_plane_size.push_back(Align64Bytes(size)); |
239 test_stream->aligned_buffer_size += test_stream->aligned_plane_size.back(); | 240 test_stream->aligned_buffer_size += test_stream->aligned_plane_size.back(); |
240 | 241 |
241 coded_bpl[i] = | 242 coded_bpl[i] = |
242 media::VideoFrame::RowBytes(i, kInputFormat, coded_size.width()); | 243 media::VideoFrame::RowBytes(i, kInputFormat, coded_size.width()); |
243 visible_bpl[i] = media::VideoFrame::RowBytes( | 244 visible_bpl[i] = media::VideoFrame::RowBytes( |
244 i, kInputFormat, test_stream->visible_size.width()); | 245 i, kInputFormat, test_stream->visible_size.width()); |
245 visible_plane_rows[i] = media::VideoFrame::Rows( | 246 visible_plane_rows[i] = media::VideoFrame::Rows( |
246 i, kInputFormat, test_stream->visible_size.height()); | 247 i, kInputFormat, test_stream->visible_size.height()); |
247 const size_t padding_rows = | 248 const size_t padding_rows = |
248 media::VideoFrame::Rows(i, kInputFormat, coded_size.height()) - | 249 media::VideoFrame::Rows(i, kInputFormat, coded_size.height()) - |
249 visible_plane_rows[i]; | 250 visible_plane_rows[i]; |
250 padding_sizes[i] = padding_rows * coded_bpl[i] + Align64Bytes(size) - size; | 251 padding_sizes[i] = padding_rows * coded_bpl[i] + Align64Bytes(size) - size; |
252 padding[i].resize(padding_sizes[i]); | |
251 } | 253 } |
252 | 254 |
253 base::MemoryMappedFile src_file; | 255 base::MemoryMappedFile src_file; |
254 LOG_ASSERT(src_file.Initialize(base::FilePath(test_stream->in_filename))); | 256 LOG_ASSERT(src_file.Initialize(base::FilePath(test_stream->in_filename))); |
255 LOG_ASSERT(base::CreateTemporaryFile(&test_stream->aligned_in_file)); | 257 LOG_ASSERT(base::CreateTemporaryFile(&test_stream->aligned_in_file)); |
256 | 258 |
257 size_t visible_buffer_size = media::VideoFrame::AllocationSize( | 259 size_t visible_buffer_size = media::VideoFrame::AllocationSize( |
258 kInputFormat, test_stream->visible_size); | 260 kInputFormat, test_stream->visible_size); |
259 LOG_ASSERT(src_file.length() % visible_buffer_size == 0U) | 261 LOG_ASSERT(src_file.length() % visible_buffer_size == 0U) |
260 << "Stream byte size is not a product of calculated frame byte size"; | 262 << "Stream byte size is not a product of calculated frame byte size"; |
(...skipping 13 matching lines...) Expand all Loading... | |
274 for (size_t frame = 0; frame < test_stream->num_frames; frame++) { | 276 for (size_t frame = 0; frame < test_stream->num_frames; frame++) { |
275 for (size_t i = 0; i < num_planes; i++) { | 277 for (size_t i = 0; i < num_planes; i++) { |
276 // Assert that each plane of frame starts at 64 byte boundary. | 278 // Assert that each plane of frame starts at 64 byte boundary. |
277 ASSERT_EQ(dest_offset & 63, 0) | 279 ASSERT_EQ(dest_offset & 63, 0) |
278 << "Planes of frame should be mapped at a 64 byte boundary"; | 280 << "Planes of frame should be mapped at a 64 byte boundary"; |
279 for (size_t j = 0; j < visible_plane_rows[i]; j++) { | 281 for (size_t j = 0; j < visible_plane_rows[i]; j++) { |
280 LOG_ASSERT(WriteFile(&dest_file, dest_offset, src, visible_bpl[i])); | 282 LOG_ASSERT(WriteFile(&dest_file, dest_offset, src, visible_bpl[i])); |
281 src += visible_bpl[i]; | 283 src += visible_bpl[i]; |
282 dest_offset += coded_bpl[i]; | 284 dest_offset += coded_bpl[i]; |
283 } | 285 } |
286 if (padding_sizes[i]) { | |
wuchengli
2015/11/19 03:33:40
We can use padding[i].size() and remove |padding_s
kcwu
2015/11/20 10:04:06
Done.
| |
287 CHECK(WriteFile(&dest_file, dest_offset, &padding[i][0], | |
wuchengli
2015/11/19 03:33:40
s/CHECK/LOG_ASSERT/
kcwu
2015/11/20 10:04:06
Done.
| |
288 padding_sizes[i])); | |
289 } | |
284 dest_offset += padding_sizes[i]; | 290 dest_offset += padding_sizes[i]; |
285 } | 291 } |
286 } | 292 } |
287 LOG_ASSERT(test_stream->mapped_aligned_in_file.Initialize(dest_file.Pass())); | 293 LOG_ASSERT(test_stream->mapped_aligned_in_file.Initialize(dest_file.Pass())); |
288 // Assert that memory mapped of file starts at 64 byte boundary. So each | 294 // Assert that memory mapped of file starts at 64 byte boundary. So each |
289 // plane of frames also start at 64 byte boundary. | 295 // plane of frames also start at 64 byte boundary. |
290 | 296 |
291 ASSERT_EQ( | 297 ASSERT_EQ( |
292 reinterpret_cast<off_t>(test_stream->mapped_aligned_in_file.data()) & 63, | 298 reinterpret_cast<off_t>(test_stream->mapped_aligned_in_file.data()) & 63, |
293 0) | 299 0) |
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1503 | 1509 |
1504 content::g_env = | 1510 content::g_env = |
1505 reinterpret_cast<content::VideoEncodeAcceleratorTestEnvironment*>( | 1511 reinterpret_cast<content::VideoEncodeAcceleratorTestEnvironment*>( |
1506 testing::AddGlobalTestEnvironment( | 1512 testing::AddGlobalTestEnvironment( |
1507 new content::VideoEncodeAcceleratorTestEnvironment( | 1513 new content::VideoEncodeAcceleratorTestEnvironment( |
1508 test_stream_data.Pass(), log_path, run_at_fps, | 1514 test_stream_data.Pass(), log_path, run_at_fps, |
1509 needs_encode_latency))); | 1515 needs_encode_latency))); |
1510 | 1516 |
1511 return RUN_ALL_TESTS(); | 1517 return RUN_ALL_TESTS(); |
1512 } | 1518 } |
OLD | NEW |