annotate aiffdec.c @ 5352:c8a47f9a36a8 libavformat

Fix a typo in rtp_h264.c:parse_h264_sdp_line(). Patch by Gordon Irlam (gordonipub2 AT gordoni DOT com). This fixes H.264 over RTP when the SDP contains a "framesize:" attribute (for example, rtsp://video3.americafree.tv/AFTVCartoonsH264250.sdp )
author lucabe
date Thu, 05 Nov 2009 14:25:37 +0000
parents 6b37260d470e
children af65f63f2063
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
1 /*
5283
63c52dca959b Split up the AIFF muxer and demuxer into separate files.
jbr
parents: 5279
diff changeset
2 * AIFF/AIFF-C demuxer
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
3 * Copyright (c) 2006 Patrick Guimond
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
4 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1172
diff changeset
5 * This file is part of FFmpeg.
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1172
diff changeset
6 *
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1172
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1172
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
11 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1172
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
15 * Lesser General Public License for more details.
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
16 *
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1172
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
20 */
3286
6f61c3b36632 Use full path for #includes from another directory.
diego
parents: 3111
diff changeset
21
6f61c3b36632 Use full path for #includes from another directory.
diego
parents: 3111
diff changeset
22 #include "libavutil/intfloat_readwrite.h"
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
23 #include "avformat.h"
2545
213268d7594e move unrelated functions declarations out of allformats.h
aurel
parents: 2274
diff changeset
24 #include "raw.h"
5283
63c52dca959b Split up the AIFF muxer and demuxer into separate files.
jbr
parents: 5279
diff changeset
25 #include "aiff.h"
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
26
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
27 #define AIFF 0
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
28 #define AIFF_C_VERSION1 0xA2805140
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
29
5279
0a917464c1dc Do not read data past the end of the SSND chunk in the AIFF demuxer.
jbr
parents: 5255
diff changeset
30 typedef struct {
0a917464c1dc Do not read data past the end of the SSND chunk in the AIFF demuxer.
jbr
parents: 5255
diff changeset
31 int64_t data_end;
0a917464c1dc Do not read data past the end of the SSND chunk in the AIFF demuxer.
jbr
parents: 5255
diff changeset
32 } AIFFInputContext;
0a917464c1dc Do not read data past the end of the SSND chunk in the AIFF demuxer.
jbr
parents: 5255
diff changeset
33
3967
4fd67f05bad9 Use enum typers instead of int.
benoit
parents: 3908
diff changeset
34 static enum CodecID aiff_codec_get_id(int bps)
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
35 {
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
36 if (bps <= 8)
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
37 return CODEC_ID_PCM_S8;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
38 if (bps <= 16)
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
39 return CODEC_ID_PCM_S16BE;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
40 if (bps <= 24)
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
41 return CODEC_ID_PCM_S24BE;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
42 if (bps <= 32)
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
43 return CODEC_ID_PCM_S32BE;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
44
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
45 /* bigger than 32 isn't allowed */
3967
4fd67f05bad9 Use enum typers instead of int.
benoit
parents: 3908
diff changeset
46 return CODEC_ID_NONE;
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
47 }
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
48
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
49 /* returns the size of the found tag */
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
50 static int get_tag(ByteIOContext *pb, uint32_t * tag)
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
51 {
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
52 int size;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
53
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
54 if (url_feof(pb))
2274
b21c2af60bc9 Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents: 2273
diff changeset
55 return AVERROR(EIO);
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
56
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
57 *tag = get_le32(pb);
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
58 size = get_be32(pb);
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
59
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
60 if (size < 0)
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
61 size = 0x7fffffff;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
62
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
63 return size;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
64 }
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
65
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
66 /* Metadata string read */
4364
52e876e7c0cf use new metadata API in aiff demuxer
aurel
parents: 4362
diff changeset
67 static void get_meta(AVFormatContext *s, const char *key, int size)
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
68 {
4364
52e876e7c0cf use new metadata API in aiff demuxer
aurel
parents: 4362
diff changeset
69 uint8_t str[1024];
52e876e7c0cf use new metadata API in aiff demuxer
aurel
parents: 4362
diff changeset
70 int res = get_buffer(s->pb, str, FFMIN(sizeof(str)-1, size));
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
71 if (res < 0)
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
72 return;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
73
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
74 str[res] = 0;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
75 if (size & 1)
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
76 size++;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
77 size -= res;
1792
bcoudurier
parents: 1791
diff changeset
78 if (size)
4364
52e876e7c0cf use new metadata API in aiff demuxer
aurel
parents: 4362
diff changeset
79 url_fskip(s->pb, size);
52e876e7c0cf use new metadata API in aiff demuxer
aurel
parents: 4362
diff changeset
80
52e876e7c0cf use new metadata API in aiff demuxer
aurel
parents: 4362
diff changeset
81 av_metadata_set(&s->metadata, key, str);
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
82 }
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
83
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
84 /* Returns the number of sound data frames or negative on error */
1124
d3aff2c607f9 Add const to (mostly) char* and make some functions static, which aren't used
diego
parents: 1123
diff changeset
85 static unsigned int get_aiff_header(ByteIOContext *pb, AVCodecContext *codec,
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
86 int size, unsigned version)
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
87 {
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
88 AVExtFloat ext;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
89 double sample_rate;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
90 unsigned int num_frames;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
91
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
92 if (size & 1)
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
93 size++;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
94 codec->codec_type = CODEC_TYPE_AUDIO;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
95 codec->channels = get_be16(pb);
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
96 num_frames = get_be32(pb);
3908
1d3d17de20ba Bump Major version, this commit is almost just renaming bits_per_sample to
michael
parents: 3891
diff changeset
97 codec->bits_per_coded_sample = get_be16(pb);
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
98
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
99 get_buffer(pb, (uint8_t*)&ext, sizeof(ext));/* Sample rate is in */
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
100 sample_rate = av_ext2dbl(ext); /* 80 bits BE IEEE extended float */
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
101 codec->sample_rate = sample_rate;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
102 size -= 18;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
103
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
104 /* Got an AIFF-C? */
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
105 if (version == AIFF_C_VERSION1) {
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
106 codec->codec_tag = get_le32(pb);
5283
63c52dca959b Split up the AIFF muxer and demuxer into separate files.
jbr
parents: 5279
diff changeset
107 codec->codec_id = ff_codec_get_id(ff_codec_aiff_tags, codec->codec_tag);
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
108
3066
5a69d7493dab ima4 in aiff support
bcoudurier
parents: 2771
diff changeset
109 switch (codec->codec_id) {
5a69d7493dab ima4 in aiff support
bcoudurier
parents: 2771
diff changeset
110 case CODEC_ID_PCM_S16BE:
3908
1d3d17de20ba Bump Major version, this commit is almost just renaming bits_per_sample to
michael
parents: 3891
diff changeset
111 codec->codec_id = aiff_codec_get_id(codec->bits_per_coded_sample);
1d3d17de20ba Bump Major version, this commit is almost just renaming bits_per_sample to
michael
parents: 3891
diff changeset
112 codec->bits_per_coded_sample = av_get_bits_per_sample(codec->codec_id);
3066
5a69d7493dab ima4 in aiff support
bcoudurier
parents: 2771
diff changeset
113 break;
5a69d7493dab ima4 in aiff support
bcoudurier
parents: 2771
diff changeset
114 case CODEC_ID_ADPCM_IMA_QT:
5a69d7493dab ima4 in aiff support
bcoudurier
parents: 2771
diff changeset
115 codec->block_align = 34*codec->channels;
3067
2dc78258f848 fix duration for ima4
bcoudurier
parents: 3066
diff changeset
116 codec->frame_size = 64;
3066
5a69d7493dab ima4 in aiff support
bcoudurier
parents: 2771
diff changeset
117 break;
3079
475106eb507e fix mace duration
bcoudurier
parents: 3075
diff changeset
118 case CODEC_ID_MACE3:
3111
6f505b24ed57 set block align for mace3/6
bcoudurier
parents: 3110
diff changeset
119 codec->block_align = 2*codec->channels;
6f505b24ed57 set block align for mace3/6
bcoudurier
parents: 3110
diff changeset
120 codec->frame_size = 6;
6f505b24ed57 set block align for mace3/6
bcoudurier
parents: 3110
diff changeset
121 break;
3079
475106eb507e fix mace duration
bcoudurier
parents: 3075
diff changeset
122 case CODEC_ID_MACE6:
3111
6f505b24ed57 set block align for mace3/6
bcoudurier
parents: 3110
diff changeset
123 codec->block_align = 1*codec->channels;
3079
475106eb507e fix mace duration
bcoudurier
parents: 3075
diff changeset
124 codec->frame_size = 6;
475106eb507e fix mace duration
bcoudurier
parents: 3075
diff changeset
125 break;
3891
fbe8704f513a set block align and frame size for gsm in aiff
bcoudurier
parents: 3871
diff changeset
126 case CODEC_ID_GSM:
fbe8704f513a set block align and frame size for gsm in aiff
bcoudurier
parents: 3871
diff changeset
127 codec->block_align = 33;
fbe8704f513a set block align and frame size for gsm in aiff
bcoudurier
parents: 3871
diff changeset
128 codec->frame_size = 160;
fbe8704f513a set block align and frame size for gsm in aiff
bcoudurier
parents: 3871
diff changeset
129 break;
3066
5a69d7493dab ima4 in aiff support
bcoudurier
parents: 2771
diff changeset
130 default:
5a69d7493dab ima4 in aiff support
bcoudurier
parents: 2771
diff changeset
131 break;
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
132 }
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
133 size -= 4;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
134 } else {
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
135 /* Need the codec type */
3908
1d3d17de20ba Bump Major version, this commit is almost just renaming bits_per_sample to
michael
parents: 3891
diff changeset
136 codec->codec_id = aiff_codec_get_id(codec->bits_per_coded_sample);
1d3d17de20ba Bump Major version, this commit is almost just renaming bits_per_sample to
michael
parents: 3891
diff changeset
137 codec->bits_per_coded_sample = av_get_bits_per_sample(codec->codec_id);
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
138 }
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
139
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
140 /* Block align needs to be computed in all cases, as the definition
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
141 * is specific to applications -> here we use the WAVE format definition */
3066
5a69d7493dab ima4 in aiff support
bcoudurier
parents: 2771
diff changeset
142 if (!codec->block_align)
3908
1d3d17de20ba Bump Major version, this commit is almost just renaming bits_per_sample to
michael
parents: 3891
diff changeset
143 codec->block_align = (codec->bits_per_coded_sample * codec->channels) >> 3;
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
144
3110
3dade22abed6 correctly compute bit rate for compressed audio, should fix seeking in aiff
bcoudurier
parents: 3079
diff changeset
145 codec->bit_rate = (codec->frame_size ? codec->sample_rate/codec->frame_size :
3dade22abed6 correctly compute bit rate for compressed audio, should fix seeking in aiff
bcoudurier
parents: 3079
diff changeset
146 codec->sample_rate) * (codec->block_align << 3);
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
147
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
148 /* Chunk is over */
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
149 if (size)
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
150 url_fseek(pb, size, SEEK_CUR);
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
151
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
152 return num_frames;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
153 }
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
154
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
155 static int aiff_probe(AVProbeData *p)
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
156 {
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
157 /* check file header */
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
158 if (p->buf[0] == 'F' && p->buf[1] == 'O' &&
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
159 p->buf[2] == 'R' && p->buf[3] == 'M' &&
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
160 p->buf[8] == 'A' && p->buf[9] == 'I' &&
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
161 p->buf[10] == 'F' && (p->buf[11] == 'F' || p->buf[11] == 'C'))
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
162 return AVPROBE_SCORE_MAX;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
163 else
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
164 return 0;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
165 }
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
166
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
167 /* aiff input */
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
168 static int aiff_read_header(AVFormatContext *s,
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
169 AVFormatParameters *ap)
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
170 {
2206
c049274b7bd4 support files with COMM chunk after SSND, fix invalid_nocommon.aiff which is spec compliant
bcoudurier
parents: 2060
diff changeset
171 int size, filesize;
3973
549a09cf23fe Remove offset_t typedef and use int64_t directly instead.
diego
parents: 3967
diff changeset
172 int64_t offset = 0;
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
173 uint32_t tag;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
174 unsigned version = AIFF_C_VERSION1;
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2545
diff changeset
175 ByteIOContext *pb = s->pb;
4889
848722752aa5 Remove useless init from aiff_read_header() found by CSA.
michael
parents: 4364
diff changeset
176 AVStream * st;
5279
0a917464c1dc Do not read data past the end of the SSND chunk in the AIFF demuxer.
jbr
parents: 5255
diff changeset
177 AIFFInputContext *aiff = s->priv_data;
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
178
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
179 /* check FORM header */
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
180 filesize = get_tag(pb, &tag);
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
181 if (filesize < 0 || tag != MKTAG('F', 'O', 'R', 'M'))
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
182 return AVERROR_INVALIDDATA;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
183
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
184 /* AIFF data type */
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
185 tag = get_le32(pb);
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
186 if (tag == MKTAG('A', 'I', 'F', 'F')) /* Got an AIFF file */
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
187 version = AIFF;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
188 else if (tag != MKTAG('A', 'I', 'F', 'C')) /* An AIFF-C file then */
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
189 return AVERROR_INVALIDDATA;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
190
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
191 filesize -= 4;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
192
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
193 st = av_new_stream(s, 0);
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
194 if (!st)
2273
7eb456c4ed8a Replace all occurrences of AVERROR_NOMEM with AVERROR(ENOMEM).
takis
parents: 2209
diff changeset
195 return AVERROR(ENOMEM);
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
196
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
197 while (filesize > 0) {
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
198 /* parse different chunks */
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
199 size = get_tag(pb, &tag);
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
200 if (size < 0)
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
201 return size;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
202
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
203 filesize -= size + 8;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
204
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
205 switch (tag) {
3072
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
206 case MKTAG('C', 'O', 'M', 'M'): /* Common chunk */
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
207 /* Then for the complete header info */
3295
4616ba855d62 cosmetics, remove space before opening parenthesis
bcoudurier
parents: 3286
diff changeset
208 st->nb_frames = get_aiff_header(pb, st->codec, size, version);
3072
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
209 if (st->nb_frames < 0)
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
210 return st->nb_frames;
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
211 if (offset > 0) // COMM is after SSND
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
212 goto got_sound;
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
213 break;
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
214 case MKTAG('F', 'V', 'E', 'R'): /* Version chunk */
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
215 version = get_be32(pb);
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
216 break;
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
217 case MKTAG('N', 'A', 'M', 'E'): /* Sample name chunk */
4364
52e876e7c0cf use new metadata API in aiff demuxer
aurel
parents: 4362
diff changeset
218 get_meta(s, "title" , size);
3072
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
219 break;
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
220 case MKTAG('A', 'U', 'T', 'H'): /* Author chunk */
4364
52e876e7c0cf use new metadata API in aiff demuxer
aurel
parents: 4362
diff changeset
221 get_meta(s, "author" , size);
3072
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
222 break;
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
223 case MKTAG('(', 'c', ')', ' '): /* Copyright chunk */
4364
52e876e7c0cf use new metadata API in aiff demuxer
aurel
parents: 4362
diff changeset
224 get_meta(s, "copyright", size);
3072
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
225 break;
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
226 case MKTAG('A', 'N', 'N', 'O'): /* Annotation chunk */
4364
52e876e7c0cf use new metadata API in aiff demuxer
aurel
parents: 4362
diff changeset
227 get_meta(s, "comment" , size);
3072
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
228 break;
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
229 case MKTAG('S', 'S', 'N', 'D'): /* Sampled sound chunk */
5279
0a917464c1dc Do not read data past the end of the SSND chunk in the AIFF demuxer.
jbr
parents: 5255
diff changeset
230 aiff->data_end = url_ftell(pb) + size;
3072
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
231 offset = get_be32(pb); /* Offset of sound data */
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
232 get_be32(pb); /* BlockSize... don't care */
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
233 offset += url_ftell(pb); /* Compute absolute data offset */
3297
df2df4c07d12 try to demux even if codec is not recognized, should demux M1F1-float32C-AFsp.aif and fix #454
bcoudurier
parents: 3296
diff changeset
234 if (st->codec->block_align) /* Assume COMM already parsed */
3072
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
235 goto got_sound;
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
236 if (url_is_streamed(pb)) {
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
237 av_log(s, AV_LOG_ERROR, "file is not seekable\n");
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
238 return -1;
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
239 }
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
240 url_fskip(pb, size - 8);
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
241 break;
3074
815859771e8b support QDM2 in aiff, QDM2.aif
bcoudurier
parents: 3073
diff changeset
242 case MKTAG('w', 'a', 'v', 'e'):
3075
b273d958cf52 10l, protect malloc overflow
bcoudurier
parents: 3074
diff changeset
243 if ((uint64_t)size > (1<<30))
b273d958cf52 10l, protect malloc overflow
bcoudurier
parents: 3074
diff changeset
244 return -1;
3074
815859771e8b support QDM2 in aiff, QDM2.aif
bcoudurier
parents: 3073
diff changeset
245 st->codec->extradata = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE);
815859771e8b support QDM2 in aiff, QDM2.aif
bcoudurier
parents: 3073
diff changeset
246 if (!st->codec->extradata)
815859771e8b support QDM2 in aiff, QDM2.aif
bcoudurier
parents: 3073
diff changeset
247 return AVERROR(ENOMEM);
815859771e8b support QDM2 in aiff, QDM2.aif
bcoudurier
parents: 3073
diff changeset
248 st->codec->extradata_size = size;
815859771e8b support QDM2 in aiff, QDM2.aif
bcoudurier
parents: 3073
diff changeset
249 get_buffer(pb, st->codec->extradata, size);
815859771e8b support QDM2 in aiff, QDM2.aif
bcoudurier
parents: 3073
diff changeset
250 break;
3072
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
251 default: /* Jump */
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
252 if (size & 1) /* Always even aligned */
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
253 size++;
0e84da9b7183 indentation
bcoudurier
parents: 3071
diff changeset
254 url_fskip (pb, size);
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
255 }
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
256 }
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
257
3297
df2df4c07d12 try to demux even if codec is not recognized, should demux M1F1-float32C-AFsp.aif and fix #454
bcoudurier
parents: 3296
diff changeset
258 if (!st->codec->block_align) {
df2df4c07d12 try to demux even if codec is not recognized, should demux M1F1-float32C-AFsp.aif and fix #454
bcoudurier
parents: 3296
diff changeset
259 av_log(s, AV_LOG_ERROR, "could not find COMM tag\n");
df2df4c07d12 try to demux even if codec is not recognized, should demux M1F1-float32C-AFsp.aif and fix #454
bcoudurier
parents: 3296
diff changeset
260 return -1;
df2df4c07d12 try to demux even if codec is not recognized, should demux M1F1-float32C-AFsp.aif and fix #454
bcoudurier
parents: 3296
diff changeset
261 }
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
262
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
263 got_sound:
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
264 /* Now positioned, get the sound data start and end */
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
265 if (st->nb_frames)
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
266 s->file_size = st->nb_frames * st->codec->block_align;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
267
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
268 av_set_pts_info(st, 64, 1, st->codec->sample_rate);
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
269 st->start_time = 0;
3067
2dc78258f848 fix duration for ima4
bcoudurier
parents: 3066
diff changeset
270 st->duration = st->codec->frame_size ?
2dc78258f848 fix duration for ima4
bcoudurier
parents: 3066
diff changeset
271 st->nb_frames * st->codec->frame_size : st->nb_frames;
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
272
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
273 /* Position the stream at the first block */
2206
c049274b7bd4 support files with COMM chunk after SSND, fix invalid_nocommon.aiff which is spec compliant
bcoudurier
parents: 2060
diff changeset
274 url_fseek(pb, offset, SEEK_SET);
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
275
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
276 return 0;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
277 }
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
278
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
279 #define MAX_SIZE 4096
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
280
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
281 static int aiff_read_packet(AVFormatContext *s,
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
282 AVPacket *pkt)
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
283 {
1087
8ffbf9385972 fix pcm_s24be demuxing, simplify
bcoudurier
parents: 925
diff changeset
284 AVStream *st = s->streams[0];
5279
0a917464c1dc Do not read data past the end of the SSND chunk in the AIFF demuxer.
jbr
parents: 5255
diff changeset
285 AIFFInputContext *aiff = s->priv_data;
0a917464c1dc Do not read data past the end of the SSND chunk in the AIFF demuxer.
jbr
parents: 5255
diff changeset
286 int64_t max_size;
1087
8ffbf9385972 fix pcm_s24be demuxing, simplify
bcoudurier
parents: 925
diff changeset
287 int res;
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
288
5279
0a917464c1dc Do not read data past the end of the SSND chunk in the AIFF demuxer.
jbr
parents: 5255
diff changeset
289 /* calculate size of remaining data */
0a917464c1dc Do not read data past the end of the SSND chunk in the AIFF demuxer.
jbr
parents: 5255
diff changeset
290 max_size = aiff->data_end - url_ftell(s->pb);
0a917464c1dc Do not read data past the end of the SSND chunk in the AIFF demuxer.
jbr
parents: 5255
diff changeset
291 if (max_size <= 0)
0a917464c1dc Do not read data past the end of the SSND chunk in the AIFF demuxer.
jbr
parents: 5255
diff changeset
292 return AVERROR_EOF;
0a917464c1dc Do not read data past the end of the SSND chunk in the AIFF demuxer.
jbr
parents: 5255
diff changeset
293
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
294 /* Now for that packet */
5279
0a917464c1dc Do not read data past the end of the SSND chunk in the AIFF demuxer.
jbr
parents: 5255
diff changeset
295 max_size = FFMIN(max_size, (MAX_SIZE / st->codec->block_align) * st->codec->block_align);
0a917464c1dc Do not read data past the end of the SSND chunk in the AIFF demuxer.
jbr
parents: 5255
diff changeset
296 res = av_get_packet(s->pb, pkt, max_size);
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
297 if (res < 0)
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
298 return res;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
299
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
300 /* Only one stream in an AIFF file */
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
301 pkt->stream_index = 0;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
302 return 0;
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
303 }
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
304
1169
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
305 AVInputFormat aiff_demuxer = {
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
306 "aiff",
3424
7a0230981402 Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents: 3297
diff changeset
307 NULL_IF_CONFIG_SMALL("Audio IFF"),
5279
0a917464c1dc Do not read data past the end of the SSND chunk in the AIFF demuxer.
jbr
parents: 5255
diff changeset
308 sizeof(AIFFInputContext),
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
309 aiff_probe,
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
310 aiff_read_header,
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
311 aiff_read_packet,
3073
ed7b32bedcb5 remove useless close function
bcoudurier
parents: 3072
diff changeset
312 NULL,
3435
a81155640306 Remove wrappers of pcm_read_seek().
ramiro
parents: 3424
diff changeset
313 pcm_read_seek,
5283
63c52dca959b Split up the AIFF muxer and demuxer into separate files.
jbr
parents: 5279
diff changeset
314 .codec_tag= (const AVCodecTag* const []){ff_codec_aiff_tags, 0},
925
2d9a65a1d9ea AIFF format support by (Patrick Guimond <patg a.t patg d.o.t homeunix d.o.t org)
michael
parents:
diff changeset
315 };