OpenJPH
Open-source implementation of JPEG2000 Part-15
|
mem_outfile stores encoded j2k codestreams in memory More...
#include <ojph_file.h>
Public Member Functions | |
OJPH_EXPORT | mem_outfile () |
OJPH_EXPORT | ~mem_outfile () |
OJPH_EXPORT void | open (size_t initial_size=65536) |
virtual OJPH_EXPORT size_t | write (const void *ptr, size_t size) |
virtual OJPH_EXPORT si64 | tell () |
virtual OJPH_EXPORT void | close () |
OJPH_EXPORT const ui8 * | get_data () |
OJPH_EXPORT const ui8 * | get_data () const |
![]() | |
virtual | ~outfile_base () |
virtual void | flush () |
Private Attributes | |
bool | is_open |
size_t | buf_size |
ui8 * | buf |
ui8 * | cur_ptr |
mem_outfile stores encoded j2k codestreams in memory
This code was first developed by Chris Hafey https://github.com/chafey I took the code and integrated with OpenJPH, with some modifications.
This class serves as a memory-based file storage. For example, generated j2k codestream is stored in memory instead of a conventional file. The memory buffer associated with this class grows with the addition of new data.
memory data can be accessed using get_data()
Definition at line 123 of file ojph_file.h.
ojph::mem_outfile::mem_outfile | ( | ) |
ojph::mem_outfile::~mem_outfile | ( | ) |
|
virtual |
Call this function to close the file and deallocate memory
The object can be used again after calling close
Reimplemented from ojph::outfile_base.
Definition at line 132 of file ojph_file.cpp.
References buf, buf_size, cur_ptr, and is_open.
Referenced by ~mem_outfile().
|
inline |
Call this function to access memory file data.
It is not recommended to store the returned value because buffer storage address can change between write calls.
Definition at line 178 of file ojph_file.h.
References buf.
|
inline |
Call this function to access memory file data (for const objects)
This is similar to the above function, except that it can be used with constant objects.
Definition at line 188 of file ojph_file.h.
References buf.
void ojph::mem_outfile::open | ( | size_t | initial_size = 65536 | ) |
Call this function to open a memory file.
This function creates a memory buffer to be used for storing the generated j2k codestream.
initial_size | is the initial memory buffer size. The default value is 2^16. |
Definition at line 116 of file ojph_file.cpp.
|
inlinevirtual |
Call this function to know the file size (i.e., number of bytes used to store the file).
Reimplemented from ojph::outfile_base.
Definition at line 161 of file ojph_file.h.
Referenced by write().
|
virtual |
Call this function to write data to the memory file.
This function adds new data to the memory file. The memory buffer of the file grows as needed.
ptr | is the address of the new data. |
size | the number of bytes in the new data. |
The function starts with a buffer size of 65536. Then, whenever the need arises, this buffer is expanded by a factor approx 1.5x
Implements ojph::outfile_base.
Definition at line 143 of file ojph_file.cpp.
|
private |
Definition at line 193 of file ojph_file.h.
Referenced by close(), get_data(), get_data(), mem_outfile(), open(), tell(), and write().
|
private |
Definition at line 192 of file ojph_file.h.
Referenced by close(), mem_outfile(), open(), and write().
|
private |
Definition at line 194 of file ojph_file.h.
Referenced by close(), mem_outfile(), open(), tell(), and write().
|
private |
Definition at line 191 of file ojph_file.h.
Referenced by close(), mem_outfile(), open(), and write().