diff options
author | Matt A. Tobin <email@mattatobin.com> | 2020-04-07 23:30:51 -0400 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-04-14 13:26:42 +0200 |
commit | 277f2116b6660e9bbe7f5d67524be57eceb49b8b (patch) | |
tree | 4595f7cc71418f71b9a97dfaeb03a30aa60f336a /third_party/aom/av1/encoder/hash.c | |
parent | d270404436f6e84ffa3b92af537ac721bf10d66e (diff) | |
download | UXP-277f2116b6660e9bbe7f5d67524be57eceb49b8b.tar UXP-277f2116b6660e9bbe7f5d67524be57eceb49b8b.tar.gz UXP-277f2116b6660e9bbe7f5d67524be57eceb49b8b.tar.lz UXP-277f2116b6660e9bbe7f5d67524be57eceb49b8b.tar.xz UXP-277f2116b6660e9bbe7f5d67524be57eceb49b8b.zip |
Move aom source to a sub-directory under media/libaom
There is no damned reason to treat this differently than any other media lib given its license and there never was.
Diffstat (limited to 'third_party/aom/av1/encoder/hash.c')
-rw-r--r-- | third_party/aom/av1/encoder/hash.c | 125 |
1 files changed, 0 insertions, 125 deletions
diff --git a/third_party/aom/av1/encoder/hash.c b/third_party/aom/av1/encoder/hash.c deleted file mode 100644 index 180115d9f..000000000 --- a/third_party/aom/av1/encoder/hash.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2016, Alliance for Open Media. All rights reserved - * - * This source code is subject to the terms of the BSD 2 Clause License and - * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License - * was not distributed with this source code in the LICENSE file, you can - * obtain it at www.aomedia.org/license/software. If the Alliance for Open - * Media Patent License 1.0 was not distributed with this source code in the - * PATENTS file, you can obtain it at www.aomedia.org/license/patent. - */ - -#include "av1/encoder/hash.h" - -static void crc_calculator_process_data(CRC_CALCULATOR *p_crc_calculator, - uint8_t *pData, uint32_t dataLength) { - for (uint32_t i = 0; i < dataLength; i++) { - const uint8_t index = - (p_crc_calculator->remainder >> (p_crc_calculator->bits - 8)) ^ - pData[i]; - p_crc_calculator->remainder <<= 8; - p_crc_calculator->remainder ^= p_crc_calculator->table[index]; - } -} - -static void crc_calculator_reset(CRC_CALCULATOR *p_crc_calculator) { - p_crc_calculator->remainder = 0; -} - -static uint32_t crc_calculator_get_crc(CRC_CALCULATOR *p_crc_calculator) { - return p_crc_calculator->remainder & p_crc_calculator->final_result_mask; -} - -static void crc_calculator_init_table(CRC_CALCULATOR *p_crc_calculator) { - const uint32_t high_bit = 1 << (p_crc_calculator->bits - 1); - const uint32_t byte_high_bit = 1 << (8 - 1); - - for (uint32_t value = 0; value < 256; value++) { - uint32_t remainder = 0; - for (uint8_t mask = byte_high_bit; mask != 0; mask >>= 1) { - if (value & mask) { - remainder ^= high_bit; - } - - if (remainder & high_bit) { - remainder <<= 1; - remainder ^= p_crc_calculator->trunc_poly; - } else { - remainder <<= 1; - } - } - p_crc_calculator->table[value] = remainder; - } -} - -void av1_crc_calculator_init(CRC_CALCULATOR *p_crc_calculator, uint32_t bits, - uint32_t truncPoly) { - p_crc_calculator->remainder = 0; - p_crc_calculator->bits = bits; - p_crc_calculator->trunc_poly = truncPoly; - p_crc_calculator->final_result_mask = (1 << bits) - 1; - crc_calculator_init_table(p_crc_calculator); -} - -uint32_t av1_get_crc_value(void *crc_calculator, uint8_t *p, int length) { - CRC_CALCULATOR *p_crc_calculator = (CRC_CALCULATOR *)crc_calculator; - crc_calculator_reset(p_crc_calculator); - crc_calculator_process_data(p_crc_calculator, p, length); - return crc_calculator_get_crc(p_crc_calculator); -} - -/* CRC-32C (iSCSI) polynomial in reversed bit order. */ -#define POLY 0x82f63b78 - -/* Construct table for software CRC-32C calculation. */ -void av1_crc32c_calculator_init(CRC32C *p_crc32c) { - uint32_t crc; - - for (int n = 0; n < 256; n++) { - crc = n; - crc = crc & 1 ? (crc >> 1) ^ POLY : crc >> 1; - crc = crc & 1 ? (crc >> 1) ^ POLY : crc >> 1; - crc = crc & 1 ? (crc >> 1) ^ POLY : crc >> 1; - crc = crc & 1 ? (crc >> 1) ^ POLY : crc >> 1; - crc = crc & 1 ? (crc >> 1) ^ POLY : crc >> 1; - crc = crc & 1 ? (crc >> 1) ^ POLY : crc >> 1; - crc = crc & 1 ? (crc >> 1) ^ POLY : crc >> 1; - crc = crc & 1 ? (crc >> 1) ^ POLY : crc >> 1; - p_crc32c->table[0][n] = crc; - } - for (int n = 0; n < 256; n++) { - crc = p_crc32c->table[0][n]; - for (int k = 1; k < 8; k++) { - crc = p_crc32c->table[0][crc & 0xff] ^ (crc >> 8); - p_crc32c->table[k][n] = crc; - } - } -} - -/* Table-driven software version as a fall-back. This is about 15 times slower - than using the hardware instructions. This assumes little-endian integers, - as is the case on Intel processors that the assembler code here is for. */ -uint32_t av1_get_crc32c_value_c(CRC32C *p, uint8_t *buf, size_t len) { - const uint8_t *next = (const uint8_t *)(buf); - uint64_t crc; - - crc = 0 ^ 0xffffffff; - while (len && ((uintptr_t)next & 7) != 0) { - crc = p->table[0][(crc ^ *next++) & 0xff] ^ (crc >> 8); - len--; - } - while (len >= 8) { - crc ^= *(uint64_t *)next; - crc = p->table[7][crc & 0xff] ^ p->table[6][(crc >> 8) & 0xff] ^ - p->table[5][(crc >> 16) & 0xff] ^ p->table[4][(crc >> 24) & 0xff] ^ - p->table[3][(crc >> 32) & 0xff] ^ p->table[2][(crc >> 40) & 0xff] ^ - p->table[1][(crc >> 48) & 0xff] ^ p->table[0][crc >> 56]; - next += 8; - len -= 8; - } - while (len) { - crc = p->table[0][(crc ^ *next++) & 0xff] ^ (crc >> 8); - len--; - } - return (uint32_t)crc ^ 0xffffffff; -} |