Skip to content

Commit

Permalink
1. Explicitly configure failure scenarios. 2. Change log level
Browse files Browse the repository at this point in the history
  • Loading branch information
yilun-zhangs committed Jul 24, 2024
1 parent ad15422 commit aa0a3d1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
15 changes: 8 additions & 7 deletions code/src/iamf_dec/IAMF_OBU.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -596,15 +596,15 @@ 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;
}
} 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);
Expand Down Expand Up @@ -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;
}

Expand Down
25 changes: 18 additions & 7 deletions code/src/iamf_dec/IAMF_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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.");
}
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions code/src/iamf_dec/IAMF_decoder_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit aa0a3d1

Please sign in to comment.