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

Function aiff_read_header

libavformat/aiffdec.c:225–424  ·  view source on GitHub ↗

aiff input */

Source from the content-addressed store, hash-verified

223
224/* aiff input */
225static int aiff_read_header(AVFormatContext *s)
226{
227 int ret;
228 int64_t filesize, size;
229 int64_t offset = 0, position;
230 uint32_t tag;
231 unsigned version = AIFF_C_VERSION1;
232 AVIOContext *pb = s->pb;
233 AVStream * st;
234 AIFFInputContext *aiff = s->priv_data;
235 ID3v2ExtraMeta *id3v2_extra_meta;
236
237 /* check FORM header */
238 filesize = get_tag(pb, &tag);
239 if (filesize < 4 || tag != MKTAG('F', 'O', 'R', 'M'))
240 return AVERROR_INVALIDDATA;
241
242 /* AIFF data type */
243 tag = avio_rl32(pb);
244 if (tag == MKTAG('A', 'I', 'F', 'F')) /* Got an AIFF file */
245 version = AIFF;
246 else if (tag != MKTAG('A', 'I', 'F', 'C')) /* An AIFF-C file then */
247 return AVERROR_INVALIDDATA;
248
249 filesize -= 4;
250
251 st = avformat_new_stream(s, NULL);
252 if (!st)
253 return AVERROR(ENOMEM);
254
255 while (filesize > 0) {
256 /* parse different chunks */
257 size = get_tag(pb, &tag);
258
259 if (size == AVERROR_EOF && offset > 0 && st->codecpar->block_align) {
260 av_log(s, AV_LOG_WARNING, "header parser hit EOF\n");
261 goto got_sound;
262 }
263 if (size < 0)
264 return size;
265
266 filesize -= size + 8;
267
268 switch (tag) {
269 case MKTAG('C', 'O', 'M', 'M'): /* Common chunk */
270 /* Then for the complete header info */
271 st->nb_frames = get_aiff_header(s, size, version);
272 if (st->nb_frames < 0)
273 return st->nb_frames;
274 if (offset > 0) // COMM is after SSND
275 goto got_sound;
276 break;
277 case MKTAG('I', 'D', '3', ' '):
278 position = avio_tell(pb);
279 ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta, size);
280 if (id3v2_extra_meta)
281 if ((ret = ff_id3v2_parse_apic(s, id3v2_extra_meta)) < 0 ||
282 (ret = ff_id3v2_parse_chapters(s, id3v2_extra_meta)) < 0) {

Callers

nothing calls this directly

Calls 15

avio_rl32Function · 0.85
avformat_new_streamFunction · 0.85
av_logFunction · 0.85
get_aiff_headerFunction · 0.85
avio_tellFunction · 0.85
ff_id3v2_readFunction · 0.85
ff_id3v2_parse_apicFunction · 0.85
ff_id3v2_parse_chaptersFunction · 0.85
ff_id3v2_free_extra_metaFunction · 0.85
avio_skipFunction · 0.85
avio_rb32Function · 0.85
get_metaFunction · 0.85

Tested by

no test coverage detected