62 #define FFT_FIXED_32 1
98 ps->
var0.mant = 0x20000000;
100 ps->
var1.mant = 0x20000000;
104 static const int exp2tab[4] = {
Q31(1.0000000000/2),
Q31(1.1892071150/2),
Q31(1.4142135624/2),
Q31(1.6817928305/2) };
108 dst[0] = (idx & 15) - 4;
109 dst[1] = (idx >> 4 & 15) - 4;
116 dst[0] = (idx & 3) - 1;
117 dst[1] = (idx >> 2 & 3) - 1;
118 dst[2] = (idx >> 4 & 3) - 1;
119 dst[3] = (idx >> 6 & 3) - 1;
124 static inline int *
DEC_UPAIR(
int *dst,
unsigned idx,
unsigned sign)
126 dst[0] = (idx & 15) * (1 - (sign & 0xFFFFFFFE));
127 dst[1] = (idx >> 4 & 15) * (1 - ((sign & 1) << 1));
132 static inline int *
DEC_UQUAD(
int *dst,
unsigned idx,
unsigned sign)
134 unsigned nz = idx >> 12;
136 dst[0] = (idx & 3) * (1 + (((
int)sign >> 31) << 1));
139 dst[1] = (idx >> 2 & 3) * (1 + (((
int)sign >> 31) << 1));
142 dst[2] = (idx >> 4 & 3) * (1 + (((
int)sign >> 31) << 1));
145 dst[3] = (idx >> 6 & 3) * (1 + (((
int)sign >> 31) << 1));
154 for (i=0; i<
len; i++) {
166 int ssign = scale < 0 ? -1 : 1;
171 s = offset - (s >> 2);
175 for (i=0; i<
len; i++) {
176 out = (int)(((int64_t)src[i] *
c) >> 32);
177 dst[i] = ((int)(out+round) >>
s) * ssign;
183 for (i=0; i<
len; i++) {
184 out = (int)((int64_t)((int64_t)src[i] * c + round) >>
s);
185 dst[i] = out * ssign;
192 int ssign = scale < 0 ? -1 : 1;
198 while (band_energy > 0x7fff) {
203 s = 21 + nlz - (s >> 2);
207 for (i=0; i<
len; i++) {
208 out = (int)(((int64_t)coefs[i] *
c) >> 32);
209 coefs[i] = ((int)(out+round) >>
s) * ssign;
215 for (i=0; i<
len; i++) {
216 out = (int)((int64_t)((int64_t)coefs[i] * c + round) >>
s);
217 coefs[i] = out * ssign;
230 tmp.
mant = (tmp.
mant + 0x00200000
U) & 0xFFC00000U;
244 tmp.
mant = (tmp.
mant + 0x001FFFFF
U + (tmp.
mant & 0x00400000
U >> 16)) & 0xFFC00000
U;
277 if (var0.
exp > 1 || (var0.
exp == 1 && var0.
mant > 0x20000000)) {
285 if (var1.exp > 1 || (var1.exp == 1 && var1.mant > 0x20000000)) {
299 *coef += (pv.
mant + (1 << (shift - 1))) >> shift;
341 int *dest = target->
coeffs;
343 int g, i, group, k, idx = 0;
346 "Dependent coupling is not supported together with LTP\n");
350 for (i = 0; i < ics->
max_sfb; i++, idx++) {
357 shift = (-gain-1024) >> 3;
361 shift = (gain-1024) >> 3;
366 round = 1 << (shift - 1);
368 for (group = 0; group < ics->
group_len[
g]; group++) {
369 for (k = offsets[i]; k < offsets[i + 1]; k++) {
370 tmp = (int)(((int64_t)src[group * 128 + k] * c + \
371 (int64_t)0x1000000000) >> 37);
372 dest[group * 128 + k] += (tmp +
round) >> shift;
377 for (group = 0; group < ics->
group_len[
g]; group++) {
378 for (k = offsets[i]; k < offsets[i + 1]; k++) {
379 tmp = (int)(((int64_t)src[group * 128 + k] * c + \
380 (int64_t)0x1000000000) >> 37);
381 dest[group * 128 + k] += tmp <<
shift;
404 int *dest = target->
ret;
408 shift = (gain-1024) >> 3;
411 round = 1 << (shift - 1);
413 for (i = 0; i <
len; i++) {
414 tmp = (int)(((int64_t)src[i] * c + (int64_t)0x1000000000) >> 37);
415 dest[i] += (tmp +
round) >> shift;
419 for (i = 0; i <
len; i++) {
420 tmp = (int)(((int64_t)src[i] * c + (int64_t)0x1000000000) >> 37);
421 dest[i] += tmp <<
shift;
static int shift(int a, int b)
static void flush(AVCodecContext *avctx)
static av_always_inline SoftFloat flt16_round(SoftFloat pf)
static int * DEC_UPAIR(int *dst, unsigned idx, unsigned sign)
static void apply_dependent_coupling_fixed(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)
Apply dependent channel coupling (applied before IMDCT).
static av_cold int init(AVCodecContext *avctx)
static av_const SoftFloat av_div_sf(SoftFloat a, SoftFloat b)
b has to be normalized and not zero.
static int * DEC_SQUAD(int *dst, unsigned idx)
INTFLOAT * ret
PCM output.
static void vector_pow43(int *coefs, int len)
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
static void subband_scale(int *dst, int *src, int scale, int offset, int len)
const uint16_t * swb_offset
table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular wind...
SingleChannelElement ch[2]
static av_cold int aac_decode_init(AVCodecContext *avctx)
static void apply_independent_coupling_fixed(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)
Apply independent channel coupling (applied after IMDCT).
bitstream reader API header.
static av_always_inline void predict(PredictorState *ps, int *coef, int output_enable)
float coeffs[1024]
coefficients for IMDCT, maybe processed
static double alpha(void *priv, double x, double y)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Spectral Band Replication definitions and structures.
const char * name
Name of the codec implementation.
static av_always_inline av_const double round(double x)
uint8_t max_sfb
number of scalefactor bands per group
static av_always_inline void reset_predict_state(PredictorState *ps)
static const uint8_t offset[127][2]
Libavcodec external API header.
static const uint64_t aac_channel_layout[16]
AAC Spectral Band Replication function declarations.
static int aac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
AAC definitions and structures.
static const int cce_scale_fixed[8]
AVSampleFormat
Audio sample formats.
static uint32_t cbrt_tab[1<< 13]
IndividualChannelStream ics
static av_cold int aac_decode_close(AVCodecContext *avctx)
static void noise_scale(int *coefs, int scale, int band_energy, int len)
static av_const SoftFloat av_sub_sf(SoftFloat a, SoftFloat b)
static av_const SoftFloat av_add_sf(SoftFloat a, SoftFloat b)
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
OutputConfiguration oc[2]
common internal api header.
Single Channel Element - used for both SCE and LFE elements.
static av_const SoftFloat av_mul_sf(SoftFloat a, SoftFloat b)
Individual Channel Stream.
channel element - generic struct for SCE/CPE/CCE/LFE
static const int exp2tab[4]
Scalefactors and spectral data are all zero.
static int * DEC_SPAIR(int *dst, unsigned idx)
static av_always_inline SoftFloat flt16_trunc(SoftFloat pf)
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[]
AVCodec ff_aac_fixed_decoder
int sbr
-1 implicit, 1 presence
static av_const SoftFloat av_int2sf(int v, int frac_bits)
Converts a mantisse and exponent to a SoftFloat.
static av_always_inline SoftFloat flt16_even(SoftFloat pf)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int * DEC_UQUAD(int *dst, unsigned idx, unsigned sign)