diff options
| author | Mickael Savinaud <savmickael@users.noreply.github.com> | 2011-10-11 08:01:31 +0000 |
|---|---|---|
| committer | Mickael Savinaud <savmickael@users.noreply.github.com> | 2011-10-11 08:01:31 +0000 |
| commit | 990dd18474c667538a3e3069bcce384b92cd2641 (patch) | |
| tree | 4027363c0ecd7f3ef88249474a402656b48384b3 /libopenjpeg/cio.c | |
| parent | c4642d4fda91704f97dc85aa4f7513eaff1b571e (diff) | |
[trunk] WIP: add stream length value to read unknown marker size, backport 855 into V2 framework, correct memory leak into get_cstr_info
Diffstat (limited to 'libopenjpeg/cio.c')
| -rw-r--r-- | libopenjpeg/cio.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/libopenjpeg/cio.c b/libopenjpeg/cio.c index a65ff5c4..85a320c8 100644 --- a/libopenjpeg/cio.c +++ b/libopenjpeg/cio.c @@ -439,11 +439,11 @@ OPJ_API void OPJ_CALLCONV opj_stream_destroy(opj_stream_t* p_stream) OPJ_API void OPJ_CALLCONV opj_stream_set_read_function(opj_stream_t* p_stream, opj_stream_read_fn p_function) { opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream; - if - ((!l_stream) || (! (l_stream->m_status & opj_stream_e_input))) - { + + if ((!l_stream) || (! (l_stream->m_status & opj_stream_e_input))) { return; } + l_stream->m_read_fn = p_function; } @@ -502,6 +502,18 @@ OPJ_API void OPJ_CALLCONV opj_stream_set_user_data(opj_stream_t* p_stream, void } /** + * Sets the given data to be used as a user data for the stream. + * @param p_stream the stream to modify + * @param p_data the data to set. +*/ +OPJ_API void OPJ_CALLCONV opj_stream_set_user_data_length(opj_stream_t* p_stream, OPJ_UINT32 data_length) +{ + opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream; + + l_stream->m_user_data_length = data_length; +} + +/** * Reads some bytes from the stream. * @param p_stream the stream to read data from. * @param p_buffer pointer to the data buffer that will receive the data. @@ -852,6 +864,21 @@ OPJ_SIZE_T opj_stream_tell (const opj_stream_private_t * p_stream) return p_stream->m_byte_offset; } + +/** + * Get the number of bytes left before the end of the stream (similar to cio_numbytesleft). + * + * @param p_stream the stream to get the information from. + * + * @return Number of bytes left before the end of the stream. + */ +OPJ_SIZE_T opj_stream_get_number_byte_left (const opj_stream_private_t * p_stream) +{ + return p_stream->m_user_data_length ? + p_stream->m_user_data_length - p_stream->m_byte_offset : + 0; +} + /** * Skips a number of bytes from the stream. * @param p_stream the stream to skip data from. |
