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
31
32 #define ADTS_HEADER_SIZE 7
33
45
46 #define ADTS_MAX_FRAME_BYTES ((1 << 13) - 1)
47
49 {
53 int off;
54
57 if (off < 0)
58 return off;
63
67 }
71 }
75 }
79 }
83 }
86
90 }
91
93
94 return 0;
95 }
96
98 {
101
107
108 return 0;
109 }
110
113 {
115
121 }
122
124
125 /* adts_fixed_header */
126 put_bits(&pb, 12, 0xfff);
/* syncword */
129 put_bits(&pb, 1, 1);
/* protection_absent */
132 put_bits(&pb, 1, 0);
/* private_bit */
134 put_bits(&pb, 1, 0);
/* original_copy */
136
137 /* adts_variable_header */
138 put_bits(&pb, 1, 0);
/* copyright_identification_bit */
139 put_bits(&pb, 1, 0);
/* copyright_identification_start */
140 put_bits(&pb, 13, full_frame_size);
/* aac_frame_length */
141 put_bits(&pb, 11, 0x7ff);
/* adts_buffer_fullness */
142 put_bits(&pb, 2, 0);
/* number_of_raw_data_blocks_in_frame */
143
145
146 return 0;
147 }
148
150 {
154
156 return 0;
160 if (err < 0)
161 return err;
166 }
167 }
169
170 return 0;
171 }
172
174 {
176
179
180 return 0;
181 }
182
183 #define ENC AV_OPT_FLAG_ENCODING_PARAM
184 #define OFFSET(obj) offsetof(ADTSContext, obj)
189 };
190
196 };
197
201 .mime_type = "audio/aac",
202 .extensions = "aac,adts",
209 .priv_class = &adts_muxer_class,
211 };