54 if (base->
seek(base, -4, SEEK_END) < 13) {
63 if (base->
seek(base, -5, SEEK_END) < 0 || base->
read(base, &flags, 1) != 1) {
67 bool has_checksums = (flags & 0x80);
79 uint32_t expected_frame_length = frames_num * (has_checksums ? 12 : 8) + 9;
82 off64_t frame_start_ofs = 8 + expected_frame_length;
85 off64_t seek_frame_start = base->
seek(base, -frame_start_ofs, SEEK_END);
86 if (seek_frame_start < frames_num * 8) {
95 if (!
zstd_read_u32(base, &frame_length) || frame_length != expected_frame_length) {
103 size_t compressed_ofs = 0;
104 size_t uncompressed_ofs = 0;
105 for (
int i = 0; i < frames_num; i++) {
106 uint32_t compressed_size, uncompressed_size;
110 if (has_checksums && base->
seek(base, 4, SEEK_CUR) < 0) {
115 compressed_ofs += compressed_size;
116 uncompressed_ofs += uncompressed_size;
122 if (seek_frame_start != compressed_ofs || base->
seek(base, seek_frame_start, SEEK_SET) < 0) {
125 memset(&zstd->
seek, 0,
sizeof(zstd->
seek));
172 char *uncompressed_data =
MEM_mallocN(uncompressed_size, __func__);
173 char *compressed_data =
MEM_mallocN(compressed_size, __func__);
175 zstd->
base->
read(zstd->
base, compressed_data, compressed_size) < compressed_size) {
181 size_t res = ZSTD_decompressDCtx(
182 zstd->
ctx, uncompressed_data, uncompressed_size, compressed_data, compressed_size);
184 if (ZSTD_isError(res) || res < uncompressed_size) {
191 return uncompressed_data;
207 if (framedata ==
NULL) {
213 size_t frame_read_len = frame_end_offset - zstd->
reader.
offset;
216 memcpy((
char *)
buffer + read_len, framedata + offset_in_frame, frame_read_len);
217 read_len += frame_read_len;
228 if (whence == SEEK_SET) {
231 else if (whence == SEEK_END) {
259 zstd->
in_buf.size = readsize;
267 if (ZSTD_isError(ZSTD_decompressStream(zstd->
ctx, &
output, &zstd->
in_buf))) {
280 ZSTD_freeDCtx(zstd->
ctx);
301 zstd->
ctx = ZSTD_createDCtx();
BLI_INLINE void BLI_endian_switch_uint32(unsigned int *val) ATTR_NONNULL(1)
Wrapper for reading from various sources (e.g. raw files, compressed files, memory....
MINLINE size_t min_zz(size_t a, size_t b)
Read Guarded memory(de)allocation.
__forceinline ssef low(const avxf &a)
__forceinline ssef high(const avxf &a)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
static ssize_t zstd_read(FileReader *reader, void *buffer, size_t size)
static void zstd_close(FileReader *reader)
static off64_t zstd_seek(FileReader *reader, off64_t offset, int whence)
static const char * zstd_ensure_cache(ZstdReader *zstd, int frame)
FileReader * BLI_filereader_new_zstd(FileReader *base)
static int zstd_frame_from_pos(ZstdReader *zstd, size_t pos)
static bool zstd_read_seek_table(ZstdReader *zstd)
static bool zstd_read_u32(FileReader *base, uint32_t *val)
static ssize_t zstd_read_seekable(FileReader *reader, void *buffer, size_t size)
ccl_global float * buffer
ccl_global KernelShaderEvalInput ccl_global float * output
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
struct ZstdReader::@127 seek
size_t * uncompressed_ofs
static int magic(const Tex *tex, const float texvec[3], TexResult *texres)