Coverage Report

Created: 2026-09-07 06:44

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/aom/av1/encoder/x86/hash_sse42.c
Line
Count
Source
1
/*
2
 * Copyright (c) 2018, Alliance for Open Media. All rights reserved.
3
 *
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.
10
 */
11
12
#include <stdint.h>
13
#include <smmintrin.h>
14
15
#include "config/av1_rtcd.h"
16
17
// Byte-boundary alignment issues
18
0
#define ALIGN_SIZE 8
19
0
#define ALIGN_MASK (ALIGN_SIZE - 1)
20
21
#define CALC_CRC(op, crc, type, buf, len) \
22
0
  while ((len) >= sizeof(type)) {         \
23
0
    (crc) = op((crc), *(type *)(buf));    \
24
0
    (len) -= sizeof(type);                \
25
0
    buf += sizeof(type);                  \
26
0
  }
27
28
/**
29
 * Calculates 32-bit CRC for the input buffer
30
 * polynomial is 0x11EDC6F41
31
 * @return A 32-bit unsigned integer representing the CRC
32
 */
33
uint32_t av1_get_crc32c_value_sse4_2(void *crc_calculator, const uint8_t *p,
34
0
                                     size_t len) {
35
0
  (void)crc_calculator;
36
0
  const uint8_t *buf = p;
37
0
  uint32_t crc = 0xFFFFFFFF;
38
39
  // Align the input to the word boundary
40
0
  for (; (len > 0) && ((intptr_t)buf & ALIGN_MASK); len--, buf++) {
41
0
    crc = _mm_crc32_u8(crc, *buf);
42
0
  }
43
44
0
#ifdef __x86_64__
45
0
  uint64_t crc64 = crc;
46
0
  CALC_CRC(_mm_crc32_u64, crc64, uint64_t, buf, len)
47
0
  crc = (uint32_t)crc64;
48
0
#endif
49
0
  CALC_CRC(_mm_crc32_u32, crc, uint32_t, buf, len)
50
0
  CALC_CRC(_mm_crc32_u16, crc, uint16_t, buf, len)
51
0
  CALC_CRC(_mm_crc32_u8, crc, uint8_t, buf, len)
52
0
  return (crc ^ 0xFFFFFFFF);
53
0
}