36 #define FFT_FIXED_32 0
82 static inline float *
VMUL2(
float *dst,
const float *
v,
unsigned idx,
86 *dst++ = v[idx & 15] *
s;
87 *dst++ = v[idx>>4 & 15] *
s;
93 static inline float *
VMUL4(
float *dst,
const float *
v,
unsigned idx,
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;
106 static inline float *
VMUL2S(
float *dst,
const float *
v,
unsigned idx,
107 unsigned sign,
const float *scale)
111 s0.
f = s1.
f = *scale;
112 s0.
i ^= sign >> 1 << 31;
115 *dst++ = v[idx & 15] * s0.
f;
116 *dst++ = v[idx>>4 & 15] * s1.
f;
123 static inline float *
VMUL4S(
float *dst,
const float *
v,
unsigned idx,
124 unsigned sign,
const float *scale)
126 unsigned nz = idx >> 12;
130 t.
i = s.
i ^ (sign & 1
U<<31);
131 *dst++ = v[idx & 3] * t.
f;
133 sign <<= nz & 1; nz >>= 1;
134 t.
i = s.
i ^ (sign & 1
U<<31);
135 *dst++ = v[idx>>2 & 3] * t.
f;
137 sign <<= nz & 1; nz >>= 1;
138 t.
i = s.
i ^ (sign & 1
U<<31);
139 *dst++ = v[idx>>4 & 3] * t.
f;
142 t.
i = s.
i ^ (sign & 1
U<<31);
143 *dst++ = v[idx>>6 & 3] * t.
f;
153 tmp.
i = (tmp.
i + 0x00008000
U) & 0xFFFF0000U;
161 tmp.
i = (tmp.
i + 0x00007FFF
U + (tmp.
i & 0x00010000
U >> 16)) & 0xFFFF0000
U;
169 pun.
i &= 0xFFFF0000
U;
176 const float a = 0.953125;
177 const float alpha = 0.90625;
181 float r0 = ps->
r0, r1 = ps->
r1;
182 float cor0 = ps->
cor0, cor1 = ps->
cor1;
183 float var0 = ps->
var0, var1 = ps->
var1;
185 k1 = var0 > 1 ? cor0 *
flt16_even(a / var0) : 0;
186 k2 = var1 > 1 ? cor1 *
flt16_even(a / var1) : 0;
215 float *dest = target->
coeffs;
217 int g,
i, group, k, idx = 0;
220 "Dependent coupling is not supported together with LTP\n");
224 for (i = 0; i < ics->
max_sfb; i++, idx++) {
227 for (group = 0; group < ics->
group_len[
g]; group++) {
228 for (k = offsets[i]; k < offsets[i + 1]; k++) {
230 dest[group * 128 + k] += gain * src[group * 128 + k];
252 float *dest = target->
ret;
255 for (i = 0; i <
len; i++)
256 dest[i] += gain * src[i];
261 #define LOAS_SYNC_WORD 0x2b7
287 int sync_extension = 0;
288 int bits_consumed, esize;
296 if (config_start_bit % 8) {
298 "Non-byte-aligned audio-specific config");
304 gb->
buffer + (config_start_bit / 8),
305 asclen, sync_extension);
307 if (bits_consumed < 0)
321 esize = (bits_consumed+7) / 8;
336 return bits_consumed;
342 int ret, audio_mux_version =
get_bits(gb, 1);
345 if (audio_mux_version)
350 if (audio_mux_version)
370 if (!audio_mux_version) {
401 if (audio_mux_version) {
424 int mux_slot_length = 0;
427 mux_slot_length += tmp;
428 }
while (tmp == 255);
429 return mux_slot_length;
450 "no decoder config found\n");
458 }
else if (mux_slot_length_bytes * 8 + 256 <
get_bits_left(gb)) {
460 "frame length mismatch %d << %d\n",
470 int *got_frame_ptr,
AVPacket *avpkt)
485 if (muxlength > avpkt->
size)
509 "ADTS header detected, probably as result of configuration "
static float * VMUL4S(float *dst, const float *v, unsigned idx, unsigned sign, const float *scale)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static void flush(AVCodecContext *avctx)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static void skip_bits_long(GetBitContext *s, int n)
static av_cold int init(AVCodecContext *avctx)
static float * VMUL2S(float *dst, const float *v, unsigned idx, unsigned sign, const float *scale)
INTFLOAT * ret
PCM output.
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
static void apply_independent_coupling(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)
Apply independent channel coupling (applied after IMDCT).
Reference: libavcodec/aacdec.c.
static av_always_inline void predict(PredictorState *ps, float *coef, int output_enable)
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...
N Error Resilient Long Term Prediction.
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
SingleChannelElement ch[2]
N Error Resilient Low Delay.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static av_cold int aac_decode_init(AVCodecContext *avctx)
static int get_bits_count(const GetBitContext *s)
bitstream reader API header.
static int read_stream_mux_config(struct LATMContext *latmctx, GetBitContext *gb)
N Error Resilient Low Complexity.
AACContext aac_ctx
containing AACContext
static uint32_t latm_get_value(GetBitContext *b)
static int get_bits_left(GetBitContext *gb)
float coeffs[1024]
coefficients for IMDCT, maybe processed
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)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int frame_length_type
0/1 variable/fixed frame length
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Spectral Band Replication definitions and structures.
const char * name
Name of the codec implementation.
uint8_t max_sfb
number of scalefactor bands per group
static int latm_decode_frame(AVCodecContext *avctx, void *out, int *got_frame_ptr, AVPacket *avpkt)
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
AVCodec ff_aac_latm_decoder
Libavcodec external API header.
static const uint64_t aac_channel_layout[16]
static int read_payload_length_info(struct LATMContext *ctx, GetBitContext *gb)
AAC Spectral Band Replication function declarations.
static int aac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
int initialized
initialized after a valid extradata was seen
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
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).
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
int frame_length
frame length for fixed frame length
#define AV_LOG_INFO
Standard information.
static const AVProfile profiles[]
AVSampleFormat
Audio sample formats.
int audio_mux_version_A
LATM syntax version.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
main external API structure.
IndividualChannelStream ics
static av_cold int aac_decode_close(AVCodecContext *avctx)
static void skip_bits(GetBitContext *s, int n)
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.
static av_cold int latm_decode_init(AVCodecContext *avctx)
static int read_audio_mux_element(struct LATMContext *latmctx, GetBitContext *gb)
static int latm_decode_audio_specific_config(struct LATMContext *latmctx, GetBitContext *gb, int asclen)
static float * VMUL2(float *dst, const float *v, unsigned idx, const float *scale)
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
N Error Resilient Enhanced Low Delay.
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
static av_always_inline void reset_predict_state(PredictorState *ps)
OutputConfiguration oc[2]
common internal api header.
Single Channel Element - used for both SCE and LFE elements.
Individual Channel Stream.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
channel element - generic struct for SCE/CPE/CCE/LFE
Scalefactors and spectral data are all zero.
enum BandType band_type[128]
band types
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[]
int sbr
-1 implicit, 1 presence
static av_always_inline float flt16_trunc(float pf)
static av_always_inline float flt16_even(float pf)
static const AVClass aac_decoder_class
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static av_always_inline float flt16_round(float pf)
static float * VMUL4(float *dst, const float *v, unsigned idx, const float *scale)