@@ -254,6 +254,10 @@ static int _valid_profile(uint8_t primary, uint8_t addional) {
254254IAMF_Version * iamf_version_new (IAMF_OBU * obu ) {
255255 IAMF_Version * ver = 0 ;
256256 BitStream b ;
257+ union {
258+ uint32_t _id ;
259+ uint8_t _4cc [4 ];
260+ } code = {._4cc = {'i' , 'a' , 'm' , 'f' }};
257261
258262 ver = IAMF_MALLOCZ (IAMF_Version , 1 );
259263 if (!ver ) {
@@ -273,6 +277,12 @@ IAMF_Version *iamf_version_new(IAMF_OBU *obu) {
273277 "%u." ,
274278 (char * )& ver -> iamf_code , ver -> primary_profile , ver -> additional_profile );
275279
280+ if (ver -> iamf_code != code ._id ) {
281+ ia_loge ("ia sequence header object: Invalid iamf code %.4s." ,
282+ (char * )& ver -> iamf_code );
283+ goto version_fail ;
284+ }
285+
276286 if (!_valid_profile (ver -> primary_profile , ver -> additional_profile )) {
277287 ia_loge (
278288 "ia sequence header object: Invalid primary profile %u or additional "
@@ -296,6 +306,18 @@ static int _valid_codec(uint32_t codec) {
296306 return iamf_codec_check (iamf_codec_4cc_get_codecID (codec ));
297307}
298308
309+ #define OPUS_VERSION_MAX 15
310+ static int _valid_decoder_conifg (uint32_t codec , uint8_t * conf , size_t size ) {
311+ if (iamf_codec_4cc_get_codecID (codec ) == IAMF_CODEC_OPUS ) {
312+ if (conf [0 ] > OPUS_VERSION_MAX ) {
313+ ia_logw ("opus config invalid: version %u should less than %u." , conf [0 ],
314+ OPUS_VERSION_MAX );
315+ return 0 ;
316+ }
317+ }
318+ return 1 ;
319+ }
320+
299321IAMF_CodecConf * iamf_codec_conf_new (IAMF_OBU * obu ) {
300322 IAMF_CodecConf * conf = 0 ;
301323 BitStream b ;
@@ -335,6 +357,10 @@ IAMF_CodecConf *iamf_codec_conf_new(IAMF_OBU *obu) {
335357 goto codec_conf_fail ;
336358 }
337359
360+ if (!_valid_decoder_conifg (conf -> codec_id , conf -> decoder_conf ,
361+ conf -> decoder_conf_size ))
362+ goto codec_conf_fail ;
363+
338364#if SUPPORT_VERIFIER
339365 vlog_obu (IAMF_OBU_CODEC_CONFIG , conf , 0 , 0 );
340366#endif
0 commit comments