OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The Android Open Source Project | 2 * Copyright 2015 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkCodecPriv_DEFINED | 8 #ifndef SkCodecPriv_DEFINED |
9 #define SkCodecPriv_DEFINED | 9 #define SkCodecPriv_DEFINED |
10 | 10 |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 inline uint32_t get_int(uint8_t* buffer, uint32_t i) { | 244 inline uint32_t get_int(uint8_t* buffer, uint32_t i) { |
245 uint32_t result; | 245 uint32_t result; |
246 memcpy(&result, &(buffer[i]), 4); | 246 memcpy(&result, &(buffer[i]), 4); |
247 #ifdef SK_CPU_BENDIAN | 247 #ifdef SK_CPU_BENDIAN |
248 return SkEndianSwap32(result); | 248 return SkEndianSwap32(result); |
249 #else | 249 #else |
250 return result; | 250 return result; |
251 #endif | 251 #endif |
252 } | 252 } |
253 | 253 |
| 254 /* |
| 255 * @param data Buffer to read bytes from |
| 256 * @param isLittleEndian Output parameter |
| 257 * Indicates if the data is little endian |
| 258 * Is unaffected on false returns |
| 259 */ |
| 260 inline bool is_valid_endian_marker(const uint8_t* data, bool* isLittleEndian) { |
| 261 // II indicates Intel (little endian) and MM indicates motorola (big endian)
. |
| 262 if (('I' != data[0] || 'I' != data[1]) && ('M' != data[0] || 'M' != data[1])
) { |
| 263 return false; |
| 264 } |
| 265 |
| 266 *isLittleEndian = ('I' == data[0]); |
| 267 return true; |
| 268 } |
| 269 |
| 270 inline uint16_t get_endian_short(const uint8_t* data, bool littleEndian) { |
| 271 if (littleEndian) { |
| 272 return (data[1] << 8) | (data[0]); |
| 273 } |
| 274 |
| 275 return (data[0] << 8) | (data[1]); |
| 276 } |
| 277 |
254 #endif // SkCodecPriv_DEFINED | 278 #endif // SkCodecPriv_DEFINED |
OLD | NEW |