diff --git a/code/src/iamf_dec/IAMF_OBU.c b/code/src/iamf_dec/IAMF_OBU.c index 7063931e..b3c5b449 100755 --- a/code/src/iamf_dec/IAMF_OBU.c +++ b/code/src/iamf_dec/IAMF_OBU.c @@ -330,7 +330,7 @@ IAMF_CodecConf *iamf_codec_conf_new(IAMF_OBU *obu) { conf->nb_samples_per_frame, conf->roll_distance); if (!_valid_codec(conf->codec_id)) { - ia_loge("codec configure object: id %" PRIu64 ", invalid codec %.4s", + ia_logw("codec configure object: id %" PRIu64 ", invalid codec %.4s", conf->codec_conf_id, (char *)&conf->codec_id); goto codec_conf_fail; } @@ -446,7 +446,7 @@ IAMF_Element *iamf_element_new(IAMF_OBU *obu) { } else { uint64_t size = bs_getAleb128(&b); bs_skipABytes(&b, size); - ia_loge("Don't support parameter type %" PRIu64 + ia_logw("Don't support parameter type %" PRIu64 " in Audio Element %" PRId64 ", parameter definition bytes %" PRIu64 ".", type, elem->element_id, size); @@ -596,7 +596,7 @@ IAMF_Element *iamf_element_new(IAMF_OBU *obu) { conf->substream_count + conf->coupled_substream_count, conf->mapping_size); } else { - ia_loge("audio element object: id %" PRIu64 + ia_logw("audio element object: id %" PRIu64 ", invalid ambisonics mode %" PRIu64, elem->element_id, conf->ambisonics_mode); goto element_fail; @@ -604,7 +604,7 @@ IAMF_Element *iamf_element_new(IAMF_OBU *obu) { } else { uint64_t size = bs_getAleb128(&b); bs_skipABytes(&b, size); - ia_loge("audio element object: id %" PRIu64 + ia_logw("audio element object: id %" PRIu64 ", Don't support type %u, element config " "bytes %" PRIu64, elem->element_id, elem->element_type, size); @@ -712,11 +712,12 @@ IAMF_MixPresentation *iamf_mix_presentation_new(IAMF_OBU *obu) { mixp->mix_presentation_id, mixp->num_labels, mixp->num_sub_mixes); if (!mixp->num_sub_mixes) { - ia_loge("Mix Presentation Object: num_sub_mixes should not be set to 0."); + ia_logw("Mix Presentation Object: num_sub_mixes should not be set to 0."); goto mix_presentation_fail; - } else if (mixp->num_sub_mixes > 1) { + } else if (mixp->num_sub_mixes > IAMF_MIX_PRESENTATION_MAX_SUBS) { ia_logw( - "Mix Presentation Object: Do not support num_sub_mixes more than 1."); + "Mix Presentation Object: Do not support num_sub_mixes more than %u.", + IAMF_MIX_PRESENTATION_MAX_SUBS); goto mix_presentation_fail; } diff --git a/code/src/iamf_dec/IAMF_decoder.c b/code/src/iamf_dec/IAMF_decoder.c index ad181028..0c4fbbf5 100755 --- a/code/src/iamf_dec/IAMF_decoder.c +++ b/code/src/iamf_dec/IAMF_decoder.c @@ -1203,9 +1203,14 @@ static int iamf_database_mix_presentation_is_valid(IAMF_DataBase *db, int channels = 0; ElementItem *pi = 0; - if (mp->num_sub_mixes < IAMF_MIX_PRESENTATION_MAX_SUBS) return 0; sub = mp->sub_mixes; - if (sub->nb_elements > _profile_limit[db->profile].max_elements) return 0; + if (sub->nb_elements > _profile_limit[db->profile].max_elements) { + ia_logw("Too many elements %" PRIu64 + " (should be <= %u) in mix presentation %" PRIu64 " for profile %u", + sub->nb_elements, _profile_limit[db->profile].max_elements, + mp->mix_presentation_id, db->profile); + return 0; + } for (int e = 0; e < sub->nb_elements; ++e) { econf = &sub->conf_s[e]; @@ -3014,6 +3019,7 @@ uint32_t iamf_decoder_internal_read_descriptors_OBUs(IAMF_DecoderHandle handle, } } } else { + handle->ctx.flags |= IAMF_FLAG_FRAME_START; if (!(~handle->ctx.flags & IAMF_FLAG_DESCRIPTORS)) handle->ctx.flags |= IAMF_FLAG_CONFIG; break; @@ -3128,7 +3134,7 @@ int32_t iamf_decoder_internal_add_descrptor_OBU(IAMF_DecoderHandle handle, db = &handle->ctx.db; obj = IAMF_object_new(obu, 0); if (!obj) { - ia_loge("fail to new object for %s(%d)", IAMF_OBU_type_string(obu->type), + ia_logw("fail to new object for %s(%d)", IAMF_OBU_type_string(obu->type), obu->type); return IAMF_ERR_ALLOC_FAIL; } @@ -3920,8 +3926,7 @@ IAMF_DecoderHandle IAMF_decoder_open(void) { handle->ctx.threshold_db = LIMITER_MaximumTruePeak; handle->ctx.loudness = 1.0f; handle->ctx.sampling_rate = OUTPUT_SAMPLERATE; - handle->ctx.normalization_loudness = - MAX_LIMITED_NORMALIZATION_LOUDNESS; + handle->ctx.normalization_loudness = MAX_LIMITED_NORMALIZATION_LOUDNESS; handle->ctx.status = IAMF_DECODER_STATUS_INIT; handle->ctx.mix_presentation_id = INVALID_ID; handle->limiter = audio_effect_peak_limiter_create(); @@ -4061,10 +4066,10 @@ int iamf_decoder_internal_configure(IAMF_DecoderHandle handle, } else { ret = IAMF_ERR_INTERNAL; if (ctx->mix_presentation_id != INVALID_ID) - ia_loge("Fail to find the mix presentation %" PRId64 " obu.", + ia_logw("Fail to find the mix presentation %" PRId64 " obu.", ctx->mix_presentation_id); else - ia_loge("Fail to find the valid mix presentation obu, try again."); + ia_logw("Fail to find the valid mix presentation obu, try again."); } } @@ -4078,6 +4083,10 @@ int IAMF_decoder_configure(IAMF_DecoderHandle handle, const uint8_t *data, if (rsize) { *rsize = rs; + if ((ret != IAMF_OK && ret != IAMF_ERR_BUFFER_TOO_SMALL) || + (ret == IAMF_ERR_BUFFER_TOO_SMALL && + (handle->ctx.flags & IAMF_FLAG_FRAME_START))) + ia_loge("fail to configure decoder."); return ret; } @@ -4090,6 +4099,8 @@ int IAMF_decoder_configure(IAMF_DecoderHandle handle, const uint8_t *data, ret = iamf_decoder_internal_configure(handle, 0, 0, 0); } + if (ret != IAMF_OK) ia_loge("fail to configure decoder."); + return ret; } diff --git a/code/src/iamf_dec/IAMF_decoder_private.h b/code/src/iamf_dec/IAMF_decoder_private.h index 261cbe35..90134f68 100755 --- a/code/src/iamf_dec/IAMF_decoder_private.h +++ b/code/src/iamf_dec/IAMF_decoder_private.h @@ -39,6 +39,7 @@ #define IAMF_FLAG_AUDIO_ELEMENT 0x04 #define IAMF_FLAG_MIX_PRESENTATION 0x08 #define IAMF_FLAG_CONFIG 0x10 +#define IAMF_FLAG_FRAME_START 0x20 #define IAMF_FLAG_DESCRIPTORS \ (IAMF_FLAG_MAGIC_CODE | IAMF_FLAG_CODEC_CONFIG | IAMF_FLAG_AUDIO_ELEMENT | \ IAMF_FLAG_MIX_PRESENTATION)