Skip to content

Commit 2d0a033

Browse files
authored
Removes direct access to COC segment marker. (#312)
* Removes direct access to COC segment marker, and adds a test. This commit borrows from #272 and #309. * Changed the default creation behaviour of COC marker segment and removed an unneeded file.
1 parent e3c948f commit 2d0a033

5 files changed

Lines changed: 330 additions & 116 deletions

File tree

src/core/codestream/ojph_params.cpp

Lines changed: 49 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,32 @@ namespace ojph {
253253
}
254254

255255
////////////////////////////////////////////////////////////////////////////
256-
param_coc param_cod::get_coc(ui32 component_idx)
256+
void param_cod::set_num_decomposition(ui32 comp_idx, ui32 num_decompositions)
257257
{
258-
local::param_cod *p = state->get_coc(component_idx);
259-
if (p == state) // no COC segment marker for this component
260-
p = state->add_coc_object(component_idx);
261-
return param_coc(p);
258+
local::param_cod* cdp = state->get_or_add_coc(comp_idx);
259+
ojph::param_cod(cdp).set_num_decomposition(num_decompositions);
260+
}
261+
262+
////////////////////////////////////////////////////////////////////////////
263+
void param_cod::set_block_dims(ui32 comp_idx, ui32 width, ui32 height)
264+
{
265+
local::param_cod* cdp = state->get_or_add_coc(comp_idx);
266+
ojph::param_cod(cdp).set_block_dims(width, height);
267+
}
268+
269+
////////////////////////////////////////////////////////////////////////////
270+
void param_cod::set_precinct_size(ui32 comp_idx, int num_levels,
271+
size* precinct_size)
272+
{
273+
local::param_cod* cdp = state->get_or_add_coc(comp_idx);
274+
ojph::param_cod(cdp).set_precinct_size(num_levels, precinct_size);
275+
}
276+
277+
////////////////////////////////////////////////////////////////////////////
278+
void param_cod::set_reversible(ui32 comp_idx, bool reversible)
279+
{
280+
local::param_cod* cdp = state->get_or_add_coc(comp_idx);
281+
ojph::param_cod(cdp).set_reversible(reversible);
262282
}
263283

264284
////////////////////////////////////////////////////////////////////////////
@@ -352,56 +372,32 @@ namespace ojph {
352372
}
353373

354374
////////////////////////////////////////////////////////////////////////////
355-
//
356-
//
357-
//
358-
//
359-
//
360-
////////////////////////////////////////////////////////////////////////////
375+
ui32 param_cod::get_num_decompositions(ui32 comp_idx) const
376+
{ return state->get_coc(comp_idx)->get_num_decompositions(); }
361377

362378
////////////////////////////////////////////////////////////////////////////
363-
void param_coc::set_num_decomposition(ui32 num_decompositions)
364-
{ ojph::param_cod(state).set_num_decomposition(num_decompositions); }
379+
size param_cod::get_block_dims(ui32 comp_idx) const
380+
{ return state->get_coc(comp_idx)->get_block_dims(); }
365381

366382
////////////////////////////////////////////////////////////////////////////
367-
void param_coc::set_block_dims(ui32 width, ui32 height)
368-
{ ojph::param_cod(state).set_block_dims(width, height); }
383+
size param_cod::get_log_block_dims(ui32 comp_idx) const
384+
{ return state->get_coc(comp_idx)->get_log_block_dims(); }
369385

370386
////////////////////////////////////////////////////////////////////////////
371-
void param_coc::set_precinct_size(int num_levels, size* precinct_size)
372-
{ ojph::param_cod(state).set_precinct_size(num_levels, precinct_size); }
387+
bool param_cod::is_reversible(ui32 comp_idx) const
388+
{ return state->get_coc(comp_idx)->is_reversible(); }
373389

374390
////////////////////////////////////////////////////////////////////////////
375-
void param_coc::set_reversible(bool reversible)
376-
{ ojph::param_cod(state).set_reversible(reversible); }
391+
size param_cod::get_precinct_size(ui32 comp_idx, ui32 level_num) const
392+
{ return state->get_coc(comp_idx)->get_precinct_size(level_num); }
377393

378394
////////////////////////////////////////////////////////////////////////////
379-
ui32 param_coc::get_num_decompositions() const
380-
{ return ojph::param_cod(state).get_num_decompositions(); }
395+
size param_cod::get_log_precinct_size(ui32 comp_idx, ui32 level_num) const
396+
{ return state->get_coc(comp_idx)->get_log_precinct_size(level_num); }
381397

382398
////////////////////////////////////////////////////////////////////////////
383-
size param_coc::get_block_dims() const
384-
{ return ojph::param_cod(state).get_block_dims(); }
385-
386-
////////////////////////////////////////////////////////////////////////////
387-
size param_coc::get_log_block_dims() const
388-
{ return ojph::param_cod(state).get_log_block_dims(); }
389-
390-
////////////////////////////////////////////////////////////////////////////
391-
bool param_coc::is_reversible() const
392-
{ return ojph::param_cod(state).is_reversible(); }
393-
394-
////////////////////////////////////////////////////////////////////////////
395-
size param_coc::get_precinct_size(ui32 level_num) const
396-
{ return ojph::param_cod(state).get_precinct_size(level_num); }
397-
398-
////////////////////////////////////////////////////////////////////////////
399-
size param_coc::get_log_precinct_size(ui32 level_num) const
400-
{ return ojph::param_cod(state).get_log_precinct_size(level_num); }
401-
402-
////////////////////////////////////////////////////////////////////////////
403-
bool param_coc::get_block_vertical_causality() const
404-
{ return ojph::param_cod(state).get_block_vertical_causality(); }
399+
bool param_cod::get_block_vertical_causality(ui32 comp_idx) const
400+
{ return state->get_coc(comp_idx)->get_block_vertical_causality(); }
405401

406402

407403
////////////////////////////////////////////////////////////////////////////
@@ -1139,6 +1135,16 @@ namespace ojph {
11391135
return p->next;
11401136
}
11411137

1138+
//////////////////////////////////////////////////////////////////////////
1139+
param_cod* param_cod::get_or_add_coc(ui32 comp_idx)
1140+
{
1141+
assert(type == COD_MAIN);
1142+
local::param_cod *p = get_coc(comp_idx);
1143+
if (p == this)
1144+
p = add_coc_object(comp_idx);
1145+
return p;
1146+
}
1147+
11421148
//////////////////////////////////////////////////////////////////////////
11431149
//
11441150
//

src/core/codestream/ojph_params_local.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,9 @@ namespace ojph {
602602
////////////////////////////////////////
603603
param_cod* add_coc_object(ui32 comp_idx);
604604

605+
///////////////////////////////////////
606+
param_cod* get_or_add_coc(ui32 comp_idx);
607+
605608
////////////////////////////////////////
606609
const param_atk* access_atk() const { return atk; }
607610

@@ -629,8 +632,15 @@ namespace ojph {
629632
type = top_cod ? COC_MAIN : COD_MAIN;
630633
Lcod = 0;
631634
Scod = 0;
635+
SPcod = cod_SPcod(); // SPcod is initialized to default values
632636
next = NULL;
633637
atk = NULL;
638+
// For COC marker segment:
639+
// Lcod will be initialized on writing the marker segment to disk
640+
// Scod is initialized to 0
641+
// SGcod does not exist in COC
642+
// SPcoc is initialized to default values
643+
// atk is initialized to NULL
634644
this->top_cod = top_cod;
635645
this->comp_idx = comp_idx;
636646
}

0 commit comments

Comments
 (0)