OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 f1->StrideY(), f2->StrideY(), | 65 f1->StrideY(), f2->StrideY(), |
66 f1->width(), f1->height()) && | 66 f1->width(), f1->height()) && |
67 EqualPlane(f1->DataU(), f2->DataU(), | 67 EqualPlane(f1->DataU(), f2->DataU(), |
68 f1->StrideU(), f2->StrideU(), | 68 f1->StrideU(), f2->StrideU(), |
69 half_width, half_height) && | 69 half_width, half_height) && |
70 EqualPlane(f1->DataV(), f2->DataV(), | 70 EqualPlane(f1->DataV(), f2->DataV(), |
71 f1->StrideV(), f2->StrideV(), | 71 f1->StrideV(), f2->StrideV(), |
72 half_width, half_height); | 72 half_width, half_height); |
73 } | 73 } |
74 | 74 |
| 75 rtc::scoped_refptr<I420Buffer> ReadI420Buffer(int width, int height, FILE *f) { |
| 76 int half_width = (width + 1) / 2; |
| 77 rtc::scoped_refptr<I420Buffer> buffer( |
| 78 // Explicit stride, no padding between rows. |
| 79 I420Buffer::Create(width, height, width, half_width, half_width)); |
| 80 size_t size_y = static_cast<size_t>(width) * height; |
| 81 size_t size_uv = static_cast<size_t>(half_width) * ((height + 1) / 2); |
| 82 |
| 83 if (fread(buffer->MutableDataY(), 1, size_y, f) < size_y) |
| 84 return nullptr; |
| 85 if (fread(buffer->MutableDataU(), 1, size_uv, f) < size_uv) |
| 86 return nullptr; |
| 87 if (fread(buffer->MutableDataV(), 1, size_uv, f) < size_uv) |
| 88 return nullptr; |
| 89 return buffer; |
| 90 } |
| 91 |
75 } // namespace test | 92 } // namespace test |
76 } // namespace webrtc | 93 } // namespace webrtc |
OLD | NEW |