FFmpeg
aacdec.c
Go to the documentation of this file.
1 /*
2  * AAC decoder
3  * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org )
4  * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com )
5  * Copyright (c) 2008-2013 Alex Converse <alex.converse@gmail.com>
6  *
7  * AAC LATM decoder
8  * Copyright (c) 2008-2010 Paul Kendall <paul@kcbbs.gen.nz>
9  * Copyright (c) 2010 Janne Grunau <janne-libav@jannau.net>
10  *
11  * This file is part of FFmpeg.
12  *
13  * FFmpeg is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU Lesser General Public
15  * License as published by the Free Software Foundation; either
16  * version 2.1 of the License, or (at your option) any later version.
17  *
18  * FFmpeg is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  * Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public
24  * License along with FFmpeg; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26  */
27 
28 /**
29  * @file
30  * AAC decoder
31  * @author Oded Shimon ( ods15 ods15 dyndns org )
32  * @author Maxim Gavrilov ( maxim.gavrilov gmail com )
33  */
34 
35 #define USE_FIXED 0
36 #define TX_TYPE AV_TX_FLOAT_MDCT
37 
38 #include "libavutil/float_dsp.h"
39 #include "libavutil/opt.h"
40 #include "avcodec.h"
41 #include "codec_internal.h"
42 #include "get_bits.h"
43 #include "kbdwin.h"
44 #include "sinewin.h"
45 
46 #include "aac.h"
47 #include "aacdec.h"
48 #include "aactab.h"
49 #include "aacdectab.h"
50 #include "adts_header.h"
51 #include "cbrt_data.h"
52 #include "sbr.h"
53 #include "aacsbr.h"
54 #include "mpeg4audio.h"
55 #include "profiles.h"
56 #include "libavutil/intfloat.h"
57 
58 #include <errno.h>
59 #include <math.h>
60 #include <stdint.h>
61 #include <string.h>
62 
63 #if ARCH_ARM
64 # include "arm/aac.h"
65 #elif ARCH_MIPS
66 # include "mips/aacdec_mips.h"
67 #endif
68 
73 
75 {
76  ps->r0 = 0.0f;
77  ps->r1 = 0.0f;
78  ps->cor0 = 0.0f;
79  ps->cor1 = 0.0f;
80  ps->var0 = 1.0f;
81  ps->var1 = 1.0f;
82 }
83 
84 #ifndef VMUL2
85 static inline float *VMUL2(float *dst, const float *v, unsigned idx,
86  const float *scale)
87 {
88  float s = *scale;
89  *dst++ = v[idx & 15] * s;
90  *dst++ = v[idx>>4 & 15] * s;
91  return dst;
92 }
93 #endif
94 
95 #ifndef VMUL4
96 static inline float *VMUL4(float *dst, const float *v, unsigned idx,
97  const float *scale)
98 {
99  float s = *scale;
100  *dst++ = v[idx & 3] * s;
101  *dst++ = v[idx>>2 & 3] * s;
102  *dst++ = v[idx>>4 & 3] * s;
103  *dst++ = v[idx>>6 & 3] * s;
104  return dst;
105 }
106 #endif
107 
108 #ifndef VMUL2S
109 static inline float *VMUL2S(float *dst, const float *v, unsigned idx,
110  unsigned sign, const float *scale)
111 {
112  union av_intfloat32 s0, s1;
113 
114  s0.f = s1.f = *scale;
115  s0.i ^= sign >> 1 << 31;
116  s1.i ^= sign << 31;
117 
118  *dst++ = v[idx & 15] * s0.f;
119  *dst++ = v[idx>>4 & 15] * s1.f;
120 
121  return dst;
122 }
123 #endif
124 
125 #ifndef VMUL4S
126 static inline float *VMUL4S(float *dst, const float *v, unsigned idx,
127  unsigned sign, const float *scale)
128 {
129  unsigned nz = idx >> 12;
130  union av_intfloat32 s = { .f = *scale };
131  union av_intfloat32 t;
132 
133  t.i = s.i ^ (sign & 1U<<31);
134  *dst++ = v[idx & 3] * t.f;
135 
136  sign <<= nz & 1; nz >>= 1;
137  t.i = s.i ^ (sign & 1U<<31);
138  *dst++ = v[idx>>2 & 3] * t.f;
139 
140  sign <<= nz & 1; nz >>= 1;
141  t.i = s.i ^ (sign & 1U<<31);
142  *dst++ = v[idx>>4 & 3] * t.f;
143 
144  sign <<= nz & 1;
145  t.i = s.i ^ (sign & 1U<<31);
146  *dst++ = v[idx>>6 & 3] * t.f;
147 
148  return dst;
149 }
150 #endif
151 
152 static av_always_inline float flt16_round(float pf)
153 {
154  union av_intfloat32 tmp;
155  tmp.f = pf;
156  tmp.i = (tmp.i + 0x00008000U) & 0xFFFF0000U;
157  return tmp.f;
158 }
159 
160 static av_always_inline float flt16_even(float pf)
161 {
162  union av_intfloat32 tmp;
163  tmp.f = pf;
164  tmp.i = (tmp.i + 0x00007FFFU + (tmp.i & 0x00010000U >> 16)) & 0xFFFF0000U;
165  return tmp.f;
166 }
167 
168 static av_always_inline float flt16_trunc(float pf)
169 {
170  union av_intfloat32 pun;
171  pun.f = pf;
172  pun.i &= 0xFFFF0000U;
173  return pun.f;
174 }
175 
176 static av_always_inline void predict(PredictorState *ps, float *coef,
177  int output_enable)
178 {
179  const float a = 0.953125; // 61.0 / 64
180  const float alpha = 0.90625; // 29.0 / 32
181  float e0, e1;
182  float pv;
183  float k1, k2;
184  float r0 = ps->r0, r1 = ps->r1;
185  float cor0 = ps->cor0, cor1 = ps->cor1;
186  float var0 = ps->var0, var1 = ps->var1;
187 
188  k1 = var0 > 1 ? cor0 * flt16_even(a / var0) : 0;
189  k2 = var1 > 1 ? cor1 * flt16_even(a / var1) : 0;
190 
191  pv = flt16_round(k1 * r0 + k2 * r1);
192  if (output_enable)
193  *coef += pv;
194 
195  e0 = *coef;
196  e1 = e0 - k1 * r0;
197 
198  ps->cor1 = flt16_trunc(alpha * cor1 + r1 * e1);
199  ps->var1 = flt16_trunc(alpha * var1 + 0.5f * (r1 * r1 + e1 * e1));
200  ps->cor0 = flt16_trunc(alpha * cor0 + r0 * e0);
201  ps->var0 = flt16_trunc(alpha * var0 + 0.5f * (r0 * r0 + e0 * e0));
202 
203  ps->r1 = flt16_trunc(a * (r0 - k1 * e0));
204  ps->r0 = flt16_trunc(a * e0);
205 }
206 
207 /**
208  * Apply dependent channel coupling (applied before IMDCT).
209  *
210  * @param index index into coupling gain array
211  */
213  SingleChannelElement *target,
214  ChannelElement *cce, int index)
215 {
216  IndividualChannelStream *ics = &cce->ch[0].ics;
217  const uint16_t *offsets = ics->swb_offset;
218  float *dest = target->coeffs;
219  const float *src = cce->ch[0].coeffs;
220  int g, i, group, k, idx = 0;
221  if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) {
223  "Dependent coupling is not supported together with LTP\n");
224  return;
225  }
226  for (g = 0; g < ics->num_window_groups; g++) {
227  for (i = 0; i < ics->max_sfb; i++, idx++) {
228  if (cce->ch[0].band_type[idx] != ZERO_BT) {
229  const float gain = cce->coup.gain[index][idx];
230  for (group = 0; group < ics->group_len[g]; group++) {
231  for (k = offsets[i]; k < offsets[i + 1]; k++) {
232  // FIXME: SIMDify
233  dest[group * 128 + k] += gain * src[group * 128 + k];
234  }
235  }
236  }
237  }
238  dest += ics->group_len[g] * 128;
239  src += ics->group_len[g] * 128;
240  }
241 }
242 
243 /**
244  * Apply independent channel coupling (applied after IMDCT).
245  *
246  * @param index index into coupling gain array
247  */
249  SingleChannelElement *target,
250  ChannelElement *cce, int index)
251 {
252  const float gain = cce->coup.gain[index][0];
253  const float *src = cce->ch[0].ret;
254  float *dest = target->ret;
255  const int len = 1024 << (ac->oc[1].m4ac.sbr == 1);
256 
257  ac->fdsp->vector_fmac_scalar(dest, src, gain, len);
258 }
259 
260 #include "aacdec_template.c"
261 
262 #define LOAS_SYNC_WORD 0x2b7 ///< 11 bits LOAS sync word
263 
264 struct LATMContext {
265  AACDecContext aac_ctx; ///< containing AACContext
266  int initialized; ///< initialized after a valid extradata was seen
267 
268  // parser data
269  int audio_mux_version_A; ///< LATM syntax version
270  int frame_length_type; ///< 0/1 variable/fixed frame length
271  int frame_length; ///< frame length for fixed frame length
272 };
273 
274 static inline uint32_t latm_get_value(GetBitContext *b)
275 {
276  int length = get_bits(b, 2);
277 
278  return get_bits_long(b, (length+1)*8);
279 }
280 
282  GetBitContext *gb, int asclen)
283 {
284  AACDecContext *ac = &latmctx->aac_ctx;
285  AVCodecContext *avctx = ac->avctx;
286  MPEG4AudioConfig m4ac = { 0 };
287  GetBitContext gbc;
288  int config_start_bit = get_bits_count(gb);
289  int sync_extension = 0;
290  int bits_consumed, esize, i;
291 
292  if (asclen > 0) {
293  sync_extension = 1;
294  asclen = FFMIN(asclen, get_bits_left(gb));
295  init_get_bits(&gbc, gb->buffer, config_start_bit + asclen);
296  skip_bits_long(&gbc, config_start_bit);
297  } else if (asclen == 0) {
298  gbc = *gb;
299  } else {
300  return AVERROR_INVALIDDATA;
301  }
302 
303  if (get_bits_left(gb) <= 0)
304  return AVERROR_INVALIDDATA;
305 
306  bits_consumed = decode_audio_specific_config_gb(NULL, avctx, &m4ac,
307  &gbc, config_start_bit,
308  sync_extension);
309 
310  if (bits_consumed < config_start_bit)
311  return AVERROR_INVALIDDATA;
312  bits_consumed -= config_start_bit;
313 
314  if (asclen == 0)
315  asclen = bits_consumed;
316 
317  if (!latmctx->initialized ||
318  ac->oc[1].m4ac.sample_rate != m4ac.sample_rate ||
319  ac->oc[1].m4ac.chan_config != m4ac.chan_config) {
320 
321  if (latmctx->initialized) {
322  av_log(avctx, AV_LOG_INFO, "audio config changed (sample_rate=%d, chan_config=%d)\n", m4ac.sample_rate, m4ac.chan_config);
323  } else {
324  av_log(avctx, AV_LOG_DEBUG, "initializing latmctx\n");
325  }
326  latmctx->initialized = 0;
327 
328  esize = (asclen + 7) / 8;
329 
330  if (avctx->extradata_size < esize) {
331  av_free(avctx->extradata);
333  if (!avctx->extradata)
334  return AVERROR(ENOMEM);
335  }
336 
337  avctx->extradata_size = esize;
338  gbc = *gb;
339  for (i = 0; i < esize; i++) {
340  avctx->extradata[i] = get_bits(&gbc, 8);
341  }
342  memset(avctx->extradata+esize, 0, AV_INPUT_BUFFER_PADDING_SIZE);
343  }
344  skip_bits_long(gb, asclen);
345 
346  return 0;
347 }
348 
349 static int read_stream_mux_config(struct LATMContext *latmctx,
350  GetBitContext *gb)
351 {
352  int ret, audio_mux_version = get_bits(gb, 1);
353 
354  latmctx->audio_mux_version_A = 0;
355  if (audio_mux_version)
356  latmctx->audio_mux_version_A = get_bits(gb, 1);
357 
358  if (!latmctx->audio_mux_version_A) {
359 
360  if (audio_mux_version)
361  latm_get_value(gb); // taraFullness
362 
363  skip_bits(gb, 1); // allStreamSameTimeFraming
364  skip_bits(gb, 6); // numSubFrames
365  // numPrograms
366  if (get_bits(gb, 4)) { // numPrograms
367  avpriv_request_sample(latmctx->aac_ctx.avctx, "Multiple programs");
368  return AVERROR_PATCHWELCOME;
369  }
370 
371  // for each program (which there is only one in DVB)
372 
373  // for each layer (which there is only one in DVB)
374  if (get_bits(gb, 3)) { // numLayer
375  avpriv_request_sample(latmctx->aac_ctx.avctx, "Multiple layers");
376  return AVERROR_PATCHWELCOME;
377  }
378 
379  // for all but first stream: use_same_config = get_bits(gb, 1);
380  if (!audio_mux_version) {
381  if ((ret = latm_decode_audio_specific_config(latmctx, gb, 0)) < 0)
382  return ret;
383  } else {
384  int ascLen = latm_get_value(gb);
385  if ((ret = latm_decode_audio_specific_config(latmctx, gb, ascLen)) < 0)
386  return ret;
387  }
388 
389  latmctx->frame_length_type = get_bits(gb, 3);
390  switch (latmctx->frame_length_type) {
391  case 0:
392  skip_bits(gb, 8); // latmBufferFullness
393  break;
394  case 1:
395  latmctx->frame_length = get_bits(gb, 9);
396  break;
397  case 3:
398  case 4:
399  case 5:
400  skip_bits(gb, 6); // CELP frame length table index
401  break;
402  case 6:
403  case 7:
404  skip_bits(gb, 1); // HVXC frame length table index
405  break;
406  }
407 
408  if (get_bits(gb, 1)) { // other data
409  if (audio_mux_version) {
410  latm_get_value(gb); // other_data_bits
411  } else {
412  int esc;
413  do {
414  if (get_bits_left(gb) < 9)
415  return AVERROR_INVALIDDATA;
416  esc = get_bits(gb, 1);
417  skip_bits(gb, 8);
418  } while (esc);
419  }
420  }
421 
422  if (get_bits(gb, 1)) // crc present
423  skip_bits(gb, 8); // config_crc
424  }
425 
426  return 0;
427 }
428 
430 {
431  uint8_t tmp;
432 
433  if (ctx->frame_length_type == 0) {
434  int mux_slot_length = 0;
435  do {
436  if (get_bits_left(gb) < 8)
437  return AVERROR_INVALIDDATA;
438  tmp = get_bits(gb, 8);
439  mux_slot_length += tmp;
440  } while (tmp == 255);
441  return mux_slot_length;
442  } else if (ctx->frame_length_type == 1) {
443  return ctx->frame_length;
444  } else if (ctx->frame_length_type == 3 ||
445  ctx->frame_length_type == 5 ||
446  ctx->frame_length_type == 7) {
447  skip_bits(gb, 2); // mux_slot_length_coded
448  }
449  return 0;
450 }
451 
452 static int read_audio_mux_element(struct LATMContext *latmctx,
453  GetBitContext *gb)
454 {
455  int err;
456  uint8_t use_same_mux = get_bits(gb, 1);
457  if (!use_same_mux) {
458  if ((err = read_stream_mux_config(latmctx, gb)) < 0)
459  return err;
460  } else if (!latmctx->aac_ctx.avctx->extradata) {
461  av_log(latmctx->aac_ctx.avctx, AV_LOG_DEBUG,
462  "no decoder config found\n");
463  return 1;
464  }
465  if (latmctx->audio_mux_version_A == 0) {
466  int mux_slot_length_bytes = read_payload_length_info(latmctx, gb);
467  if (mux_slot_length_bytes < 0 || mux_slot_length_bytes * 8LL > get_bits_left(gb)) {
468  av_log(latmctx->aac_ctx.avctx, AV_LOG_ERROR, "incomplete frame\n");
469  return AVERROR_INVALIDDATA;
470  } else if (mux_slot_length_bytes * 8 + 256 < get_bits_left(gb)) {
471  av_log(latmctx->aac_ctx.avctx, AV_LOG_ERROR,
472  "frame length mismatch %d << %d\n",
473  mux_slot_length_bytes * 8, get_bits_left(gb));
474  return AVERROR_INVALIDDATA;
475  }
476  }
477  return 0;
478 }
479 
480 
482  int *got_frame_ptr, AVPacket *avpkt)
483 {
484  struct LATMContext *latmctx = avctx->priv_data;
485  int muxlength, err;
486  GetBitContext gb;
487 
488  if ((err = init_get_bits8(&gb, avpkt->data, avpkt->size)) < 0)
489  return err;
490 
491  // check for LOAS sync word
492  if (get_bits(&gb, 11) != LOAS_SYNC_WORD)
493  return AVERROR_INVALIDDATA;
494 
495  muxlength = get_bits(&gb, 13) + 3;
496  // not enough data, the parser should have sorted this out
497  if (muxlength > avpkt->size)
498  return AVERROR_INVALIDDATA;
499 
500  if ((err = read_audio_mux_element(latmctx, &gb)))
501  return (err < 0) ? err : avpkt->size;
502 
503  if (!latmctx->initialized) {
504  if (!avctx->extradata) {
505  *got_frame_ptr = 0;
506  return avpkt->size;
507  } else {
509  if ((err = decode_audio_specific_config(
510  &latmctx->aac_ctx, avctx, &latmctx->aac_ctx.oc[1].m4ac,
511  avctx->extradata, avctx->extradata_size*8LL, 1)) < 0) {
513  return err;
514  }
515  latmctx->initialized = 1;
516  }
517  }
518 
519  if (show_bits(&gb, 12) == 0xfff) {
520  av_log(latmctx->aac_ctx.avctx, AV_LOG_ERROR,
521  "ADTS header detected, probably as result of configuration "
522  "misparsing\n");
523  return AVERROR_INVALIDDATA;
524  }
525 
526  switch (latmctx->aac_ctx.oc[1].m4ac.object_type) {
527  case AOT_ER_AAC_LC:
528  case AOT_ER_AAC_LTP:
529  case AOT_ER_AAC_LD:
530  case AOT_ER_AAC_ELD:
531  err = aac_decode_er_frame(avctx, out, got_frame_ptr, &gb);
532  break;
533  default:
534  err = aac_decode_frame_int(avctx, out, got_frame_ptr, &gb, avpkt);
535  }
536  if (err < 0)
537  return err;
538 
539  return muxlength;
540 }
541 
543 {
544  struct LATMContext *latmctx = avctx->priv_data;
545  int ret = aac_decode_init(avctx);
546 
547  if (avctx->extradata_size > 0)
548  latmctx->initialized = !ret;
549 
550  return ret;
551 }
552 
554  .p.name = "aac",
555  CODEC_LONG_NAME("AAC (Advanced Audio Coding)"),
556  .p.type = AVMEDIA_TYPE_AUDIO,
557  .p.id = AV_CODEC_ID_AAC,
558  .priv_data_size = sizeof(AACDecContext),
560  .close = aac_decode_close,
562  .p.sample_fmts = (const enum AVSampleFormat[]) {
564  },
565  .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DR1,
566  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
567  .p.ch_layouts = ff_aac_ch_layout,
568  .flush = flush,
569  .p.priv_class = &aac_decoder_class,
570  .p.profiles = NULL_IF_CONFIG_SMALL(ff_aac_profiles),
571 };
572 
573 /*
574  Note: This decoder filter is intended to decode LATM streams transferred
575  in MPEG transport streams which only contain one program.
576  To do a more complex LATM demuxing a separate LATM demuxer should be used.
577 */
579  .p.name = "aac_latm",
580  CODEC_LONG_NAME("AAC LATM (Advanced Audio Coding LATM syntax)"),
581  .p.type = AVMEDIA_TYPE_AUDIO,
582  .p.id = AV_CODEC_ID_AAC_LATM,
583  .priv_data_size = sizeof(struct LATMContext),
585  .close = aac_decode_close,
587  .p.sample_fmts = (const enum AVSampleFormat[]) {
589  },
590  .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DR1,
591  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
592  .p.ch_layouts = ff_aac_ch_layout,
593  .flush = flush,
594  .p.profiles = NULL_IF_CONFIG_SMALL(ff_aac_profiles),
595 };
AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:66
skip_bits_long
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
Definition: get_bits.h:278
LATMContext::frame_length_type
int frame_length_type
0/1 variable/fixed frame length
Definition: aacdec.c:270
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:42
get_bits_left
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:695
AVERROR
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
opt.h
decode_audio_specific_config_gb
static int decode_audio_specific_config_gb(AACDecContext *ac, AVCodecContext *avctx, MPEG4AudioConfig *m4ac, GetBitContext *gb, int get_bit_alignment, int sync_extension)
Decode audio specific configuration; reference: table 1.13.
Definition: aacdec_template.c:984
out
FILE * out
Definition: movenc.c:54
aac_decode_init
static av_cold int aac_decode_init(AVCodecContext *avctx)
Definition: aacdec_template.c:1148
aac_kbd_short_120
static INTFLOAT aac_kbd_short_120[120]
Definition: aacdec.c:72
get_bits_long
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
Definition: get_bits.h:421
get_bits_count
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:266
PredictorState::var1
AAC_FLOAT var1
Definition: aac.h:95
aacsbr.h
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:344
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
PredictorState::var0
AAC_FLOAT var0
Definition: aac.h:94
AVPacket::data
uint8_t * data
Definition: packet.h:522
av_intfloat32::i
uint32_t i
Definition: intfloat.h:28
aacdectab.h
b
#define b
Definition: input.c:41
AOT_ER_AAC_LTP
@ AOT_ER_AAC_LTP
N Error Resilient Long Term Prediction.
Definition: mpeg4audio.h:88
FFCodec
Definition: codec_internal.h:127
ff_aac_profiles
const AVProfile ff_aac_profiles[]
Definition: profiles.c:26
decode_audio_specific_config
static int decode_audio_specific_config(AACDecContext *ac, AVCodecContext *avctx, MPEG4AudioConfig *m4ac, const uint8_t *data, int64_t bit_size, int sync_extension)
Definition: aacdec_template.c:1051
apply_independent_coupling
static void apply_independent_coupling(AACDecContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)
Apply independent channel coupling (applied after IMDCT).
Definition: aacdec.c:248
ff_aac_decoder
const FFCodec ff_aac_decoder
Definition: aacdec.c:553
SingleChannelElement::ret
INTFLOAT * ret
PCM output.
Definition: aacdec.h:142
latm_decode_audio_specific_config
static int latm_decode_audio_specific_config(struct LATMContext *latmctx, GetBitContext *gb, int asclen)
Definition: aacdec.c:281
intfloat.h
ChannelElement::ch
SingleChannelElement ch[2]
Definition: aacdec.h:153
push_output_configuration
static int push_output_configuration(AACDecContext *ac)
Save current output configuration if and only if it has been locked.
Definition: aacdec_template.c:415
init_get_bits
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
Definition: get_bits.h:514
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:30
sbr.h
MPEG4AudioConfig
Definition: mpeg4audio.h:29
skip_bits
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:381
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:335
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
mpeg4audio.h
ChannelElement::coup
ChannelCoupling coup
Definition: aacdec.h:155
latm_decode_init
static av_cold int latm_decode_init(AVCodecContext *avctx)
Definition: aacdec.c:542
read_audio_mux_element
static int read_audio_mux_element(struct LATMContext *latmctx, GetBitContext *gb)
Definition: aacdec.c:452
GetBitContext
Definition: get_bits.h:108
VMUL2
static float * VMUL2(float *dst, const float *v, unsigned idx, const float *scale)
Definition: aacdec.c:85
PredictorState::r0
AAC_FLOAT r0
Definition: aac.h:96
SingleChannelElement::ics
IndividualChannelStream ics
Definition: aacdec.h:132
aac_decode_frame
static int aac_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Definition: aacdec_template.c:3313
AOT_ER_AAC_LC
@ AOT_ER_AAC_LC
N Error Resilient Low Complexity.
Definition: mpeg4audio.h:87
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
ZERO_BT
@ ZERO_BT
Scalefactors and spectral data are all zero.
Definition: aac.h:70
av_cold
#define av_cold
Definition: attributes.h:90
init_get_bits8
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:545
AVCodecContext::extradata_size
int extradata_size
Definition: avcodec.h:524
AOT_ER_AAC_LD
@ AOT_ER_AAC_LD
N Error Resilient Low Delay.
Definition: mpeg4audio.h:92
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:287
aac_decoder_class
static const AVClass aac_decoder_class
Definition: aacdec_template.c:3445
s
#define s(width, name)
Definition: cbs_vp9.c:198
SingleChannelElement::coeffs
INTFLOAT coeffs[1024]
coefficients for IMDCT, maybe processed
Definition: aacdec.h:137
reset_predict_state
static av_always_inline void reset_predict_state(PredictorState *ps)
Definition: aacdec.c:74
offsets
static const int offsets[]
Definition: hevc_pel.c:34
g
const char * g
Definition: vf_curves.c:127
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
s1
#define s1
Definition: regdef.h:38
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
PredictorState
Predictor State.
Definition: aac.h:91
ctx
AVFormatContext * ctx
Definition: movenc.c:48
get_bits.h
LATMContext::frame_length
int frame_length
frame length for fixed frame length
Definition: aacdec.c:271
kbdwin.h
ff_aac_ch_layout
const AVChannelLayout ff_aac_ch_layout[]
Definition: aacdec_common.c:95
IndividualChannelStream
Individual Channel Stream.
Definition: aacdec.h:84
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
aacdec_mips.h
AACDecContext::fdsp
AVFloatDSPContext * fdsp
Definition: aacdec.h:235
GetBitContext::buffer
const uint8_t * buffer
Definition: get_bits.h:109
NULL
#define NULL
Definition: coverity.c:32
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:64
IndividualChannelStream::num_window_groups
int num_window_groups
Definition: aacdec.h:88
aac_decode_close
static av_cold int aac_decode_close(AVCodecContext *avctx)
Definition: aacdec_template.c:3376
profiles.h
flush
void(* flush)(AVBSFContext *ctx)
Definition: dts2pts.c:367
flt16_trunc
static av_always_inline float flt16_trunc(float pf)
Definition: aacdec.c:168
aac.h
aactab.h
flt16_even
static av_always_inline float flt16_even(float pf)
Definition: aacdec.c:160
LATMContext::initialized
int initialized
initialized after a valid extradata was seen
Definition: aacdec.c:266
av_intfloat32
Definition: intfloat.h:27
PredictorState::r1
AAC_FLOAT r1
Definition: aac.h:97
flt16_round
static av_always_inline float flt16_round(float pf)
Definition: aacdec.c:152
index
int index
Definition: gxfenc.c:89
pop_output_configuration
static void pop_output_configuration(AACDecContext *ac)
Restore the previous output configuration if and only if the current configuration is unlocked.
Definition: aacdec_template.c:431
float_dsp.h
VMUL2S
static float * VMUL2S(float *dst, const float *v, unsigned idx, unsigned sign, const float *scale)
Definition: aacdec.c:109
AV_CODEC_CAP_CHANNEL_CONF
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition: codec.h:106
AV_CODEC_ID_AAC
@ AV_CODEC_ID_AAC
Definition: codec_id.h:442
VMUL4
static float * VMUL4(float *dst, const float *v, unsigned idx, const float *scale)
Definition: aacdec.c:96
VMUL4S
static float * VMUL4S(float *dst, const float *v, unsigned idx, unsigned sign, const float *scale)
Definition: aacdec.c:126
f
f
Definition: af_crystalizer.c:121
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:365
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
AVPacket::size
int size
Definition: packet.h:523
scale
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition: vvc_intra.c:291
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:106
codec_internal.h
DECLARE_ALIGNED
#define DECLARE_ALIGNED(n, t, v)
Definition: mem_internal.h:109
sine_120
static INTFLOAT sine_120[120]
Definition: aacdec.c:69
sine_960
static INTFLOAT sine_960[960]
Definition: aacdec.c:70
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
sinewin.h
SingleChannelElement::band_type
enum BandType band_type[128]
band types
Definition: aacdec.h:134
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
cbrt_data.h
aac_kbd_long_960
static INTFLOAT aac_kbd_long_960[960]
Definition: aacdec.c:71
LATMContext
Definition: aacdec.c:264
SingleChannelElement
Single Channel Element - used for both SCE and LFE elements.
Definition: aacdec.h:131
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
aac_decode_er_frame
static int aac_decode_er_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, GetBitContext *gb)
Definition: aacdec_template.c:3031
AVFloatDSPContext::vector_fmac_scalar
void(* vector_fmac_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float and add to destination vector.
Definition: float_dsp.h:52
AVCodecContext::extradata
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:523
show_bits
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
Definition: get_bits.h:371
aac.h
ChannelElement
channel element - generic struct for SCE/CPE/CCE/LFE
Definition: aacdec.h:148
IndividualChannelStream::swb_offset
const uint16_t * swb_offset
table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular wind...
Definition: aacdec.h:91
AOT_ER_AAC_ELD
@ AOT_ER_AAC_ELD
N Error Resilient Enhanced Low Delay.
Definition: mpeg4audio.h:108
predict
static av_always_inline void predict(PredictorState *ps, float *coef, int output_enable)
Definition: aacdec.c:176
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
av_always_inline
#define av_always_inline
Definition: attributes.h:49
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AAC_RENAME
#define AAC_RENAME(x)
Definition: aac_defines.h:86
MPEG4AudioConfig::chan_config
int chan_config
Definition: mpeg4audio.h:33
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
latm_decode_frame
static int latm_decode_frame(AVCodecContext *avctx, AVFrame *out, int *got_frame_ptr, AVPacket *avpkt)
Definition: aacdec.c:481
len
int len
Definition: vorbis_enc_data.h:426
AACDecContext::oc
OutputConfiguration oc[2]
Definition: aacdec.h:258
apply_dependent_coupling
static void apply_dependent_coupling(AACDecContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)
Apply dependent channel coupling (applied before IMDCT).
Definition: aacdec.c:212
avcodec.h
pv
#define pv
Definition: regdef.h:60
ret
ret
Definition: filter_design.txt:187
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: defs.h:40
MPEG4AudioConfig::object_type
int object_type
Definition: mpeg4audio.h:30
U
#define U(x)
Definition: vpx_arith.h:37
aacdec.h
LATMContext::audio_mux_version_A
int audio_mux_version_A
LATM syntax version.
Definition: aacdec.c:269
AACDecContext
main AAC decoding context
Definition: aacdec.h:186
AVCodecContext
main external API structure.
Definition: avcodec.h:445
AACDecContext::avctx
struct AVCodecContext * avctx
Definition: aacdec.h:188
ff_aac_latm_decoder
const FFCodec ff_aac_latm_decoder
Definition: aacdec.c:578
ChannelCoupling::gain
INTFLOAT gain[16][120]
Definition: aacdec.h:125
MPEG4AudioConfig::sbr
int sbr
-1 implicit, 1 presence
Definition: mpeg4audio.h:34
read_stream_mux_config
static int read_stream_mux_config(struct LATMContext *latmctx, GetBitContext *gb)
Definition: aacdec.c:349
OutputConfiguration::m4ac
MPEG4AudioConfig m4ac
Definition: aacdec.h:160
av_intfloat32::f
float f
Definition: intfloat.h:29
aacdec_template.c
PredictorState::cor1
AAC_FLOAT cor1
Definition: aac.h:93
s0
#define s0
Definition: regdef.h:37
avpriv_request_sample
#define avpriv_request_sample(...)
Definition: tableprint_vlc.h:36
adts_header.h
LOAS_SYNC_WORD
#define LOAS_SYNC_WORD
11 bits LOAS sync word
Definition: aacdec.c:262
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
alpha
static const int16_t alpha[]
Definition: ilbcdata.h:55
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:472
AVPacket
This structure stores compressed data.
Definition: packet.h:499
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
latm_get_value
static uint32_t latm_get_value(GetBitContext *b)
Definition: aacdec.c:274
IndividualChannelStream::max_sfb
uint8_t max_sfb
number of scalefactor bands per group
Definition: aacdec.h:85
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AV_CODEC_ID_AAC_LATM
@ AV_CODEC_ID_AAC_LATM
Definition: codec_id.h:489
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
read_payload_length_info
static int read_payload_length_info(struct LATMContext *ctx, GetBitContext *gb)
Definition: aacdec.c:429
aac_decode_frame_int
static int aac_decode_frame_int(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, GetBitContext *gb, const AVPacket *avpkt)
Definition: aacdec_template.c:3103
IndividualChannelStream::group_len
uint8_t group_len[8]
Definition: aacdec.h:89
INTFLOAT
float INTFLOAT
Definition: aac_defines.h:88
AOT_AAC_LTP
@ AOT_AAC_LTP
Y Long Term Prediction.
Definition: mpeg4audio.h:76
LATMContext::aac_ctx
AACDecContext aac_ctx
containing AACContext
Definition: aacdec.c:265
MPEG4AudioConfig::sample_rate
int sample_rate
Definition: mpeg4audio.h:32
PredictorState::cor0
AAC_FLOAT cor0
Definition: aac.h:92