Grok 10.0.5
MemStream.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016-2023 Grok Image Compression Inc.
3 *
4 * This source code is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License, version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This source code is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Affero General Public License for more details.
12 *
13 * You should have received a copy of the GNU Affero General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#pragma once
19namespace grk
20{
21#ifdef _WIN32
22typedef void* grk_handle;
23#else
24typedef int32_t grk_handle;
25#endif
26
27/*
28 * Callback function prototype for zero copy read function
29 */
30typedef size_t (*grk_stream_zero_copy_read_fn)(uint8_t** buffer, size_t numBytes, void* user_data);
31
32struct MemStream
33{
34 MemStream(uint8_t* buffer, size_t offset, size_t length, bool owns);
35 MemStream();
36 ~MemStream();
37 uint8_t* buf;
38 size_t off;
39 size_t len;
40 grk_handle fd; // for file mapping
42};
43
44void set_up_mem_stream(grk_stream* stream, size_t len, bool is_read_stream);
45
54grk_stream* create_mem_stream(uint8_t* buf, size_t len, bool ownsBuffer, bool is_read_stream);
55
57
58} // namespace grk
BufferedStream * stream
Definition BitIO.h:88
uint8_t buf
Definition BitIO.h:84
size_t offset
Definition BitIO.h:80
uint32_t len
Definition Codeblock.h:38
uint64_t length
Definition FileFormat.h:82
grk_handle fd
Definition MemStream.h:40
size_t off
Definition MemStream.h:38
bool ownsBuffer
Definition MemStream.h:41
uint8_t * buffer
packet header storage original buffer
Definition PPMMarker.h:64
int32_t grk_handle
Definition TileCache.h:25
Copyright (C) 2016-2023 Grok Image Compression Inc.
Definition ICacheable.h:20
grk_stream * create_mem_stream(uint8_t *buf, size_t len, bool ownsBuffer, bool is_read_stream)
Create stream from buffer.
Definition MemStream.cpp:149
void set_up_mem_stream(grk_stream *stream, size_t len, bool is_read_stream)
Definition MemStream.cpp:122
grk_object grk_stream
Definition TileCache.h:23
size_t(* grk_stream_zero_copy_read_fn)(uint8_t **buffer, size_t numBytes, void *user_data)
Definition MemStream.h:30
size_t get_mem_stream_offset(grk_stream *stream)
Definition MemStream.cpp:136
void * user_data
Definition plugin_interface.h:117