FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavformat/aiffdec.c
Date: 2026-05-02 17:52:23
Exec Total Coverage
Lines: 170 291 58.4%
Functions: 7 7 100.0%
Branches: 88 193 45.6%

Line Branch Exec Source
1 /*
2 * AIFF/AIFF-C demuxer
3 * Copyright (c) 2006 Patrick Guimond
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include "libavutil/attributes.h"
23 #include "libavutil/intreadwrite.h"
24 #include "libavutil/dict.h"
25 #include "libavutil/mem.h"
26 #include "avformat.h"
27 #include "avio_internal.h"
28 #include "demux.h"
29 #include "internal.h"
30 #include "pcm.h"
31 #include "aiff.h"
32 #include "id3v2.h"
33 #include "mov_chan.h"
34 #include "replaygain.h"
35
36 #define AIFF 0
37 #define AIFF_C_VERSION1 0xA2805140
38
39 typedef struct AIFFInputContext {
40 int64_t data_end;
41 int block_duration;
42 } AIFFInputContext;
43
44 6 static enum AVCodecID aiff_codec_get_id(int bps)
45 {
46
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (bps <= 8)
47 return AV_CODEC_ID_PCM_S8;
48
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
6 if (bps <= 16)
49 4 return AV_CODEC_ID_PCM_S16BE;
50
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (bps <= 24)
51 2 return AV_CODEC_ID_PCM_S24BE;
52 if (bps <= 32)
53 return AV_CODEC_ID_PCM_S32BE;
54
55 /* bigger than 32 isn't allowed */
56 return AV_CODEC_ID_NONE;
57 }
58
59 /* returns the size of the found tag */
60 58 static int64_t get_tag(AVIOContext *pb, uint32_t * tag)
61 {
62 int64_t size;
63
64
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
58 if (avio_feof(pb))
65 return AVERROR_INVALIDDATA;
66
67 58 *tag = avio_rl32(pb);
68 58 size = avio_rb32(pb);
69
70 58 return size;
71 }
72
73 /* Metadata string read */
74 8 static void get_meta(AVFormatContext *s, const char *key, int64_t size)
75 {
76 8 uint8_t *str = NULL;
77
78
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (size < SIZE_MAX)
79 8 str = av_malloc(size+1);
80
81
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (str) {
82 8 int res = avio_read(s->pb, str, size);
83
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (res < 0){
84 av_free(str);
85 return;
86 }
87 8 size -= res;
88 8 str[res] = 0;
89 8 av_dict_set(&s->metadata, key, str, AV_DICT_DONT_STRDUP_VAL);
90 }
91
92 8 avio_skip(s->pb, size);
93 }
94
95 /* Returns the number of sound data frames or negative on error */
96 12 static int get_aiff_header(AVFormatContext *s, int64_t size,
97 unsigned version)
98 {
99 12 AVIOContext *pb = s->pb;
100 12 AVCodecParameters *par = s->streams[0]->codecpar;
101 12 AIFFInputContext *aiff = s->priv_data;
102 int exp;
103 uint64_t val;
104 int sample_rate;
105 unsigned int num_frames;
106 int channels;
107
108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (size & 1)
109 size++;
110 12 par->codec_type = AVMEDIA_TYPE_AUDIO;
111 12 channels = avio_rb16(pb);
112
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
12 if (par->ch_layout.nb_channels && par->ch_layout.nb_channels != channels)
113 return AVERROR_INVALIDDATA;
114 12 par->ch_layout.nb_channels = channels;
115 12 num_frames = avio_rb32(pb);
116 12 par->bits_per_coded_sample = avio_rb16(pb);
117
118 12 exp = avio_rb16(pb) - 16383 - 63;
119 12 val = avio_rb64(pb);
120
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if (exp <-63 || exp >63) {
121 av_log(s, AV_LOG_ERROR, "exp %d is out of range\n", exp);
122 return AVERROR_INVALIDDATA;
123 }
124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (exp >= 0)
125 sample_rate = val << exp;
126 else
127 12 sample_rate = (val + (1ULL<<(-exp-1))) >> -exp;
128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (sample_rate <= 0)
129 return AVERROR_INVALIDDATA;
130
131 12 par->sample_rate = sample_rate;
132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (size < 18)
133 return AVERROR_INVALIDDATA;
134 12 size -= 18;
135
136 /* get codec id for AIFF-C */
137
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if (size < 4) {
138 6 version = AIFF;
139
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 } else if (version == AIFF_C_VERSION1) {
140 6 par->codec_tag = avio_rl32(pb);
141 6 par->codec_id = ff_codec_get_id(ff_codec_aiff_tags, par->codec_tag);
142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (par->codec_id == AV_CODEC_ID_NONE)
143 avpriv_request_sample(s, "unknown or unsupported codec tag: %s",
144 av_fourcc2str(par->codec_tag));
145 6 size -= 4;
146 }
147
148
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
12 if (version != AIFF_C_VERSION1 || par->codec_id == AV_CODEC_ID_PCM_S16BE) {
149 6 par->codec_id = aiff_codec_get_id(par->bits_per_coded_sample);
150 6 par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id);
151 6 aiff->block_duration = 1;
152 } else {
153
2/9
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
6 switch (par->codec_id) {
154 2 case AV_CODEC_ID_PCM_F32BE:
155 case AV_CODEC_ID_PCM_F64BE:
156 case AV_CODEC_ID_PCM_S16LE:
157 case AV_CODEC_ID_PCM_ALAW:
158 case AV_CODEC_ID_PCM_MULAW:
159 2 aiff->block_duration = 1;
160 2 break;
161 4 case AV_CODEC_ID_ADPCM_IMA_QT:
162 4 par->block_align = 34 * channels;
163 4 break;
164 case AV_CODEC_ID_MACE3:
165 par->block_align = 2 * channels;
166 break;
167 case AV_CODEC_ID_ADPCM_G726LE:
168 par->bits_per_coded_sample = 5;
169 av_fallthrough;
170 case AV_CODEC_ID_ADPCM_IMA_WS:
171 case AV_CODEC_ID_ADPCM_G722:
172 case AV_CODEC_ID_MACE6:
173 case AV_CODEC_ID_CBD2_DPCM:
174 case AV_CODEC_ID_SDX2_DPCM:
175 par->block_align = 1 * channels;
176 break;
177 case AV_CODEC_ID_GSM:
178 par->block_align = 33;
179 break;
180 case AV_CODEC_ID_G728:
181 par->block_align = 5;
182 break;
183 case AV_CODEC_ID_ADPCM_N64:
184 par->block_align = 9;
185 break;
186 default:
187 aiff->block_duration = 1;
188 break;
189 }
190
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
6 if (par->block_align > 0)
191 4 aiff->block_duration = av_get_audio_frame_duration2(par,
192 par->block_align);
193 }
194
195 /* Block align needs to be computed in all cases, as the definition
196 * is specific to applications -> here we use the WAVE format definition */
197
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if (!par->block_align)
198 8 par->block_align = (av_get_bits_per_sample(par->codec_id) * channels) >> 3;
199
200
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if (aiff->block_duration) {
201 12 par->bit_rate = av_rescale(par->sample_rate, par->block_align * 8LL,
202 12 aiff->block_duration);
203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (par->bit_rate < 0)
204 par->bit_rate = 0;
205 }
206
207 /* Chunk is over */
208
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if (size)
209 6 avio_skip(pb, size);
210
211 12 return num_frames;
212 }
213
214 7480 static int aiff_probe(const AVProbeData *p)
215 {
216 /* check file header */
217
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 7458 times.
7480 if (AV_RL32(p->buf) == MKTAG('F', 'O', 'R', 'M') &&
218
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 AV_RB32(p->buf + 4) >= 4 &&
219
4/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 1 times.
22 p->buf[8] == 'A' && p->buf[9] == 'I' &&
220
4/6
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
12 p->buf[10] == 'F' && (p->buf[11] == 'F' || p->buf[11] == 'C'))
221 12 return AVPROBE_SCORE_MAX;
222 else
223 7468 return 0;
224 }
225
226 /* aiff input */
227 12 static int aiff_read_header(AVFormatContext *s)
228 {
229 int ret;
230 int64_t filesize, size;
231 12 int64_t offset = 0, position;
232 uint32_t tag;
233 12 unsigned version = AIFF_C_VERSION1;
234 12 AVIOContext *pb = s->pb;
235 AVStream * st;
236 12 AIFFInputContext *aiff = s->priv_data;
237 ID3v2ExtraMeta *id3v2_extra_meta;
238
239 /* check FORM header */
240 12 filesize = get_tag(pb, &tag);
241
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if (filesize < 4 || tag != MKTAG('F', 'O', 'R', 'M'))
242 return AVERROR_INVALIDDATA;
243
244 /* AIFF data type */
245 12 tag = avio_rl32(pb);
246
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if (tag == MKTAG('A', 'I', 'F', 'F')) /* Got an AIFF file */
247 6 version = AIFF;
248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if (tag != MKTAG('A', 'I', 'F', 'C')) /* An AIFF-C file then */
249 return AVERROR_INVALIDDATA;
250
251 12 filesize -= 4;
252
253 12 st = avformat_new_stream(s, NULL);
254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (!st)
255 return AVERROR(ENOMEM);
256
257
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 12 times.
58 while (filesize > 0) {
258 /* parse different chunks */
259 46 size = get_tag(pb, &tag);
260
261
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
46 if (size == AVERROR_EOF && offset > 0 && st->codecpar->block_align) {
262 av_log(s, AV_LOG_WARNING, "header parser hit EOF\n");
263 goto got_sound;
264 }
265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 if (size < 0)
266 return size;
267
268 46 filesize -= size + 8;
269
270
7/14
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
46 switch (tag) {
271 12 case MKTAG('C', 'O', 'M', 'M'): /* Common chunk */
272 /* Then for the complete header info */
273 12 st->nb_frames = get_aiff_header(s, size, version);
274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (st->nb_frames < 0)
275 return st->nb_frames;
276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (offset > 0) // COMM is after SSND
277 goto got_sound;
278 12 break;
279 6 case MKTAG('I', 'D', '3', ' '):
280 6 position = avio_tell(pb);
281 6 ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta, size);
282
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (id3v2_extra_meta)
283
2/4
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
12 if ((ret = ff_id3v2_parse_apic(s, id3v2_extra_meta)) < 0 ||
284 6 (ret = ff_id3v2_parse_chapters(s, id3v2_extra_meta)) < 0) {
285 ff_id3v2_free_extra_meta(&id3v2_extra_meta);
286 return ret;
287 }
288 6 ff_id3v2_free_extra_meta(&id3v2_extra_meta);
289
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
6 if (position + size > avio_tell(pb))
290 avio_skip(pb, position + size - avio_tell(pb));
291 6 break;
292 6 case MKTAG('F', 'V', 'E', 'R'): /* Version chunk */
293 6 version = avio_rb32(pb);
294 6 break;
295 6 case MKTAG('N', 'A', 'M', 'E'): /* Sample name chunk */
296 6 get_meta(s, "title" , size);
297 6 break;
298 case MKTAG('A', 'U', 'T', 'H'): /* Author chunk */
299 get_meta(s, "author" , size);
300 break;
301 2 case MKTAG('(', 'c', ')', ' '): /* Copyright chunk */
302 2 get_meta(s, "copyright", size);
303 2 break;
304 case MKTAG('A', 'N', 'N', 'O'): /* Annotation chunk */
305 get_meta(s, "comment" , size);
306 break;
307 12 case MKTAG('S', 'S', 'N', 'D'): /* Sampled sound chunk */
308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (size < 8)
309 return AVERROR_INVALIDDATA;
310 12 aiff->data_end = avio_tell(pb) + size;
311 12 offset = avio_rb32(pb); /* Offset of sound data */
312 12 avio_rb32(pb); /* BlockSize... don't care */
313 12 offset += avio_tell(pb); /* Compute absolute data offset */
314
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if (st->codecpar->block_align && !(pb->seekable & AVIO_SEEKABLE_NORMAL)) /* Assume COMM already parsed */
315 goto got_sound;
316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (!(pb->seekable & AVIO_SEEKABLE_NORMAL)) {
317 av_log(s, AV_LOG_ERROR, "file is not seekable\n");
318 return -1;
319 }
320 12 avio_skip(pb, size - 8);
321 12 break;
322 case MKTAG('w', 'a', 'v', 'e'):
323 if ((uint64_t)size > (1<<30))
324 return AVERROR_INVALIDDATA;
325 if ((ret = ff_get_extradata(s, st->codecpar, pb, size)) < 0)
326 return ret;
327 if ( (st->codecpar->codec_id == AV_CODEC_ID_QDMC || st->codecpar->codec_id == AV_CODEC_ID_QDM2)
328 && size>=12*4 && !st->codecpar->block_align) {
329 st->codecpar->block_align = AV_RB32(st->codecpar->extradata+11*4);
330 aiff->block_duration = AV_RB32(st->codecpar->extradata+9*4);
331 } else if (st->codecpar->codec_id == AV_CODEC_ID_QCELP) {
332 char rate = 0;
333 if (size >= 25)
334 rate = st->codecpar->extradata[24];
335 switch (rate) {
336 case 'H': // RATE_HALF
337 st->codecpar->block_align = 17;
338 break;
339 case 'F': // RATE_FULL
340 default:
341 st->codecpar->block_align = 35;
342 }
343 aiff->block_duration = 160;
344 st->codecpar->bit_rate = (int64_t)st->codecpar->sample_rate * (st->codecpar->block_align << 3) /
345 aiff->block_duration;
346 }
347 break;
348 2 case MKTAG('C','H','A','N'):
349
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 if ((ret = ff_mov_read_chan(s, pb, st, size)) < 0)
350 return ret;
351 2 break;
352 case MKTAG('A','P','C','M'): /* XA ADPCM compressed sound chunk */
353 st->codecpar->codec_id = AV_CODEC_ID_ADPCM_XA;
354 aiff->data_end = avio_tell(pb) + size;
355 offset = avio_tell(pb) + 8;
356 /* This field is unknown and its data seems to be irrelevant */
357 avio_rb32(pb);
358 st->codecpar->block_align = avio_rb32(pb);
359
360 goto got_sound;
361 break;
362 case MKTAG('A','P','P','L'):
363 if (size > 4) {
364 uint32_t chunk = avio_rl32(pb);
365
366 size -= 4;
367 if (chunk == MKTAG('s','t','o','c')) {
368 int len = avio_r8(pb);
369
370 size--;
371 if (len == 11 && size > 11) {
372 uint8_t chunk[11];
373
374 ret = ffio_read_size(pb, chunk, 11);
375 if (ret < 0)
376 return ret;
377 size -= ret;
378 if (!memcmp(chunk, "VADPCMCODES", sizeof(chunk))) {
379 if ((ret = ff_get_extradata(s, st->codecpar, pb, size)) < 0)
380 return ret;
381 size -= ret;
382 }
383 }
384 }
385 }
386 avio_skip(pb, size);
387 break;
388 case 0:
389 if (offset > 0 && st->codecpar->block_align) // COMM && SSND
390 goto got_sound;
391 av_fallthrough;
392 default: /* Jump */
393 avio_skip(pb, size);
394 }
395
396 /* Skip required padding byte for odd-sized chunks. */
397
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 42 times.
46 if (size & 1) {
398 4 filesize--;
399 4 avio_skip(pb, 1);
400 }
401 }
402
403 12 ret = ff_replaygain_export(st, s->metadata);
404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (ret < 0)
405 return ret;
406
407 12 got_sound:
408
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if (!st->codecpar->block_align && st->codecpar->codec_id == AV_CODEC_ID_QCELP) {
409 av_log(s, AV_LOG_WARNING, "qcelp without wave chunk, assuming full rate\n");
410 st->codecpar->block_align = 35;
411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 } else if (st->codecpar->block_align <= 0) {
412 av_log(s, AV_LOG_ERROR, "could not find COMM tag or invalid block_align value\n");
413 return AVERROR_INVALIDDATA;
414 }
415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (aiff->block_duration < 0)
416 return AVERROR_INVALIDDATA;
417
418 /* Now positioned, get the sound data start and end */
419 12 avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
420 12 st->start_time = 0;
421 12 st->duration = st->nb_frames * aiff->block_duration;
422
423 /* Position the stream at the first block */
424 12 avio_seek(pb, offset, SEEK_SET);
425
426 12 return 0;
427 }
428
429 #define MAX_SIZE 4096
430
431 8871 static int aiff_read_packet(AVFormatContext *s,
432 AVPacket *pkt)
433 {
434 8871 AVStream *st = s->streams[0];
435 8871 AIFFInputContext *aiff = s->priv_data;
436 int64_t max_size;
437 int res, size;
438
439 /* calculate size of remaining data */
440 8871 max_size = aiff->data_end - avio_tell(s->pb);
441
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 8850 times.
8871 if (max_size <= 0)
442 21 return AVERROR_EOF;
443
444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8850 times.
8850 if (!st->codecpar->block_align) {
445 av_log(s, AV_LOG_ERROR, "block_align not set\n");
446 return AVERROR_INVALIDDATA;
447 }
448
449 /* Now for that packet */
450
2/2
✓ Branch 0 taken 8422 times.
✓ Branch 1 taken 428 times.
8850 switch (st->codecpar->codec_id) {
451 8422 case AV_CODEC_ID_ADPCM_IMA_QT:
452 case AV_CODEC_ID_GSM:
453 case AV_CODEC_ID_QDM2:
454 case AV_CODEC_ID_QCELP:
455 8422 size = st->codecpar->block_align;
456 8422 break;
457 428 default:
458
1/2
✓ Branch 0 taken 428 times.
✗ Branch 1 not taken.
428 size = st->codecpar->block_align ? (MAX_SIZE / st->codecpar->block_align) * st->codecpar->block_align : MAX_SIZE;
459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 428 times.
428 if (!size)
460 return AVERROR_INVALIDDATA;
461 }
462 8850 size = FFMIN(max_size, size);
463 8850 res = av_get_packet(s->pb, pkt, size);
464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8850 times.
8850 if (res < 0)
465 return res;
466
467
1/2
✓ Branch 0 taken 8850 times.
✗ Branch 1 not taken.
8850 if (size >= st->codecpar->block_align)
468 8850 pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
469 /* Only one stream in an AIFF file */
470 8850 pkt->stream_index = 0;
471 8850 pkt->duration = (res / st->codecpar->block_align) * (int64_t) aiff->block_duration;
472 8850 return 0;
473 }
474
475 const FFInputFormat ff_aiff_demuxer = {
476 .p.name = "aiff",
477 .p.long_name = NULL_IF_CONFIG_SMALL("Audio IFF"),
478 .p.codec_tag = ff_aiff_codec_tags_list,
479 .priv_data_size = sizeof(AIFFInputContext),
480 .read_probe = aiff_probe,
481 .read_header = aiff_read_header,
482 .read_packet = aiff_read_packet,
483 .read_seek = ff_pcm_read_seek,
484 };
485