@@ -122,11 +122,16 @@ namespace ojph {
122122 }
123123
124124 // allocate lines
125- if (codestream->get_cod ()->is_employing_color_transform ())
125+ const param_cod* cdp = codestream->get_cod ();
126+ if (cdp->is_employing_color_transform ())
126127 {
127128 allocator->pre_alloc_obj <line_buf>(3 );
128- for (int i = 0 ; i < 3 ; ++i)
129- allocator->pre_alloc_data <si32>(width, 0 );
129+ if (cdp->access_atk ()->is_reversible ())
130+ for (int i = 0 ; i < 3 ; ++i)
131+ allocator->pre_alloc_data <si32>(width, 0 );
132+ else
133+ for (int i = 0 ; i < 3 ; ++i)
134+ allocator->pre_alloc_data <float >(width, 0 );
130135 }
131136 }
132137
@@ -230,8 +235,14 @@ namespace ojph {
230235 {
231236 num_lines = 3 ;
232237 lines = allocator->post_alloc_obj <line_buf>(num_lines);
233- for (int i = 0 ; i < 3 ; ++i)
234- lines[i].wrap (allocator->post_alloc_data <si32>(width, 0 ), width, 0 );
238+ if (reversible)
239+ for (int i = 0 ; i < 3 ; ++i)
240+ lines[i].wrap (
241+ allocator->post_alloc_data <si32>(width, 0 ), width, 0 );
242+ else
243+ for (int i = 0 ; i < 3 ; ++i)
244+ lines[i].wrap (
245+ allocator->post_alloc_data <float >(width, 0 ), width, 0 );
235246 }
236247 else
237248 {
@@ -273,13 +284,12 @@ namespace ojph {
273284 }
274285 else
275286 {
276- float mul = 1 .0f / (float )(1 <<num_bits[comp_num]);
277- const si32 *sp = line->i32 + line_offsets[comp_num];
278- float *dp = tc->f32 ;
279- if (is_signed[comp_num])
280- cnvrt_si32_to_float (sp, dp, mul, comp_width);
287+ if (nlt_type3[comp_num] == type3)
288+ irv_convert_to_float_nlt_type3 (line, line_offsets[comp_num],
289+ tc, num_bits[comp_num], is_signed[comp_num], comp_width);
281290 else
282- cnvrt_si32_to_float_shftd (sp, dp, mul, comp_width);
291+ irv_convert_to_float (line, line_offsets[comp_num],
292+ tc, num_bits[comp_num], is_signed[comp_num], comp_width);
283293 }
284294 comps[comp_num].push_line ();
285295 }
@@ -311,13 +321,14 @@ namespace ojph {
311321 }
312322 else
313323 {
314- float mul = 1 .0f / (float )(1 <<num_bits[comp_num]);
315- const si32 *sp = line->i32 + line_offsets[comp_num];
316- float *dp = lines[comp_num].f32 ;
317- if (is_signed[comp_num])
318- cnvrt_si32_to_float (sp, dp, mul, comp_width);
324+ if (nlt_type3[comp_num] == type3)
325+ irv_convert_to_float_nlt_type3 (line, line_offsets[comp_num],
326+ lines + comp_num, num_bits[comp_num], is_signed[comp_num],
327+ comp_width);
319328 else
320- cnvrt_si32_to_float_shftd (sp, dp, mul, comp_width);
329+ irv_convert_to_float (line, line_offsets[comp_num],
330+ lines + comp_num, num_bits[comp_num], is_signed[comp_num],
331+ comp_width);
321332 if (comp_num == 2 )
322333 { // irreversible color transform
323334 ict_forward (lines[0 ].f32 , lines[1 ].f32 , lines[2 ].f32 ,
@@ -364,13 +375,14 @@ namespace ojph {
364375 }
365376 else
366377 {
367- float mul = (float )(1 << num_bits[comp_num]);
368- const float *sp = src_line->f32 ;
369- si32 *dp = tgt_line->i32 + line_offsets[comp_num];
370- if (is_signed[comp_num])
371- cnvrt_float_to_si32 (sp, dp, mul, comp_width);
378+ if (nlt_type3[comp_num] == type3)
379+ irv_convert_to_integer_nlt_type3 (src_line, tgt_line,
380+ line_offsets[comp_num], num_bits[comp_num],
381+ is_signed[comp_num], comp_width);
372382 else
373- cnvrt_float_to_si32_shftd (sp, dp, mul, comp_width);
383+ irv_convert_to_integer (src_line, tgt_line,
384+ line_offsets[comp_num], num_bits[comp_num],
385+ is_signed[comp_num], comp_width);
374386 }
375387 }
376388 else
@@ -407,17 +419,19 @@ namespace ojph {
407419 }
408420 else
409421 {
410- float mul = (float )(1 << num_bits[comp_num]);
411- const float *sp;
422+ line_buf* lbp;
412423 if (comp_num < 3 )
413- sp = lines[ comp_num]. f32 ;
424+ lbp = lines + comp_num;
414425 else
415- sp = comps[comp_num].pull_line ()->f32 ;
416- si32 *dp = tgt_line->i32 + line_offsets[comp_num];
417- if (is_signed[comp_num])
418- cnvrt_float_to_si32 (sp, dp, mul, comp_width);
426+ lbp = comps[comp_num].pull_line ();
427+ if (nlt_type3[comp_num] == type3)
428+ irv_convert_to_integer_nlt_type3 (lbp, tgt_line,
429+ line_offsets[comp_num], num_bits[comp_num],
430+ is_signed[comp_num], comp_width);
419431 else
420- cnvrt_float_to_si32_shftd (sp, dp, mul, comp_width);
432+ irv_convert_to_integer (lbp, tgt_line,
433+ line_offsets[comp_num], num_bits[comp_num],
434+ is_signed[comp_num], comp_width);
421435 }
422436 }
423437
0 commit comments