Add ssse3 aom_smooth_h_predictor_4xh
[aom.git] / test / md5_helper.h
blob8c9d4f706f7dbd5cdf4fbf78030aed3905ae433c
1 /*
2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
12 #ifndef TEST_MD5_HELPER_H_
13 #define TEST_MD5_HELPER_H_
15 #include "./md5_utils.h"
16 #include "aom/aom_decoder.h"
18 namespace libaom_test {
19 class MD5 {
20 public:
21 MD5() { MD5Init(&md5_); }
23 void Add(const aom_image_t *img) {
24 for (int plane = 0; plane < 3; ++plane) {
25 const uint8_t *buf = img->planes[plane];
26 // Calculate the width and height to do the md5 check. For the chroma
27 // plane, we never want to round down and thus skip a pixel so if
28 // we are shifting by 1 (chroma_shift) we add 1 before doing the shift.
29 // This works only for chroma_shift of 0 and 1.
30 const int bytes_per_sample =
31 (img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) ? 2 : 1;
32 const int h =
33 plane ? (img->d_h + img->y_chroma_shift) >> img->y_chroma_shift
34 : img->d_h;
35 const int w =
36 (plane ? (img->d_w + img->x_chroma_shift) >> img->x_chroma_shift
37 : img->d_w) *
38 bytes_per_sample;
40 for (int y = 0; y < h; ++y) {
41 MD5Update(&md5_, buf, w);
42 buf += img->stride[plane];
47 void Add(const uint8_t *data, size_t size) {
48 MD5Update(&md5_, data, static_cast<uint32_t>(size));
51 const char *Get(void) {
52 static const char hex[16] = {
53 '0', '1', '2', '3', '4', '5', '6', '7',
54 '8', '9', 'a', 'b', 'c', 'd', 'e', 'f',
56 uint8_t tmp[16];
57 MD5Context ctx_tmp = md5_;
59 MD5Final(tmp, &ctx_tmp);
60 for (int i = 0; i < 16; i++) {
61 res_[i * 2 + 0] = hex[tmp[i] >> 4];
62 res_[i * 2 + 1] = hex[tmp[i] & 0xf];
64 res_[32] = 0;
66 return res_;
69 protected:
70 char res_[33];
71 MD5Context md5_;
74 } // namespace libaom_test
76 #endif // TEST_MD5_HELPER_H_