1 /*
2 * Snappy decompression algorithm
3 * Copyright (c) 2015 Luca Barbato
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
24
25 enum {
30 };
31
33 {
37
38 do {
39 tmp = bytestream2_get_byte(gb);
45
47 }
48
50 {
52
54 case 63:
55 len += bytestream2_get_le32(gb);
56 break;
57 case 62:
58 len += bytestream2_get_le24(gb);
59 break;
60 case 61:
61 len += bytestream2_get_le16(gb);
62 break;
63 case 60:
64 len += bytestream2_get_byte(gb);
65 break;
66 default: // val < 60
68 }
69
72
74
76 }
77
79 unsigned int off,
int len)
80 {
81 uint8_t *q;
83 if (off > p - start ||
size <
len)
85
86 q = p - off;
87
90
92 }
93
96 {
98 unsigned int off = bytestream2_get_byte(gb) | (
val & 0x38) << 5;
99
101 }
102
105 {
107 unsigned int off = bytestream2_get_le16(gb);
108
110 }
111
114 {
116 unsigned int off = bytestream2_get_le32(gb);
117
119 }
120
122 {
124
125 if (len < 0 || len > UINT_MAX)
127
129 }
130
132 {
135
137
139 }
140
142 {
145 uint8_t *p;
146
149
152
154 p = buf;
155
157 uint8_t
s = bytestream2_get_byte(gb);
159
163 break;
166 break;
169 break;
172 break;
173 }
174
177
180 }
181
182 return 0;
183 }