OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebM 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 24 matching lines...) Expand all Loading... |
35 const int w = (plane ? (img->d_w + img->x_chroma_shift) >> | 35 const int w = (plane ? (img->d_w + img->x_chroma_shift) >> |
36 img->x_chroma_shift : img->d_w) * bytes_per_sample; | 36 img->x_chroma_shift : img->d_w) * bytes_per_sample; |
37 | 37 |
38 for (int y = 0; y < h; ++y) { | 38 for (int y = 0; y < h; ++y) { |
39 MD5Update(&md5_, buf, w); | 39 MD5Update(&md5_, buf, w); |
40 buf += img->stride[plane]; | 40 buf += img->stride[plane]; |
41 } | 41 } |
42 } | 42 } |
43 } | 43 } |
44 | 44 |
| 45 void Add(const uint8_t *data, size_t size) { |
| 46 MD5Update(&md5_, data, static_cast<uint32_t>(size)); |
| 47 } |
| 48 |
45 const char *Get(void) { | 49 const char *Get(void) { |
46 static const char hex[16] = { | 50 static const char hex[16] = { |
47 '0', '1', '2', '3', '4', '5', '6', '7', | 51 '0', '1', '2', '3', '4', '5', '6', '7', |
48 '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', | 52 '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', |
49 }; | 53 }; |
50 uint8_t tmp[16]; | 54 uint8_t tmp[16]; |
51 MD5Context ctx_tmp = md5_; | 55 MD5Context ctx_tmp = md5_; |
52 | 56 |
53 MD5Final(tmp, &ctx_tmp); | 57 MD5Final(tmp, &ctx_tmp); |
54 for (int i = 0; i < 16; i++) { | 58 for (int i = 0; i < 16; i++) { |
55 res_[i * 2 + 0] = hex[tmp[i] >> 4]; | 59 res_[i * 2 + 0] = hex[tmp[i] >> 4]; |
56 res_[i * 2 + 1] = hex[tmp[i] & 0xf]; | 60 res_[i * 2 + 1] = hex[tmp[i] & 0xf]; |
57 } | 61 } |
58 res_[32] = 0; | 62 res_[32] = 0; |
59 | 63 |
60 return res_; | 64 return res_; |
61 } | 65 } |
62 | 66 |
63 protected: | 67 protected: |
64 char res_[33]; | 68 char res_[33]; |
65 MD5Context md5_; | 69 MD5Context md5_; |
66 }; | 70 }; |
67 | 71 |
68 } // namespace libvpx_test | 72 } // namespace libvpx_test |
69 | 73 |
70 #endif // TEST_MD5_HELPER_H_ | 74 #endif // TEST_MD5_HELPER_H_ |
OLD | NEW |