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 {
59  void (*search_for_quantizers)(AVCodecContext *avctx, struct AACEncContext *s,
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);
65  void (*encode_tns_info)(struct AACEncContext *s, SingleChannelElement *sce);
66  void (*encode_ltp_info)(struct AACEncContext *s, SingleChannelElement *sce, int common_window);
67  void (*encode_main_pred)(struct AACEncContext *s, SingleChannelElement *sce);
68  void (*adjust_common_pred)(struct AACEncContext *s, ChannelElement *cpe);
69  void (*adjust_common_ltp)(struct AACEncContext *s, ChannelElement *cpe);
70  void (*apply_main_pred)(struct AACEncContext *s, SingleChannelElement *sce);
71  void (*apply_tns_filt)(struct AACEncContext *s, SingleChannelElement *sce);
73  void (*ltp_insert_new_frame)(struct AACEncContext *s);
77  void (*search_for_tns)(struct AACEncContext *s, SingleChannelElement *sce);
78  void (*search_for_ltp)(struct AACEncContext *s, SingleChannelElement *sce, int common_window);
80  void (*search_for_is)(struct AACEncContext *s, AVCodecContext *avctx, ChannelElement *cpe);
81  void (*search_for_pred)(struct AACEncContext *s, SingleChannelElement *sce);
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 } },
370  .config_map = { 10, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_SCE },
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 */
#define AV_CH_LAYOUT_7POINT1
#define AV_CH_LAYOUT_4POINT1
const AACCoefficientsEncoder * coder
Definition: aacenc.h:399
#define AV_CH_LAYOUT_HEXADECAGONAL
int coder
Definition: aacenc.h:46
static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce, int win, int group_len, const float lambda)
Encode band info for single window group bands.
Definition: aaccoder.c:77
#define AV_CH_LAYOUT_6POINT1
Definition: lpc.h:52
#define AV_CH_LAYOUT_6POINT0
#define AV_CH_LAYOUT_SURROUND
static float win(SuperEqualizerContext *s, float n, int N)
Definition: aac.h:57
Definition: aac.h:58
static void update_ltp(AACContext *ac, SingleChannelElement *sce)
Update the LTP buffer for next frame.
#define AV_CH_LAYOUT_7POINT0_FRONT
int lambda_count
count(lambda), for Qvg reporting
Definition: aacenc.h:405
#define AV_CH_LAYOUT_4POINT0
#define AV_CH_LAYOUT_7POINT0
float lambda
Definition: aacenc.h:402
#define AV_CH_LAYOUT_STEREO
#define AV_CH_LAYOUT_5POINT0
static void search_for_pns(AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce)
Definition: aaccoder.c:543
static double cb(void *priv, double x, double y)
Definition: vf_geq.c:215
AACEncOptions options
encoding options
Definition: aacenc.h:380
AAC encoder context.
Definition: aacenc.h:378
uint8_t
void ff_quantize_band_cost_cache_init(struct AACEncContext *s)
Definition: aacenc.c:123
int intensity_stereo
Definition: aacenc.h:53
LPCContext lpc
used by TNS
Definition: aacenc.h:390
void ff_aac_coder_init_mips(AACEncContext *c)
int samplerate_index
MPEG-4 samplerate index.
Definition: aacenc.h:391
Definition: aac.h:60
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
const uint8_t * chan_map
channel configuration map
Definition: aacenc.h:394
#define AV_CH_LAYOUT_HEXAGONAL
AudioFrameQueue afq
Definition: aacenc.h:408
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
Definition: mem.h:117
context used by psychoacoustic model
Definition: psymodel.h:89
#define AV_CH_BACK_LEFT
int profile
copied from avctx
Definition: aacenc.h:388
ptrdiff_t size
Definition: opengl_enc.c:100
#define AV_CH_LAYOUT_5POINT1
int64_t layout
Definition: aacenc.h:96
const uint8_t * reorder_map
lavc to aac reorder map
Definition: aacenc.h:393
AACCoder
Definition: aacenc.h:37
static const AACPCEInfo aac_pce_configs[]
List of PCE (Program Configuration Element) for the channel layouts listed in channel_layout.h.
Definition: aacenc.h:139
#define AV_CH_LAYOUT_QUAD
#define AV_CH_LAYOUT_2_1
#define AV_CH_LAYOUT_2_2
#define AV_CH_LAYOUT_6POINT0_FRONT
#define AV_CH_TOP_CENTER
Definition: fft.h:83
AVClass * av_class
Definition: aacenc.h:379
int cur_channel
current channel for coder context
Definition: aacenc.h:400
int last_frame_pb_count
number of bits for the previous frame
Definition: aacenc.h:403
#define AV_CH_LAYOUT_3POINT1
static void set_special_band_scalefactors(AACEncContext *s, SingleChannelElement *sce)
Definition: aaccoder.c:196
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
int channels
channel count
Definition: aacenc.h:392
#define s(width, name)
Definition: cbs_vp9.c:257
static void mark_pns(AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce)
Definition: aaccoder.c:685
AAC definitions and structures.
FFTContext mdct128
short (128 samples) frame transform context
Definition: aacenc.h:383
PutBitContext pb
Definition: aacenc.h:381
#define AV_CH_LAYOUT_5POINT1_BACK
AVFloatDSPContext * fdsp
Definition: aacenc.h:384
int mid_side
Definition: aacenc.h:52
#define AV_CH_LAYOUT_6POINT1_BACK
const AACCoefficientsEncoder ff_aac_coders[]
Definition: aaccoder.c:897
void ff_aac_dsp_init_x86(AACEncContext *s)
Libavcodec external API header.
main external API structure.
Definition: avcodec.h:531
float lambda_sum
sum(lambda), for Qvg reporting
Definition: aacenc.h:404
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
Describe the class of an AVClass context structure.
Definition: log.h:67
#define AV_CH_LAYOUT_7POINT1_WIDE_BACK
int index
Definition: gxfenc.c:89
#define AV_CH_LAYOUT_5POINT0_BACK
uint16_t quantize_band_cost_cache_generation
Definition: aacenc.h:412
#define AV_CH_LAYOUT_OCTAGONAL
FFPsyContext psy
Definition: aacenc.h:397
int needs_pce
flag for non-standard layout
Definition: aacenc.h:389
struct FFPsyPreprocessContext * psypp
Definition: aacenc.h:398
#define AV_CH_BACK_CENTER
#define AV_CH_LAYOUT_7POINT1_WIDE
float * samples
Definition: aacenc.h:421
AACPCEInfo pce
PCE data, if needed.
Definition: aacenc.h:385
Single Channel Element - used for both SCE and LFE elements.
Definition: aac.h:249
#define AV_CH_LAYOUT_2POINT1
ChannelElement * cpe
channel elements
Definition: aacenc.h:396
channel element - generic struct for SCE/CPE/CCE/LFE
Definition: aac.h:276
FFTContext mdct1024
long (1024 samples) frame transform context
Definition: aacenc.h:382
int random_state
Definition: aacenc.h:401
static 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)
#define AV_CH_LAYOUT_6POINT1_FRONT
FILE * out
Definition: movenc.c:54
#define AV_CH_LAYOUT_MONO
static void search_for_ms(AACEncContext *s, ChannelElement *cpe)
Definition: aaccoder.c:756
int pred
Definition: aacenc.h:51
GLuint buffer
Definition: opengl_enc.c:101
#define AV_CH_BACK_RIGHT
RawDataBlockType
Definition: aac.h:56
bitstream writer API