@@ -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);
0 commit comments