OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1209 // Allocate a buffer with end page aligned. | 1209 // Allocate a buffer with end page aligned. |
1210 const int kPadToHeapSized = 16 * 1024 * 1024; | 1210 const int kPadToHeapSized = 16 * 1024 * 1024; |
1211 std::unique_ptr<uint8_t[]> page_buffer( | 1211 std::unique_ptr<uint8_t[]> page_buffer( |
1212 new uint8_t[((data_size + kPadToHeapSized + 4095) & ~4095)]); | 1212 new uint8_t[((data_size + kPadToHeapSized + 4095) & ~4095)]); |
1213 uint8_t* data_ptr = page_buffer.get(); | 1213 uint8_t* data_ptr = page_buffer.get(); |
1214 if (!data_ptr) { | 1214 if (!data_ptr) { |
1215 LOG(LS_WARNING) << "Failed to allocate memory for ValidateFrame test."; | 1215 LOG(LS_WARNING) << "Failed to allocate memory for ValidateFrame test."; |
1216 EXPECT_FALSE(expected_result); // NULL is okay if failure was expected. | 1216 EXPECT_FALSE(expected_result); // NULL is okay if failure was expected. |
1217 return; | 1217 return; |
1218 } | 1218 } |
1219 // TODO(pbos): Remove kPad once http://llvm.org/PR28348 is fixed and the fix | 1219 data_ptr += kPadToHeapSized + (-(static_cast<int>(data_size)) & 4095); |
tommi
2016/06/30 10:39:18
instead of 4095, can we use 0xfff? I find it a lo
pbos-webrtc
2016/06/30 12:16:54
I agree, but I find this hard to read overall, I'm
| |
1220 // is rolled in. | |
1221 volatile const int kPad = 4095; | |
1222 data_ptr += kPadToHeapSized + (-(static_cast<int>(data_size)) & kPad); | |
1223 memcpy(data_ptr, sample, std::min(data_size, sample_size)); | 1220 memcpy(data_ptr, sample, std::min(data_size, sample_size)); |
1224 for (int i = 0; i < repeat_; ++i) { | 1221 for (int i = 0; i < repeat_; ++i) { |
1225 EXPECT_EQ(expected_result, frame.Validate(fourcc, kWidth, kHeight, | 1222 EXPECT_EQ(expected_result, frame.Validate(fourcc, kWidth, kHeight, |
1226 data_ptr, | 1223 data_ptr, |
1227 sample_size + size_adjust)); | 1224 sample_size + size_adjust)); |
1228 } | 1225 } |
1229 } | 1226 } |
1230 | 1227 |
1231 // Test validate for I420 MJPG buffer. | 1228 // Test validate for I420 MJPG buffer. |
1232 void ValidateMjpgI420() { | 1229 void ValidateMjpgI420() { |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1833 target.reset(source->Copy()); | 1830 target.reset(source->Copy()); |
1834 EXPECT_TRUE(IsEqual(*source, *target, 0)); | 1831 EXPECT_TRUE(IsEqual(*source, *target, 0)); |
1835 const T* const_source = source.get(); | 1832 const T* const_source = source.get(); |
1836 EXPECT_EQ(const_source->video_frame_buffer(), target->video_frame_buffer()); | 1833 EXPECT_EQ(const_source->video_frame_buffer(), target->video_frame_buffer()); |
1837 } | 1834 } |
1838 | 1835 |
1839 int repeat_; | 1836 int repeat_; |
1840 }; | 1837 }; |
1841 | 1838 |
1842 #endif // WEBRTC_MEDIA_BASE_VIDEOFRAME_UNITTEST_H_ | 1839 #endif // WEBRTC_MEDIA_BASE_VIDEOFRAME_UNITTEST_H_ |
OLD | NEW |