1 /*
2 * AIFF/AIFF-C muxer
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 <stdint.h>
23
32
43
45 {
51
53 return 0;
54
56 return 0;
57
61
64 while (pict_list) {
67 pict_list = pict_list->
next;
68 }
70
72 size = end - pos;
73
74 /* Update chunk size */
78
79 if (size & 1)
81
82 return 0;
83 }
84
86 {
89
92
96 if (size & 1)
98 }
99 }
100
102 {
107 int i, aifc = 0;
108
117 }
118 }
122 }
123
125
126 /* First verify if format is ok */
128 return -1;
130 aifc = 1;
131
132 /* FORM AIFF header */
137
138 if (aifc) { // compressed audio
141 return -1;
142 }
143 /* Version chunk */
147 }
148
153 }
154
159
160 /* Common chunk */
162 avio_wb32(pb, aifc ? 24 : 18);
/* size */
164
167
172 return -1;
173 }
176
178
180 avio_wb16(pb, (sample_rate >> 52) + (16383 - 1023));
181 avio_wb64(pb, UINT64_C(1) << 63 | sample_rate << 11);
182
183 if (aifc) {
186 }
187
192 }
193
194 /* Sound data chunk */
197 avio_wb32(pb, 0);
/* Sound samples data size */
199 avio_wb32(pb, 0);
/* Block-size (block align) */
200
203
204 /* Data is starting here */
206
207 return 0;
208 }
209
211 {
216 else {
219
221 return 0;
222
223 /* warn only once for each stream */
227 }
229 return 0;
230
232 if (!pict_list)
234
238 }
239
242 else {
246 last->
next = pict_list;
247 }
248 }
249
250 return 0;
251 }
252
254 {
260
261 /* Chunks sizes must be even */
262 int64_t file_size, end_size;
264 if (file_size & 1) {
266 end_size++;
267 }
268
270 /* Number of sample frames */
273
274 /* Sound Data chunk size */
277
278 /* return to the end */
280
281 /* Write ID3 tags */
285
286 /* File length */
290
292 }
293
294 while (pict_list) {
298 pict_list = next;
299 }
300
301 return 0;
302 }
303
304 #define OFFSET(x) offsetof(AIFFOutputContext, x)
305 #define ENC AV_OPT_FLAG_ENCODING_PARAM
307 { "write_id3v2", "Enable ID3 tags writing.",
309 { "id3v2_version", "Select ID3v2 version to write. Currently 3 and 4 are supported.",
311 { NULL },
312 };
313
319 };
320
324 .mime_type = "audio/aiff",
325 .extensions = "aif,aiff,afc,aifc",
334 };