FFmpeg  2.8.17
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules 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 "imdct15.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 "cbrt_tablegen.h"
54 #include "sbr.h"
55 #include "aacsbr.h"
56 #include "mpeg4audio.h"
57 #include "aacadtsdec.h"
58 #include "libavutil/intfloat.h"
59 
60 #include <errno.h>
61 #include <math.h>
62 #include <stdint.h>
63 #include <string.h>
64 
65 #if ARCH_ARM
66 # include "arm/aac.h"
67 #elif ARCH_MIPS
68 # include "mips/aacdec_mips.h"
69 #endif
70 
72 {
73  ps->r0 = 0.0f;
74  ps->r1 = 0.0f;
75  ps->cor0 = 0.0f;
76  ps->cor1 = 0.0f;
77  ps->var0 = 1.0f;
78  ps->var1 = 1.0f;
79 }
80 
81 #ifndef VMUL2
82 static inline float *VMUL2(float *dst, const float *v, unsigned idx,
83  const float *scale)
84 {
85  float s = *scale;
86  *dst++ = v[idx & 15] * s;
87  *dst++ = v[idx>>4 & 15] * s;
88  return dst;
89 }
90 #endif
91 
92 #ifndef VMUL4
93 static inline float *VMUL4(float *dst, const float *v, unsigned idx,
94  const float *scale)
95 {
96  float s = *scale;
97  *dst++ = v[idx & 3] * s;
98  *dst++ = v[idx>>2 & 3] * s;
99  *dst++ = v[idx>>4 & 3] * s;
100  *dst++ = v[idx>>6 & 3] * s;
101  return dst;
102 }
103 #endif
104 
105 #ifndef VMUL2S
106 static inline float *VMUL2S(float *dst, const float *v, unsigned idx,
107  unsigned sign, const float *scale)
108 {
109  union av_intfloat32 s0, s1;
110 
111  s0.f = s1.f = *scale;
112  s0.i ^= sign >> 1 << 31;
113  s1.i ^= sign << 31;
114 
115  *dst++ = v[idx & 15] * s0.f;
116  *dst++ = v[idx>>4 & 15] * s1.f;
117 
118  return dst;
119 }
120 #endif
121 
122 #ifndef VMUL4S
123 static inline float *VMUL4S(float *dst, const float *v, unsigned idx,
124  unsigned sign, const float *scale)
125 {
126  unsigned nz = idx >> 12;
127  union av_intfloat32 s = { .f = *scale };
128  union av_intfloat32 t;
129 
130  t.i = s.i ^ (sign & 1U<<31);
131  *dst++ = v[idx & 3] * t.f;
132 
133  sign <<= nz & 1; nz >>= 1;
134  t.i = s.i ^ (sign & 1U<<31);
135  *dst++ = v[idx>>2 & 3] * t.f;
136 
137  sign <<= nz & 1; nz >>= 1;
138  t.i = s.i ^ (sign & 1U<<31);
139  *dst++ = v[idx>>4 & 3] * t.f;
140 
141  sign <<= nz & 1;
142  t.i = s.i ^ (sign & 1U<<31);
143  *dst++ = v[idx>>6 & 3] * t.f;
144 
145  return dst;
146 }
147 #endif
148 
149 static av_always_inline float flt16_round(float pf)
150 {
151  union av_intfloat32 tmp;
152  tmp.f = pf;
153  tmp.i = (tmp.i + 0x00008000U) & 0xFFFF0000U;
154  return tmp.f;
155 }
156 
157 static av_always_inline float flt16_even(float pf)
158 {
159  union av_intfloat32 tmp;
160  tmp.f = pf;
161  tmp.i = (tmp.i + 0x00007FFFU + (tmp.i & 0x00010000U >> 16)) & 0xFFFF0000U;
162  return tmp.f;
163 }
164 
165 static av_always_inline float flt16_trunc(float pf)
166 {
167  union av_intfloat32 pun;
168  pun.f = pf;
169  pun.i &= 0xFFFF0000U;
170  return pun.f;
171 }
172 
173 static av_always_inline void predict(PredictorState *ps, float *coef,
174  int output_enable)
175 {
176  const float a = 0.953125; // 61.0 / 64
177  const float alpha = 0.90625; // 29.0 / 32
178  float e0, e1;
179  float pv;
180  float k1, k2;
181  float r0 = ps->r0, r1 = ps->r1;
182  float cor0 = ps->cor0, cor1 = ps->cor1;
183  float var0 = ps->var0, var1 = ps->var1;
184 
185  k1 = var0 > 1 ? cor0 * flt16_even(a / var0) : 0;
186  k2 = var1 > 1 ? cor1 * flt16_even(a / var1) : 0;
187 
188  pv = flt16_round(k1 * r0 + k2 * r1);
189  if (output_enable)
190  *coef += pv;
191 
192  e0 = *coef;
193  e1 = e0 - k1 * r0;
194 
195  ps->cor1 = flt16_trunc(alpha * cor1 + r1 * e1);
196  ps->var1 = flt16_trunc(alpha * var1 + 0.5f * (r1 * r1 + e1 * e1));
197  ps->cor0 = flt16_trunc(alpha * cor0 + r0 * e0);
198  ps->var0 = flt16_trunc(alpha * var0 + 0.5f * (r0 * r0 + e0 * e0));
199 
200  ps->r1 = flt16_trunc(a * (r0 - k1 * e0));
201  ps->r0 = flt16_trunc(a * e0);
202 }
203 
204 /**
205  * Apply dependent channel coupling (applied before IMDCT).
206  *
207  * @param index index into coupling gain array
208  */
210  SingleChannelElement *target,
211  ChannelElement *cce, int index)
212 {
213  IndividualChannelStream *ics = &cce->ch[0].ics;
214  const uint16_t *offsets = ics->swb_offset;
215  float *dest = target->coeffs;
216  const float *src = cce->ch[0].coeffs;
217  int g, i, group, k, idx = 0;
218  if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) {
220  "Dependent coupling is not supported together with LTP\n");
221  return;
222  }
223  for (g = 0; g < ics->num_window_groups; g++) {
224  for (i = 0; i < ics->max_sfb; i++, idx++) {
225  if (cce->ch[0].band_type[idx] != ZERO_BT) {
226  const float gain = cce->coup.gain[index][idx];
227  for (group = 0; group < ics->group_len[g]; group++) {
228  for (k = offsets[i]; k < offsets[i + 1]; k++) {
229  // FIXME: SIMDify
230  dest[group * 128 + k] += gain * src[group * 128 + k];
231  }
232  }
233  }
234  }
235  dest += ics->group_len[g] * 128;
236  src += ics->group_len[g] * 128;
237  }
238 }
239 
240 /**
241  * Apply independent channel coupling (applied after IMDCT).
242  *
243  * @param index index into coupling gain array
244  */
246  SingleChannelElement *target,
247  ChannelElement *cce, int index)
248 {
249  int i;
250  const float gain = cce->coup.gain[index][0];
251  const float *src = cce->ch[0].ret;
252  float *dest = target->ret;
253  const int len = 1024 << (ac->oc[1].m4ac.sbr == 1);
254 
255  for (i = 0; i < len; i++)
256  dest[i] += gain * src[i];
257 }
258 
259 #include "aacdec_template.c"
260 
261 #define LOAS_SYNC_WORD 0x2b7 ///< 11 bits LOAS sync word
262 
263 struct LATMContext {
264  AACContext aac_ctx; ///< containing AACContext
265  int initialized; ///< initialized after a valid extradata was seen
266 
267  // parser data
268  int audio_mux_version_A; ///< LATM syntax version
269  int frame_length_type; ///< 0/1 variable/fixed frame length
270  int frame_length; ///< frame length for fixed frame length
271 };
272 
273 static inline uint32_t latm_get_value(GetBitContext *b)
274 {
275  int length = get_bits(b, 2);
276 
277  return get_bits_long(b, (length+1)*8);
278 }
279 
281  GetBitContext *gb, int asclen)
282 {
283  AACContext *ac = &latmctx->aac_ctx;
284  AVCodecContext *avctx = ac->avctx;
285  MPEG4AudioConfig m4ac = { 0 };
286  int config_start_bit = get_bits_count(gb);
287  int sync_extension = 0;
288  int bits_consumed, esize;
289 
290  if (asclen) {
291  sync_extension = 1;
292  asclen = FFMIN(asclen, get_bits_left(gb));
293  } else
294  asclen = get_bits_left(gb);
295 
296  if (config_start_bit % 8) {
298  "Non-byte-aligned audio-specific config");
299  return AVERROR_PATCHWELCOME;
300  }
301  if (asclen <= 0)
302  return AVERROR_INVALIDDATA;
303  bits_consumed = decode_audio_specific_config(NULL, avctx, &m4ac,
304  gb->buffer + (config_start_bit / 8),
305  asclen, sync_extension);
306 
307  if (bits_consumed < 0)
308  return AVERROR_INVALIDDATA;
309 
310  if (!latmctx->initialized ||
311  ac->oc[1].m4ac.sample_rate != m4ac.sample_rate ||
312  ac->oc[1].m4ac.chan_config != m4ac.chan_config) {
313 
314  if(latmctx->initialized) {
315  av_log(avctx, AV_LOG_INFO, "audio config changed\n");
316  } else {
317  av_log(avctx, AV_LOG_DEBUG, "initializing latmctx\n");
318  }
319  latmctx->initialized = 0;
320 
321  esize = (bits_consumed+7) / 8;
322 
323  if (avctx->extradata_size < esize) {
324  av_free(avctx->extradata);
326  if (!avctx->extradata)
327  return AVERROR(ENOMEM);
328  }
329 
330  avctx->extradata_size = esize;
331  memcpy(avctx->extradata, gb->buffer + (config_start_bit/8), esize);
332  memset(avctx->extradata+esize, 0, AV_INPUT_BUFFER_PADDING_SIZE);
333  }
334  skip_bits_long(gb, bits_consumed);
335 
336  return bits_consumed;
337 }
338 
339 static int read_stream_mux_config(struct LATMContext *latmctx,
340  GetBitContext *gb)
341 {
342  int ret, audio_mux_version = get_bits(gb, 1);
343 
344  latmctx->audio_mux_version_A = 0;
345  if (audio_mux_version)
346  latmctx->audio_mux_version_A = get_bits(gb, 1);
347 
348  if (!latmctx->audio_mux_version_A) {
349 
350  if (audio_mux_version)
351  latm_get_value(gb); // taraFullness
352 
353  skip_bits(gb, 1); // allStreamSameTimeFraming
354  skip_bits(gb, 6); // numSubFrames
355  // numPrograms
356  if (get_bits(gb, 4)) { // numPrograms
357  avpriv_request_sample(latmctx->aac_ctx.avctx, "Multiple programs");
358  return AVERROR_PATCHWELCOME;
359  }
360 
361  // for each program (which there is only one in DVB)
362 
363  // for each layer (which there is only one in DVB)
364  if (get_bits(gb, 3)) { // numLayer
365  avpriv_request_sample(latmctx->aac_ctx.avctx, "Multiple layers");
366  return AVERROR_PATCHWELCOME;
367  }
368 
369  // for all but first stream: use_same_config = get_bits(gb, 1);
370  if (!audio_mux_version) {
371  if ((ret = latm_decode_audio_specific_config(latmctx, gb, 0)) < 0)
372  return ret;
373  } else {
374  int ascLen = latm_get_value(gb);
375  if ((ret = latm_decode_audio_specific_config(latmctx, gb, ascLen)) < 0)
376  return ret;
377  ascLen -= ret;
378  skip_bits_long(gb, ascLen);
379  }
380 
381  latmctx->frame_length_type = get_bits(gb, 3);
382  switch (latmctx->frame_length_type) {
383  case 0:
384  skip_bits(gb, 8); // latmBufferFullness
385  break;
386  case 1:
387  latmctx->frame_length = get_bits(gb, 9);
388  break;
389  case 3:
390  case 4:
391  case 5:
392  skip_bits(gb, 6); // CELP frame length table index
393  break;
394  case 6:
395  case 7:
396  skip_bits(gb, 1); // HVXC frame length table index
397  break;
398  }
399 
400  if (get_bits(gb, 1)) { // other data
401  if (audio_mux_version) {
402  latm_get_value(gb); // other_data_bits
403  } else {
404  int esc;
405  do {
406  if (get_bits_left(gb) < 9)
407  return AVERROR_INVALIDDATA;
408  esc = get_bits(gb, 1);
409  skip_bits(gb, 8);
410  } while (esc);
411  }
412  }
413 
414  if (get_bits(gb, 1)) // crc present
415  skip_bits(gb, 8); // config_crc
416  }
417 
418  return 0;
419 }
420 
422 {
423  uint8_t tmp;
424 
425  if (ctx->frame_length_type == 0) {
426  int mux_slot_length = 0;
427  do {
428  if (get_bits_left(gb) < 8)
429  return AVERROR_INVALIDDATA;
430  tmp = get_bits(gb, 8);
431  mux_slot_length += tmp;
432  } while (tmp == 255);
433  return mux_slot_length;
434  } else if (ctx->frame_length_type == 1) {
435  return ctx->frame_length;
436  } else if (ctx->frame_length_type == 3 ||
437  ctx->frame_length_type == 5 ||
438  ctx->frame_length_type == 7) {
439  skip_bits(gb, 2); // mux_slot_length_coded
440  }
441  return 0;
442 }
443 
444 static int read_audio_mux_element(struct LATMContext *latmctx,
445  GetBitContext *gb)
446 {
447  int err;
448  uint8_t use_same_mux = get_bits(gb, 1);
449  if (!use_same_mux) {
450  if ((err = read_stream_mux_config(latmctx, gb)) < 0)
451  return err;
452  } else if (!latmctx->aac_ctx.avctx->extradata) {
453  av_log(latmctx->aac_ctx.avctx, AV_LOG_DEBUG,
454  "no decoder config found\n");
455  return AVERROR(EAGAIN);
456  }
457  if (latmctx->audio_mux_version_A == 0) {
458  int mux_slot_length_bytes = read_payload_length_info(latmctx, gb);
459  if (mux_slot_length_bytes < 0 || mux_slot_length_bytes * 8LL > get_bits_left(gb)) {
460  av_log(latmctx->aac_ctx.avctx, AV_LOG_ERROR, "incomplete frame\n");
461  return AVERROR_INVALIDDATA;
462  } else if (mux_slot_length_bytes * 8 + 256 < get_bits_left(gb)) {
463  av_log(latmctx->aac_ctx.avctx, AV_LOG_ERROR,
464  "frame length mismatch %d << %d\n",
465  mux_slot_length_bytes * 8, get_bits_left(gb));
466  return AVERROR_INVALIDDATA;
467  }
468  }
469  return 0;
470 }
471 
472 
473 static int latm_decode_frame(AVCodecContext *avctx, void *out,
474  int *got_frame_ptr, AVPacket *avpkt)
475 {
476  struct LATMContext *latmctx = avctx->priv_data;
477  int muxlength, err;
478  GetBitContext gb;
479 
480  if ((err = init_get_bits8(&gb, avpkt->data, avpkt->size)) < 0)
481  return err;
482 
483  // check for LOAS sync word
484  if (get_bits(&gb, 11) != LOAS_SYNC_WORD)
485  return AVERROR_INVALIDDATA;
486 
487  muxlength = get_bits(&gb, 13) + 3;
488  // not enough data, the parser should have sorted this out
489  if (muxlength > avpkt->size)
490  return AVERROR_INVALIDDATA;
491 
492  if ((err = read_audio_mux_element(latmctx, &gb)) < 0)
493  return err;
494 
495  if (!latmctx->initialized) {
496  if (!avctx->extradata) {
497  *got_frame_ptr = 0;
498  return avpkt->size;
499  } else {
501  if ((err = decode_audio_specific_config(
502  &latmctx->aac_ctx, avctx, &latmctx->aac_ctx.oc[1].m4ac,
503  avctx->extradata, avctx->extradata_size*8LL, 1)) < 0) {
505  return err;
506  }
507  latmctx->initialized = 1;
508  }
509  }
510 
511  if (show_bits(&gb, 12) == 0xfff) {
512  av_log(latmctx->aac_ctx.avctx, AV_LOG_ERROR,
513  "ADTS header detected, probably as result of configuration "
514  "misparsing\n");
515  return AVERROR_INVALIDDATA;
516  }
517 
518  switch (latmctx->aac_ctx.oc[1].m4ac.object_type) {
519  case AOT_ER_AAC_LC:
520  case AOT_ER_AAC_LTP:
521  case AOT_ER_AAC_LD:
522  case AOT_ER_AAC_ELD:
523  err = aac_decode_er_frame(avctx, out, got_frame_ptr, &gb);
524  break;
525  default:
526  err = aac_decode_frame_int(avctx, out, got_frame_ptr, &gb, avpkt);
527  }
528  if (err < 0)
529  return err;
530 
531  return muxlength;
532 }
533 
535 {
536  struct LATMContext *latmctx = avctx->priv_data;
537  int ret = aac_decode_init(avctx);
538 
539  if (avctx->extradata_size > 0)
540  latmctx->initialized = !ret;
541 
542  return ret;
543 }
544 
546  .name = "aac",
547  .long_name = NULL_IF_CONFIG_SMALL("AAC (Advanced Audio Coding)"),
548  .type = AVMEDIA_TYPE_AUDIO,
549  .id = AV_CODEC_ID_AAC,
550  .priv_data_size = sizeof(AACContext),
552  .close = aac_decode_close,
554  .sample_fmts = (const enum AVSampleFormat[]) {
556  },
558  .channel_layouts = aac_channel_layout,
559  .flush = flush,
560  .priv_class = &aac_decoder_class,
561  .profiles = profiles,
562 };
563 
564 /*
565  Note: This decoder filter is intended to decode LATM streams transferred
566  in MPEG transport streams which only contain one program.
567  To do a more complex LATM demuxing a separate LATM demuxer should be used.
568 */
570  .name = "aac_latm",
571  .long_name = NULL_IF_CONFIG_SMALL("AAC LATM (Advanced Audio Coding LATM syntax)"),
572  .type = AVMEDIA_TYPE_AUDIO,
573  .id = AV_CODEC_ID_AAC_LATM,
574  .priv_data_size = sizeof(struct LATMContext),
575  .init = latm_decode_init,
576  .close = aac_decode_close,
577  .decode = latm_decode_frame,
578  .sample_fmts = (const enum AVSampleFormat[]) {
580  },
582  .channel_layouts = aac_channel_layout,
583  .flush = flush,
584  .profiles = profiles,
585 };
static float * VMUL4S(float *dst, const float *v, unsigned idx, unsigned sign, const float *scale)
Definition: aacdec.c:123
float, planar
Definition: samplefmt.h:70
AAC decoder data.
#define NULL
Definition: coverity.c:32
float v
const char * s
Definition: avisynth_c.h:631
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
static void flush(AVCodecContext *avctx)
AVCodecContext * avctx
Definition: aac.h:290
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:261
static void skip_bits_long(GetBitContext *s, int n)
Definition: get_bits.h:218
const char * g
Definition: vf_curves.c:108
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:106
#define avpriv_request_sample(...)
int size
Definition: avcodec.h:1434
const char * b
Definition: vf_curves.c:109
const uint8_t * buffer
Definition: get_bits.h:56
INTFLOAT * ret
PCM output.
Definition: aac.h:264
AAC decoder.
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition: avcodec.h:916
static void apply_independent_coupling(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)
Apply independent channel coupling (applied after IMDCT).
Definition: aacdec.c:245
Reference: libavcodec/aacdec.c.
static av_always_inline void predict(PredictorState *ps, float *coef, int output_enable)
Definition: aacdec.c:173
AVCodec.
Definition: avcodec.h:3482
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:178
N Error Resilient Long Term Prediction.
Definition: mpeg4audio.h:76
AAC_FLOAT cor0
Definition: aac.h:136
uint8_t
#define av_cold
Definition: attributes.h:74
#define av_malloc(s)
AAC_FLOAT var1
Definition: aac.h:139
AVOptions.
SingleChannelElement ch[2]
Definition: aac.h:279
N Error Resilient Low Delay.
Definition: mpeg4audio.h:80
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:1627
static av_cold int aac_decode_init(AVCodecContext *avctx)
uint8_t * data
Definition: avcodec.h:1433
AAC_FLOAT cor1
Definition: aac.h:137
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:213
bitstream reader API header.
static int read_stream_mux_config(struct LATMContext *latmctx, GetBitContext *gb)
Definition: aacdec.c:339
N Error Resilient Low Complexity.
Definition: mpeg4audio.h:75
#define av_log(a,...)
AACContext aac_ctx
containing AACContext
Definition: aacdec.c:264
static uint32_t latm_get_value(GetBitContext *b)
Definition: aacdec.c:273
#define U(x)
Definition: vp56_arith.h:37
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:594
MPEG4AudioConfig m4ac
Definition: aac.h:124
float coeffs[1024]
coefficients for IMDCT, maybe processed
Definition: aac.h:258
static void pop_output_configuration(AACContext *ac)
Restore the previous output configuration if and only if the current configuration is unlocked...
static double alpha(void *priv, double x, double y)
Definition: vf_geq.c:99
AVCodec ff_aac_decoder
Definition: aacdec.c:545
#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:269
#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:178
#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:3489
uint8_t max_sfb
number of scalefactor bands per group
Definition: aac.h:172
static int latm_decode_frame(AVCodecContext *avctx, void *out, int *got_frame_ptr, AVPacket *avpkt)
Definition: aacdec.c:473
static void push_output_configuration(AACContext *ac)
Save current output configuration if and only if it has been locked.
#define LOAS_SYNC_WORD
11 bits LOAS sync word
Definition: aacdec.c:261
AVCodec ff_aac_latm_decoder
Definition: aacdec.c:569
Libavcodec external API header.
Predictor State.
Definition: aac.h:135
static const uint64_t aac_channel_layout[16]
Definition: aacdectab.h:65
static int read_payload_length_info(struct LATMContext *ctx, GetBitContext *gb)
Definition: aacdec.c:421
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:92
int initialized
initialized after a valid extradata was seen
Definition: aacdec.c:265
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
Definition: get_bits.h:288
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:209
#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:270
#define AV_LOG_INFO
Standard information.
Definition: log.h:187
static const AVProfile profiles[]
AVS_Value src
Definition: avisynth_c.h:482
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:59
int audio_mux_version_A
LATM syntax version.
Definition: aacdec.c:268
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:446
main external API structure.
Definition: avcodec.h:1512
IndividualChannelStream ics
Definition: aac.h:246
int extradata_size
Definition: avcodec.h:1628
uint8_t group_len[8]
Definition: aac.h:176
static av_cold int aac_decode_close(AVCodecContext *avctx)
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:298
static int decode_audio_specific_config(AACContext *ac, AVCodecContext *avctx, MPEG4AudioConfig *m4ac, const uint8_t *data, int64_t bit_size, int sync_extension)
Decode audio specific configuration; reference: table 1.13.
int index
Definition: gxfenc.c:89
static av_cold int latm_decode_init(AVCodecContext *avctx)
Definition: aacdec.c:534
static int read_audio_mux_element(struct LATMContext *latmctx, GetBitContext *gb)
Definition: aacdec.c:444
static int latm_decode_audio_specific_config(struct LATMContext *latmctx, GetBitContext *gb, int asclen)
Definition: aacdec.c:280
static float * VMUL2(float *dst, const float *v, unsigned idx, const float *scale)
Definition: aacdec.c:82
main AAC context
Definition: aac.h:288
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
Definition: get_bits.h:338
ChannelCoupling coup
Definition: aac.h:281
INTFLOAT gain[16][120]
Definition: aac.h:239
N Error Resilient Enhanced Low Delay.
Definition: mpeg4audio.h:96
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
Definition: ccaption_dec.c:521
static av_always_inline void reset_predict_state(PredictorState *ps)
Definition: aacdec.c:71
OutputConfiguration oc[2]
Definition: aac.h:349
common internal api header.
Single Channel Element - used for both SCE and LFE elements.
Definition: aac.h:245
Individual Channel Stream.
Definition: aac.h:171
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
Definition: avcodec.h:636
channel element - generic struct for SCE/CPE/CCE/LFE
Definition: aac.h:270
void * priv_data
Definition: avcodec.h:1554
#define av_free(p)
int len
Scalefactors and spectral data are all zero.
Definition: aac.h:83
Y Long Term Prediction.
Definition: mpeg4audio.h:64
enum BandType band_type[128]
band types
Definition: aac.h:249
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:701
int sbr
-1 implicit, 1 presence
Definition: mpeg4audio.h:34
#define av_always_inline
Definition: attributes.h:37
static av_always_inline float flt16_trunc(float pf)
Definition: aacdec.c:165
static av_always_inline float flt16_even(float pf)
Definition: aacdec.c:157
static const AVClass aac_decoder_class
AAC data declarations.
This structure stores compressed data.
Definition: avcodec.h:1410
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:857
AAC_FLOAT var0
Definition: aac.h:138
static av_always_inline float flt16_round(float pf)
Definition: aacdec.c:149
static float * VMUL4(float *dst, const float *v, unsigned idx, const float *scale)
Definition: aacdec.c:93