51 while (root * 2 + 1 <
size) {
52 int child = root * 2 + 1;
69 sizeof(*
h) + 2 *
sizeof(up) + 2 *
sizeof(
len) +
sizeof(
map));
72 up = (
int*)(
h + stats_size);
75 map = (uint16_t*)(up + 2 * stats_size);
76 len = (uint8_t*)(
map + stats_size);
82 for (
i = 0;
i<stats_size;
i++) {
93 for (
i =
size / 2 - 1;
i >= 0;
i--)
96 for (next =
size; next <
size * 2 - 1; next++) {
98 uint64_t min1v =
h[0].val;
100 h[0].val = INT64_MAX;
102 up[
h[0].name] = next;
122 Node *nodes,
int node,
int pl,
int *
pos,
int no_zero_count)
127 if (
s !=
HNODE || (no_zero_count && !nodes[node].count)) {
148 &
pos, no_zero_count);
150 xlat, 1, 1, 0, 0, logctx);
165 for (
i = 0;
i < nb_codes;
i++) {
173 "Too high symbol frequencies. "
174 "Tree construction is not possible\n");
179 nodes[nb_codes*2-1].
count = 0;
180 for (
i = 0;
i < nb_codes * 2 - 1;
i += 2) {
184 for(j = cur_node; j >
i + 2; j--){
185 if(cur_count > nodes[j-1].count ||
186 (cur_count == nodes[j-1].count &&
189 nodes[j] = nodes[j - 1];
192 nodes[j].
count = cur_count;
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static double val(void *priv, double ch)
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static CheckasmStats stats
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int ff_huff_gen_len_table(uint8_t *dst, const uint64_t *stats, int stats_size, int skip0)
static void heap_sift(HeapElem *h, int root, int size)
static int build_huff_tree(VLC *vlc, Node *nodes, int head, int flags, int nb_bits, void *logctx)
int ff_huff_build_tree(void *logctx, VLC *vlc, int nb_codes, int nb_bits, Node *nodes, HuffCmp cmp, int flags)
nodes size must be 2*nb_codes first nb_codes nodes.count must be set
static void get_tree_codes(int8_t *lens, uint8_t *xlat, Node *nodes, int node, int pl, int *pos, int no_zero_count)
huffman tree builder and VLC generator
#define FF_HUFFMAN_FLAG_ZERO_COUNT
int(* HuffCmp)(const void *va, const void *vb)
#define FF_HUFFMAN_FLAG_HNODE_FIRST
const VDPAUPixFmtMap * map
Utility Preprocessor macros.
#define FFSWAP(type, a, b)
Memory handling functions.
static av_always_inline int cmp(MPVEncContext *const s, const int x, const int y, const int subx, const int suby, const int size, const int h, int ref_index, int src_index, me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, const int flags)
compares a block (either a full macroblock or a partition thereof) against a proposed motion-compensa...
#define AV_QSORT(p, num, type, cmp)
Quicksort This sort is fast, and fully inplace but not stable and it is possible to construct input t...
#define av_malloc_array(a, b)
int ff_vlc_init_from_lengths(VLC *vlc, int nb_bits, int nb_codes, const int8_t *lens, int lens_wrap, const void *symbols, int symbols_wrap, int symbols_size, int offset, int flags, void *logctx)
Build VLC decoding tables suitable for use with get_vlc2()