opencv

Форк
0
/
crc32_braid_comb.c 
57 строк · 2.3 Кб
1
/* crc32_braid_comb.c -- compute the CRC-32 of a data stream
2
 * Copyright (C) 1995-2022 Mark Adler
3
 * For conditions of distribution and use, see copyright notice in zlib.h
4
 *
5
 * This interleaved implementation of a CRC makes use of pipelined multiple
6
 * arithmetic-logic units, commonly found in modern CPU cores. It is due to
7
 * Kadatch and Jenkins (2010). See doc/crc-doc.1.0.pdf in this distribution.
8
 */
9

10
#include "zbuild.h"
11
#include "zutil.h"
12
#include "crc32_braid_p.h"
13
#include "crc32_braid_tbl.h"
14
#include "crc32_braid_comb_p.h"
15

16
/* ========================================================================= */
17
static uint32_t crc32_combine_(uint32_t crc1, uint32_t crc2, z_off64_t len2) {
18
    return multmodp(x2nmodp(len2, 3), crc1) ^ crc2;
19
}
20
static uint32_t crc32_combine_gen_(z_off64_t len2) {
21
     return x2nmodp(len2, 3);
22
}
23
static uint32_t crc32_combine_op_(uint32_t crc1, uint32_t crc2, const uint32_t op) {
24
    return multmodp(op, crc1) ^ crc2;
25
}
26

27
/* ========================================================================= */
28

29
#ifdef ZLIB_COMPAT
30
unsigned long Z_EXPORT PREFIX(crc32_combine)(unsigned long crc1, unsigned long crc2, z_off_t len2) {
31
    return (unsigned long)crc32_combine_((uint32_t)crc1, (uint32_t)crc2, len2);
32
}
33
unsigned long Z_EXPORT PREFIX4(crc32_combine)(unsigned long crc1, unsigned long crc2, z_off64_t len2) {
34
    return (unsigned long)crc32_combine_((uint32_t)crc1, (uint32_t)crc2, len2);
35
}
36
unsigned long Z_EXPORT PREFIX(crc32_combine_gen)(z_off_t len2) {
37
    return crc32_combine_gen_(len2);
38
}
39
unsigned long Z_EXPORT PREFIX4(crc32_combine_gen)(z_off64_t len2) {
40
    return crc32_combine_gen_(len2);
41
}
42
unsigned long Z_EXPORT PREFIX(crc32_combine_op)(unsigned long crc1, unsigned long crc2, const unsigned long op) {
43
    return (unsigned long)crc32_combine_op_((uint32_t)crc1, (uint32_t)crc2, (uint32_t)op);
44
}
45
#else
46
uint32_t Z_EXPORT PREFIX4(crc32_combine)(uint32_t crc1, uint32_t crc2, z_off64_t len2) {
47
    return crc32_combine_(crc1, crc2, len2);
48
}
49
uint32_t Z_EXPORT PREFIX(crc32_combine_gen)(z_off64_t len2) {
50
    return crc32_combine_gen_(len2);
51
}
52
uint32_t Z_EXPORT PREFIX(crc32_combine_op)(uint32_t crc1, uint32_t crc2, const uint32_t op) {
53
    return crc32_combine_op_(crc1, crc2, op);
54
}
55
#endif
56

57
/* ========================================================================= */
58

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.