62 #define FFT_FIXED_32 1 99 ps->
var0.mant = 0x20000000;
101 ps->
var1.mant = 0x20000000;
105 static const int exp2tab[4] = {
Q31(1.0000000000/2),
Q31(1.1892071150/2),
Q31(1.4142135624/2),
Q31(1.6817928305/2) };
109 dst[0] = (idx & 15) - 4;
110 dst[1] = (idx >> 4 & 15) - 4;
117 dst[0] = (idx & 3) - 1;
118 dst[1] = (idx >> 2 & 3) - 1;
119 dst[2] = (idx >> 4 & 3) - 1;
120 dst[3] = (idx >> 6 & 3) - 1;
125 static inline int *
DEC_UPAIR(
int *dst,
unsigned idx,
unsigned sign)
127 dst[0] = (idx & 15) * (1 - (sign & 0xFFFFFFFE));
128 dst[1] = (idx >> 4 & 15) * (1 - ((sign & 1) * 2));
133 static inline int *
DEC_UQUAD(
int *dst,
unsigned idx,
unsigned sign)
135 unsigned nz = idx >> 12;
137 dst[0] = (idx & 3) * (1 + (((
int)sign >> 31) * 2));
140 dst[1] = (idx >> 2 & 3) * (1 + (((
int)sign >> 31) * 2));
143 dst[2] = (idx >> 4 & 3) * (1 + (((
int)sign >> 31) * 2));
146 dst[3] = (idx >> 6 & 3) * (1 + (((
int)sign >> 31) * 2));
155 for (i=0; i<
len; i++) {
167 int ssign = scale < 0 ? -1 : 1;
172 s = offset - (s >> 2);
175 for (i=0; i<
len; i++) {
180 for (i=0; i<
len; i++) {
181 out = (
int)(((int64_t)src[i] *
c) >> 32);
182 dst[i] = ((
int)(out+round) >>
s) * ssign;
184 }
else if (s > -32) {
187 for (i=0; i<
len; i++) {
188 out = (
int)((int64_t)((int64_t)src[i] * c + round) >>
s);
189 dst[i] = out * (unsigned)ssign;
198 int ssign = scale < 0 ? -1 : 1;
204 while (band_energy > 0x7fff) {
209 s = 21 + nlz - (s >> 2);
212 for (i=0; i<
len; i++) {
216 round = s ? 1 << (s-1) : 0;
217 for (i=0; i<
len; i++) {
218 out = (
int)(((int64_t)coefs[i] *
c) >> 32);
219 coefs[i] = ((
int)(out+round) >>
s) * ssign;
225 for (i=0; i<
len; i++) {
226 out = (
int)((int64_t)((int64_t)coefs[i] * c + round) >>
s);
227 coefs[i] = out * ssign;
240 tmp.
mant = (tmp.
mant + 0x00200000
U) & 0xFFC00000U;
254 tmp.
mant = (tmp.
mant + 0x001FFFFF
U + (tmp.
mant & 0x00400000
U >> 16)) & 0xFFC00000
U;
287 if (var0.
exp > 1 || (var0.
exp == 1 && var0.
mant > 0x20000000)) {
295 if (var1.exp > 1 || (var1.exp == 1 && var1.mant > 0x20000000)) {
310 *coef += (unsigned)((pv.
mant + (1 << (shift - 1))) >>
shift);
312 *coef += (unsigned)pv.
mant << -shift;
355 int *dest = target->
coeffs;
357 int g, i, group, k, idx = 0;
360 "Dependent coupling is not supported together with LTP\n");
364 for (i = 0; i < ics->
max_sfb; i++, idx++) {
371 shift = (-gain-1024) >> 3;
375 shift = (gain-1024) >> 3;
380 }
else if (shift < 0) {
382 round = 1 << (shift - 1);
384 for (group = 0; group < ics->
group_len[
g]; group++) {
385 for (k = offsets[i]; k < offsets[i + 1]; k++) {
386 tmp = (
int)(((int64_t)src[group * 128 + k] * c + \
387 (int64_t)0x1000000000) >> 37);
388 dest[group * 128 + k] += (tmp +
round) >> shift;
393 for (group = 0; group < ics->
group_len[
g]; group++) {
394 for (k = offsets[i]; k < offsets[i + 1]; k++) {
395 tmp = (
int)(((int64_t)src[group * 128 + k] * c + \
396 (int64_t)0x1000000000) >> 37);
397 dest[group * 128 + k] += tmp * (1
U <<
shift);
420 unsigned int *dest = target->
ret;
424 shift = (gain-1024) >> 3;
427 }
else if (shift < 0) {
429 round = 1 << (shift - 1);
431 for (i = 0; i <
len; i++) {
432 tmp = (
int)(((int64_t)src[i] * c + (int64_t)0x1000000000) >> 37);
433 dest[i] += (tmp +
round) >> shift;
437 for (i = 0; i <
len; i++) {
438 tmp = (
int)(((int64_t)src[i] * c + (int64_t)0x1000000000) >> 37);
439 dest[i] += tmp * (1 <<
shift);
static int shift(int a, int b)
static float alpha(float a)
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)
const AVProfile ff_aac_profiles[]
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)
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
const uint16_t * swb_offset
table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular wind...
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
SingleChannelElement ch[2]
static av_cold int aac_decode_init(AVCodecContext *avctx)
uint32_t ff_cbrt_tab_fixed[1<< 13]
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)
#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]
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]
Libavcodec external API header.
AVSampleFormat
Audio sample formats.
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)
INTFLOAT coeffs[1024]
coefficients for IMDCT, maybe processed
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
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)