Lines Matching refs:huff
118 static int tm2_read_tree(TM2Context *ctx, int length, TM2Huff *huff) in tm2_read_tree() argument
121 if (length > huff->max_bits) { in tm2_read_tree()
123 huff->max_bits); in tm2_read_tree()
131 if (huff->num >= huff->max_num) { in tm2_read_tree()
135 huff->nums[huff->num] = get_bits_long(&ctx->gb, huff->val_bits); in tm2_read_tree()
136 huff->lens[huff->num] = length; in tm2_read_tree()
137 huff->num++; in tm2_read_tree()
140 if ((ret2 = tm2_read_tree(ctx, length + 1, huff)) < 0) in tm2_read_tree()
142 if ((ret = tm2_read_tree(ctx, length + 1, huff)) < 0) in tm2_read_tree()
150 TM2Huff huff; in tm2_build_huff_table() local
153 huff.val_bits = get_bits(&ctx->gb, 5); in tm2_build_huff_table()
154 huff.max_bits = get_bits(&ctx->gb, 5); in tm2_build_huff_table()
155 huff.min_bits = get_bits(&ctx->gb, 5); in tm2_build_huff_table()
156 huff.nodes = get_bits(&ctx->gb, 17); in tm2_build_huff_table()
157 huff.num = 0; in tm2_build_huff_table()
160 if ((huff.val_bits < 1) || (huff.val_bits > 32) || in tm2_build_huff_table()
161 (huff.max_bits < 0) || (huff.max_bits > 25)) { in tm2_build_huff_table()
163 "length: %i, max code length: %i\n", huff.val_bits, huff.max_bits); in tm2_build_huff_table()
166 if ((huff.nodes <= 0) || (huff.nodes > 0x10000)) { in tm2_build_huff_table()
168 "nodes: %i\n", huff.nodes); in tm2_build_huff_table()
172 if (huff.max_bits == 0) in tm2_build_huff_table()
173 huff.max_bits = 1; in tm2_build_huff_table()
176 huff.max_num = (huff.nodes + 1) >> 1; in tm2_build_huff_table()
177 huff.nums = av_calloc(huff.max_num, sizeof(int)); in tm2_build_huff_table()
178 huff.lens = av_mallocz(huff.max_num); in tm2_build_huff_table()
180 if (!huff.nums || !huff.lens) { in tm2_build_huff_table()
185 res = tm2_read_tree(ctx, 0, &huff); in tm2_build_huff_table()
187 if (res >= 0 && res != huff.max_bits) { in tm2_build_huff_table()
189 res, huff.max_bits); in tm2_build_huff_table()
192 if (huff.num != huff.max_num) { in tm2_build_huff_table()
194 huff.num, huff.max_num); in tm2_build_huff_table()
200 res = ff_init_vlc_from_lengths(&code->vlc, huff.max_bits, huff.max_num, in tm2_build_huff_table()
201 huff.lens, sizeof(huff.lens[0]), in tm2_build_huff_table()
206 code->bits = huff.max_bits; in tm2_build_huff_table()
207 code->length = huff.max_num; in tm2_build_huff_table()
208 code->recode = huff.nums; in tm2_build_huff_table()
209 huff.nums = NULL; in tm2_build_huff_table()
215 av_free(huff.nums); in tm2_build_huff_table()
216 av_free(huff.lens); in tm2_build_huff_table()