MemStream.h
Go to the documentation of this file.
/*
* Copyright (C) 2016-2023 Grok Image Compression Inc.
*
* This source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
namespace grk
{
#ifdef _WIN32
typedef void* grk_handle;
#else
typedef int32_t grk_handle;
#endif
/*
* Callback function prototype for zero copy read function
*/
typedef size_t (*grk_stream_zero_copy_read_fn)(uint8_t** buffer, size_t numBytes, void* user_data);
struct MemStream
{
MemStream(uint8_t* buffer, size_t offset, size_t length, bool owns);
MemStream();
~MemStream();
uint8_t* buf;
size_t off;
size_t len;
grk_handle fd; // for file mapping
bool ownsBuffer;
};
void set_up_mem_stream(grk_stream* stream, size_t len, bool is_read_stream);
grk_stream* create_mem_stream(uint8_t* buf, size_t len, bool ownsBuffer, bool is_read_stream);
size_t get_mem_stream_offset(grk_stream* stream);
} // namespace grk
grk
Copyright (C) 2016-2023 Grok Image Compression Inc.
Definition ICacheable.h:20
grk::create_mem_stream
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
grk::set_up_mem_stream
void set_up_mem_stream(grk_stream *stream, size_t len, bool is_read_stream)
Definition MemStream.cpp:122
grk::grk_read
void grk_read(const uint8_t *buffer, TYPE *value, uint32_t numBytes)
Definition BufferedStream.h:239
grk::grk_handle
int32_t grk_handle
Definition MemStream.h:24
grk::grk_stream_zero_copy_read_fn
size_t(* grk_stream_zero_copy_read_fn)(uint8_t **buffer, size_t numBytes, void *user_data)
Definition MemStream.h:30
grk::get_mem_stream_offset
size_t get_mem_stream_offset(grk_stream *stream)
Definition MemStream.cpp:136
_grk_object
Grok ref-counted object.
Definition grok.h:126
grk::MemStream
Definition MemStream.h:33
grk::MemStream::fd
grk_handle fd
Definition MemStream.h:40
grk::MemStream::buf
uint8_t * buf
Definition MemStream.h:37
grk::MemStream::ownsBuffer
bool ownsBuffer
Definition MemStream.h:41
grk::MemStream::len
size_t len
Definition MemStream.h:39
grk::MemStream::off
size_t off
Definition MemStream.h:38
grk::MemStream::MemStream
MemStream()
Definition MemStream.cpp:24
grk::MemStream::~MemStream
~MemStream()
Definition MemStream.cpp:25