Use ff_mp4_read_descr() to read both the tags and the vlc value that comes after it, which was not being taken into account. Ref: https://github.com/AOMediaCodec/libiamf/issues/119
Unified · Split
| @@ -67,7 +67,7 @@ static int aac_decoder_config(IAMFCodecConfig *codec_config, · 66 unmodified lines | ||
| 67 | 67 | if (codec_config->audio_roll_distance >= 0) |
| 68 | 68 | return AVERROR_INVALIDDATA; |
| 69 | 69 | |
| 70 | − tag = avio_r8(pb); | |
| 70 | + ff_mp4_read_descr(logctx, pb, &tag); | |
| 71 | 71 | if (tag != MP4DecConfigDescrTag) |
| 72 | 72 | return AVERROR_INVALIDDATA; |
| 73 | 73 | |
| @@ -87,12 +87,9 @@ static int aac_decoder_config(IAMFCodecConfig *codec_config, · 13 unmodified lines | ||
| 87 | 87 | if (codec_id && codec_id != codec_config->codec_id) |
| 88 | 88 | return AVERROR_INVALIDDATA; |
| 89 | 89 | |
| 90 | − tag = avio_r8(pb); | |
| 91 | − if (tag != MP4DecSpecificDescrTag) | |
| 92 | − return AVERROR_INVALIDDATA; | |
| 93 | − | |
| 94 | − left = len - avio_tell(pb); | |
| 95 | − if (left <= 0) | |
| 90 | + left = ff_mp4_read_descr(logctx, pb, &tag); | |
| 91 | + if (tag != MP4DecSpecificDescrTag || | |
| 92 | + !left || left > (len - avio_tell(pb))) | |
| 96 | 93 | return AVERROR_INVALIDDATA; |
| 97 | 94 | |
| 98 | 95 | // We pad extradata here because avpriv_mpeg4audio_get_config2() needs it. |
| @@ -100,9 +97,9 @@ static int aac_decoder_config(IAMFCodecConfig *codec_config, · 1 unmodified line | ||
| 100 | 97 | if (!codec_config->extradata) |
| 101 | 98 | return AVERROR(ENOMEM); |
| 102 | 99 | |
| 103 | − codec_config->extradata_size = avio_read(pb, codec_config->extradata, left); | |
| 104 | − if (codec_config->extradata_size < left) | |
| 105 | − return AVERROR_INVALIDDATA; | |
| 100 | + codec_config->extradata_size = ffio_read_size(pb, codec_config->extradata, left); | |
| 101 | + if (ret < 0) | |
| 102 | + return ret; | |
| 106 | 103 | memset(codec_config->extradata + codec_config->extradata_size, 0, |
| 107 | 104 | AV_INPUT_BUFFER_PADDING_SIZE); |
| 108 | 105 | |