FFmpeg: libavformat/cafenc.c Source File
Go to the documentation of this file. 1 /*
2 * Core Audio Format muxer
3 * Copyright (c) 2011 Carl Eugen Hoyos
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
29
30 #define FRAME_SIZE_OFFSET 40
31
38
43 return 1; //< kCAFLinearPCMFormatFlagIsFloat
47 return 2; //< kCAFLinearPCMFormatFlagIsLittleEndian
50 return 3; //< kCAFLinearPCMFormatFlagIsFloat | kCAFLinearPCMFormatFlagIsLittleEndian
51 default:
52 return 0;
53 }
54 }
55
71 return 1;
74 return 6;
76 return 64;
81 return 160;
83 return 320;
85 return 384;
88 return 1152;
90 return 1536;
95 return 4096;
100 default:
101 return 0;
102 }
103 }
104
106 {
112 int64_t chunk_size = 0;
114
115 if (
s->nb_streams != 1) {
118 }
119
124 }
125
129 }
130
131 if (!codec_tag) {
134 }
135
137 av_log(
s,
AV_LOG_ERROR,
"Muxing variable packet size not supported on non seekable output\n");
139 }
140
143
147
157
162 }
163
175 avio_w8(pb, 0);
/* decoder version */
176
177 avio_wb16(pb, 0x81FF);
/* Mode set (all modes for AMR_NB) */
178 avio_w8(pb, 0x00);
/* Mode change period (no restriction) */
179 avio_w8(pb, 0x01);
/* Frames per sample */
184 }
185
190 chunk_size += strlen(t->
key) + strlen(t->
value) + 2;
191 }
198 }
199 }
200
205
206 return 0;
207 }
208
210 {
213
215 uint8_t *pkt_sizes;
217 if (alloc_size < 0)
219
222 alloc_size);
223 if (!pkt_sizes)
226 for (
i = 4;
i > 0;
i--) {
228 if (top)
230 }
233 }
235 return 0;
236 }
237
239 {
244
247
252 if (!packet_size) {
256 }
265 }
266 }
267 return 0;
268 }
269
273 .mime_type = "audio/x-caf",
274 .extensions = "caf",
282 };
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
@ AV_CODEC_ID_ADPCM_IMA_QT
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
static av_always_inline void ffio_wfourcc(AVIOContext *pb, const uint8_t *s)
This struct describes the properties of an encoded stream.
static int caf_write_packet(AVFormatContext *s, AVPacket *pkt)
int av_dict_count(const AVDictionary *m)
Get number of entries in dictionary.
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
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.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
int64_t duration
Decoding: duration of the stream, in stream time base.
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.
@ AV_CHANNEL_ORDER_NATIVE
The native channel order, i.e.
int frame_size
Audio only.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
static int caf_write_header(AVFormatContext *s)
AVCodecParameters * codecpar
Codec parameters associated with this stream.
union AVChannelLayout::@296 u
Details about which channels are present in this layout.
static uint32_t samples_per_packet(enum AVCodecID codec_id, int channels, int block_align)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static int write_trailer(AVFormatContext *s1)
void avio_w8(AVIOContext *s, int b)
AVChannelLayout ch_layout
Audio only.
int sample_rate
Audio only.
@ AV_CODEC_ID_GSM
as in Berlin toast format
AVCodecID
Identify the syntax and semantics of the bitstream.
int extradata_size
Size of the extradata content in bytes.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
const AVOutputFormat ff_caf_muxer
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
int ff_standardize_creation_time(AVFormatContext *s)
Standardize creation_time metadata in AVFormatContext to an ISO-8601 timestamp string.
#define FRAME_SIZE_OFFSET
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 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.
const AVCodecTag ff_codec_caf_tags[]
Known codec tags for CAF.
static int caf_write_trailer(AVFormatContext *s)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
const AVCodecTag *const ff_caf_codec_tags_list[]
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
void avio_wb64(AVIOContext *s, uint64_t val)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
@ AV_CODEC_ID_ADPCM_IMA_WAV
void avio_wb16(AVIOContext *s, unsigned int val)
static uint32_t codec_flags(enum AVCodecID codec_id)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int write_packet(AVFormatContext *s1, AVPacket *pkt)
static void write_header(FFV1Context *f)
void ff_mov_write_chan(AVIOContext *pb, int64_t channel_layout)
int avio_put_str(AVIOContext *s, const char *str)
Write a NULL-terminated string.
Generated on Wed Aug 24 2022 21:42:13 for FFmpeg by
doxygen
1.8.17