@@ -445,9 +445,9 @@ IAMF_Element *iamf_element_new(IAMF_OBU *obu) {
445445 uint64_t size = bs_getAleb128 (& b );
446446 bs_skipABytes (& b , size );
447447 ia_loge ("Don't support parameter type %" PRIu64
448- " in Audio Element, parameter "
449- "definition bytes %" PRIu64 "." ,
450- type , size );
448+ " in Audio Element %" PRId64
449+ ", parameter definition bytes %" PRIu64 "." ,
450+ elem -> element_id , type , size );
451451 continue ;
452452 }
453453
@@ -473,6 +473,7 @@ IAMF_Element *iamf_element_new(IAMF_OBU *obu) {
473473
474474 if (elem -> element_type == AUDIO_ELEMENT_TYPE_CHANNEL_BASED ) {
475475 ScalableChannelLayoutConf * chs_conf ;
476+ int channels = 0 ;
476477 chs_conf = IAMF_MALLOCZ (ScalableChannelLayoutConf , 1 );
477478 if (!chs_conf ) {
478479 ia_loge (
@@ -484,8 +485,8 @@ IAMF_Element *iamf_element_new(IAMF_OBU *obu) {
484485
485486 val = bs_get32b (& b , 3 );
486487 bs_skip (& b , 5 );
487- chs_conf -> nb_layers = val ;
488- ia_logd ("scalable channel layers %d" , chs_conf -> nb_layers );
488+ chs_conf -> num_layers = val ;
489+ ia_logd ("scalable channel layers %d" , chs_conf -> num_layers );
489490 if (val ) {
490491 ChannelLayerConf * layer_conf_s ;
491492 layer_conf_s = IAMF_MALLOCZ (ChannelLayerConf , val );
@@ -502,6 +503,22 @@ IAMF_Element *iamf_element_new(IAMF_OBU *obu) {
502503 layer_conf_s [i ].recon_gain_flag = bs_get32b (& b , 1 );
503504 layer_conf_s [i ].nb_substreams = bs_getA8b (& b );
504505 layer_conf_s [i ].nb_coupled_substreams = bs_getA8b (& b );
506+ channels += (layer_conf_s [i ].nb_substreams +
507+ layer_conf_s [i ].nb_coupled_substreams );
508+ if (chs_conf -> nb_layers == i ) {
509+ uint8_t loudspeaker_layout = layer_conf_s [i ].loudspeaker_layout ;
510+ if (ia_channel_layout_type_check (loudspeaker_layout ) &&
511+ (layer_conf_s [i ].nb_substreams > 0 ) &&
512+ (ia_channel_layout_get_channels_count (loudspeaker_layout ) ==
513+ channels )) {
514+ ++ chs_conf -> nb_layers ;
515+ } else {
516+ ia_logw ("element (%" PRId64
517+ ") Layer %d: Invalid loudspeaker layout %d" ,
518+ elem -> element_id , i , layer_conf_s [i ].loudspeaker_layout );
519+ }
520+ }
521+
505522 ia_logd (
506523 "\tlayer[%d] info: layout %d, output gain %d, recon gain %d, "
507524 "sub-streams count %d, coupled sub-streams %d" ,
@@ -525,6 +542,7 @@ IAMF_Element *iamf_element_new(IAMF_OBU *obu) {
525542 g -> output_gain_flag & U8_MASK , g -> output_gain & U16_MASK );
526543 }
527544 }
545+ ia_logd ("valid scalable channel layers %d" , chs_conf -> nb_layers );
528546 }
529547 } else if (elem -> element_type == AUDIO_ELEMENT_TYPE_SCENE_BASED ) {
530548 AmbisonicsConf * conf = IAMF_MALLOCZ (AmbisonicsConf , 1 );
@@ -617,7 +635,7 @@ void iamf_element_free(IAMF_Element *obj) {
617635 obj -> channels_conf ) {
618636 ScalableChannelLayoutConf * conf = obj -> channels_conf ;
619637 if (conf -> layer_conf_s ) {
620- for (int i = 0 ; i < conf -> nb_layers ; ++ i ) {
638+ for (int i = 0 ; i < conf -> num_layers ; ++ i ) {
621639 IAMF_FREE (conf -> layer_conf_s [i ].output_gain_info );
622640 }
623641 free (conf -> layer_conf_s );
@@ -855,7 +873,8 @@ IAMF_MixPresentation *iamf_mix_presentation_new(IAMF_OBU *obu) {
855873 layouts [i ] = TARGET_LAYOUT (b );
856874 ia_logd ("\tLayout %d > binaural." , i );
857875 } else {
858- ia_logw ("Undefine layout type %d." , type );
876+ ia_logw ("Undefine layout type %d in mix presentation %" PRId64 "." ,
877+ type , mixp -> mix_presentation_id );
859878 }
860879 bs_align (& b );
861880
0 commit comments