FFmpeg
aacenc.h
Go to the documentation of this file.
1 /*
2  * AAC encoder
3  * Copyright (C) 2008 Konstantin Shishkov
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 #ifndef AVCODEC_AACENC_H
23 #define AVCODEC_AACENC_H
24 
25 #include "libavutil/float_dsp.h"
26 #include "libavutil/mem_internal.h"
27 
28 #include "avcodec.h"
29 #include "put_bits.h"
30 
31 #include "aac.h"
32 #include "audio_frame_queue.h"
33 #include "psymodel.h"
34 
35 #include "lpc.h"
36 
37 typedef enum AACCoder {
41 
43 }AACCoder;
44 
45 typedef struct AACEncOptions {
46  int coder;
47  int pns;
48  int tns;
49  int ltp;
50  int pce;
51  int pred;
52  int mid_side;
55 
56 struct AACEncContext;
57 
58 typedef struct AACCoefficientsEncoder {
60  SingleChannelElement *sce, const float lambda);
62  int win, int group_len, const float lambda);
63  void (*quantize_and_encode_band)(struct AACEncContext *s, PutBitContext *pb, const float *in, float *out, int size,
64  int scale_idx, int cb, const float lambda, int rtz);
66  void (*encode_ltp_info)(struct AACEncContext *s, SingleChannelElement *sce, int common_window);
78  void (*search_for_ltp)(struct AACEncContext *s, SingleChannelElement *sce, int common_window);
83 
85 
87  float rd;
88  float energy;
89  int bits;
90  char cb;
91  char rtz;
92  uint16_t generation;
94 
95 typedef struct AACPCEInfo {
96  int64_t layout;
97  int num_ele[4]; ///< front, side, back, lfe
98  int pairing[3][8]; ///< front, side, back
99  int index[4][8]; ///< front, side, back, lfe
100  uint8_t config_map[16]; ///< configs the encoder's channel specific settings
101  uint8_t reorder_map[16]; ///< maps channels from lavc to aac order
102 } AACPCEInfo;
103 
104 /**
105  * List of PCE (Program Configuration Element) for the channel layouts listed
106  * in channel_layout.h
107  *
108  * For those wishing in the future to add other layouts:
109  *
110  * - num_ele: number of elements in each group of front, side, back, lfe channels
111  * (an element is of type SCE (single channel), CPE (channel pair) for
112  * the first 3 groups; and is LFE for LFE group).
113  *
114  * - pairing: 0 for an SCE element or 1 for a CPE; does not apply to LFE group
115  *
116  * - index: there are three independent indices for SCE, CPE and LFE;
117  * they are incremented irrespective of the group to which the element belongs;
118  * they are not reset when going from one group to another
119  *
120  * Example: for 7.0 channel layout,
121  * .pairing = { { 1, 0 }, { 1 }, { 1 }, }, (3 CPE and 1 SCE in front group)
122  * .index = { { 0, 0 }, { 1 }, { 2 }, },
123  * (index is 0 for the single SCE but goes from 0 to 2 for the CPEs)
124  *
125  * The index order impacts the channel ordering. But is otherwise arbitrary
126  * (the sequence could have been 2, 0, 1 instead of 0, 1, 2).
127  *
128  * Spec allows for discontinuous indices, e.g. if one has a total of two SCE,
129  * SCE.0 SCE.15 is OK per spec; BUT it won't be decoded by our AAC decoder
130  * which at this time requires that indices fully cover some range starting
131  * from 0 (SCE.1 SCE.0 is OK but not SCE.0 SCE.15).
132  *
133  * - config_map: total number of elements and their types. Beware, the way the
134  * types are ordered impacts the final channel ordering.
135  *
136  * - reorder_map: reorders the channels.
137  *
138  */
139 static const AACPCEInfo aac_pce_configs[] = {
140  {
142  .num_ele = { 1, 0, 0, 0 },
143  .pairing = { { 0 }, },
144  .index = { { 0 }, },
145  .config_map = { 1, TYPE_SCE, },
146  .reorder_map = { 0 },
147  },
148  {
149  .layout = AV_CH_LAYOUT_STEREO,
150  .num_ele = { 1, 0, 0, 0 },
151  .pairing = { { 1 }, },
152  .index = { { 0 }, },
153  .config_map = { 1, TYPE_CPE, },
154  .reorder_map = { 0, 1 },
155  },
156  {
157  .layout = AV_CH_LAYOUT_2POINT1,
158  .num_ele = { 1, 0, 0, 1 },
159  .pairing = { { 1 }, },
160  .index = { { 0 },{ 0 },{ 0 },{ 0 } },
161  .config_map = { 2, TYPE_CPE, TYPE_LFE },
162  .reorder_map = { 0, 1, 2 },
163  },
164  {
165  .layout = AV_CH_LAYOUT_2_1,
166  .num_ele = { 1, 0, 1, 0 },
167  .pairing = { { 1 },{ 0 },{ 0 } },
168  .index = { { 0 },{ 0 },{ 0 }, },
169  .config_map = { 2, TYPE_CPE, TYPE_SCE },
170  .reorder_map = { 0, 1, 2 },
171  },
172  {
173  .layout = AV_CH_LAYOUT_SURROUND,
174  .num_ele = { 2, 0, 0, 0 },
175  .pairing = { { 1, 0 }, },
176  .index = { { 0, 0 }, },
177  .config_map = { 2, TYPE_CPE, TYPE_SCE, },
178  .reorder_map = { 0, 1, 2 },
179  },
180  {
181  .layout = AV_CH_LAYOUT_3POINT1,
182  .num_ele = { 2, 0, 0, 1 },
183  .pairing = { { 1, 0 }, },
184  .index = { { 0, 0 }, { 0 }, { 0 }, { 0 }, },
185  .config_map = { 3, TYPE_CPE, TYPE_SCE, TYPE_LFE },
186  .reorder_map = { 0, 1, 2, 3 },
187  },
188  {
189  .layout = AV_CH_LAYOUT_4POINT0,
190  .num_ele = { 2, 0, 1, 0 },
191  .pairing = { { 1, 0 }, { 0 }, { 0 }, },
192  .index = { { 0, 0 }, { 0 }, { 1 } },
193  .config_map = { 3, TYPE_CPE, TYPE_SCE, TYPE_SCE },
194  .reorder_map = { 0, 1, 2, 3 },
195  },
196  {
197  .layout = AV_CH_LAYOUT_4POINT1,
198  .num_ele = { 2, 1, 1, 0 },
199  .pairing = { { 1, 0 }, { 0 }, { 0 }, },
200  .index = { { 0, 0 }, { 1 }, { 2 }, { 0 } },
201  .config_map = { 4, TYPE_CPE, TYPE_SCE, TYPE_SCE, TYPE_SCE },
202  .reorder_map = { 0, 1, 2, 3, 4 },
203  },
204  {
205  .layout = AV_CH_LAYOUT_2_2,
206  .num_ele = { 1, 1, 0, 0 },
207  .pairing = { { 1 }, { 1 }, },
208  .index = { { 0 }, { 1 }, },
209  .config_map = { 2, TYPE_CPE, TYPE_CPE },
210  .reorder_map = { 0, 1, 2, 3 },
211  },
212  {
213  .layout = AV_CH_LAYOUT_QUAD,
214  .num_ele = { 1, 0, 1, 0 },
215  .pairing = { { 1 }, { 0 }, { 1 }, },
216  .index = { { 0 }, { 0 }, { 1 } },
217  .config_map = { 2, TYPE_CPE, TYPE_CPE },
218  .reorder_map = { 0, 1, 2, 3 },
219  },
220  {
221  .layout = AV_CH_LAYOUT_5POINT0,
222  .num_ele = { 2, 1, 0, 0 },
223  .pairing = { { 1, 0 }, { 1 }, },
224  .index = { { 0, 0 }, { 1 } },
225  .config_map = { 3, TYPE_CPE, TYPE_SCE, TYPE_CPE },
226  .reorder_map = { 0, 1, 2, 3, 4 },
227  },
228  {
229  .layout = AV_CH_LAYOUT_5POINT1,
230  .num_ele = { 2, 1, 1, 0 },
231  .pairing = { { 1, 0 }, { 0 }, { 1 }, },
232  .index = { { 0, 0 }, { 1 }, { 1 } },
233  .config_map = { 4, TYPE_CPE, TYPE_SCE, TYPE_SCE, TYPE_CPE },
234  .reorder_map = { 0, 1, 2, 3, 4, 5 },
235  },
236  {
237  .layout = AV_CH_LAYOUT_5POINT0_BACK,
238  .num_ele = { 2, 0, 1, 0 },
239  .pairing = { { 1, 0 }, { 0 }, { 1 } },
240  .index = { { 0, 0 }, { 0 }, { 1 } },
241  .config_map = { 3, TYPE_CPE, TYPE_SCE, TYPE_CPE },
242  .reorder_map = { 0, 1, 2, 3, 4 },
243  },
244  {
245  .layout = AV_CH_LAYOUT_5POINT1_BACK,
246  .num_ele = { 2, 1, 1, 0 },
247  .pairing = { { 1, 0 }, { 0 }, { 1 }, },
248  .index = { { 0, 0 }, { 1 }, { 1 } },
249  .config_map = { 4, TYPE_CPE, TYPE_SCE, TYPE_SCE, TYPE_CPE },
250  .reorder_map = { 0, 1, 2, 3, 4, 5 },
251  },
252  {
253  .layout = AV_CH_LAYOUT_6POINT0,
254  .num_ele = { 2, 1, 1, 0 },
255  .pairing = { { 1, 0 }, { 1 }, { 0 }, },
256  .index = { { 0, 0 }, { 1 }, { 1 } },
257  .config_map = { 4, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_SCE },
258  .reorder_map = { 0, 1, 2, 3, 4, 5 },
259  },
260  {
261  .layout = AV_CH_LAYOUT_6POINT0_FRONT,
262  .num_ele = { 2, 1, 0, 0 },
263  .pairing = { { 1, 1 }, { 1 } },
264  .index = { { 1, 0 }, { 2 }, },
265  .config_map = { 3, TYPE_CPE, TYPE_CPE, TYPE_CPE, },
266  .reorder_map = { 0, 1, 2, 3, 4, 5 },
267  },
268  {
269  .layout = AV_CH_LAYOUT_HEXAGONAL,
270  .num_ele = { 2, 0, 2, 0 },
271  .pairing = { { 1, 0 },{ 0 },{ 1, 0 }, },
272  .index = { { 0, 0 },{ 0 },{ 1, 1 } },
273  .config_map = { 4, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_SCE, },
274  .reorder_map = { 0, 1, 2, 3, 4, 5 },
275  },
276  {
277  .layout = AV_CH_LAYOUT_6POINT1,
278  .num_ele = { 2, 1, 2, 0 },
279  .pairing = { { 1, 0 },{ 0 },{ 1, 0 }, },
280  .index = { { 0, 0 },{ 1 },{ 1, 2 } },
281  .config_map = { 5, TYPE_CPE, TYPE_SCE, TYPE_SCE, TYPE_CPE, TYPE_SCE },
282  .reorder_map = { 0, 1, 2, 3, 4, 5, 6 },
283  },
284  {
285  .layout = AV_CH_LAYOUT_6POINT1_BACK,
286  .num_ele = { 2, 1, 2, 0 },
287  .pairing = { { 1, 0 }, { 0 }, { 1, 0 }, },
288  .index = { { 0, 0 }, { 1 }, { 1, 2 } },
289  .config_map = { 5, TYPE_CPE, TYPE_SCE, TYPE_SCE, TYPE_CPE, TYPE_SCE },
290  .reorder_map = { 0, 1, 2, 3, 4, 5, 6 },
291  },
292  {
293  .layout = AV_CH_LAYOUT_6POINT1_FRONT,
294  .num_ele = { 2, 1, 2, 0 },
295  .pairing = { { 1, 0 }, { 0 }, { 1, 0 }, },
296  .index = { { 0, 0 }, { 1 }, { 1, 2 } },
297  .config_map = { 5, TYPE_CPE, TYPE_SCE, TYPE_SCE, TYPE_CPE, TYPE_SCE },
298  .reorder_map = { 0, 1, 2, 3, 4, 5, 6 },
299  },
300  {
301  .layout = AV_CH_LAYOUT_7POINT0,
302  .num_ele = { 2, 1, 1, 0 },
303  .pairing = { { 1, 0 }, { 1 }, { 1 }, },
304  .index = { { 0, 0 }, { 1 }, { 2 }, },
305  .config_map = { 4, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_CPE },
306  .reorder_map = { 0, 1, 2, 3, 4, 5, 6 },
307  },
308  {
309  .layout = AV_CH_LAYOUT_7POINT0_FRONT,
310  .num_ele = { 2, 1, 1, 0 },
311  .pairing = { { 1, 0 }, { 1 }, { 1 }, },
312  .index = { { 0, 0 }, { 1 }, { 2 }, },
313  .config_map = { 4, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_CPE },
314  .reorder_map = { 0, 1, 2, 3, 4, 5, 6 },
315  },
316  {
317  .layout = AV_CH_LAYOUT_7POINT1,
318  .num_ele = { 2, 1, 2, 0 },
319  .pairing = { { 1, 0 }, { 0 }, { 1, 1 }, },
320  .index = { { 0, 0 }, { 1 }, { 1, 2 }, { 0 } },
321  .config_map = { 5, TYPE_CPE, TYPE_SCE, TYPE_SCE, TYPE_CPE, TYPE_CPE },
322  .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7 },
323  },
324  {
325  .layout = AV_CH_LAYOUT_7POINT1_WIDE,
326  .num_ele = { 2, 1, 2, 0 },
327  .pairing = { { 1, 0 }, { 0 },{ 1, 1 }, },
328  .index = { { 0, 0 }, { 1 }, { 1, 2 }, { 0 } },
329  .config_map = { 5, TYPE_CPE, TYPE_SCE, TYPE_SCE, TYPE_CPE, TYPE_CPE },
330  .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7 },
331  },
332  {
334  .num_ele = { 2, 1, 2, 0 },
335  .pairing = { { 1, 0 }, { 0 }, { 1, 1 }, },
336  .index = { { 0, 0 }, { 1 }, { 1, 2 }, { 0 } },
337  .config_map = { 5, TYPE_CPE, TYPE_SCE, TYPE_SCE, TYPE_CPE, TYPE_CPE },
338  .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7 },
339  },
340  {
341  .layout = AV_CH_LAYOUT_OCTAGONAL,
342  .num_ele = { 2, 1, 2, 0 },
343  .pairing = { { 1, 0 }, { 1 }, { 1, 0 }, },
344  .index = { { 0, 0 }, { 1 }, { 2, 1 } },
345  .config_map = { 5, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_SCE },
346  .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7 },
347  },
348  { /* Meant for order 2/mixed ambisonics */
350  .num_ele = { 2, 2, 2, 0 },
351  .pairing = { { 1, 0 }, { 1, 0 }, { 1, 0 }, },
352  .index = { { 0, 0 }, { 1, 1 }, { 2, 2 } },
353  .config_map = { 6, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_SCE },
354  .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7, 8 },
355  },
356  { /* Meant for order 2/mixed ambisonics */
359  .num_ele = { 2, 2, 2, 0 },
360  .pairing = { { 1, 1 }, { 1, 0 }, { 1, 0 }, },
361  .index = { { 0, 1 }, { 2, 0 }, { 3, 1 } },
362  .config_map = { 6, TYPE_CPE, TYPE_CPE, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_SCE },
363  .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
364  },
365  {
366  .layout = AV_CH_LAYOUT_HEXADECAGONAL,
367  .num_ele = { 4, 2, 4, 0 },
368  .pairing = { { 1, 0, 1, 0 }, { 1, 1 }, { 1, 0, 1, 0 }, },
369  .index = { { 0, 0, 1, 1 }, { 2, 3 }, { 4, 2, 5, 3 } },
371  .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
372  },
373 };
374 
375 /**
376  * AAC encoder context
377  */
378 typedef struct AACEncContext {
380  AACEncOptions options; ///< encoding options
382  FFTContext mdct1024; ///< long (1024 samples) frame transform context
383  FFTContext mdct128; ///< short (128 samples) frame transform context
385  AACPCEInfo pce; ///< PCE data, if needed
386  float *planar_samples[16]; ///< saved preprocessed input
387 
388  int profile; ///< copied from avctx
389  int needs_pce; ///< flag for non-standard layout
390  LPCContext lpc; ///< used by TNS
391  int samplerate_index; ///< MPEG-4 samplerate index
392  int channels; ///< channel count
393  const uint8_t *reorder_map; ///< lavc to aac reorder map
394  const uint8_t *chan_map; ///< channel configuration map
395 
396  ChannelElement *cpe; ///< channel elements
400  int cur_channel; ///< current channel for coder context
402  float lambda;
403  int last_frame_pb_count; ///< number of bits for the previous frame
404  float lambda_sum; ///< sum(lambda), for Qvg reporting
405  int lambda_count; ///< count(lambda), for Qvg reporting
406  enum RawDataBlockType cur_type; ///< channel group type cur_channel belongs to
407 
409  DECLARE_ALIGNED(16, int, qcoefs)[96]; ///< quantized coefficients
410  DECLARE_ALIGNED(32, float, scoefs)[1024]; ///< scaled coefficients
411 
413  AACQuantizeBandCostCacheEntry quantize_band_cost_cache[256][128]; ///< memoization area for quantize_band_cost
414 
415  void (*abs_pow34)(float *out, const float *in, const int size);
416  void (*quant_bands)(int *out, const float *in, const float *scaled,
417  int size, int is_signed, int maxval, const float Q34,
418  const float rounding);
419 
420  struct {
421  float *samples;
422  } buffer;
423 } AACEncContext;
424 
428 
429 
430 #endif /* AVCODEC_AACENC_H */
AV_CH_LAYOUT_7POINT0
#define AV_CH_LAYOUT_7POINT0
Definition: channel_layout.h:110
AACQuantizeBandCostCacheEntry
Definition: aacenc.h:86
AV_CH_LAYOUT_6POINT1
#define AV_CH_LAYOUT_6POINT1
Definition: channel_layout.h:107
AACCoefficientsEncoder::apply_tns_filt
void(* apply_tns_filt)(struct AACEncContext *s, SingleChannelElement *sce)
Definition: aacenc.h:71
AV_CH_LAYOUT_7POINT1_WIDE_BACK
#define AV_CH_LAYOUT_7POINT1_WIDE_BACK
Definition: channel_layout.h:114
AACEncOptions::ltp
int ltp
Definition: aacenc.h:49
AACCoefficientsEncoder::encode_window_bands_info
void(* encode_window_bands_info)(struct AACEncContext *s, SingleChannelElement *sce, int win, int group_len, const float lambda)
Definition: aacenc.h:61
AV_CH_LAYOUT_5POINT0_BACK
#define AV_CH_LAYOUT_5POINT0_BACK
Definition: channel_layout.h:102
AACEncContext::planar_samples
float * planar_samples[16]
saved preprocessed input
Definition: aacenc.h:386
AACCoefficientsEncoder::search_for_quantizers
void(* search_for_quantizers)(AVCodecContext *avctx, struct AACEncContext *s, SingleChannelElement *sce, const float lambda)
Definition: aacenc.h:59
AACQuantizeBandCostCacheEntry::cb
char cb
Definition: aacenc.h:90
AACEncContext::needs_pce
int needs_pce
flag for non-standard layout
Definition: aacenc.h:389
mem_internal.h
AACEncOptions::coder
int coder
Definition: aacenc.h:46
out
FILE * out
Definition: movenc.c:54
cb
static double cb(void *priv, double x, double y)
Definition: vf_geq.c:215
AV_CH_LAYOUT_HEXADECAGONAL
#define AV_CH_LAYOUT_HEXADECAGONAL
Definition: channel_layout.h:116
AACEncContext::av_class
AVClass * av_class
Definition: aacenc.h:379
AV_CH_LAYOUT_MONO
#define AV_CH_LAYOUT_MONO
Definition: channel_layout.h:90
AACEncContext::abs_pow34
void(* abs_pow34)(float *out, const float *in, const int size)
Definition: aacenc.h:415
AACCoefficientsEncoder::search_for_pns
void(* search_for_pns)(struct AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce)
Definition: aacenc.h:75
AACCoefficientsEncoder::search_for_ms
void(* search_for_ms)(struct AACEncContext *s, ChannelElement *cpe)
Definition: aacenc.h:79
AV_CH_LAYOUT_HEXAGONAL
#define AV_CH_LAYOUT_HEXAGONAL
Definition: channel_layout.h:106
AACEncContext::samplerate_index
int samplerate_index
MPEG-4 samplerate index.
Definition: aacenc.h:391
AV_CH_LAYOUT_6POINT0_FRONT
#define AV_CH_LAYOUT_6POINT0_FRONT
Definition: channel_layout.h:105
AV_CH_LAYOUT_6POINT1_FRONT
#define AV_CH_LAYOUT_6POINT1_FRONT
Definition: channel_layout.h:109
AACCoefficientsEncoder::search_for_tns
void(* search_for_tns)(struct AACEncContext *s, SingleChannelElement *sce)
Definition: aacenc.h:77
AAC_CODER_NB
@ AAC_CODER_NB
Definition: aacenc.h:42
lpc.h
AACQuantizeBandCostCacheEntry::generation
uint16_t generation
Definition: aacenc.h:92
AACCoefficientsEncoder::update_ltp
void(* update_ltp)(struct AACEncContext *s, SingleChannelElement *sce)
Definition: aacenc.h:72
AACPCEInfo::layout
int64_t layout
Definition: aacenc.h:96
AACEncContext::chan_map
const uint8_t * chan_map
channel configuration map
Definition: aacenc.h:394
AAC_CODER_FAST
@ AAC_CODER_FAST
Definition: aacenc.h:40
win
static float win(SuperEqualizerContext *s, float n, int N)
Definition: af_superequalizer.c:119
AV_CH_LAYOUT_6POINT0
#define AV_CH_LAYOUT_6POINT0
Definition: channel_layout.h:104
LPCContext
Definition: lpc.h:52
ff_quantize_band_cost_cache_init
void ff_quantize_band_cost_cache_init(struct AACEncContext *s)
Definition: aacenc.c:124
AACEncContext::psy
FFPsyContext psy
Definition: aacenc.h:397
TYPE_CPE
@ TYPE_CPE
Definition: aac.h:58
audio_frame_queue.h
AV_CH_BACK_LEFT
#define AV_CH_BACK_LEFT
Definition: channel_layout.h:53
AACEncContext::options
AACEncOptions options
encoding options
Definition: aacenc.h:380
AACEncOptions::pce
int pce
Definition: aacenc.h:50
AV_CH_LAYOUT_STEREO
#define AV_CH_LAYOUT_STEREO
Definition: channel_layout.h:91
AACPCEInfo::num_ele
int num_ele[4]
front, side, back, lfe
Definition: aacenc.h:97
AACEncContext::fdsp
AVFloatDSPContext * fdsp
Definition: aacenc.h:384
AV_CH_LAYOUT_QUAD
#define AV_CH_LAYOUT_QUAD
Definition: channel_layout.h:99
AACEncContext::lambda_count
int lambda_count
count(lambda), for Qvg reporting
Definition: aacenc.h:405
AACEncContext::lambda_sum
float lambda_sum
sum(lambda), for Qvg reporting
Definition: aacenc.h:404
ff_aac_coders
const AACCoefficientsEncoder ff_aac_coders[]
Definition: aaccoder.c:897
s
#define s(width, name)
Definition: cbs_vp9.c:257
AV_CH_LAYOUT_7POINT0_FRONT
#define AV_CH_LAYOUT_7POINT0_FRONT
Definition: channel_layout.h:111
AACEncContext::mdct1024
FFTContext mdct1024
long (1024 samples) frame transform context
Definition: aacenc.h:382
AudioFrameQueue
Definition: audio_frame_queue.h:32
AACEncContext::reorder_map
const uint8_t * reorder_map
lavc to aac reorder map
Definition: aacenc.h:393
AACCoefficientsEncoder::adjust_common_ltp
void(* adjust_common_ltp)(struct AACEncContext *s, ChannelElement *cpe)
Definition: aacenc.h:69
AACPCEInfo::reorder_map
uint8_t reorder_map[16]
maps channels from lavc to aac order
Definition: aacenc.h:101
AACQuantizeBandCostCacheEntry::energy
float energy
Definition: aacenc.h:88
AACCoefficientsEncoder::encode_ltp_info
void(* encode_ltp_info)(struct AACEncContext *s, SingleChannelElement *sce, int common_window)
Definition: aacenc.h:66
PutBitContext
Definition: put_bits.h:44
AV_CH_LAYOUT_2_1
#define AV_CH_LAYOUT_2_1
Definition: channel_layout.h:93
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
aac_pce_configs
static const AACPCEInfo aac_pce_configs[]
List of PCE (Program Configuration Element) for the channel layouts listed in channel_layout....
Definition: aacenc.h:139
AV_CH_TOP_CENTER
#define AV_CH_TOP_CENTER
Definition: channel_layout.h:60
AACEncContext::cur_type
enum RawDataBlockType cur_type
channel group type cur_channel belongs to
Definition: aacenc.h:406
AACCoefficientsEncoder::search_for_pred
void(* search_for_pred)(struct AACEncContext *s, SingleChannelElement *sce)
Definition: aacenc.h:81
AV_CH_LAYOUT_5POINT1
#define AV_CH_LAYOUT_5POINT1
Definition: channel_layout.h:101
aac.h
AACEncContext::random_state
int random_state
Definition: aacenc.h:401
AACCoefficientsEncoder::ltp_insert_new_frame
void(* ltp_insert_new_frame)(struct AACEncContext *s)
Definition: aacenc.h:73
AACEncContext::quantize_band_cost_cache_generation
uint16_t quantize_band_cost_cache_generation
Definition: aacenc.h:412
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
AACCoefficientsEncoder::adjust_common_pred
void(* adjust_common_pred)(struct AACEncContext *s, ChannelElement *cpe)
Definition: aacenc.h:68
AACEncContext::qcoefs
int qcoefs[96]
quantized coefficients
Definition: aacenc.h:409
float_dsp.h
AACCoefficientsEncoder::apply_main_pred
void(* apply_main_pred)(struct AACEncContext *s, SingleChannelElement *sce)
Definition: aacenc.h:70
AACEncOptions::tns
int tns
Definition: aacenc.h:48
AACPCEInfo
Definition: aacenc.h:95
AACEncContext::samples
float * samples
Definition: aacenc.h:421
AAC_CODER_ANMR
@ AAC_CODER_ANMR
Definition: aacenc.h:38
AACCoefficientsEncoder::set_special_band_scalefactors
void(* set_special_band_scalefactors)(struct AACEncContext *s, SingleChannelElement *sce)
Definition: aacenc.h:74
AACEncContext::channels
int channels
channel count
Definition: aacenc.h:392
size
int size
Definition: twinvq_data.h:10344
AACCoefficientsEncoder::quantize_and_encode_band
void(* quantize_and_encode_band)(struct AACEncContext *s, PutBitContext *pb, const float *in, float *out, int size, int scale_idx, int cb, const float lambda, int rtz)
Definition: aacenc.h:63
FFPsyPreprocessContext
Definition: psymodel.c:93
AVFloatDSPContext
Definition: float_dsp.h:24
AACEncContext::quant_bands
void(* quant_bands)(int *out, const float *in, const float *scaled, int size, int is_signed, int maxval, const float Q34, const float rounding)
Definition: aacenc.h:416
AAC_CODER_TWOLOOP
@ AAC_CODER_TWOLOOP
Definition: aacenc.h:39
ff_aac_coder_init_mips
void ff_aac_coder_init_mips(AACEncContext *c)
Definition: aaccoder_mips.c:2484
AACCoefficientsEncoder::mark_pns
void(* mark_pns)(struct AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce)
Definition: aacenc.h:76
AV_CH_LAYOUT_5POINT1_BACK
#define AV_CH_LAYOUT_5POINT1_BACK
Definition: channel_layout.h:103
AACPCEInfo::index
int index[4][8]
front, side, back, lfe
Definition: aacenc.h:99
AV_CH_LAYOUT_3POINT1
#define AV_CH_LAYOUT_3POINT1
Definition: channel_layout.h:95
AACEncContext::cur_channel
int cur_channel
current channel for coder context
Definition: aacenc.h:400
AACCoder
AACCoder
Definition: aacenc.h:37
DECLARE_ALIGNED
#define DECLARE_ALIGNED(n, t, v)
Definition: mem.h:117
AV_CH_LAYOUT_OCTAGONAL
#define AV_CH_LAYOUT_OCTAGONAL
Definition: channel_layout.h:115
AV_CH_LAYOUT_5POINT0
#define AV_CH_LAYOUT_5POINT0
Definition: channel_layout.h:100
in
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
Definition: audio_convert.c:326
AACPCEInfo::config_map
uint8_t config_map[16]
configs the encoder's channel specific settings
Definition: aacenc.h:100
FFTContext
Definition: fft.h:83
AACEncOptions::intensity_stereo
int intensity_stereo
Definition: aacenc.h:53
AACCoefficientsEncoder::encode_main_pred
void(* encode_main_pred)(struct AACEncContext *s, SingleChannelElement *sce)
Definition: aacenc.h:67
RawDataBlockType
RawDataBlockType
Definition: aac.h:56
SingleChannelElement
Single Channel Element - used for both SCE and LFE elements.
Definition: aac.h:249
AACEncContext::mdct128
FFTContext mdct128
short (128 samples) frame transform context
Definition: aacenc.h:383
AV_CH_LAYOUT_2POINT1
#define AV_CH_LAYOUT_2POINT1
Definition: channel_layout.h:92
AACQuantizeBandCostCacheEntry::rd
float rd
Definition: aacenc.h:87
AACCoefficientsEncoder::search_for_is
void(* search_for_is)(struct AACEncContext *s, AVCodecContext *avctx, ChannelElement *cpe)
Definition: aacenc.h:80
ChannelElement
channel element - generic struct for SCE/CPE/CCE/LFE
Definition: aac.h:276
AACPCEInfo::pairing
int pairing[3][8]
front, side, back
Definition: aacenc.h:98
AV_CH_LAYOUT_7POINT1
#define AV_CH_LAYOUT_7POINT1
Definition: channel_layout.h:112
AV_CH_LAYOUT_4POINT1
#define AV_CH_LAYOUT_4POINT1
Definition: channel_layout.h:97
AACQuantizeBandCostCacheEntry::bits
int bits
Definition: aacenc.h:89
AV_CH_BACK_CENTER
#define AV_CH_BACK_CENTER
Definition: channel_layout.h:57
AV_CH_LAYOUT_7POINT1_WIDE
#define AV_CH_LAYOUT_7POINT1_WIDE
Definition: channel_layout.h:113
TYPE_LFE
@ TYPE_LFE
Definition: aac.h:60
uint8_t
uint8_t
Definition: audio_convert.c:194
ff_aac_dsp_init_x86
void ff_aac_dsp_init_x86(AACEncContext *s)
Definition: aacencdsp_init.c:34
TYPE_SCE
@ TYPE_SCE
Definition: aac.h:57
AACEncContext::quantize_band_cost_cache
AACQuantizeBandCostCacheEntry quantize_band_cost_cache[256][128]
memoization area for quantize_band_cost
Definition: aacenc.h:413
AACEncContext::psypp
struct FFPsyPreprocessContext * psypp
Definition: aacenc.h:398
AACCoefficientsEncoder
Definition: aacenc.h:58
AACEncOptions::pns
int pns
Definition: aacenc.h:47
avcodec.h
AACEncOptions::mid_side
int mid_side
Definition: aacenc.h:52
AACEncContext::profile
int profile
copied from avctx
Definition: aacenc.h:388
AACEncContext::lpc
LPCContext lpc
used by TNS
Definition: aacenc.h:390
AACEncContext::buffer
struct AACEncContext::@6 buffer
AV_CH_LAYOUT_SURROUND
#define AV_CH_LAYOUT_SURROUND
Definition: channel_layout.h:94
AACEncContext::afq
AudioFrameQueue afq
Definition: aacenc.h:408
AACEncContext::pce
AACPCEInfo pce
PCE data, if needed.
Definition: aacenc.h:385
AACEncContext
AAC encoder context.
Definition: aacenc.h:378
AACQuantizeBandCostCacheEntry::rtz
char rtz
Definition: aacenc.h:91
AACCoefficientsEncoder::encode_tns_info
void(* encode_tns_info)(struct AACEncContext *s, SingleChannelElement *sce)
Definition: aacenc.h:65
AACEncContext::last_frame_pb_count
int last_frame_pb_count
number of bits for the previous frame
Definition: aacenc.h:403
AVCodecContext
main external API structure.
Definition: avcodec.h:536
AACCoefficientsEncoder::search_for_ltp
void(* search_for_ltp)(struct AACEncContext *s, SingleChannelElement *sce, int common_window)
Definition: aacenc.h:78
AACEncContext::scoefs
float scoefs[1024]
scaled coefficients
Definition: aacenc.h:410
AACEncContext::coder
const AACCoefficientsEncoder * coder
Definition: aacenc.h:399
AACEncContext::pb
PutBitContext pb
Definition: aacenc.h:381
AV_CH_LAYOUT_4POINT0
#define AV_CH_LAYOUT_4POINT0
Definition: channel_layout.h:96
AV_CH_LAYOUT_6POINT1_BACK
#define AV_CH_LAYOUT_6POINT1_BACK
Definition: channel_layout.h:108
AACEncOptions::pred
int pred
Definition: aacenc.h:51
AV_CH_BACK_RIGHT
#define AV_CH_BACK_RIGHT
Definition: channel_layout.h:54
AACEncContext::lambda
float lambda
Definition: aacenc.h:402
put_bits.h
FFPsyContext
context used by psychoacoustic model
Definition: psymodel.h:89
AACEncOptions
Definition: aacenc.h:45
psymodel.h
AV_CH_LAYOUT_2_2
#define AV_CH_LAYOUT_2_2
Definition: channel_layout.h:98
AACEncContext::cpe
ChannelElement * cpe
channel elements
Definition: aacenc.h:396