FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 FFT_FLOAT 1
36 #define FFT_FIXED_32 0
37 #define USE_FIXED 0
38 
39 #include "libavutil/float_dsp.h"
40 #include "libavutil/opt.h"
41 #include "avcodec.h"
42 #include "internal.h"
43 #include "get_bits.h"
44 #include "fft.h"
45 #include "mdct15.h"
46 #include "lpc.h"
47 #include "kbdwin.h"
48 #include "sinewin.h"
49 
50 #include "aac.h"
51 #include "aactab.h"
52 #include "aacdectab.h"
53 #include "adts_header.h"
54 #include "cbrt_data.h"
55 #include "sbr.h"
56 #include "aacsbr.h"
57 #include "mpeg4audio.h"
58 #include "profiles.h"
59 #include "libavutil/intfloat.h"
60 
61 #include <errno.h>
62 #include <math.h>
63 #include <stdint.h>
64 #include <string.h>
65 
66 #if ARCH_ARM
67 # include "arm/aac.h"
68 #elif ARCH_MIPS
69 # include "mips/aacdec_mips.h"
70 #endif
71 
73 {
74  ps->r0 = 0.0f;
75  ps->r1 = 0.0f;
76  ps->cor0 = 0.0f;
77  ps->cor1 = 0.0f;
78  ps->var0 = 1.0f;
79  ps->var1 = 1.0f;
80 }
81 
82 #ifndef VMUL2
83 static inline float *VMUL2(float *dst, const float *v, unsigned idx,
84  const float *scale)
85 {
86  float s = *scale;
87  *dst++ = v[idx & 15] * s;
88  *dst++ = v[idx>>4 & 15] * s;
89  return dst;
90 }
91 #endif
92 
93 #ifndef VMUL4
94 static inline float *VMUL4(float *dst, const float *v, unsigned idx,
95  const float *scale)
96 {
97  float s = *scale;
98  *dst++ = v[idx & 3] * s;
99  *dst++ = v[idx>>2 & 3] * s;
100  *dst++ = v[idx>>4 & 3] * s;
101  *dst++ = v[idx>>6 & 3] * s;
102  return dst;
103 }
104 #endif
105 
106 #ifndef VMUL2S
107 static inline float *VMUL2S(float *dst, const float *v, unsigned idx,
108  unsigned sign, const float *scale)
109 {
110  union av_intfloat32 s0, s1;
111 
112  s0.f = s1.f = *scale;
113  s0.i ^= sign >> 1 << 31;
114  s1.i ^= sign << 31;
115 
116  *dst++ = v[idx & 15] * s0.f;
117  *dst++ = v[idx>>4 & 15] * s1.f;
118 
119  return dst;
120 }
121 #endif
122 
123 #ifndef VMUL4S
124 static inline float *VMUL4S(float *dst, const float *v, unsigned idx,
125  unsigned sign, const float *scale)
126 {
127  unsigned nz = idx >> 12;
128  union av_intfloat32 s = { .f = *scale };
129  union av_intfloat32 t;
130 
131  t.i = s.i ^ (sign & 1U<<31);
132  *dst++ = v[idx & 3] * t.f;
133 
134  sign <<= nz & 1; nz >>= 1;
135  t.i = s.i ^ (sign & 1U<<31);
136  *dst++ = v[idx>>2 & 3] * t.f;
137 
138  sign <<= nz & 1; nz >>= 1;
139  t.i = s.i ^ (sign & 1U<<31);
140  *dst++ = v[idx>>4 & 3] * t.f;
141 
142  sign <<= nz & 1;
143  t.i = s.i ^ (sign & 1U<<31);
144  *dst++ = v[idx>>6 & 3] * t.f;
145 
146  return dst;
147 }
148 #endif
149 
150 static av_always_inline float flt16_round(float pf)
151 {
152  union av_intfloat32 tmp;
153  tmp.f = pf;
154  tmp.i = (tmp.i + 0x00008000U) & 0xFFFF0000U;
155  return tmp.f;
156 }
157 
158 static av_always_inline float flt16_even(float pf)
159 {
160  union av_intfloat32 tmp;
161  tmp.f = pf;
162  tmp.i = (tmp.i + 0x00007FFFU + (tmp.i & 0x00010000U >> 16)) & 0xFFFF0000U;
163  return tmp.f;
164 }
165 
166 static av_always_inline float flt16_trunc(float pf)
167 {
168  union av_intfloat32 pun;
169  pun.f = pf;
170  pun.i &= 0xFFFF0000U;
171  return pun.f;
172 }
173 
174 static av_always_inline void predict(PredictorState *ps, float *coef,
175  int output_enable)
176 {
177  const float a = 0.953125; // 61.0 / 64
178  const float alpha = 0.90625; // 29.0 / 32
179  float e0, e1;
180  float pv;
181  float k1, k2;
182  float r0 = ps->r0, r1 = ps->r1;
183  float cor0 = ps->cor0, cor1 = ps->cor1;
184  float var0 = ps->var0, var1 = ps->var1;
185 
186  k1 = var0 > 1 ? cor0 * flt16_even(a / var0) : 0;
187  k2 = var1 > 1 ? cor1 * flt16_even(a / var1) : 0;
188 
189  pv = flt16_round(k1 * r0 + k2 * r1);
190  if (output_enable)
191  *coef += pv;
192 
193  e0 = *coef;
194  e1 = e0 - k1 * r0;
195 
196  ps->cor1 = flt16_trunc(alpha * cor1 + r1 * e1);
197  ps->var1 = flt16_trunc(alpha * var1 + 0.5f * (r1 * r1 + e1 * e1));
198  ps->cor0 = flt16_trunc(alpha * cor0 + r0 * e0);
199  ps->var0 = flt16_trunc(alpha * var0 + 0.5f * (r0 * r0 + e0 * e0));
200 
201  ps->r1 = flt16_trunc(a * (r0 - k1 * e0));
202  ps->r0 = flt16_trunc(a * e0);
203 }
204 
205 /**
206  * Apply dependent channel coupling (applied before IMDCT).
207  *
208  * @param index index into coupling gain array
209  */
211  SingleChannelElement *target,
212  ChannelElement *cce, int index)
213 {
214  IndividualChannelStream *ics = &cce->ch[0].ics;
215  const uint16_t *offsets = ics->swb_offset;
216  float *dest = target->coeffs;
217  const float *src = cce->ch[0].coeffs;
218  int g, i, group, k, idx = 0;
219  if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) {
221  "Dependent coupling is not supported together with LTP\n");
222  return;
223  }
224  for (g = 0; g < ics->num_window_groups; g++) {
225  for (i = 0; i < ics->max_sfb; i++, idx++) {
226  if (cce->ch[0].band_type[idx] != ZERO_BT) {
227  const float gain = cce->coup.gain[index][idx];
228  for (group = 0; group < ics->group_len[g]; group++) {
229  for (k = offsets[i]; k < offsets[i + 1]; k++) {
230  // FIXME: SIMDify
231  dest[group * 128 + k] += gain * src[group * 128 + k];
232  }
233  }
234  }
235  }
236  dest += ics->group_len[g] * 128;
237  src += ics->group_len[g] * 128;
238  }
239 }
240 
241 /**
242  * Apply independent channel coupling (applied after IMDCT).
243  *
244  * @param index index into coupling gain array
245  */
247  SingleChannelElement *target,
248  ChannelElement *cce, int index)
249 {
250  int i;
251  const float gain = cce->coup.gain[index][0];
252  const float *src = cce->ch[0].ret;
253  float *dest = target->ret;
254  const int len = 1024 << (ac->oc[1].m4ac.sbr == 1);
255 
256  for (i = 0; i < len; i++)
257  dest[i] += gain * src[i];
258 }
259 
260 #include "aacdec_template.c"
261 
262 #define LOAS_SYNC_WORD 0x2b7 ///< 11 bits LOAS sync word
263 
264 struct LATMContext {
265  AACContext 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  AACContext *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  esc = get_bits(gb, 1);
415  skip_bits(gb, 8);
416  } while (esc);
417  }
418  }
419 
420  if (get_bits(gb, 1)) // crc present
421  skip_bits(gb, 8); // config_crc
422  }
423 
424  return 0;
425 }
426 
428 {
429  uint8_t tmp;
430 
431  if (ctx->frame_length_type == 0) {
432  int mux_slot_length = 0;
433  do {
434  if (get_bits_left(gb) < 8)
435  return AVERROR_INVALIDDATA;
436  tmp = get_bits(gb, 8);
437  mux_slot_length += tmp;
438  } while (tmp == 255);
439  return mux_slot_length;
440  } else if (ctx->frame_length_type == 1) {
441  return ctx->frame_length;
442  } else if (ctx->frame_length_type == 3 ||
443  ctx->frame_length_type == 5 ||
444  ctx->frame_length_type == 7) {
445  skip_bits(gb, 2); // mux_slot_length_coded
446  }
447  return 0;
448 }
449 
450 static int read_audio_mux_element(struct LATMContext *latmctx,
451  GetBitContext *gb)
452 {
453  int err;
454  uint8_t use_same_mux = get_bits(gb, 1);
455  if (!use_same_mux) {
456  if ((err = read_stream_mux_config(latmctx, gb)) < 0)
457  return err;
458  } else if (!latmctx->aac_ctx.avctx->extradata) {
459  av_log(latmctx->aac_ctx.avctx, AV_LOG_DEBUG,
460  "no decoder config found\n");
461  return 1;
462  }
463  if (latmctx->audio_mux_version_A == 0) {
464  int mux_slot_length_bytes = read_payload_length_info(latmctx, gb);
465  if (mux_slot_length_bytes < 0 || mux_slot_length_bytes * 8LL > get_bits_left(gb)) {
466  av_log(latmctx->aac_ctx.avctx, AV_LOG_ERROR, "incomplete frame\n");
467  return AVERROR_INVALIDDATA;
468  } else if (mux_slot_length_bytes * 8 + 256 < get_bits_left(gb)) {
469  av_log(latmctx->aac_ctx.avctx, AV_LOG_ERROR,
470  "frame length mismatch %d << %d\n",
471  mux_slot_length_bytes * 8, get_bits_left(gb));
472  return AVERROR_INVALIDDATA;
473  }
474  }
475  return 0;
476 }
477 
478 
479 static int latm_decode_frame(AVCodecContext *avctx, void *out,
480  int *got_frame_ptr, AVPacket *avpkt)
481 {
482  struct LATMContext *latmctx = avctx->priv_data;
483  int muxlength, err;
484  GetBitContext gb;
485 
486  if ((err = init_get_bits8(&gb, avpkt->data, avpkt->size)) < 0)
487  return err;
488 
489  // check for LOAS sync word
490  if (get_bits(&gb, 11) != LOAS_SYNC_WORD)
491  return AVERROR_INVALIDDATA;
492 
493  muxlength = get_bits(&gb, 13) + 3;
494  // not enough data, the parser should have sorted this out
495  if (muxlength > avpkt->size)
496  return AVERROR_INVALIDDATA;
497 
498  if ((err = read_audio_mux_element(latmctx, &gb)))
499  return (err < 0) ? err : avpkt->size;
500 
501  if (!latmctx->initialized) {
502  if (!avctx->extradata) {
503  *got_frame_ptr = 0;
504  return avpkt->size;
505  } else {
507  if ((err = decode_audio_specific_config(
508  &latmctx->aac_ctx, avctx, &latmctx->aac_ctx.oc[1].m4ac,
509  avctx->extradata, avctx->extradata_size*8LL, 1)) < 0) {
511  return err;
512  }
513  latmctx->initialized = 1;
514  }
515  }
516 
517  if (show_bits(&gb, 12) == 0xfff) {
518  av_log(latmctx->aac_ctx.avctx, AV_LOG_ERROR,
519  "ADTS header detected, probably as result of configuration "
520  "misparsing\n");
521  return AVERROR_INVALIDDATA;
522  }
523 
524  switch (latmctx->aac_ctx.oc[1].m4ac.object_type) {
525  case AOT_ER_AAC_LC:
526  case AOT_ER_AAC_LTP:
527  case AOT_ER_AAC_LD:
528  case AOT_ER_AAC_ELD:
529  err = aac_decode_er_frame(avctx, out, got_frame_ptr, &gb);
530  break;
531  default:
532  err = aac_decode_frame_int(avctx, out, got_frame_ptr, &gb, avpkt);
533  }
534  if (err < 0)
535  return err;
536 
537  return muxlength;
538 }
539 
541 {
542  struct LATMContext *latmctx = avctx->priv_data;
543  int ret = aac_decode_init(avctx);
544 
545  if (avctx->extradata_size > 0)
546  latmctx->initialized = !ret;
547 
548  return ret;
549 }
550 
552  .name = "aac",
553  .long_name = NULL_IF_CONFIG_SMALL("AAC (Advanced Audio Coding)"),
554  .type = AVMEDIA_TYPE_AUDIO,
555  .id = AV_CODEC_ID_AAC,
556  .priv_data_size = sizeof(AACContext),
558  .close = aac_decode_close,
560  .sample_fmts = (const enum AVSampleFormat[]) {
562  },
564  .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
565  .channel_layouts = aac_channel_layout,
566  .flush = flush,
567  .priv_class = &aac_decoder_class,
569 };
570 
571 /*
572  Note: This decoder filter is intended to decode LATM streams transferred
573  in MPEG transport streams which only contain one program.
574  To do a more complex LATM demuxing a separate LATM demuxer should be used.
575 */
577  .name = "aac_latm",
578  .long_name = NULL_IF_CONFIG_SMALL("AAC LATM (Advanced Audio Coding LATM syntax)"),
579  .type = AVMEDIA_TYPE_AUDIO,
580  .id = AV_CODEC_ID_AAC_LATM,
581  .priv_data_size = sizeof(struct LATMContext),
582  .init = latm_decode_init,
583  .close = aac_decode_close,
584  .decode = latm_decode_frame,
585  .sample_fmts = (const enum AVSampleFormat[]) {
587  },
589  .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
590  .channel_layouts = aac_channel_layout,
591  .flush = flush,
593 };
static float * VMUL4S(float *dst, const float *v, unsigned idx, unsigned sign, const float *scale)
Definition: aacdec.c:124
float, planar
Definition: samplefmt.h:69
AAC decoder data.
#define NULL
Definition: coverity.c:32
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
static void flush(AVCodecContext *avctx)
AVCodecContext * avctx
Definition: aac.h:295
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:381
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
Definition: get_bits.h:293
const char * g
Definition: vf_curves.c:115
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static float * VMUL2S(float *dst, const float *v, unsigned idx, unsigned sign, const float *scale)
Definition: aacdec.c:107
static int decode_audio_specific_config_gb(AACContext *ac, AVCodecContext *avctx, MPEG4AudioConfig *m4ac, GetBitContext *gb, int get_bit_alignment, int sync_extension)
Decode audio specific configuration; reference: table 1.13.
const AVProfile ff_aac_profiles[]
Definition: profiles.c:26
int size
Definition: avcodec.h:1446
const char * b
Definition: vf_curves.c:116
const uint8_t * buffer
Definition: get_bits.h:62
INTFLOAT * ret
PCM output.
Definition: aac.h:269
AAC decoder.
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition: avcodec.h:1020
static void apply_independent_coupling(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)
Apply independent channel coupling (applied after IMDCT).
Definition: aacdec.c:246
Reference: libavcodec/aacdec.c.
static av_always_inline void predict(PredictorState *ps, float *coef, int output_enable)
Definition: aacdec.c:174
#define src
Definition: vp8dsp.c:254
AVCodec.
Definition: avcodec.h:3424
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:42
static int aac_decode_er_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, GetBitContext *gb)
const uint16_t * swb_offset
table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular wind...
Definition: aac.h:181
N Error Resilient Long Term Prediction.
Definition: mpeg4audio.h:90
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: internal.h:40
AAC_FLOAT cor0
Definition: aac.h:136
uint8_t
#define av_cold
Definition: attributes.h:82
#define av_malloc(s)
AAC_FLOAT var1
Definition: aac.h:139
AVOptions.
SingleChannelElement ch[2]
Definition: aac.h:284
#define f(width, name)
Definition: cbs_vp9.c:255
N Error Resilient Low Delay.
Definition: mpeg4audio.h:94
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:1634
static av_cold int aac_decode_init(AVCodecContext *avctx)
uint8_t * data
Definition: avcodec.h:1445
AAC_FLOAT cor1
Definition: aac.h:137
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:219
bitstream reader API header.
static int read_stream_mux_config(struct LATMContext *latmctx, GetBitContext *gb)
Definition: aacdec.c:349
N Error Resilient Low Complexity.
Definition: mpeg4audio.h:89
#define av_log(a,...)
AACContext aac_ctx
containing AACContext
Definition: aacdec.c:265
static uint32_t latm_get_value(GetBitContext *b)
Definition: aacdec.c:274
#define U(x)
Definition: vp56_arith.h:37
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:814
MPEG4AudioConfig m4ac
Definition: aac.h:124
static void pop_output_configuration(AACContext *ac)
Restore the previous output configuration if and only if the current configuration is unlocked...
AVCodec ff_aac_decoder
Definition: aacdec.c:551
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
AAC_FLOAT r1
Definition: aac.h:141
#define AVERROR(e)
Definition: error.h:43
int frame_length_type
0/1 variable/fixed frame length
Definition: aacdec.c:270
#define pv
Definition: regdef.h:60
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
AAC_FLOAT r0
Definition: aac.h:140
Spectral Band Replication definitions and structures.
GLsizei GLsizei * length
Definition: opengl_enc.c:115
const char * name
Name of the codec implementation.
Definition: avcodec.h:3431
uint8_t max_sfb
number of scalefactor bands per group
Definition: aac.h:175
static int latm_decode_frame(AVCodecContext *avctx, void *out, int *got_frame_ptr, AVPacket *avpkt)
Definition: aacdec.c:479
#define LOAS_SYNC_WORD
11 bits LOAS sync word
Definition: aacdec.c:262
AVCodec ff_aac_latm_decoder
Definition: aacdec.c:576
Predictor State.
Definition: aac.h:135
static const uint64_t aac_channel_layout[16]
Definition: aacdectab.h:57
static int read_payload_length_info(struct LATMContext *ctx, GetBitContext *gb)
Definition: aacdec.c:427
AAC Spectral Band Replication function declarations.
static int aac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
#define FFMIN(a, b)
Definition: common.h:96
int initialized
initialized after a valid extradata was seen
Definition: aacdec.c:266
AVFormatContext * ctx
Definition: movenc.c:48
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
Definition: get_bits.h:443
#define s(width, name)
Definition: cbs_vp9.c:257
uint32_t i
Definition: intfloat.h:28
AAC definitions and structures.
static int aac_decode_frame_int(AVCodecContext *avctx, void *data, int *got_frame_ptr, GetBitContext *gb, AVPacket *avpkt)
static void apply_dependent_coupling(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)
Apply dependent channel coupling (applied before IMDCT).
Definition: aacdec.c:210
static int push_output_configuration(AACContext *ac)
Save current output configuration if and only if it has been locked.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:62
int frame_length
frame length for fixed frame length
Definition: aacdec.c:271
#define AV_LOG_INFO
Standard information.
Definition: log.h:187
Libavcodec external API header.
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
int audio_mux_version_A
LATM syntax version.
Definition: aacdec.c:269
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:650
static const int16_t alpha[]
Definition: ilbcdata.h:55
main external API structure.
Definition: avcodec.h:1533
IndividualChannelStream ics
Definition: aac.h:249
int extradata_size
Definition: avcodec.h:1635
uint8_t group_len[8]
Definition: aac.h:179
static av_cold int aac_decode_close(AVCodecContext *avctx)
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:460
static int decode_audio_specific_config(AACContext *ac, AVCodecContext *avctx, MPEG4AudioConfig *m4ac, const uint8_t *data, int64_t bit_size, int sync_extension)
int index
Definition: gxfenc.c:89
static av_cold int latm_decode_init(AVCodecContext *avctx)
Definition: aacdec.c:540
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
Definition: get_bits.h:615
static int read_audio_mux_element(struct LATMContext *latmctx, GetBitContext *gb)
Definition: aacdec.c:450
static int latm_decode_audio_specific_config(struct LATMContext *latmctx, GetBitContext *gb, int asclen)
Definition: aacdec.c:281
static float * VMUL2(float *dst, const float *v, unsigned idx, const float *scale)
Definition: aacdec.c:83
main AAC context
Definition: aac.h:293
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
Definition: get_bits.h:531
ChannelCoupling coup
Definition: aac.h:286
INTFLOAT coeffs[1024]
coefficients for IMDCT, maybe processed
Definition: aac.h:262
INTFLOAT gain[16][120]
Definition: aac.h:242
N Error Resilient Enhanced Low Delay.
Definition: mpeg4audio.h:110
static av_always_inline void reset_predict_state(PredictorState *ps)
Definition: aacdec.c:72
OutputConfiguration oc[2]
Definition: aac.h:356
common internal api header.
Single Channel Element - used for both SCE and LFE elements.
Definition: aac.h:248
Individual Channel Stream.
Definition: aac.h:174
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
Definition: avcodec.h:782
channel element - generic struct for SCE/CPE/CCE/LFE
Definition: aac.h:275
void * priv_data
Definition: avcodec.h:1560
#define av_free(p)
int len
Scalefactors and spectral data are all zero.
Definition: aac.h:83
Y Long Term Prediction.
Definition: mpeg4audio.h:78
enum BandType band_type[128]
band types
Definition: aac.h:252
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:701
FILE * out
Definition: movenc.c:54
int sbr
-1 implicit, 1 presence
Definition: mpeg4audio.h:38
#define av_always_inline
Definition: attributes.h:39
static av_always_inline float flt16_trunc(float pf)
Definition: aacdec.c:166
static av_always_inline float flt16_even(float pf)
Definition: aacdec.c:158
static const AVClass aac_decoder_class
AAC data declarations.
This structure stores compressed data.
Definition: avcodec.h:1422
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:968
AAC_FLOAT var0
Definition: aac.h:138
static av_always_inline float flt16_round(float pf)
Definition: aacdec.c:150
static float * VMUL4(float *dst, const float *v, unsigned idx, const float *scale)
Definition: aacdec.c:94
static uint8_t tmp[11]
Definition: aes_ctr.c:26