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
30
41
43 {
49
51 return 0;
52
54 return 0;
55
59
62 while (pict_list) {
65 pict_list = pict_list->
next;
66 }
68
70 size = end - pos;
71
72 /* Update chunk size */
76
77 if (size & 1)
79
80 return 0;
81 }
82
84 {
87
90
94 if (size & 1)
96 }
97 }
98
100 {
105 int i, aifc = 0;
106
115 }
116 }
120 }
121
123
124 /* First verify if format is ok */
126 return -1;
128 aifc = 1;
129
130 /* FORM AIFF header */
135
136 if (aifc) { // compressed audio
139 return -1;
140 }
141 /* Version chunk */
145 }
146
151 }
152
157
158 /* Common chunk */
160 avio_wb32(pb, aifc ? 24 : 18);
/* size */
162
165
170 return -1;
171 }
174
176
178 avio_wb16(pb, (sample_rate >> 52) + (16383 - 1023));
179 avio_wb64(pb, UINT64_C(1) << 63 | sample_rate << 11);
180
181 if (aifc) {
184 }
185
190 }
191
192 /* Sound data chunk */
195 avio_wb32(pb, 0);
/* Sound samples data size */
197 avio_wb32(pb, 0);
/* Block-size (block align) */
198
201
202 /* Data is starting here */
204
205 return 0;
206 }
207
209 {
214 else {
217
219 return 0;
220
221 /* warn only once for each stream */
225 }
227 return 0;
228
230 if (!pict_list)
232
236 }
237
240 else {
244 last->
next = pict_list;
245 }
246 }
247
248 return 0;
249 }
250
252 {
258
259 /* Chunks sizes must be even */
260 int64_t file_size, end_size;
262 if (file_size & 1) {
264 end_size++;
265 }
266
268 /* Number of sample frames */
271
272 /* Sound Data chunk size */
275
276 /* return to the end */
278
279 /* Write ID3 tags */
283
284 /* File length */
288
290 }
291
292 while (pict_list) {
296 pict_list = next;
297 }
298
299 return 0;
300 }
301
302 #define OFFSET(x) offsetof(AIFFOutputContext, x)
303 #define ENC AV_OPT_FLAG_ENCODING_PARAM
305 { "write_id3v2", "Enable ID3 tags writing.",
307 { "id3v2_version", "Select ID3v2 version to write. Currently 3 and 4 are supported.",
309 { NULL },
310 };
311
317 };
318
322 .mime_type = "audio/aiff",
323 .extensions = "aif,aiff,afc,aifc",
332 };