@@ -372,17 +372,17 @@ namespace ojph {
372372 //
373373 // //////////////////////////////////////////////////////////////////////////
374374
375- // ////////////////////////////////////////////////////////////////////////
376- void param_nlt::set_type3_transformation (ui32 comp_num, bool enable )
375+ // //////////////////////////////////////////////////////////////////////////
376+ void param_nlt::set_nonlinearity (ui32 comp_num, nonlinearity type )
377377 {
378- state->set_type3_transformation (comp_num, enable );
378+ state->set_nonlinearity (comp_num, type );
379379 }
380380
381- // ////////////////////////////////////////////////////////////////////////
382- bool param_nlt::get_type3_transformation (ui32 comp_num, ui8& bit_depth,
383- bool & is_signed)
381+ // //////////////////////////////////////////////////////////////////////////
382+ bool param_nlt::get_nonlinearity (ui32 comp_num, ui8& bit_depth,
383+ bool & is_signed, nonlinearity& type) const
384384 {
385- return state->get_type3_transformation (comp_num, bit_depth, is_signed);
385+ return state->get_nonlinearity (comp_num, bit_depth, is_signed, type );
386386 }
387387
388388 // //////////////////////////////////////////////////////////////////////////
@@ -1333,7 +1333,7 @@ namespace ojph {
13331333
13341334 // first stage; find out if all components captured by the default
13351335 // entry (ALL_COMPS) has the same bit_depth/signedness,
1336- // while doing this, set the BDnlt for components not captured but the
1336+ // while doing this, set the BDnlt for components not captured by the
13371337 // default entry (ALL_COMPS)
13381338 ui32 bit_depth = 0 ; // unknown yet
13391339 bool is_signed = false ; // unknown yet
@@ -1405,23 +1405,29 @@ namespace ojph {
14051405
14061406 trim_non_existing_components (num_comps);
14071407
1408- if (is_any_enabled () == false )
1409- return ;
1410- siz.set_Rsiz_flag (param_siz::RSIZ_EXT_FLAG | param_siz::RSIZ_NLT_FLAG);
1408+ if (is_any_enabled () == true )
1409+ siz.set_Rsiz_flag (param_siz::RSIZ_EXT_FLAG | param_siz::RSIZ_NLT_FLAG);
14111410 }
14121411
14131412 // ////////////////////////////////////////////////////////////////////////
1414- void param_nlt::set_type3_transformation (ui32 comp_num, bool enable )
1413+ void param_nlt::set_nonlinearity (ui32 comp_num, nonlinearity type )
14151414 {
1415+ if (type != ojph::param_nlt::OJPH_NLT_NO_NLT &&
1416+ type != ojph::param_nlt::OJPH_NLT_BINARY_COMPLEMENT_NLT)
1417+ OJPH_ERROR (0x00050171 , " Nonliearity other than types 0 "
1418+ " (No Nonlinearity) and 3 (Binary Binary Complement to Sign Magnitude "
1419+ " Conversion) is not supported yet" );
14161420 param_nlt* p = get_comp_object (comp_num);
14171421 if (p == NULL )
14181422 p = add_object (comp_num);
1419- p->enabled = enable;
1423+ p->Tnlt = type;
1424+ p->enabled = true ;
14201425 }
14211426
14221427 // ////////////////////////////////////////////////////////////////////////
1423- bool param_nlt::get_type3_transformation (ui32 comp_num, ui8& bit_depth,
1424- bool & is_signed) const
1428+ bool
1429+ param_nlt::get_nonlinearity (ui32 comp_num, ui8& bit_depth, bool & is_signed,
1430+ nonlinearity& type) const
14251431 {
14261432 const param_nlt* p = get_comp_object (comp_num);
14271433 p = p ? p : this ;
@@ -1430,8 +1436,10 @@ namespace ojph {
14301436 bit_depth = (ui8)((p->BDnlt & 0x7F ) + 1 );
14311437 bit_depth = bit_depth <= 38 ? bit_depth : 38 ;
14321438 is_signed = (p->BDnlt & 0x80 ) == 0x80 ;
1439+ type = (nonlinearity)p->Tnlt ;
1440+ return true ;
14331441 }
1434- return p-> enabled ;
1442+ return false ;
14351443 }
14361444
14371445 // ////////////////////////////////////////////////////////////////////////
@@ -1499,14 +1507,10 @@ namespace ojph {
14991507 // ////////////////////////////////////////////////////////////////////////
15001508 const param_nlt* param_nlt::get_comp_object (ui32 comp_num) const
15011509 {
1502- if (Cnlt == comp_num)
1503- return this ;
1504- else {
1505- param_nlt* p = next;
1506- while (p && p->Cnlt != comp_num)
1507- p = p->next ;
1508- return p;
1509- }
1510+ const param_nlt* p = this ;
1511+ while (p && p->Cnlt != comp_num)
1512+ p = p->next ;
1513+ return p;
15101514 }
15111515
15121516 // ////////////////////////////////////////////////////////////////////////
@@ -1540,8 +1544,11 @@ namespace ojph {
15401544 {
15411545 param_nlt* p = this ->next ;
15421546 while (p) {
1543- if (p->enabled == true && p->Cnlt >= num_comps)
1547+ if (p->enabled == true && p->Cnlt >= num_comps) {
15441548 p->enabled = false ;
1549+ OJPH_INFO (0x00050161 , " We are removing the NLT marker segment "
1550+ " for the non-existing component %d" , p->Cnlt );
1551+ }
15451552 p = p->next ;
15461553 }
15471554 }
0 commit comments