Grok 10.0.1
grok_private.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016-2022 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
20#include "grok.h"
21
22/* opaque stream object */
24
25/*
26 * read callback
27 *
28 */
29typedef size_t (*grk_stream_read_fn)(uint8_t* buffer, size_t numBytes, void* user_data);
30
31/*
32 * write callback
33 */
34typedef size_t (*grk_stream_write_fn)(const uint8_t* buffer, size_t numBytes, void* user_data);
35/*
36 * (absolute) seek callback
37 */
38typedef bool (*grk_stream_seek_fn)(uint64_t numBytes, void* user_data);
39/*
40 * free user data callback
41 */
42typedef void (*grk_stream_free_user_data_fn)(void* user_data);
43
51
59
67
76
83void grk_stream_set_user_data_length(grk_stream* stream, uint64_t data_length);
84
91grk_stream* grk_stream_create_file_stream(const char* fname, size_t buffer_size,
92 bool is_read_stream);
93
102grk_stream* grk_stream_create_mem_stream(uint8_t* buf, size_t buffer_len, bool ownsBuffer,
103 bool is_read_stream);
104
111
121
128bool grk_compress_start(grk_codec* codec);
enum _GRK_CODEC_FORMAT GRK_CODEC_FORMAT
Supported JPEG 2000 formats.
grk_codec * grk_compress_create(GRK_CODEC_FORMAT format, grk_stream *stream)
Creates a J2K/JP2 compression codec.
Definition: grok.cpp:433
grk_object grk_stream
Definition: grok_private.h:23
size_t grk_stream_get_write_mem_stream_length(grk_stream *stream)
Get length of memory stream.
Definition: grok.cpp:613
size_t(* grk_stream_read_fn)(uint8_t *buffer, size_t numBytes, void *user_data)
Definition: grok_private.h:29
void grk_stream_set_write_function(grk_stream *stream, grk_stream_write_fn func)
Set write function.
Definition: grok.cpp:910
void grk_stream_set_read_function(grk_stream *stream, grk_stream_read_fn func)
Set read function.
Definition: grok.cpp:896
void grk_stream_set_seek_function(grk_stream *stream, grk_stream_seek_fn func)
Set (absolute) seek function (stream must be seekable)
Definition: grok.cpp:904
void grk_stream_set_user_data(grk_stream *stream, void *data, grk_stream_free_user_data_fn func)
Set user data for JPEG 2000 stream.
Definition: grok.cpp:919
bool(* grk_stream_seek_fn)(uint64_t numBytes, void *user_data)
Definition: grok_private.h:38
void grk_stream_set_user_data_length(grk_stream *stream, uint64_t data_length)
Set the length of the user data for the stream.
Definition: grok.cpp:927
void(* grk_stream_free_user_data_fn)(void *user_data)
Definition: grok_private.h:42
size_t(* grk_stream_write_fn)(const uint8_t *buffer, size_t numBytes, void *user_data)
Definition: grok_private.h:34
bool grk_compress_start(grk_codec *codec)
Start compressing image.
Definition: grok.cpp:534
grk_stream * grk_stream_create_mem_stream(uint8_t *buf, size_t buffer_len, bool ownsBuffer, bool is_read_stream)
Create stream from buffer.
Definition: grok.cpp:619
grk_stream * grk_stream_create_file_stream(const char *fname, size_t buffer_size, bool is_read_stream)
Create stream from a file identified with its filename with a specific buffer size.
Definition: grok.cpp:559
HWY_DLLEXPORT HWY_NORETURN void int const char * format
Definition: base.h:848
Grok ref-counted object.
Definition: grok.h:126