MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / base64_decode

Function base64_decode

tools/server/server-common.cpp:181–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179}
180
181static inline raw_buffer base64_decode(const std::string & encoded_string) {
182 int i = 0;
183 int j = 0;
184 int in_ = 0;
185
186 int in_len = encoded_string.size();
187
188 uint8_t char_array_4[4];
189 uint8_t char_array_3[3];
190
191 raw_buffer ret;
192
193 while (in_len-- && (encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
194 char_array_4[i++] = encoded_string[in_]; in_++;
195 if (i == 4) {
196 for (i = 0; i < 4; i++) {
197 char_array_4[i] = base64_chars.find(char_array_4[i]);
198 }
199
200 char_array_3[0] = ((char_array_4[0] ) << 2) + ((char_array_4[1] & 0x30) >> 4);
201 char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
202 char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
203
204 for (i = 0; (i < 3); i++) {
205 ret.push_back(char_array_3[i]);
206 }
207
208 i = 0;
209 }
210 }
211
212 if (i) {
213 for (j = i; j < 4; j++) {
214 char_array_4[j] = 0;
215 }
216
217 for (j = 0; j < 4; j++) {
218 char_array_4[j] = base64_chars.find(char_array_4[j]);
219 }
220
221 char_array_3[0] = ((char_array_4[0] ) << 2) + ((char_array_4[1] & 0x30) >> 4);
222 char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
223 char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
224
225 for (j = 0; j < i - 1; j++) {
226 ret.push_back(char_array_3[j]);
227 }
228 }
229
230 return ret;
231}
232
233//
234// server_tokens implementation

Callers 3

tokenize_input_subpromptFunction · 0.85
handle_mediaFunction · 0.85

Calls 4

is_base64Function · 0.85
findMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected