@@ -73,7 +73,7 @@ class MemoryWriter
7373 void push_uint32 (uint32_t value)
7474 {
7575 if (this ->end - this ->cur < 4 )
76- throw std::out_of_range (" Insufficient data to push uint32_t" );
76+ throw std::range_error (" Insufficient data to push uint32_t" );
7777
7878 *this ->cur ++ = (value >> 24 ) & 0xFF ;
7979 *this ->cur ++ = (value >> 16 ) & 0xFF ;
@@ -84,7 +84,7 @@ class MemoryWriter
8484 void push_uint16 (uint16_t value)
8585 {
8686 if (this ->end - this ->cur < 2 )
87- throw std::out_of_range (" Insufficient data to push uint32_t" );
87+ throw std::range_error (" Insufficient data to push uint32_t" );
8888
8989 *this ->cur ++ = (value >> 8 ) & 0xFF ;
9090 *this ->cur ++ = value & 0xFF ;
@@ -153,8 +153,8 @@ read_header (
153153 * OpenJPH output file that is backed by a fixed-size memory buffer
154154 */
155155class staticmem_outfile : public ojph ::outfile_base
156- {
157- public:
156+ {
157+ public:
158158 /* * A constructor */
159159 staticmem_outfile () {
160160 is_open = false ;
@@ -197,7 +197,6 @@ class staticmem_outfile : public ojph::outfile_base
197197 size_t write (const void * ptr, size_t sz)
198198 {
199199 assert (this ->is_open );
200- assert (this ->max_size );
201200 assert (this ->buf );
202201 assert (this ->cur_ptr );
203202
@@ -281,13 +280,13 @@ class staticmem_outfile : public ojph::outfile_base
281280 */
282281 size_t get_size () const { return this ->used_size ; }
283282
284- private:
283+ private:
285284 bool is_open;
286285 size_t max_size;
287286 size_t used_size;
288287 ojph::ui8 *buf;
289288 ojph::ui8 *cur_ptr;
290- };
289+ };
291290
292291extern " C" exr_result_t
293292internal_exr_undo_ht (
@@ -515,17 +514,18 @@ internal_exr_apply_ht (exr_encode_pipeline_t* encode)
515514 cod.set_block_dims (128 , 32 );
516515 cod.set_num_decomposition (5 );
517516
518- /* write the header */
519- size_t header_sz = write_header (
520- (uint8_t *) encode->compressed_buffer ,
521- encode->packed_bytes ,
522- cs_to_file_ch);
517+ try
518+ {
519+ /* write the header */
520+ size_t header_sz = write_header (
521+ (uint8_t *) encode->compressed_buffer ,
522+ encode->packed_bytes ,
523+ cs_to_file_ch);
523524
524- /* write the codestream */
525- staticmem_outfile output;
526- output.open ( ((uint8_t *) encode->compressed_buffer ) + header_sz, encode->packed_bytes - header_sz);
525+ /* write the codestream */
526+ staticmem_outfile output;
527+ output.open ( ((uint8_t *) encode->compressed_buffer ) + header_sz, encode->packed_bytes - header_sz);
527528
528- try {
529529 cs.write_headers (&output);
530530
531531 ojph::ui32 next_comp = 0 ;
@@ -542,11 +542,11 @@ internal_exr_apply_ht (exr_encode_pipeline_t* encode)
542542 int file_c = cs_to_file_ch[c].file_index ;
543543
544544 for (int64_t y = encode->chunk .start_y ;
545- y < image_height + encode->chunk .start_y ;
546- y++)
545+ y < image_height + encode->chunk .start_y ;
546+ y++)
547547 {
548548 for (ojph::ui32 line_c = 0 ; line_c < encode->channel_count ;
549- line_c++)
549+ line_c++)
550550 {
551551
552552 if (y % encode->channels [line_c].y_samples != 0 ) continue ;
@@ -558,8 +558,8 @@ internal_exr_apply_ht (exr_encode_pipeline_t* encode)
558558 {
559559 int16_t * channel_pixels = (int16_t *) (line_pixels);
560560 for (uint32_t p = 0 ;
561- p < encode->channels [file_c].width ;
562- p++)
561+ p < encode->channels [file_c].width ;
562+ p++)
563563 {
564564 cur_line->i32 [p] = *channel_pixels++;
565565 }
@@ -568,8 +568,8 @@ internal_exr_apply_ht (exr_encode_pipeline_t* encode)
568568 {
569569 int32_t * channel_pixels = (int32_t *) (line_pixels);
570570 for (uint32_t p = 0 ;
571- p < encode->channels [file_c].width ;
572- p++)
571+ p < encode->channels [file_c].width ;
572+ p++)
573573 {
574574 cur_line->i32 [p] = *channel_pixels++;
575575 }
@@ -580,7 +580,7 @@ internal_exr_apply_ht (exr_encode_pipeline_t* encode)
580580 }
581581
582582 line_pixels += encode->channels [line_c].bytes_per_element *
583- encode->channels [line_c].width ;
583+ encode->channels [line_c].width ;
584584 }
585585 }
586586 }
@@ -603,7 +603,7 @@ internal_exr_apply_ht (exr_encode_pipeline_t* encode)
603603 int16_t * channel_pixels =
604604 (int16_t *) (line_pixels + cs_to_file_ch[c].raster_line_offset );
605605 for (uint32_t p = 0 ; p < encode->channels [file_c].width ;
606- p++)
606+ p++)
607607 {
608608 cur_line->i32 [p] = *channel_pixels++;
609609 }
@@ -613,7 +613,7 @@ internal_exr_apply_ht (exr_encode_pipeline_t* encode)
613613 int32_t * channel_pixels =
614614 (int32_t *) (line_pixels + cs_to_file_ch[c].raster_line_offset );
615615 for (uint32_t p = 0 ; p < encode->channels [file_c].width ;
616- p++)
616+ p++)
617617 {
618618 cur_line->i32 [p] = *channel_pixels++;
619619 }
0 commit comments