diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-12-04 11:51:01 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-12-04 11:51:01 +0000 |
| commit | 23cfe2a3639bb4119c20cd1456f59e3744f489a7 (patch) | |
| tree | 8f042c218db2d21b886a40143b63730525059a75 | |
| parent | 17034ecea569cef36c678dbd3e543c65536d12ae (diff) | |
Add missing seek code; fix memory leak.1.0-openjpeg2
| -rw-r--r-- | src/j2k.cc | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -158,6 +158,12 @@ public: return nb_bytes; } + OPJ_BOOL seek (OPJ_SIZE_T nb_bytes) + { + _offset = nb_bytes; + return OPJ_TRUE; + } + Data data () const { return _data; } @@ -179,6 +185,13 @@ write_free_function (void* data) delete reinterpret_cast<WriteBuffer*>(data); } +static OPJ_BOOL +seek_function (OPJ_OFF_T nb_bytes, void* data) +{ + return reinterpret_cast<WriteBuffer*>(data)->seek (nb_bytes); +} + + Data dcp::compress_j2k (shared_ptr<const OpenJPEGImage> xyz, int bandwidth, int frames_per_second, bool threed, bool fourk) { @@ -275,6 +288,7 @@ dcp::compress_j2k (shared_ptr<const OpenJPEGImage> xyz, int bandwidth, int frame } opj_stream_set_write_function (stream, write_function); + opj_stream_set_seek_function (stream, seek_function); WriteBuffer* buffer = new WriteBuffer (); opj_stream_set_user_data (stream, buffer, write_free_function); @@ -289,6 +303,8 @@ dcp::compress_j2k (shared_ptr<const OpenJPEGImage> xyz, int bandwidth, int frame } if (!opj_end_compress (encoder, stream)) { + opj_destroy_codec (encoder); + opj_stream_destroy (stream); throw MiscError ("could not end JPEG2000 encoding"); } |
