Skip to content

Commit aa0a3d1

Browse files
committed
1. Explicitly configure failure scenarios. 2. Change log level
1 parent ad15422 commit aa0a3d1

3 files changed

Lines changed: 27 additions & 14 deletions

File tree

code/src/iamf_dec/IAMF_OBU.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ IAMF_CodecConf *iamf_codec_conf_new(IAMF_OBU *obu) {
330330
conf->nb_samples_per_frame, conf->roll_distance);
331331

332332
if (!_valid_codec(conf->codec_id)) {
333-
ia_loge("codec configure object: id %" PRIu64 ", invalid codec %.4s",
333+
ia_logw("codec configure object: id %" PRIu64 ", invalid codec %.4s",
334334
conf->codec_conf_id, (char *)&conf->codec_id);
335335
goto codec_conf_fail;
336336
}
@@ -446,7 +446,7 @@ IAMF_Element *iamf_element_new(IAMF_OBU *obu) {
446446
} else {
447447
uint64_t size = bs_getAleb128(&b);
448448
bs_skipABytes(&b, size);
449-
ia_loge("Don't support parameter type %" PRIu64
449+
ia_logw("Don't support parameter type %" PRIu64
450450
" in Audio Element %" PRId64
451451
", parameter definition bytes %" PRIu64 ".",
452452
type, elem->element_id, size);
@@ -596,15 +596,15 @@ IAMF_Element *iamf_element_new(IAMF_OBU *obu) {
596596
conf->substream_count + conf->coupled_substream_count,
597597
conf->mapping_size);
598598
} else {
599-
ia_loge("audio element object: id %" PRIu64
599+
ia_logw("audio element object: id %" PRIu64
600600
", invalid ambisonics mode %" PRIu64,
601601
elem->element_id, conf->ambisonics_mode);
602602
goto element_fail;
603603
}
604604
} else {
605605
uint64_t size = bs_getAleb128(&b);
606606
bs_skipABytes(&b, size);
607-
ia_loge("audio element object: id %" PRIu64
607+
ia_logw("audio element object: id %" PRIu64
608608
", Don't support type %u, element config "
609609
"bytes %" PRIu64,
610610
elem->element_id, elem->element_type, size);
@@ -712,11 +712,12 @@ IAMF_MixPresentation *iamf_mix_presentation_new(IAMF_OBU *obu) {
712712
mixp->mix_presentation_id, mixp->num_labels, mixp->num_sub_mixes);
713713

714714
if (!mixp->num_sub_mixes) {
715-
ia_loge("Mix Presentation Object: num_sub_mixes should not be set to 0.");
715+
ia_logw("Mix Presentation Object: num_sub_mixes should not be set to 0.");
716716
goto mix_presentation_fail;
717-
} else if (mixp->num_sub_mixes > 1) {
717+
} else if (mixp->num_sub_mixes > IAMF_MIX_PRESENTATION_MAX_SUBS) {
718718
ia_logw(
719-
"Mix Presentation Object: Do not support num_sub_mixes more than 1.");
719+
"Mix Presentation Object: Do not support num_sub_mixes more than %u.",
720+
IAMF_MIX_PRESENTATION_MAX_SUBS);
720721
goto mix_presentation_fail;
721722
}
722723

code/src/iamf_dec/IAMF_decoder.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,9 +1203,14 @@ static int iamf_database_mix_presentation_is_valid(IAMF_DataBase *db,
12031203
int channels = 0;
12041204
ElementItem *pi = 0;
12051205

1206-
if (mp->num_sub_mixes < IAMF_MIX_PRESENTATION_MAX_SUBS) return 0;
12071206
sub = mp->sub_mixes;
1208-
if (sub->nb_elements > _profile_limit[db->profile].max_elements) return 0;
1207+
if (sub->nb_elements > _profile_limit[db->profile].max_elements) {
1208+
ia_logw("Too many elements %" PRIu64
1209+
" (should be <= %u) in mix presentation %" PRIu64 " for profile %u",
1210+
sub->nb_elements, _profile_limit[db->profile].max_elements,
1211+
mp->mix_presentation_id, db->profile);
1212+
return 0;
1213+
}
12091214

12101215
for (int e = 0; e < sub->nb_elements; ++e) {
12111216
econf = &sub->conf_s[e];
@@ -3014,6 +3019,7 @@ uint32_t iamf_decoder_internal_read_descriptors_OBUs(IAMF_DecoderHandle handle,
30143019
}
30153020
}
30163021
} else {
3022+
handle->ctx.flags |= IAMF_FLAG_FRAME_START;
30173023
if (!(~handle->ctx.flags & IAMF_FLAG_DESCRIPTORS))
30183024
handle->ctx.flags |= IAMF_FLAG_CONFIG;
30193025
break;
@@ -3128,7 +3134,7 @@ int32_t iamf_decoder_internal_add_descrptor_OBU(IAMF_DecoderHandle handle,
31283134
db = &handle->ctx.db;
31293135
obj = IAMF_object_new(obu, 0);
31303136
if (!obj) {
3131-
ia_loge("fail to new object for %s(%d)", IAMF_OBU_type_string(obu->type),
3137+
ia_logw("fail to new object for %s(%d)", IAMF_OBU_type_string(obu->type),
31323138
obu->type);
31333139
return IAMF_ERR_ALLOC_FAIL;
31343140
}
@@ -3920,8 +3926,7 @@ IAMF_DecoderHandle IAMF_decoder_open(void) {
39203926
handle->ctx.threshold_db = LIMITER_MaximumTruePeak;
39213927
handle->ctx.loudness = 1.0f;
39223928
handle->ctx.sampling_rate = OUTPUT_SAMPLERATE;
3923-
handle->ctx.normalization_loudness =
3924-
MAX_LIMITED_NORMALIZATION_LOUDNESS;
3929+
handle->ctx.normalization_loudness = MAX_LIMITED_NORMALIZATION_LOUDNESS;
39253930
handle->ctx.status = IAMF_DECODER_STATUS_INIT;
39263931
handle->ctx.mix_presentation_id = INVALID_ID;
39273932
handle->limiter = audio_effect_peak_limiter_create();
@@ -4061,10 +4066,10 @@ int iamf_decoder_internal_configure(IAMF_DecoderHandle handle,
40614066
} else {
40624067
ret = IAMF_ERR_INTERNAL;
40634068
if (ctx->mix_presentation_id != INVALID_ID)
4064-
ia_loge("Fail to find the mix presentation %" PRId64 " obu.",
4069+
ia_logw("Fail to find the mix presentation %" PRId64 " obu.",
40654070
ctx->mix_presentation_id);
40664071
else
4067-
ia_loge("Fail to find the valid mix presentation obu, try again.");
4072+
ia_logw("Fail to find the valid mix presentation obu, try again.");
40684073
}
40694074
}
40704075

@@ -4078,6 +4083,10 @@ int IAMF_decoder_configure(IAMF_DecoderHandle handle, const uint8_t *data,
40784083

40794084
if (rsize) {
40804085
*rsize = rs;
4086+
if ((ret != IAMF_OK && ret != IAMF_ERR_BUFFER_TOO_SMALL) ||
4087+
(ret == IAMF_ERR_BUFFER_TOO_SMALL &&
4088+
(handle->ctx.flags & IAMF_FLAG_FRAME_START)))
4089+
ia_loge("fail to configure decoder.");
40814090
return ret;
40824091
}
40834092

@@ -4090,6 +4099,8 @@ int IAMF_decoder_configure(IAMF_DecoderHandle handle, const uint8_t *data,
40904099
ret = iamf_decoder_internal_configure(handle, 0, 0, 0);
40914100
}
40924101

4102+
if (ret != IAMF_OK) ia_loge("fail to configure decoder.");
4103+
40934104
return ret;
40944105
}
40954106

code/src/iamf_dec/IAMF_decoder_private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#define IAMF_FLAG_AUDIO_ELEMENT 0x04
4040
#define IAMF_FLAG_MIX_PRESENTATION 0x08
4141
#define IAMF_FLAG_CONFIG 0x10
42+
#define IAMF_FLAG_FRAME_START 0x20
4243
#define IAMF_FLAG_DESCRIPTORS \
4344
(IAMF_FLAG_MAGIC_CODE | IAMF_FLAG_CODEC_CONFIG | IAMF_FLAG_AUDIO_ELEMENT | \
4445
IAMF_FLAG_MIX_PRESENTATION)

0 commit comments

Comments
 (0)