Skip to content

Commit 02f3aa2

Browse files
authored
Merge pull request #172 from aous72/supporting_differing_components
This adds support for COC.
2 parents 545acbd + 52a865e commit 02f3aa2

14 files changed

+422
-179
lines changed

src/core/codestream/ojph_codeblock.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ namespace ojph {
7474
const size& cb_size,
7575
coded_cb_header* coded_cb,
7676
ui32 K_max, int line_offset,
77-
ui32 precision)
77+
ui32 precision, ui32 comp_idx)
7878
{
7979
mem_fixed_allocator* allocator = codestream->get_allocator();
8080

@@ -101,10 +101,10 @@ namespace ojph {
101101
this->K_max = K_max;
102102
for (int i = 0; i < 4; ++i)
103103
this->max_val64[i] = 0;
104-
ojph::param_cod cod = codestream->access_cod();
105-
this->reversible = cod.is_reversible();
104+
const param_cod* coc = codestream->get_coc(comp_idx);
105+
this->reversible = coc->is_reversible();
106106
this->resilient = codestream->is_resilient();
107-
this->stripe_causal = cod.get_block_vertical_causality();
107+
this->stripe_causal = coc->get_block_vertical_causality();
108108
this->zero_block = false;
109109
this->coded_cb = coded_cb;
110110

src/core/codestream/ojph_codeblock.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ namespace ojph {
7575
ui32 precision);
7676
void finalize_alloc(codestream *codestream, subband* parent,
7777
const size& nominal, const size& cb_size,
78-
coded_cb_header* coded_cb,
79-
ui32 K_max, int tbx0, ui32 precision);
78+
coded_cb_header* coded_cb, ui32 K_max,
79+
int tbx0, ui32 precision, ui32 comp_idx);
8080
void push(line_buf *line);
8181
void encode(mem_elastic_allocator *elastic);
8282
void recreate(const size& cb_size, coded_cb_header* coded_cb);

src/core/codestream/ojph_codestream_local.cpp

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ namespace ojph {
7979

8080
precinct_scratch_needed_bytes = 0;
8181

82-
used_coc_fields = 0;
83-
coc = coc_store;
84-
8582
atk = atk_store;
8683
atk[0].init_irv97();
8784
atk[0].link(atk_store + 1);
@@ -626,6 +623,9 @@ namespace ojph {
626623
if (!cod.write(file))
627624
OJPH_ERROR(0x00030025, "Error writing to file");
628625

626+
if (!cod.write_coc(file, num_comps))
627+
OJPH_ERROR(0x0003002E, "Error writing to file");
628+
629629
if (!qcd.write(file))
630630
OJPH_ERROR(0x00030026, "Error writing to file");
631631

@@ -751,7 +751,7 @@ namespace ojph {
751751
skip_marker(file, "CPF", NULL, OJPH_MSG_LEVEL::NO_MSG, false);
752752
else if (marker_idx == 3)
753753
{
754-
cod.read(file, param_cod::COD_MAIN);
754+
cod.read(file);
755755
received_markers |= 1;
756756
ojph::param_cod c(&cod);
757757
int num_qlayers = c.get_num_layers();
@@ -762,12 +762,17 @@ namespace ojph {
762762
}
763763
else if (marker_idx == 4)
764764
{
765-
ui32 num_comps = siz.get_num_components();
766-
if (coc == coc_store &&
767-
num_comps * sizeof(param_cod) > sizeof(coc_store))
768-
coc = new param_cod[num_comps];
769-
coc[used_coc_fields++].read(
770-
file, param_cod::COC_MAIN, num_comps, &cod);
765+
param_cod* p = cod.add_coc_object(param_cod::OJPH_COD_UNKNOWN);
766+
p->read_coc(file, siz.get_num_components(), &cod);
767+
if (p->get_comp_idx() >= siz.get_num_components())
768+
OJPH_INFO(0x00030056, "The codestream carries a COC marker "
769+
"segment for a component indexed by %d, which is more than the "
770+
"allowed index number, since the codestream has %d components",
771+
p->get_comp_idx(), num_comps);
772+
param_cod *q = cod.get_coc(p->get_comp_idx());
773+
if (p != q && p->get_comp_idx() == q->get_comp_idx())
774+
OJPH_ERROR(0x00030057, "The codestream has two COC marker "
775+
"segments for one component of index %d", p->get_comp_idx());
771776
}
772777
else if (marker_idx == 5)
773778
{
@@ -779,15 +784,14 @@ namespace ojph {
779784
param_qcd* p = qcd.add_qcc_object(param_qcd::OJPH_QCD_UNKNOWN);
780785
p->read_qcc(file, siz.get_num_components());
781786
if (p->get_comp_idx() >= siz.get_num_components())
782-
OJPH_ERROR(0x00030054, "The codestream carries a QCC narker "
787+
OJPH_ERROR(0x00030054, "The codestream carries a QCC marker "
783788
"segment for a component indexed by %d, which is more than the "
784789
"allowed index number, since the codestream has %d components",
785790
p->get_comp_idx(), num_comps);
786791
param_qcd *q = qcd.get_qcc(p->get_comp_idx());
787792
if (p != q && p->get_comp_idx() == q->get_comp_idx())
788793
OJPH_ERROR(0x00030055, "The codestream has two QCC marker "
789-
"segments for one component of index %d",
790-
p->get_comp_idx());
794+
"segments for one component of index %d", p->get_comp_idx());
791795
}
792796
else if (marker_idx == 7)
793797
skip_marker(file, "RGN", "RGN is not supported yet",
@@ -827,12 +831,6 @@ namespace ojph {
827831
}
828832

829833
cod.update_atk(atk);
830-
for (int i = 0; i < used_coc_fields; ++i)
831-
{
832-
if (i == 0) cod.link_cod(coc);
833-
else coc[i - 1].link_cod(coc + i);
834-
coc[i].update_atk(atk);
835-
}
836834
siz.link(&cod);
837835
if (dfs.exists())
838836
siz.link(&dfs);

src/core/codestream/ojph_codestream_local.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,6 @@ namespace ojph {
159159
param_tlm tlm; // tile-part lengths
160160
param_nlt nlt; // non-linearity point transformation
161161

162-
private: // this is to handle qcc and coc
163-
int used_coc_fields;
164-
param_cod *coc; // coding style component
165-
param_cod coc_store[4]; // we allocate 4, we allocate more if needed
166-
167162
private: // these are from Part 2 of the standard
168163
param_dfs dfs; // downsmapling factor styles
169164
param_atk* atk; // a pointer to atk

0 commit comments

Comments
 (0)