OpenJPH
Open-source implementation of JPEG2000 Part-15
|
mem_outfile stores encoded j2k codestreams in memory More...
#include <ojph_file.h>
Public Member Functions | |
mem_outfile () | |
~mem_outfile () override | |
void | open (size_t initial_size=65536) |
size_t | write (const void *ptr, size_t size) override |
si64 | tell () override |
void | close () override |
const ui8 * | get_data () |
const ui8 * | get_data () const |
![]() | |
virtual | ~outfile_base () |
virtual size_t | write (const void *ptr, size_t size)=0 |
virtual si64 | tell () |
virtual void | flush () |
virtual void | close () |
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 116 of file ojph_file.h.
ojph::mem_outfile::mem_outfile | ( | ) |
|
override |
|
overridevirtual |
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 164 of file ojph_file.h.
|
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 173 of file ojph_file.h.
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.
|
inlineoverridevirtual |
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 149 of file ojph_file.h.
Referenced by write().
|
overridevirtual |
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 178 of file ojph_file.h.
Referenced by close(), mem_outfile(), open(), and write().
|
private |
Definition at line 177 of file ojph_file.h.
Referenced by close(), mem_outfile(), open(), and write().
|
private |
Definition at line 179 of file ojph_file.h.
Referenced by close(), mem_outfile(), open(), and write().
|
private |
Definition at line 176 of file ojph_file.h.
Referenced by close(), mem_outfile(), open(), and write().