Lines Matching refs:mlz

21 #include "mlz.h"
23 av_cold int ff_mlz_init_dict(void *context, MLZ *mlz)
25 mlz->dict = av_mallocz(TABLE_SIZE * sizeof(*mlz->dict));
26 if (!mlz->dict)
29 mlz->flush_code = FLUSH_CODE;
30 mlz->current_dic_index_max = DIC_INDEX_INIT;
31 mlz->dic_code_bit = CODE_BIT_INIT;
32 mlz->bump_code = (DIC_INDEX_INIT - 1);
33 mlz->next_code = FIRST_CODE;
34 mlz->freeze_flag = 0;
35 mlz->context = context;
40 av_cold void ff_mlz_flush_dict(MLZ *mlz) {
41 MLZDict *dict = mlz->dict;
48 mlz->current_dic_index_max = DIC_INDEX_INIT;
49 mlz->dic_code_bit = CODE_BIT_INIT; // DicCodeBitInit;
50 mlz->bump_code = mlz->current_dic_index_max - 1;
51 mlz->next_code = FIRST_CODE;
52 mlz->freeze_flag = 0;
66 static int decode_string(MLZ* mlz, unsigned char *buff, int string_code, int *first_char_code, unsigned long bufsize) {
67 MLZDict* dict = mlz->dict;
90 av_log(mlz->context, AV_LOG_ERROR, "MLZ offset error.\n");
98 av_log(mlz->context, AV_LOG_ERROR, "MLZ dic index error.\n");
105 av_log(mlz->context, AV_LOG_ERROR, "MLZ dic index error.\n");
109 av_log(mlz->context, AV_LOG_ERROR, "MLZ dic offset error.\n");
128 int ff_mlz_decompression(MLZ* mlz, GetBitContext* gb, int size, unsigned char *buff) {
129 MLZDict *dict = mlz->dict;
139 string_code = input_code(gb, mlz->dic_code_bit);
143 ff_mlz_flush_dict(mlz);
148 mlz->freeze_flag = 1;
151 if (string_code > mlz->current_dic_index_max) {
152 av_log(mlz->context, AV_LOG_ERROR, "String code %d exceeds maximum value of %d.\n", string_code, mlz->current_dic_index_max);
155 if (string_code == (int) mlz->bump_code) {
156 ++mlz->dic_code_bit;
157 mlz->current_dic_index_max *= 2;
158 mlz->bump_code = mlz->current_dic_index_max - 1;
160 if (string_code >= mlz->next_code) {
161 int ret = decode_string(mlz, &buff[output_chars], last_string_code, &char_code, size - output_chars);
163 av_log(mlz->context, AV_LOG_ERROR, "output chars overflow\n");
167 ret = decode_string(mlz, &buff[output_chars], char_code, &char_code, size - output_chars);
169 av_log(mlz->context, AV_LOG_ERROR, "output chars overflow\n");
173 set_new_entry_dict(dict, mlz->next_code, last_string_code, char_code);
174 if (mlz->next_code >= TABLE_SIZE - 1) {
175 av_log(mlz->context, AV_LOG_ERROR, "Too many MLZ codes\n");
178 mlz->next_code++;
180 int ret = decode_string(mlz, &buff[output_chars], string_code, &char_code, size - output_chars);
182 av_log(mlz->context, AV_LOG_ERROR, "output chars overflow\n");
186 if (output_chars <= size && !mlz->freeze_flag) {
188 set_new_entry_dict(dict, mlz->next_code, last_string_code, char_code);
189 if (mlz->next_code >= TABLE_SIZE - 1) {
190 av_log(mlz->context, AV_LOG_ERROR, "Too many MLZ codes\n");
193 mlz->next_code++;