1 /*
2 * Copyright (c) 2016 Umair Khan <omerjerk@gmail.com>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
22
24 {
28
36
37 return 0;
38 }
39
47 }
53 }
54
61 } else {
63 }
64 }
65
66 static int decode_string(
MLZ* mlz,
unsigned char *buff,
int string_code,
int *first_char_code,
unsigned long bufsize) {
68 unsigned long count,
offset;
69 int current_code, parent_code, tmp_code;
70
71 count = 0;
72 current_code = string_code;
74
75 while (count < bufsize) {
76 switch (current_code) {
78 return count;
79 break;
80 default:
82 *first_char_code = current_code;
83 buff[0] = current_code;
84 count++;
85 return count;
86 } else {
91 return count;
92 }
94 count++;
95 }
97 if ((current_code < 0) || (current_code > (
DIC_INDEX_MAX - 1))) {
99 return count;
100 }
106 return count;
107 }
110 return count;
111 }
112 }
113 break;
114 }
115 }
116 return count;
117 }
118
120 int tmp_code = 0;
122 for (
i = 0;
i <
len; ++
i) {
124 }
125 return tmp_code;
126 }
127
130 unsigned long output_chars;
131 int string_code, last_string_code, char_code;
132
133 string_code = 0;
134 char_code = -1;
135 last_string_code = -1;
136 output_chars = 0;
137
138 while (output_chars <
size) {
140 switch (string_code) {
144 char_code = -1;
145 last_string_code = -1;
146 break;
149 break;
150 default:
153 return output_chars;
154 }
155 if (string_code == (
int) mlz->
bump_code) {
159 } else {
161 int ret =
decode_string(mlz, &buff[output_chars], last_string_code, &char_code,
size - output_chars);
162 if (ret < 0 || ret >
size - output_chars) {
164 return output_chars;
165 }
168 if (ret < 0 || ret >
size - output_chars) {
170 return output_chars;
171 }
176 return output_chars;
177 }
179 } else {
180 int ret =
decode_string(mlz, &buff[output_chars], string_code, &char_code,
size - output_chars);
181 if (ret < 0 || ret >
size - output_chars) {
183 return output_chars;
184 }
186 if (output_chars <= size && !mlz->freeze_flag) {
187 if (last_string_code != -1) {
191 return output_chars;
192 }
194 }
195 } else {
196 break;
197 }
198 }
199 last_string_code = string_code;
200 }
201 break;
202 }
203 }
204 return output_chars;
205 }