FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
aacdec_fixed.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013
3  * MIPS Technologies, Inc., California.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * AAC decoder fixed-point implementation
30  *
31  * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org )
32  * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com )
33  *
34  * This file is part of FFmpeg.
35  *
36  * FFmpeg is free software; you can redistribute it and/or
37  * modify it under the terms of the GNU Lesser General Public
38  * License as published by the Free Software Foundation; either
39  * version 2.1 of the License, or (at your option) any later version.
40  *
41  * FFmpeg is distributed in the hope that it will be useful,
42  * but WITHOUT ANY WARRANTY; without even the implied warranty of
43  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
44  * Lesser General Public License for more details.
45  *
46  * You should have received a copy of the GNU Lesser General Public
47  * License along with FFmpeg; if not, write to the Free Software
48  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
49  */
50 
51 /**
52  * @file
53  * AAC decoder
54  * @author Oded Shimon ( ods15 ods15 dyndns org )
55  * @author Maxim Gavrilov ( maxim.gavrilov gmail com )
56  *
57  * Fixed point implementation
58  * @author Stanislav Ocovaj ( stanislav.ocovaj imgtec com )
59  */
60 
61 #define FFT_FLOAT 0
62 #define FFT_FIXED_32 1
63 #define USE_FIXED 1
64 
65 #include "libavutil/fixed_dsp.h"
66 #include "libavutil/opt.h"
67 #include "avcodec.h"
68 #include "internal.h"
69 #include "get_bits.h"
70 #include "fft.h"
71 #include "lpc.h"
72 #include "kbdwin.h"
73 #include "sinewin.h"
74 
75 #include "aac.h"
76 #include "aactab.h"
77 #include "aacdectab.h"
78 #include "cbrt_tablegen.h"
79 #include "sbr.h"
80 #include "aacsbr.h"
81 #include "mpeg4audio.h"
82 #include "aacadtsdec.h"
83 #include "libavutil/intfloat.h"
84 
85 #include <math.h>
86 #include <string.h>
87 
89 {
90  ps->r0.mant = 0;
91  ps->r0.exp = 0;
92  ps->r1.mant = 0;
93  ps->r1.exp = 0;
94  ps->cor0.mant = 0;
95  ps->cor0.exp = 0;
96  ps->cor1.mant = 0;
97  ps->cor1.exp = 0;
98  ps->var0.mant = 0x20000000;
99  ps->var0.exp = 1;
100  ps->var1.mant = 0x20000000;
101  ps->var1.exp = 1;
102 }
103 
104 static const int exp2tab[4] = { Q31(1.0000000000/2), Q31(1.1892071150/2), Q31(1.4142135624/2), Q31(1.6817928305/2) }; // 2^0, 2^0.25, 2^0.5, 2^0.75
105 
106 static inline int *DEC_SPAIR(int *dst, unsigned idx)
107 {
108  dst[0] = (idx & 15) - 4;
109  dst[1] = (idx >> 4 & 15) - 4;
110 
111  return dst + 2;
112 }
113 
114 static inline int *DEC_SQUAD(int *dst, unsigned idx)
115 {
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;
120 
121  return dst + 4;
122 }
123 
124 static inline int *DEC_UPAIR(int *dst, unsigned idx, unsigned sign)
125 {
126  dst[0] = (idx & 15) * (1 - (sign & 0xFFFFFFFE));
127  dst[1] = (idx >> 4 & 15) * (1 - ((sign & 1) << 1));
128 
129  return dst + 2;
130 }
131 
132 static inline int *DEC_UQUAD(int *dst, unsigned idx, unsigned sign)
133 {
134  unsigned nz = idx >> 12;
135 
136  dst[0] = (idx & 3) * (1 + (((int)sign >> 31) << 1));
137  sign <<= nz & 1;
138  nz >>= 1;
139  dst[1] = (idx >> 2 & 3) * (1 + (((int)sign >> 31) << 1));
140  sign <<= nz & 1;
141  nz >>= 1;
142  dst[2] = (idx >> 4 & 3) * (1 + (((int)sign >> 31) << 1));
143  sign <<= nz & 1;
144  nz >>= 1;
145  dst[3] = (idx >> 6 & 3) * (1 + (((int)sign >> 31) << 1));
146 
147  return dst + 4;
148 }
149 
150 static void vector_pow43(int *coefs, int len)
151 {
152  int i, coef;
153 
154  for (i=0; i<len; i++) {
155  coef = coefs[i];
156  if (coef < 0)
157  coef = -(int)cbrt_tab[-coef];
158  else
159  coef = (int)cbrt_tab[coef];
160  coefs[i] = coef;
161  }
162 }
163 
164 static void subband_scale(int *dst, int *src, int scale, int offset, int len)
165 {
166  int ssign = scale < 0 ? -1 : 1;
167  int s = FFABS(scale);
168  unsigned int round;
169  int i, out, c = exp2tab[s & 3];
170 
171  s = offset - (s >> 2);
172 
173  if (s > 0) {
174  round = 1 << (s-1);
175  for (i=0; i<len; i++) {
176  out = (int)(((int64_t)src[i] * c) >> 32);
177  dst[i] = ((int)(out+round) >> s) * ssign;
178  }
179  }
180  else {
181  s = s + 32;
182  round = 1 << (s-1);
183  for (i=0; i<len; i++) {
184  out = (int)((int64_t)((int64_t)src[i] * c + round) >> s);
185  dst[i] = out * ssign;
186  }
187  }
188 }
189 
190 static void noise_scale(int *coefs, int scale, int band_energy, int len)
191 {
192  int ssign = scale < 0 ? -1 : 1;
193  int s = FFABS(scale);
194  unsigned int round;
195  int i, out, c = exp2tab[s & 3];
196  int nlz = 0;
197 
198  while (band_energy > 0x7fff) {
199  band_energy >>= 1;
200  nlz++;
201  }
202  c /= band_energy;
203  s = 21 + nlz - (s >> 2);
204 
205  if (s > 0) {
206  round = 1 << (s-1);
207  for (i=0; i<len; i++) {
208  out = (int)(((int64_t)coefs[i] * c) >> 32);
209  coefs[i] = ((int)(out+round) >> s) * ssign;
210  }
211  }
212  else {
213  s = s + 32;
214  round = 1 << (s-1);
215  for (i=0; i<len; i++) {
216  out = (int)((int64_t)((int64_t)coefs[i] * c + round) >> s);
217  coefs[i] = out * ssign;
218  }
219  }
220 }
221 
223 {
224  SoftFloat tmp;
225  int s;
226 
227  tmp.exp = pf.exp;
228  s = pf.mant >> 31;
229  tmp.mant = (pf.mant ^ s) - s;
230  tmp.mant = (tmp.mant + 0x00200000U) & 0xFFC00000U;
231  tmp.mant = (tmp.mant ^ s) - s;
232 
233  return tmp;
234 }
235 
237 {
238  SoftFloat tmp;
239  int s;
240 
241  tmp.exp = pf.exp;
242  s = pf.mant >> 31;
243  tmp.mant = (pf.mant ^ s) - s;
244  tmp.mant = (tmp.mant + 0x001FFFFFU + (tmp.mant & 0x00400000U >> 16)) & 0xFFC00000U;
245  tmp.mant = (tmp.mant ^ s) - s;
246 
247  return tmp;
248 }
249 
251 {
252  SoftFloat pun;
253  int s;
254 
255  pun.exp = pf.exp;
256  s = pf.mant >> 31;
257  pun.mant = (pf.mant ^ s) - s;
258  pun.mant = pun.mant & 0xFFC00000U;
259  pun.mant = (pun.mant ^ s) - s;
260 
261  return pun;
262 }
263 
264 static av_always_inline void predict(PredictorState *ps, int *coef,
265  int output_enable)
266 {
267  const SoftFloat a = { 1023410176, 0 }; // 61.0 / 64
268  const SoftFloat alpha = { 973078528, 0 }; // 29.0 / 32
269  SoftFloat e0, e1;
270  SoftFloat pv;
271  SoftFloat k1, k2;
272  SoftFloat r0 = ps->r0, r1 = ps->r1;
273  SoftFloat cor0 = ps->cor0, cor1 = ps->cor1;
274  SoftFloat var0 = ps->var0, var1 = ps->var1;
275  SoftFloat tmp;
276 
277  if (var0.exp > 1 || (var0.exp == 1 && var0.mant > 0x20000000)) {
278  k1 = av_mul_sf(cor0, flt16_even(av_div_sf(a, var0)));
279  }
280  else {
281  k1.mant = 0;
282  k1.exp = 0;
283  }
284 
285  if (var1.exp > 1 || (var1.exp == 1 && var1.mant > 0x20000000)) {
286  k2 = av_mul_sf(cor1, flt16_even(av_div_sf(a, var1)));
287  }
288  else {
289  k2.mant = 0;
290  k2.exp = 0;
291  }
292 
293  tmp = av_mul_sf(k1, r0);
294  pv = flt16_round(av_add_sf(tmp, av_mul_sf(k2, r1)));
295  if (output_enable) {
296  int shift = 28 - pv.exp;
297 
298  if (shift < 31)
299  *coef += (pv.mant + (1 << (shift - 1))) >> shift;
300  }
301 
302  e0 = av_int2sf(*coef, 2);
303  e1 = av_sub_sf(e0, tmp);
304 
305  ps->cor1 = flt16_trunc(av_add_sf(av_mul_sf(alpha, cor1), av_mul_sf(r1, e1)));
306  tmp = av_add_sf(av_mul_sf(r1, r1), av_mul_sf(e1, e1));
307  tmp.exp--;
308  ps->var1 = flt16_trunc(av_add_sf(av_mul_sf(alpha, var1), tmp));
309  ps->cor0 = flt16_trunc(av_add_sf(av_mul_sf(alpha, cor0), av_mul_sf(r0, e0)));
310  tmp = av_add_sf(av_mul_sf(r0, r0), av_mul_sf(e0, e0));
311  tmp.exp--;
312  ps->var0 = flt16_trunc(av_add_sf(av_mul_sf(alpha, var0), tmp));
313 
314  ps->r1 = flt16_trunc(av_mul_sf(a, av_sub_sf(r0, av_mul_sf(k1, e0))));
315  ps->r0 = flt16_trunc(av_mul_sf(a, e0));
316 }
317 
318 
319 static const int cce_scale_fixed[8] = {
320  Q30(1.0), //2^(0/8)
321  Q30(1.0905077327), //2^(1/8)
322  Q30(1.1892071150), //2^(2/8)
323  Q30(1.2968395547), //2^(3/8)
324  Q30(1.4142135624), //2^(4/8)
325  Q30(1.5422108254), //2^(5/8)
326  Q30(1.6817928305), //2^(6/8)
327  Q30(1.8340080864), //2^(7/8)
328 };
329 
330 /**
331  * Apply dependent channel coupling (applied before IMDCT).
332  *
333  * @param index index into coupling gain array
334  */
336  SingleChannelElement *target,
337  ChannelElement *cce, int index)
338 {
339  IndividualChannelStream *ics = &cce->ch[0].ics;
340  const uint16_t *offsets = ics->swb_offset;
341  int *dest = target->coeffs;
342  const int *src = cce->ch[0].coeffs;
343  int g, i, group, k, idx = 0;
344  if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) {
346  "Dependent coupling is not supported together with LTP\n");
347  return;
348  }
349  for (g = 0; g < ics->num_window_groups; g++) {
350  for (i = 0; i < ics->max_sfb; i++, idx++) {
351  if (cce->ch[0].band_type[idx] != ZERO_BT) {
352  const int gain = cce->coup.gain[index][idx];
353  int shift, round, c, tmp;
354 
355  if (gain < 0) {
356  c = -cce_scale_fixed[-gain & 7];
357  shift = (-gain-1024) >> 3;
358  }
359  else {
360  c = cce_scale_fixed[gain & 7];
361  shift = (gain-1024) >> 3;
362  }
363 
364  if (shift < 0) {
365  shift = -shift;
366  round = 1 << (shift - 1);
367 
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;
373  }
374  }
375  }
376  else {
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;
382  }
383  }
384  }
385  }
386  }
387  dest += ics->group_len[g] * 128;
388  src += ics->group_len[g] * 128;
389  }
390 }
391 
392 /**
393  * Apply independent channel coupling (applied after IMDCT).
394  *
395  * @param index index into coupling gain array
396  */
398  SingleChannelElement *target,
399  ChannelElement *cce, int index)
400 {
401  int i, c, shift, round, tmp;
402  const int gain = cce->coup.gain[index][0];
403  const int *src = cce->ch[0].ret;
404  int *dest = target->ret;
405  const int len = 1024 << (ac->oc[1].m4ac.sbr == 1);
406 
407  c = cce_scale_fixed[gain & 7];
408  shift = (gain-1024) >> 3;
409  if (shift < 0) {
410  shift = -shift;
411  round = 1 << (shift - 1);
412 
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;
416  }
417  }
418  else {
419  for (i = 0; i < len; i++) {
420  tmp = (int)(((int64_t)src[i] * c + (int64_t)0x1000000000) >> 37);
421  dest[i] += tmp << shift;
422  }
423  }
424 }
425 
426 #include "aacdec_template.c"
427 
429  .name = "aac_fixed",
430  .long_name = NULL_IF_CONFIG_SMALL("AAC (Advanced Audio Coding)"),
431  .type = AVMEDIA_TYPE_AUDIO,
432  .id = AV_CODEC_ID_AAC,
433  .priv_data_size = sizeof(AACContext),
435  .close = aac_decode_close,
437  .sample_fmts = (const enum AVSampleFormat[]) {
439  },
441  .channel_layouts = aac_channel_layout,
442  .flush = flush,
443 };
AAC decoder data.
const char * s
Definition: avisynth_c.h:631
static int shift(int a, int b)
Definition: sonic.c:82
static void flush(AVCodecContext *avctx)
AVCodecContext * avctx
Definition: aac.h:290
static av_always_inline SoftFloat flt16_round(SoftFloat pf)
Definition: aacdec_fixed.c:222
static int * DEC_UPAIR(int *dst, unsigned idx, unsigned sign)
Definition: aacdec_fixed.c:124
static void apply_dependent_coupling_fixed(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)
Apply dependent channel coupling (applied before IMDCT).
Definition: aacdec_fixed.c:335
const char * g
Definition: vf_curves.c:108
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static av_const SoftFloat av_div_sf(SoftFloat a, SoftFloat b)
b has to be normalized and not zero.
Definition: softfloat.h:108
static int * DEC_SQUAD(int *dst, unsigned idx)
Definition: aacdec_fixed.c:114
INTFLOAT * ret
PCM output.
Definition: aac.h:264
AAC decoder.
static void vector_pow43(int *coefs, int len)
Definition: aacdec_fixed.c:150
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition: avcodec.h:916
static void subband_scale(int *dst, int *src, int scale, int offset, int len)
Definition: aacdec_fixed.c:164
AVCodec.
Definition: avcodec.h:3472
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
AAC_FLOAT cor0
Definition: aac.h:136
#define Q30(x)
Definition: aac_defines.h:93
AAC_FLOAT var1
Definition: aac.h:139
AVOptions.
SingleChannelElement ch[2]
Definition: aac.h:279
static av_cold int aac_decode_init(AVCodecContext *avctx)
AAC_FLOAT cor1
Definition: aac.h:137
static void apply_independent_coupling_fixed(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index)
Apply independent channel coupling (applied after IMDCT).
Definition: aacdec_fixed.c:397
bitstream reader API header.
int32_t mant
Definition: softfloat.h:35
static av_always_inline void predict(PredictorState *ps, int *coef, int output_enable)
Definition: aacdec_fixed.c:264
#define av_log(a,...)
#define U(x)
Definition: vp56_arith.h:37
MPEG4AudioConfig m4ac
Definition: aac.h:124
float coeffs[1024]
coefficients for IMDCT, maybe processed
Definition: aac.h:258
static double alpha(void *priv, double x, double y)
Definition: vf_geq.c:99
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
AAC_FLOAT r1
Definition: aac.h:141
#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:175
AAC_FLOAT r0
Definition: aac.h:140
Spectral Band Replication definitions and structures.
const char * name
Name of the codec implementation.
Definition: avcodec.h:3479
static av_always_inline av_const double round(double x)
Definition: libm.h:162
uint8_t max_sfb
number of scalefactor bands per group
Definition: aac.h:172
static av_always_inline void reset_predict_state(PredictorState *ps)
Definition: aacdec_fixed.c:88
static const uint8_t offset[127][2]
Definition: vf_spp.c:92
Libavcodec external API header.
Predictor State.
Definition: aac.h:135
static const uint64_t aac_channel_layout[16]
Definition: aacdectab.h:65
#define Q31(x)
Definition: aac_defines.h:94
AAC Spectral Band Replication function declarations.
static int aac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
signed 32 bits, planar
Definition: samplefmt.h:69
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:68
AAC definitions and structures.
static const int cce_scale_fixed[8]
Definition: aacdec_fixed.c:319
AVS_Value src
Definition: avisynth_c.h:482
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:59
static uint32_t cbrt_tab[1<< 13]
Definition: cbrt_tablegen.h:46
IndividualChannelStream ics
Definition: aac.h:246
uint8_t group_len[8]
Definition: aac.h:176
static av_cold int aac_decode_close(AVCodecContext *avctx)
int index
Definition: gxfenc.c:89
static void noise_scale(int *coefs, int scale, int band_energy, int len)
Definition: aacdec_fixed.c:190
main AAC context
Definition: aac.h:288
static av_const SoftFloat av_sub_sf(SoftFloat a, SoftFloat b)
Definition: softfloat.h:135
ChannelCoupling coup
Definition: aac.h:281
static av_const SoftFloat av_add_sf(SoftFloat a, SoftFloat b)
Definition: softfloat.h:127
INTFLOAT gain[16][120]
Definition: aac.h:239
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
Definition: ccaption_dec.c:523
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
static av_const SoftFloat av_mul_sf(SoftFloat a, SoftFloat b)
Definition: softfloat.h:97
static double c[64]
Individual Channel Stream.
Definition: aac.h:171
int32_t exp
Definition: softfloat.h:36
channel element - generic struct for SCE/CPE/CCE/LFE
Definition: aac.h:270
static const int exp2tab[4]
Definition: aacdec_fixed.c:104
int len
Scalefactors and spectral data are all zero.
Definition: aac.h:83
static int * DEC_SPAIR(int *dst, unsigned idx)
Definition: aacdec_fixed.c:106
Y Long Term Prediction.
Definition: mpeg4audio.h:64
static av_always_inline SoftFloat flt16_trunc(SoftFloat pf)
Definition: aacdec_fixed.c:250
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
AVCodec ff_aac_fixed_decoder
Definition: aacdec_fixed.c:428
int sbr
-1 implicit, 1 presence
Definition: mpeg4audio.h:34
static av_const SoftFloat av_int2sf(int v, int frac_bits)
Converts a mantisse and exponent to a SoftFloat.
Definition: softfloat.h:145
#define av_always_inline
Definition: attributes.h:37
static av_always_inline SoftFloat flt16_even(SoftFloat pf)
Definition: aacdec_fixed.c:236
AAC data declarations.
#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 int * DEC_UQUAD(int *dst, unsigned idx, unsigned sign)
Definition: aacdec_fixed.c:132