32#define ALIGN _Alignof(size_t)
53#define ENTRY_PSL_VAL(entry) (*(size_t*)(entry))
54#define ENTRY_KEY_PTR(entry) ((entry) + sizeof(size_t))
55#define ENTRY_VAL_PTR(entry) (ENTRY_KEY_PTR(entry) + ctx->key_size)
57#define KEYS_EQUAL(k1, k2) (!memcmp((k1), (k2), ctx->key_size))
60 size_t val_size,
size_t max_entries)
62 const size_t keyval_size = key_size + val_size;
64 if (keyval_size < key_size ||
65 keyval_size >
FFMIN(SIZE_MAX -
sizeof(
size_t) - (
ALIGN - 1),
104 for (
size_t psl = 1; psl <=
ctx->max_entries; psl++) {
105 size_t wrapped_index = (
hash + psl) %
ctx->max_entries;
106 uint8_t *
entry =
ctx->table + wrapped_index *
ctx->entry_size;
124 size_t wrapped_index =
hash %
ctx->max_entries;
125 uint8_t *
set =
ctx->swapbuf;
126 uint8_t *
tmp =
ctx->swapbuf +
ctx->key_size +
ctx->val_size;
131 for (
size_t i = 0;
i <
ctx->max_entries;
i++) {
132 if (++wrapped_index ==
ctx->max_entries)
134 uint8_t *
entry =
ctx->table + wrapped_index *
ctx->entry_size;
146 if (
ctx->nb_entries ==
ctx->max_entries)
165 if (!
ctx->nb_entries)
170 size_t wrapped_index =
hash %
ctx->max_entries;
172 for (
size_t psl = 1; psl <=
ctx->max_entries; psl++) {
173 if (++wrapped_index ==
ctx->max_entries)
175 uint8_t *
entry =
ctx->table + wrapped_index *
ctx->entry_size;
183 for (psl++; psl <=
ctx->max_entries; psl++) {
184 if (++wrapped_index ==
ctx->max_entries)
186 next_entry =
ctx->table + wrapped_index *
ctx->entry_size;
191 memcpy(
entry, next_entry,
ctx->entry_size);
203 memset(
ctx->table, 0,
ctx->entry_size *
ctx->max_entries);
static double val(void *priv, double ch)
static uint8_t hash[HASH_SIZE]
static AVFormatContext * ctx
#define i(width, name, range_min, range_max)
Public header for CRC hash function implementation.
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define ENTRY_KEY_PTR(entry)
av_cold int ff_hashtable_alloc(FFHashtableContext **ctx, size_t key_size, size_t val_size, size_t max_entries)
Create a fixed-sized Robin Hood hash table.
#define ENTRY_PSL_VAL(entry)
#define ENTRY_VAL_PTR(entry)
#define KEYS_EQUAL(k1, k2)
int ff_hashtable_set(struct FFHashtableContext *ctx, const void *key, const void *val)
Store a value in a hash table given a key.
static size_t hash_key(const struct FFHashtableContext *ctx, const void *key)
int ff_hashtable_delete(struct FFHashtableContext *ctx, const void *key)
Delete a value from a hash table given a key.
void ff_hashtable_clear(struct FFHashtableContext *ctx)
Delete all values from a hash table.
int ff_hashtable_get(const struct FFHashtableContext *ctx, const void *key, void *val)
Look up a value from a hash table given a key.
av_cold void ff_hashtable_freep(FFHashtableContext **ctx)
Free a hash table.
Macro definitions for various function/variable attributes.
Utility Preprocessor macros.
#define FFSWAP(type, a, b)
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
static void set(uint8_t *a[], int ch, int index, int ch_count, enum AVSampleFormat f, double v)