FFmpeg: libavformat/aiffenc.c Source File
Go to the documentation of this file. 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
34
45
47 {
53
54 if (!
s->metadata && !
s->nb_chapters && !list_entry)
55 return 0;
56
60
63 while (list_entry) {
66 list_entry = list_entry->
next;
67 }
69
72
73 /* Update chunk size */
77
80
81 return 0;
82 }
83
85 {
88
91
97 }
98 }
99
101 {
107
109 for (
i = 0;
i <
s->nb_streams;
i++) {
116 }
117 }
121 }
122
124
125 /* First verify if format is ok */
129 aifc = 1;
130
131 /* FORM AIFF header */
136
137 if (aifc) { // compressed audio
141 }
142 /* Version chunk */
146 }
147
152 }
153
158
159 /* Common chunk */
161 avio_wb32(pb, aifc ? 24 : 18);
/* size */
163
166
172 }
175
177
181
182 if (aifc) {
185 }
186
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 return 0;
205 }
206
208 {
213 else {
214 /* warn only once for each stream */
218 }
220 return 0;
221
223 }
224
225 return 0;
226 }
227
229 {
234
235 /* Chunks sizes must be even */
236 int64_t file_size, data_size;
238 if (data_size & 1)
240
242 /* Write ID3 tags */
246
247 /* File length */
251
252 /* Number of sample frames */
255
256 /* Sound Data chunk size */
259 }
260
262 }
263
265 {
267
269 }
270
271 #define OFFSET(x) offsetof(AIFFOutputContext, x)
272 #define ENC AV_OPT_FLAG_ENCODING_PARAM
274 { "write_id3v2", "Enable ID3 tags writing.",
276 { "id3v2_version", "Select ID3v2 version to write. Currently 3 and 4 are supported.",
279 };
280
286 };
287
291 .p.mime_type = "audio/aiff",
292 .p.extensions = "aif,aiff,afc,aifc",
302 };
#define AV_LOG_WARNING
Something somehow does not look correct.
int avpriv_packet_list_put(PacketList *packet_buffer, AVPacket *pkt, int(*copy)(AVPacket *dst, const AVPacket *src), int flags)
Append an AVPacket to the list.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Filter the word "frame" indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
enum AVMediaType codec_type
General type of the encoded data.
static av_always_inline void ffio_wfourcc(AVIOContext *pb, const uint8_t *s)
This struct describes the properties of an encoded stream.
static int aiff_write_packet(AVFormatContext *s, AVPacket *pkt)
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
enum AVChannelOrder order
Channel order used in this layout.
uint64_t mask
This member must be used for AV_CHANNEL_ORDER_NATIVE, and may be used for AV_CHANNEL_ORDER_AMBISONIC ...
int nb_channels
Number of channels in this layout.
void ff_id3v2_start(ID3v2EncContext *id3, AVIOContext *pb, int id3v2_version, const char *magic)
Initialize an ID3v2 tag.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
static const AVOption options[]
int ff_id3v2_write_metadata(AVFormatContext *s, ID3v2EncContext *id3)
Convert and write all global metadata from s into an ID3v2 tag.
const FFOutputFormat ff_aiff_muxer
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
const char * av_default_item_name(void *ptr)
Return the context name.
void avio_w8(AVIOContext *s, int b)
AVChannelLayout ch_layout
Audio only.
struct PacketListEntry * next
int sample_rate
Audio only.
int extradata_size
Size of the extradata content in bytes.
int ff_id3v2_write_apic(AVFormatContext *s, ID3v2EncContext *id3, AVPacket *pkt)
Write an attached picture from pkt into an ID3v2 tag.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void avpriv_packet_list_free(PacketList *pkt_buf)
Wipe the list and unref all the packets in it.
static int aiff_write_trailer(AVFormatContext *s)
#define ID3v2_DEFAULT_MAGIC
Default magic bytes for ID3v2 header: "ID3".
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
void avio_wb32(AVIOContext *s, unsigned int val)
void avio_wl32(AVIOContext *s, unsigned int val)
static int put_id3v2_tags(AVFormatContext *s, AIFFOutputContext *aiff)
@ AV_CHANNEL_ORDER_NATIVE
The native channel order, i.e.
static av_always_inline uint64_t av_double2int(double f)
Reinterpret a double as a 64-bit integer.
#define i(width, name, range_min, range_max)
int block_align
Audio only.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static int aiff_write_header(AVFormatContext *s)
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
static const AVClass aiff_muxer_class
void ff_id3v2_finish(ID3v2EncContext *id3, AVIOContext *pb, int padding_bytes)
Finalize an opened ID3v2 tag.
static void aiff_deinit(AVFormatContext *s)
static void put_meta(AVFormatContext *s, const char *key, uint32_t id)
void avio_wb64(AVIOContext *s, uint64_t val)
int bits_per_coded_sample
The number of bits per sample in the codedwords.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
const AVCodecTag *const ff_aiff_codec_tags_list[]
This structure stores compressed data.
void avio_wb16(AVIOContext *s, unsigned int val)
union AVChannelLayout::@314 u
Details about which channels are present in this layout.
#define MKTAG(a, b, c, d)
void ff_mov_write_chan(AVIOContext *pb, int64_t channel_layout)
Generated on Tue Feb 28 2023 21:34:01 for FFmpeg by
doxygen
1.8.17