FFmpeg: libavformat/adtsenc.c Source File
Go to the documentation of this file. 1 /*
2 * ADTS muxer.
3 * Copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier@smartjog.com>
4 * Mans Rullgard <mans@mansr.com>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
33
34 #define ADTS_HEADER_SIZE 7
35
48
49 #define ADTS_MAX_FRAME_BYTES ((1 << 14) - 1)
50
52 {
57
62 if (off < 0)
63 return off;
68
72 }
76 }
80 }
84 }
88 }
91
95 }
96
98
99 return 0;
100 }
101
103 {
106
110 }
114
115 return 0;
116 }
117
119 {
121
124
125 return 0;
126 }
127
129 uint8_t *buf,
int size,
int pce_size)
130 {
132
138 }
139
141
142 /* adts_fixed_header */
143 put_bits(&pb, 12, 0xfff);
/* syncword */
146 put_bits(&pb, 1, 1);
/* protection_absent */
147 put_bits(&pb, 2,
ctx->objecttype);
/* profile_objecttype */
149 put_bits(&pb, 1, 0);
/* private_bit */
150 put_bits(&pb, 3,
ctx->channel_conf);
/* channel_configuration */
151 put_bits(&pb, 1, 0);
/* original_copy */
153
154 /* adts_variable_header */
155 put_bits(&pb, 1, 0);
/* copyright_identification_bit */
156 put_bits(&pb, 1, 0);
/* copyright_identification_start */
157 put_bits(&pb, 13, full_frame_size);
/* aac_frame_length */
158 put_bits(&pb, 11, 0x7ff);
/* adts_buffer_fullness */
159 put_bits(&pb, 2, 0);
/* number_of_raw_data_blocks_in_frame */
160
162
163 return 0;
164 }
165
167 {
172
174 return 0;
176 uint8_t *side_data;
177 size_t side_data_size;
179
181 &side_data_size);
182 if (side_data_size) {
189 memcpy(par->
extradata, side_data, side_data_size);
190 }
191 }
195 if (err < 0)
196 return err;
201 }
202 }
204
205 return 0;
206 }
207
209 {
211
214
215 return 0;
216 }
217
218 #define ENC AV_OPT_FLAG_ENCODING_PARAM
219 #define OFFSET(obj) offsetof(ADTSContext, obj)
225 };
226
232 };
233
237 .mime_type = "audio/aac",
238 .extensions = "aac,adts",
248 };
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
static int adts_write_trailer(AVFormatContext *s)
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 int adts_init(AVFormatContext *s)
This struct describes the properties of an encoded stream.
static int adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, const uint8_t *buf, int size)
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
#define MAX_PCE_SIZE
Maximum size of a PCE including the 3-bit ID_PCE.
static const AVOption options[]
#define ADTS_MAX_FRAME_BYTES
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static int adts_write_packet(AVFormatContext *s, AVPacket *pkt)
static int adts_write_header(AVFormatContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
int avpriv_mpeg4audio_get_config2(MPEG4AudioConfig *c, const uint8_t *buf, int size, int sync_extension, void *logctx)
Parse MPEG-4 systems extradata from a raw buffer to retrieve audio configuration.
int ff_ape_write_tag(AVFormatContext *s)
Write an APE tag into a file.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
static int write_trailer(AVFormatContext *s1)
const char * av_default_item_name(void *ptr)
Return the context name.
static int ff_copy_pce_data(PutBitContext *pb, GetBitContext *gb)
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.
#define ID3v2_DEFAULT_MAGIC
Default magic bytes for ID3v2 header: "ID3".
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue)
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
static const AVClass adts_muxer_class
const AVOutputFormat ff_adts_muxer
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
@ AV_PKT_DATA_NEW_EXTRADATA
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
uint8_t pce_data[MAX_PCE_SIZE]
static int adts_write_frame_header(ADTSContext *ctx, uint8_t *buf, int size, int pce_size)
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
#define flags(name, subs,...)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static void write_header(FFV1Context *f)
int ff_id3v2_write_simple(struct AVFormatContext *s, int id3v2_version, const char *magic)
Write an ID3v2 tag containing all global metadata from s.
Generated on Wed Aug 24 2022 21:38:19 for FFmpeg by
doxygen
1.8.17