@@ -195,10 +195,14 @@ ht_undo_impl (
195195 reinterpret_cast <const ojph::ui8*> (compressed_data) + header_sz,
196196 comp_buf_size - header_sz);
197197
198- ojph::codestream cs;
199- cs. read_headers (&infile) ;
198+ if (decode-> decompress_priv_data == NULL )
199+ return EXR_ERR_MISSING_CONTEXT_ARG ;
200200
201- ojph::param_siz siz = cs.access_siz ();
201+ ojph::codestream* cs = (ojph::codestream*) decode->decompress_priv_data ;
202+ cs->restart ();
203+ cs->read_headers (&infile);
204+
205+ ojph::param_siz siz = cs->access_siz ();
202206
203207 ojph::ui32 image_height =
204208 siz.get_image_extent ().y - siz.get_image_offset ().y ;
@@ -213,19 +217,19 @@ ht_undo_impl (
213217 decode->channels [c].y_samples > 1 )
214218 { is_planar = true ; }
215219 }
216- cs. set_planar (is_planar);
220+ cs-> set_planar (is_planar);
217221
218222 assert (decode->chunk .width == siz.get_image_extent ().x - siz.get_image_offset ().x );
219223 assert (decode->chunk .height == image_height);
220224 assert (decode->channel_count == siz.get_num_components ());
221225
222- cs. create ();
226+ cs-> create ();
223227
224228 assert (sizeof (uint16_t ) == 2 );
225229 assert (sizeof (uint32_t ) == 4 );
226230 ojph::ui32 next_comp = 0 ;
227231 ojph::line_buf* cur_line;
228- if (cs. is_planar ())
232+ if (cs-> is_planar ())
229233 {
230234 for (int16_t c = 0 ; c < decode->channel_count ; c++)
231235 {
@@ -249,7 +253,7 @@ ht_undo_impl (
249253
250254 if (line_c == static_cast <ojph::ui32>(file_c))
251255 {
252- cur_line = cs. pull (next_comp);
256+ cur_line = cs-> pull (next_comp);
253257 assert (next_comp == c);
254258
255259 if (decode->channels [file_c].data_type ==
@@ -292,7 +296,7 @@ ht_undo_impl (
292296 for (int16_t c = 0 ; c < decode->channel_count ; c++)
293297 {
294298 int file_c = cs_to_file_ch[c].file_index ;
295- cur_line = cs. pull (next_comp);
299+ cur_line = cs-> pull (next_comp);
296300 assert (next_comp == c);
297301 if (decode->channels [file_c].data_type == EXR_PIXEL_HALF)
298302 {
@@ -525,6 +529,26 @@ ht_apply_impl (exr_encode_pipeline_t* encode)
525529 return rv;
526530}
527531
532+ extern " C" exr_result_t
533+ internal_exr_decompressor_init_ht (exr_decode_pipeline_t * decode)
534+ {
535+ decode->decompress_priv_data = new ojph::codestream;
536+
537+ return EXR_ERR_SUCCESS;
538+ }
539+
540+ extern " C" void
541+ internal_exr_decompressor_destroy_ht (exr_decode_pipeline_t * decode)
542+ {
543+ if (decode->decompress_priv_data )
544+ {
545+ ojph::codestream* cs = (ojph::codestream*) decode->decompress_priv_data ;
546+ delete cs;
547+ decode->decompress_priv_data = NULL ;
548+ }
549+ }
550+
551+
528552extern " C" exr_result_t
529553internal_exr_apply_ht (exr_encode_pipeline_t * encode)
530554{
0 commit comments