Grok  7.6.6
MemStream.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016-2021 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
19 namespace grk {
20 
21 #ifdef _WIN32
22 typedef void* grk_handle;
23 #else
24 typedef int32_t grk_handle;
25 #endif
26 
27 /*
28  * Callback function prototype for zero copy read function
29  */
30 typedef size_t (*grk_stream_zero_copy_read_fn)(void **p_buffer, size_t nb_bytes,
31  void *user_data);
32 
33 
34 struct MemStream {
35  MemStream(uint8_t *buffer, size_t offset, size_t length, bool owns);
36  MemStream();
37  ~MemStream() ;
38  uint8_t *buf;
39  size_t off;
40  size_t len;
41  grk_handle fd; // for file mapping
42  bool ownsBuffer;
43 };
44 
45 void set_up_mem_stream(grk_stream *l_stream, size_t len,
46  bool is_read_stream);
47 grk_stream * create_mem_stream(uint8_t *buf, size_t len, bool ownsBuffer,
48  bool is_read_stream);
49 size_t get_mem_stream_offset( grk_stream *stream);
50 
51 
52 }
void * grk_stream
Definition: grok.h:829
Copyright (C) 2016-2021 Grok Image Compression Inc.
Definition: BitIO.cpp:23
grk_stream * create_mem_stream(uint8_t *buf, size_t len, bool ownsBuffer, bool is_read_stream)
Definition: MemStream.cpp:138
int32_t grk_handle
Definition: MemStream.h:24
size_t(* grk_stream_zero_copy_read_fn)(void **p_buffer, size_t nb_bytes, void *user_data)
Definition: MemStream.h:30
size_t get_mem_stream_offset(grk_stream *stream)
Definition: MemStream.cpp:127
void set_up_mem_stream(grk_stream *l_stream, size_t len, bool is_read_stream)
Definition: MemStream.cpp:114
Definition: MemStream.h:34
grk_handle fd
Definition: MemStream.h:41
uint8_t * buf
Definition: MemStream.h:38
bool ownsBuffer
Definition: MemStream.h:42
size_t len
Definition: MemStream.h:40
size_t off
Definition: MemStream.h:39
MemStream()
Definition: MemStream.cpp:27
~MemStream()
Definition: MemStream.cpp:29