61 static int decode_string(
MLZ* mlz,
unsigned char *buff,
int string_code,
int *first_char_code,
unsigned long bufsize) {
64 int current_code, parent_code, tmp_code;
67 current_code = string_code;
70 while (count < bufsize) {
71 switch (current_code) {
77 *first_char_code = current_code;
78 buff[0] = current_code;
82 offset = dict[current_code].
match_len - 1;
84 if (offset >= bufsize) {
92 if ((current_code < 0) || (current_code > (
DIC_INDEX_MAX - 1))) {
98 offset = (dict[current_code].
match_len) - 1;
117 for (i = 0; i <
len; ++i) {
125 unsigned long output_chars;
126 int string_code, last_string_code, char_code;
130 last_string_code = -1;
133 while (output_chars < size) {
135 switch (string_code) {
140 last_string_code = -1;
150 if (string_code == (
int) mlz->
bump_code) {
156 int ret =
decode_string(mlz, &buff[output_chars], last_string_code, &char_code, size - output_chars);
157 if (ret < 0 || ret > size - output_chars) {
162 ret =
decode_string(mlz, &buff[output_chars], char_code, &char_code, size - output_chars);
163 if (ret < 0 || ret > size - output_chars) {
175 int ret =
decode_string(mlz, &buff[output_chars], string_code, &char_code, size - output_chars);
176 if (ret < 0 || ret > size - output_chars) {
181 if (output_chars <= size && !mlz->freeze_flag) {
182 if (last_string_code != -1) {
194 last_string_code = string_code;
Dictionary structure for mlz decompression.
static int decode_string(MLZ *mlz, unsigned char *buff, int string_code, int *first_char_code, unsigned long bufsize)
static int input_code(GetBitContext *gb, int len)
static void set_new_entry_dict(MLZDict *dict, int string_code, int parent_code, int char_code)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const uint8_t offset[127][2]
static void * av_mallocz_array(size_t nmemb, size_t size)
int ff_mlz_decompression(MLZ *mlz, GetBitContext *gb, int size, unsigned char *buff)
Run mlz decompression on the next size bits and the output will be stored in buff.
av_cold void ff_mlz_init_dict(void *context, MLZ *mlz)
Initialize the dictionary.
static unsigned int get_bits1(GetBitContext *s)
av_cold void ff_mlz_flush_dict(MLZ *mlz)
Flush the dictionary.
int current_dic_index_max