MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / aac_decoder_config

Function aac_decoder_config

libavformat/iamf_parse.c:60–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60static int aac_decoder_config(IAMFCodecConfig *codec_config,
61 AVIOContext *pb, int len, void *logctx)
62{
63 MPEG4AudioConfig cfg = { 0 };
64 int object_type_id, codec_id, stream_type;
65 int ret, tag, left;
66
67 if (codec_config->audio_roll_distance >= 0)
68 return AVERROR_INVALIDDATA;
69
70 ff_mp4_read_descr(logctx, pb, &tag);
71 if (tag != MP4DecConfigDescrTag)
72 return AVERROR_INVALIDDATA;
73
74 object_type_id = avio_r8(pb);
75 if (object_type_id != 0x40)
76 return AVERROR_INVALIDDATA;
77
78 stream_type = avio_r8(pb);
79 if (((stream_type >> 2) != 5) || ((stream_type >> 1) & 1))
80 return AVERROR_INVALIDDATA;
81
82 avio_skip(pb, 3); // buffer size db
83 avio_skip(pb, 4); // rc_max_rate
84 avio_skip(pb, 4); // avg bitrate
85
86 codec_id = ff_codec_get_id(ff_mp4_obj_type, object_type_id);
87 if (codec_id && codec_id != codec_config->codec_id)
88 return AVERROR_INVALIDDATA;
89
90 left = ff_mp4_read_descr(logctx, pb, &tag);
91 if (tag != MP4DecSpecificDescrTag ||
92 !left || left > (len - avio_tell(pb)))
93 return AVERROR_INVALIDDATA;
94
95 // We pad extradata here because avpriv_mpeg4audio_get_config2() needs it.
96 codec_config->extradata = av_malloc((size_t)left + AV_INPUT_BUFFER_PADDING_SIZE);
97 if (!codec_config->extradata)
98 return AVERROR(ENOMEM);
99
100 ret = ffio_read_size(pb, codec_config->extradata, left);
101 if (ret < 0)
102 return ret;
103 codec_config->extradata_size = left;
104 memset(codec_config->extradata + codec_config->extradata_size, 0,
105 AV_INPUT_BUFFER_PADDING_SIZE);
106
107 ret = avpriv_mpeg4audio_get_config2(&cfg, codec_config->extradata,
108 codec_config->extradata_size, 1, logctx);
109 if (ret < 0)
110 return ret;
111
112 codec_config->sample_rate = cfg.sample_rate;
113
114 return 0;
115}
116
117static int flac_decoder_config(IAMFCodecConfig *codec_config,

Callers 1

codec_config_obuFunction · 0.85

Calls 8

ff_mp4_read_descrFunction · 0.85
avio_r8Function · 0.85
avio_skipFunction · 0.85
ff_codec_get_idFunction · 0.85
avio_tellFunction · 0.85
ffio_read_sizeFunction · 0.85
av_mallocFunction · 0.50

Tested by

no test coverage detected