Add fixed point implementation.
Signed-off-by: Nedeljko Babic <nedeljko.babic@imgtec.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
... | ... |
@@ -123,12 +123,12 @@ OBJS-$(CONFIG_WMV2DSP) += wmv2dsp.o |
123 | 123 |
OBJS-$(CONFIG_ZERO12V_DECODER) += 012v.o |
124 | 124 |
OBJS-$(CONFIG_A64MULTI_ENCODER) += a64multienc.o elbg.o |
125 | 125 |
OBJS-$(CONFIG_A64MULTI5_ENCODER) += a64multienc.o elbg.o |
126 |
-OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps.o \ |
|
126 |
+OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps_float.o \ |
|
127 | 127 |
aacadtsdec.o mpeg4audio.o kbdwin.o \ |
128 |
- sbrdsp.o aacpsdsp.o |
|
129 |
-OBJS-$(CONFIG_AAC_FIXED_DECODER) += aacdec_fixed.o aactab.o aacsbr_fixed.o \ |
|
128 |
+ sbrdsp.o aacpsdsp_float.o |
|
129 |
+OBJS-$(CONFIG_AAC_FIXED_DECODER) += aacdec_fixed.o aactab.o aacsbr_fixed.o aacps_fixed.o \ |
|
130 | 130 |
aacadtsdec.o mpeg4audio.o kbdwin.o \ |
131 |
- sbrdsp_fixed.o |
|
131 |
+ sbrdsp_fixed.o aacpsdsp_fixed.o |
|
132 | 132 |
OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o \ |
133 | 133 |
aacpsy.o aactab.o \ |
134 | 134 |
psymodel.o mpeg4audio.o kbdwin.o |
... | ... |
@@ -932,6 +932,7 @@ TOOLS = fourcc2pixfmt |
932 | 932 |
|
933 | 933 |
HOSTPROGS = aac_tablegen \ |
934 | 934 |
aacps_tablegen \ |
935 |
+ aacps_fixed_tablegen \ |
|
935 | 936 |
aacsbr_tablegen \ |
936 | 937 |
aacsbr_fixed_tablegen \ |
937 | 938 |
cabac_tablegen \ |
... | ... |
@@ -964,7 +965,7 @@ else |
964 | 964 |
$(SUBDIR)%_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DCONFIG_SMALL=0 |
965 | 965 |
endif |
966 | 966 |
|
967 |
-GEN_HEADERS = cabac_tables.h cbrt_tables.h cbrt_fixed_tables.h aacps_tables.h aacsbr_tables.h \ |
|
967 |
+GEN_HEADERS = cabac_tables.h cbrt_tables.h cbrt_fixed_tables.h aacps_tables.h aacps_fixed_tables.h aacsbr_tables.h \ |
|
968 | 968 |
aacsbr_fixed_tables.h aac_tables.h dsd_tables.h dv_tables.h \ |
969 | 969 |
sinewin_tables.h sinewin_fixed_tables.h mpegaudio_tables.h motionpixels_tables.h \ |
970 | 970 |
pcm_tables.h qdm2_tables.h |
... | ... |
@@ -976,7 +977,8 @@ $(GEN_HEADERS): $(SUBDIR)%_tables.h: $(SUBDIR)%_tablegen$(HOSTEXESUF) |
976 | 976 |
ifdef CONFIG_HARDCODED_TABLES |
977 | 977 |
$(SUBDIR)aacdec.o: $(SUBDIR)cbrt_tables.h |
978 | 978 |
$(SUBDIR)aacdec_fixed.o: $(SUBDIR)cbrt_fixed_tables.h |
979 |
-$(SUBDIR)aacps.o: $(SUBDIR)aacps_tables.h |
|
979 |
+$(SUBDIR)aacps_float.o: $(SUBDIR)aacps_tables.h |
|
980 |
+$(SUBDIR)aacps_fixed.o: $(SUBDIR)aacps_fixed_tables.h |
|
980 | 981 |
$(SUBDIR)aacsbr.o: $(SUBDIR)aacsbr_tables.h |
981 | 982 |
$(SUBDIR)aacsbr_fixed.o: $(SUBDIR)aacsbr_fixed_tables.h |
982 | 983 |
$(SUBDIR)aactab.o: $(SUBDIR)aac_tables.h |
... | ... |
@@ -35,6 +35,7 @@ |
35 | 35 |
#define AAC_RENAME(x) x ## _fixed |
36 | 36 |
#define AAC_RENAME_32(x) x ## _fixed_32 |
37 | 37 |
#define INTFLOAT int |
38 |
+#define INT64FLOAT int64_t |
|
38 | 39 |
#define SHORTFLOAT int16_t |
39 | 40 |
#define AAC_FLOAT SoftFloat |
40 | 41 |
#define AAC_SIGNE int |
... | ... |
@@ -45,9 +46,33 @@ |
45 | 45 |
#define Q31(x) (int)((x)*2147483648.0 + 0.5) |
46 | 46 |
#define RANGE15(x) x |
47 | 47 |
#define GET_GAIN(x, y) (-(y) << (x)) + 1024 |
48 |
+#define AAC_MUL16(x, y) (int)(((int64_t)(x) * (y) + 0x8000) >> 16) |
|
48 | 49 |
#define AAC_MUL26(x, y) (int)(((int64_t)(x) * (y) + 0x2000000) >> 26) |
49 | 50 |
#define AAC_MUL30(x, y) (int)(((int64_t)(x) * (y) + 0x20000000) >> 30) |
50 | 51 |
#define AAC_MUL31(x, y) (int)(((int64_t)(x) * (y) + 0x40000000) >> 31) |
52 |
+#define AAC_MADD28(x, y, a, b) (int)((((int64_t)(x) * (y)) + \ |
|
53 |
+ ((int64_t)(a) * (b)) + \ |
|
54 |
+ 0x8000000) >> 28) |
|
55 |
+#define AAC_MADD30(x, y, a, b) (int)((((int64_t)(x) * (y)) + \ |
|
56 |
+ ((int64_t)(a) * (b)) + \ |
|
57 |
+ 0x20000000) >> 30) |
|
58 |
+#define AAC_MADD30_V8(x, y, a, b, c, d, e, f) (int)((((int64_t)(x) * (y)) + \ |
|
59 |
+ ((int64_t)(a) * (b)) + \ |
|
60 |
+ ((int64_t)(c) * (d)) + \ |
|
61 |
+ ((int64_t)(e) * (f)) + \ |
|
62 |
+ 0x20000000) >> 30) |
|
63 |
+#define AAC_MSUB30(x, y, a, b) (int)((((int64_t)(x) * (y)) - \ |
|
64 |
+ ((int64_t)(a) * (b)) + \ |
|
65 |
+ 0x20000000) >> 30) |
|
66 |
+#define AAC_MSUB30_V8(x, y, a, b, c, d, e, f) (int)((((int64_t)(x) * (y)) + \ |
|
67 |
+ ((int64_t)(a) * (b)) - \ |
|
68 |
+ ((int64_t)(c) * (d)) - \ |
|
69 |
+ ((int64_t)(e) * (f)) + \ |
|
70 |
+ 0x20000000) >> 30) |
|
71 |
+#define AAC_MSUB31_V3(x, y, z) (int)((((int64_t)(x) * (z)) - \ |
|
72 |
+ ((int64_t)(y) * (z)) + \ |
|
73 |
+ 0x40000000) >> 31) |
|
74 |
+#define AAC_HALF_SUM(x, y) (x) >> 1 + (y) >> 1 |
|
51 | 75 |
#define AAC_SRA_R(x, y) (int)(((x) + (1 << ((y) - 1))) >> (y)) |
52 | 76 |
|
53 | 77 |
#else |
... | ... |
@@ -58,6 +83,7 @@ |
58 | 58 |
#define AAC_RENAME(x) x |
59 | 59 |
#define AAC_RENAME_32(x) x |
60 | 60 |
#define INTFLOAT float |
61 |
+#define INT64FLOAT float |
|
61 | 62 |
#define SHORTFLOAT float |
62 | 63 |
#define AAC_FLOAT float |
63 | 64 |
#define AAC_SIGNE unsigned |
... | ... |
@@ -68,9 +94,19 @@ |
68 | 68 |
#define Q31(x) x |
69 | 69 |
#define RANGE15(x) (32768.0 * (x)) |
70 | 70 |
#define GET_GAIN(x, y) powf((x), -(y)) |
71 |
+#define AAC_MUL16(x, y) ((x) * (y)) |
|
71 | 72 |
#define AAC_MUL26(x, y) ((x) * (y)) |
72 | 73 |
#define AAC_MUL30(x, y) ((x) * (y)) |
73 | 74 |
#define AAC_MUL31(x, y) ((x) * (y)) |
75 |
+#define AAC_MADD28(x, y, a, b) ((x) * (y) + (a) * (b)) |
|
76 |
+#define AAC_MADD30(x, y, a, b) ((x) * (y) + (a) * (b)) |
|
77 |
+#define AAC_MADD30_V8(x, y, a, b, c, d, e, f) ((x) * (y) + (a) * (b) + \ |
|
78 |
+ (c) * (d) + (e) * (f)) |
|
79 |
+#define AAC_MSUB30(x, y, a, b) ((x) * (y) - (a) * (b)) |
|
80 |
+#define AAC_MSUB30_V8(x, y, a, b, c, d, e, f) ((x) * (y) + (a) * (b) - \ |
|
81 |
+ (c) * (d) - (e) * (f)) |
|
82 |
+#define AAC_MSUB31_V3(x, y, z) ((x) - (y)) * (z) |
|
83 |
+#define AAC_HALF_SUM(x, y) ((x) + (y)) * 0.5f |
|
74 | 84 |
#define AAC_SRA_R(x, y) (x) |
75 | 85 |
|
76 | 86 |
#endif /* USE_FIXED */ |
... | ... |
@@ -17,16 +17,23 @@ |
17 | 17 |
* You should have received a copy of the GNU Lesser General Public |
18 | 18 |
* License along with FFmpeg; if not, write to the Free Software |
19 | 19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 |
+ * |
|
21 |
+ * Note: Rounding-to-nearest used unless otherwise stated |
|
22 |
+ * |
|
20 | 23 |
*/ |
21 | 24 |
|
22 | 25 |
#include <stdint.h> |
23 | 26 |
#include "libavutil/common.h" |
24 |
-#include "libavutil/internal.h" |
|
25 | 27 |
#include "libavutil/mathematics.h" |
26 | 28 |
#include "avcodec.h" |
27 | 29 |
#include "get_bits.h" |
28 | 30 |
#include "aacps.h" |
31 |
+#if USE_FIXED |
|
32 |
+#include "aacps_fixed_tablegen.h" |
|
33 |
+#else |
|
34 |
+#include "libavutil/internal.h" |
|
29 | 35 |
#include "aacps_tablegen.h" |
36 |
+#endif /* USE_FIXED */ |
|
30 | 37 |
#include "aacpsdata.c" |
31 | 38 |
|
32 | 39 |
#define PS_BASELINE 0 ///< Operate in Baseline PS mode |
... | ... |
@@ -148,7 +155,7 @@ static void ipdopd_reset(int8_t *ipd_hist, int8_t *opd_hist) |
148 | 148 |
} |
149 | 149 |
} |
150 | 150 |
|
151 |
-int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps, int bits_left) |
|
151 |
+int AAC_RENAME(ff_ps_read_data)(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps, int bits_left) |
|
152 | 152 |
{ |
153 | 153 |
int e; |
154 | 154 |
int bit_count_start = get_bits_count(gb_host); |
... | ... |
@@ -302,35 +309,41 @@ err: |
302 | 302 |
|
303 | 303 |
/** Split one subband into 2 subsubbands with a symmetric real filter. |
304 | 304 |
* The filter must have its non-center even coefficients equal to zero. */ |
305 |
-static void hybrid2_re(float (*in)[2], float (*out)[32][2], const float filter[8], int len, int reverse) |
|
305 |
+static void hybrid2_re(INTFLOAT (*in)[2], INTFLOAT (*out)[32][2], const INTFLOAT filter[8], int len, int reverse) |
|
306 | 306 |
{ |
307 | 307 |
int i, j; |
308 | 308 |
for (i = 0; i < len; i++, in++) { |
309 |
- float re_in = filter[6] * in[6][0]; //real inphase |
|
310 |
- float re_op = 0.0f; //real out of phase |
|
311 |
- float im_in = filter[6] * in[6][1]; //imag inphase |
|
312 |
- float im_op = 0.0f; //imag out of phase |
|
309 |
+ INT64FLOAT re_in = AAC_MUL31(filter[6], in[6][0]); //real inphase |
|
310 |
+ INT64FLOAT re_op = 0.0f; //real out of phase |
|
311 |
+ INT64FLOAT im_in = AAC_MUL31(filter[6], in[6][1]); //imag inphase |
|
312 |
+ INT64FLOAT im_op = 0.0f; //imag out of phase |
|
313 | 313 |
for (j = 0; j < 6; j += 2) { |
314 |
- re_op += filter[j+1] * (in[j+1][0] + in[12-j-1][0]); |
|
315 |
- im_op += filter[j+1] * (in[j+1][1] + in[12-j-1][1]); |
|
314 |
+ re_op += (INT64FLOAT)filter[j+1] * (in[j+1][0] + in[12-j-1][0]); |
|
315 |
+ im_op += (INT64FLOAT)filter[j+1] * (in[j+1][1] + in[12-j-1][1]); |
|
316 | 316 |
} |
317 |
- out[ reverse][i][0] = re_in + re_op; |
|
318 |
- out[ reverse][i][1] = im_in + im_op; |
|
319 |
- out[!reverse][i][0] = re_in - re_op; |
|
320 |
- out[!reverse][i][1] = im_in - im_op; |
|
317 |
+ |
|
318 |
+#if USE_FIXED |
|
319 |
+ re_op = (re_op + 0x40000000) >> 31; |
|
320 |
+ im_op = (im_op + 0x40000000) >> 31; |
|
321 |
+#endif /* USE_FIXED */ |
|
322 |
+ |
|
323 |
+ out[ reverse][i][0] = (INTFLOAT)(re_in + re_op); |
|
324 |
+ out[ reverse][i][1] = (INTFLOAT)(im_in + im_op); |
|
325 |
+ out[!reverse][i][0] = (INTFLOAT)(re_in - re_op); |
|
326 |
+ out[!reverse][i][1] = (INTFLOAT)(im_in - im_op); |
|
321 | 327 |
} |
322 | 328 |
} |
323 | 329 |
|
324 | 330 |
/** Split one subband into 6 subsubbands with a complex filter */ |
325 |
-static void hybrid6_cx(PSDSPContext *dsp, float (*in)[2], float (*out)[32][2], |
|
326 |
- TABLE_CONST float (*filter)[8][2], int len) |
|
331 |
+static void hybrid6_cx(PSDSPContext *dsp, INTFLOAT (*in)[2], INTFLOAT (*out)[32][2], |
|
332 |
+ TABLE_CONST INTFLOAT (*filter)[8][2], int len) |
|
327 | 333 |
{ |
328 | 334 |
int i; |
329 | 335 |
int N = 8; |
330 |
- LOCAL_ALIGNED_16(float, temp, [8], [2]); |
|
336 |
+ LOCAL_ALIGNED_16(INTFLOAT, temp, [8], [2]); |
|
331 | 337 |
|
332 | 338 |
for (i = 0; i < len; i++, in++) { |
333 |
- dsp->hybrid_analysis(temp, in, (const float (*)[8][2]) filter, 1, N); |
|
339 |
+ dsp->hybrid_analysis(temp, in, (const INTFLOAT (*)[8][2]) filter, 1, N); |
|
334 | 340 |
out[0][i][0] = temp[6][0]; |
335 | 341 |
out[0][i][1] = temp[6][1]; |
336 | 342 |
out[1][i][0] = temp[7][0]; |
... | ... |
@@ -347,18 +360,18 @@ static void hybrid6_cx(PSDSPContext *dsp, float (*in)[2], float (*out)[32][2], |
347 | 347 |
} |
348 | 348 |
|
349 | 349 |
static void hybrid4_8_12_cx(PSDSPContext *dsp, |
350 |
- float (*in)[2], float (*out)[32][2], |
|
351 |
- TABLE_CONST float (*filter)[8][2], int N, int len) |
|
350 |
+ INTFLOAT (*in)[2], INTFLOAT (*out)[32][2], |
|
351 |
+ TABLE_CONST INTFLOAT (*filter)[8][2], int N, int len) |
|
352 | 352 |
{ |
353 | 353 |
int i; |
354 | 354 |
|
355 | 355 |
for (i = 0; i < len; i++, in++) { |
356 |
- dsp->hybrid_analysis(out[0] + i, in, (const float (*)[8][2]) filter, 32, N); |
|
356 |
+ dsp->hybrid_analysis(out[0] + i, in, (const INTFLOAT (*)[8][2]) filter, 32, N); |
|
357 | 357 |
} |
358 | 358 |
} |
359 | 359 |
|
360 |
-static void hybrid_analysis(PSDSPContext *dsp, float out[91][32][2], |
|
361 |
- float in[5][44][2], float L[2][38][64], |
|
360 |
+static void hybrid_analysis(PSDSPContext *dsp, INTFLOAT out[91][32][2], |
|
361 |
+ INTFLOAT in[5][44][2], INTFLOAT L[2][38][64], |
|
362 | 362 |
int is34, int len) |
363 | 363 |
{ |
364 | 364 |
int i, j; |
... | ... |
@@ -387,8 +400,8 @@ static void hybrid_analysis(PSDSPContext *dsp, float out[91][32][2], |
387 | 387 |
} |
388 | 388 |
} |
389 | 389 |
|
390 |
-static void hybrid_synthesis(PSDSPContext *dsp, float out[2][38][64], |
|
391 |
- float in[91][32][2], int is34, int len) |
|
390 |
+static void hybrid_synthesis(PSDSPContext *dsp, INTFLOAT out[2][38][64], |
|
391 |
+ INTFLOAT in[91][32][2], int is34, int len) |
|
392 | 392 |
{ |
393 | 393 |
int i, n; |
394 | 394 |
if (is34) { |
... | ... |
@@ -429,7 +442,7 @@ static void hybrid_synthesis(PSDSPContext *dsp, float out[2][38][64], |
429 | 429 |
} |
430 | 430 |
|
431 | 431 |
/// All-pass filter decay slope |
432 |
-#define DECAY_SLOPE 0.05f |
|
432 |
+#define DECAY_SLOPE Q30(0.05f) |
|
433 | 433 |
/// Number of frequency bands that can be addressed by the parameter index, b(k) |
434 | 434 |
static const int NR_PAR_BANDS[] = { 20, 34 }; |
435 | 435 |
static const int NR_IPDOPD_BANDS[] = { 11, 17 }; |
... | ... |
@@ -483,28 +496,43 @@ static void map_idx_34_to_20(int8_t *par_mapped, const int8_t *par, int full) |
483 | 483 |
} |
484 | 484 |
} |
485 | 485 |
|
486 |
-static void map_val_34_to_20(float par[PS_MAX_NR_IIDICC]) |
|
486 |
+static void map_val_34_to_20(INTFLOAT par[PS_MAX_NR_IIDICC]) |
|
487 | 487 |
{ |
488 |
+#if USE_FIXED |
|
489 |
+ par[ 0] = (int)(((int64_t)(par[ 0] + (par[ 1]>>1)) * 1431655765 + \ |
|
490 |
+ 0x40000000) >> 31); |
|
491 |
+ par[ 1] = (int)(((int64_t)((par[ 1]>>1) + par[ 2]) * 1431655765 + \ |
|
492 |
+ 0x40000000) >> 31); |
|
493 |
+ par[ 2] = (int)(((int64_t)(par[ 3] + (par[ 4]>>1)) * 1431655765 + \ |
|
494 |
+ 0x40000000) >> 31); |
|
495 |
+ par[ 3] = (int)(((int64_t)((par[ 4]>>1) + par[ 5]) * 1431655765 + \ |
|
496 |
+ 0x40000000) >> 31); |
|
497 |
+#else |
|
488 | 498 |
par[ 0] = (2*par[ 0] + par[ 1]) * 0.33333333f; |
489 | 499 |
par[ 1] = ( par[ 1] + 2*par[ 2]) * 0.33333333f; |
490 | 500 |
par[ 2] = (2*par[ 3] + par[ 4]) * 0.33333333f; |
491 | 501 |
par[ 3] = ( par[ 4] + 2*par[ 5]) * 0.33333333f; |
492 |
- par[ 4] = ( par[ 6] + par[ 7]) * 0.5f; |
|
493 |
- par[ 5] = ( par[ 8] + par[ 9]) * 0.5f; |
|
502 |
+#endif /* USE_FIXED */ |
|
503 |
+ par[ 4] = AAC_HALF_SUM(par[ 6], par[ 7]); |
|
504 |
+ par[ 5] = AAC_HALF_SUM(par[ 8], par[ 9]); |
|
494 | 505 |
par[ 6] = par[10]; |
495 | 506 |
par[ 7] = par[11]; |
496 |
- par[ 8] = ( par[12] + par[13]) * 0.5f; |
|
497 |
- par[ 9] = ( par[14] + par[15]) * 0.5f; |
|
507 |
+ par[ 8] = AAC_HALF_SUM(par[12], par[13]); |
|
508 |
+ par[ 9] = AAC_HALF_SUM(par[14], par[15]); |
|
498 | 509 |
par[10] = par[16]; |
499 | 510 |
par[11] = par[17]; |
500 | 511 |
par[12] = par[18]; |
501 | 512 |
par[13] = par[19]; |
502 |
- par[14] = ( par[20] + par[21]) * 0.5f; |
|
503 |
- par[15] = ( par[22] + par[23]) * 0.5f; |
|
504 |
- par[16] = ( par[24] + par[25]) * 0.5f; |
|
505 |
- par[17] = ( par[26] + par[27]) * 0.5f; |
|
513 |
+ par[14] = AAC_HALF_SUM(par[20], par[21]); |
|
514 |
+ par[15] = AAC_HALF_SUM(par[22], par[23]); |
|
515 |
+ par[16] = AAC_HALF_SUM(par[24], par[25]); |
|
516 |
+ par[17] = AAC_HALF_SUM(par[26], par[27]); |
|
517 |
+#if USE_FIXED |
|
518 |
+ par[18] = (((par[28]+2)>>2) + ((par[29]+2)>>2) + ((par[30]+2)>>2) + ((par[31]+2)>>2)); |
|
519 |
+#else |
|
506 | 520 |
par[18] = ( par[28] + par[29] + par[30] + par[31]) * 0.25f; |
507 |
- par[19] = ( par[32] + par[33]) * 0.5f; |
|
521 |
+#endif /* USE_FIXED */ |
|
522 |
+ par[19] = AAC_HALF_SUM(par[32], par[33]); |
|
508 | 523 |
} |
509 | 524 |
|
510 | 525 |
static void map_idx_10_to_34(int8_t *par_mapped, const int8_t *par, int full) |
... | ... |
@@ -589,7 +617,7 @@ static void map_idx_20_to_34(int8_t *par_mapped, const int8_t *par, int full) |
589 | 589 |
par_mapped[ 0] = par[ 0]; |
590 | 590 |
} |
591 | 591 |
|
592 |
-static void map_val_20_to_34(float par[PS_MAX_NR_IIDICC]) |
|
592 |
+static void map_val_20_to_34(INTFLOAT par[PS_MAX_NR_IIDICC]) |
|
593 | 593 |
{ |
594 | 594 |
par[33] = par[19]; |
595 | 595 |
par[32] = par[19]; |
... | ... |
@@ -620,27 +648,29 @@ static void map_val_20_to_34(float par[PS_MAX_NR_IIDICC]) |
620 | 620 |
par[ 7] = par[ 4]; |
621 | 621 |
par[ 6] = par[ 4]; |
622 | 622 |
par[ 5] = par[ 3]; |
623 |
- par[ 4] = (par[ 2] + par[ 3]) * 0.5f; |
|
623 |
+ par[ 4] = AAC_HALF_SUM(par[ 2], par[ 3]); |
|
624 | 624 |
par[ 3] = par[ 2]; |
625 | 625 |
par[ 2] = par[ 1]; |
626 |
- par[ 1] = (par[ 0] + par[ 1]) * 0.5f; |
|
626 |
+ par[ 1] = AAC_HALF_SUM(par[ 0], par[ 1]); |
|
627 | 627 |
} |
628 | 628 |
|
629 |
-static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[32][2], int is34) |
|
629 |
+static void decorrelation(PSContext *ps, INTFLOAT (*out)[32][2], const INTFLOAT (*s)[32][2], int is34) |
|
630 | 630 |
{ |
631 |
- LOCAL_ALIGNED_16(float, power, [34], [PS_QMF_TIME_SLOTS]); |
|
632 |
- LOCAL_ALIGNED_16(float, transient_gain, [34], [PS_QMF_TIME_SLOTS]); |
|
633 |
- float *peak_decay_nrg = ps->peak_decay_nrg; |
|
634 |
- float *power_smooth = ps->power_smooth; |
|
635 |
- float *peak_decay_diff_smooth = ps->peak_decay_diff_smooth; |
|
636 |
- float (*delay)[PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2] = ps->delay; |
|
637 |
- float (*ap_delay)[PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2] = ps->ap_delay; |
|
638 |
- const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20; |
|
639 |
- const float peak_decay_factor = 0.76592833836465f; |
|
631 |
+ LOCAL_ALIGNED_16(INTFLOAT, power, [34], [PS_QMF_TIME_SLOTS]); |
|
632 |
+ LOCAL_ALIGNED_16(INTFLOAT, transient_gain, [34], [PS_QMF_TIME_SLOTS]); |
|
633 |
+ INTFLOAT *peak_decay_nrg = ps->peak_decay_nrg; |
|
634 |
+ INTFLOAT *power_smooth = ps->power_smooth; |
|
635 |
+ INTFLOAT *peak_decay_diff_smooth = ps->peak_decay_diff_smooth; |
|
636 |
+ INTFLOAT (*delay)[PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2] = ps->delay; |
|
637 |
+ INTFLOAT (*ap_delay)[PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2] = ps->ap_delay; |
|
638 |
+#if !USE_FIXED |
|
640 | 639 |
const float transient_impact = 1.5f; |
641 | 640 |
const float a_smooth = 0.25f; ///< Smoothing coefficient |
641 |
+#endif /* USE_FIXED */ |
|
642 |
+ const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20; |
|
642 | 643 |
int i, k, m, n; |
643 | 644 |
int n0 = 0, nL = 32; |
645 |
+ const INTFLOAT peak_decay_factor = Q31(0.76592833836465f);; |
|
644 | 646 |
|
645 | 647 |
memset(power, 0, 34 * sizeof(*power)); |
646 | 648 |
|
... | ... |
@@ -658,6 +688,33 @@ static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[3 |
658 | 658 |
} |
659 | 659 |
|
660 | 660 |
//Transient detection |
661 |
+#if USE_FIXED |
|
662 |
+ for (i = 0; i < NR_PAR_BANDS[is34]; i++) { |
|
663 |
+ for (n = n0; n < nL; n++) { |
|
664 |
+ int decayed_peak; |
|
665 |
+ int denom; |
|
666 |
+ |
|
667 |
+ decayed_peak = (int)(((int64_t)peak_decay_factor * \ |
|
668 |
+ peak_decay_nrg[i] + 0x40000000) >> 31); |
|
669 |
+ peak_decay_nrg[i] = FFMAX(decayed_peak, power[i][n]); |
|
670 |
+ power_smooth[i] += (power[i][n] - power_smooth[i] + 2) >> 2; |
|
671 |
+ peak_decay_diff_smooth[i] += (peak_decay_nrg[i] - power[i][n] - \ |
|
672 |
+ peak_decay_diff_smooth[i] + 2) >> 2; |
|
673 |
+ denom = peak_decay_diff_smooth[i] + (peak_decay_diff_smooth[i] >> 1); |
|
674 |
+ if (denom > power_smooth[i]) { |
|
675 |
+ int p = power_smooth[i]; |
|
676 |
+ while (denom < 0x40000000) { |
|
677 |
+ denom <<= 1; |
|
678 |
+ p <<= 1; |
|
679 |
+ } |
|
680 |
+ transient_gain[i][n] = p / (denom >> 16); |
|
681 |
+ } |
|
682 |
+ else { |
|
683 |
+ transient_gain[i][n] = 1 << 16; |
|
684 |
+ } |
|
685 |
+ } |
|
686 |
+ } |
|
687 |
+#else |
|
661 | 688 |
for (i = 0; i < NR_PAR_BANDS[is34]; i++) { |
662 | 689 |
for (n = n0; n < nL; n++) { |
663 | 690 |
float decayed_peak = peak_decay_factor * peak_decay_nrg[i]; |
... | ... |
@@ -671,6 +728,7 @@ static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[3 |
671 | 671 |
} |
672 | 672 |
} |
673 | 673 |
|
674 |
+#endif /* USE_FIXED */ |
|
674 | 675 |
//Decorrelation and transient reduction |
675 | 676 |
// PS_AP_LINKS - 1 |
676 | 677 |
// ----- |
... | ... |
@@ -681,8 +739,22 @@ static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[3 |
681 | 681 |
//d[k][z] (out) = transient_gain_mapped[k][z] * H[k][z] * s[k][z] |
682 | 682 |
for (k = 0; k < NR_ALLPASS_BANDS[is34]; k++) { |
683 | 683 |
int b = k_to_i[k]; |
684 |
+#if USE_FIXED |
|
685 |
+ int g_decay_slope; |
|
686 |
+ |
|
687 |
+ if (k - DECAY_CUTOFF[is34] <= 0) { |
|
688 |
+ g_decay_slope = 1 << 30; |
|
689 |
+ } |
|
690 |
+ else if (k - DECAY_CUTOFF[is34] >= 20) { |
|
691 |
+ g_decay_slope = 0; |
|
692 |
+ } |
|
693 |
+ else { |
|
694 |
+ g_decay_slope = (1 << 30) - DECAY_SLOPE * (k - DECAY_CUTOFF[is34]); |
|
695 |
+ } |
|
696 |
+#else |
|
684 | 697 |
float g_decay_slope = 1.f - DECAY_SLOPE * (k - DECAY_CUTOFF[is34]); |
685 | 698 |
g_decay_slope = av_clipf(g_decay_slope, 0.f, 1.f); |
699 |
+#endif /* USE_FIXED */ |
|
686 | 700 |
memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0])); |
687 | 701 |
memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0])); |
688 | 702 |
for (m = 0; m < PS_AP_LINKS; m++) { |
... | ... |
@@ -690,7 +762,7 @@ static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[3 |
690 | 690 |
} |
691 | 691 |
ps->dsp.decorrelate(out[k], delay[k] + PS_MAX_DELAY - 2, ap_delay[k], |
692 | 692 |
phi_fract[is34][k], |
693 |
- (const float (*)[2]) Q_fract_allpass[is34][k], |
|
693 |
+ (const INTFLOAT (*)[2]) Q_fract_allpass[is34][k], |
|
694 | 694 |
transient_gain[b], g_decay_slope, nL - n0); |
695 | 695 |
} |
696 | 696 |
for (; k < SHORT_DELAY_BAND[is34]; k++) { |
... | ... |
@@ -749,14 +821,14 @@ static void remap20(int8_t (**p_par_mapped)[PS_MAX_NR_IIDICC], |
749 | 749 |
} |
750 | 750 |
} |
751 | 751 |
|
752 |
-static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2], int is34) |
|
752 |
+static void stereo_processing(PSContext *ps, INTFLOAT (*l)[32][2], INTFLOAT (*r)[32][2], int is34) |
|
753 | 753 |
{ |
754 | 754 |
int e, b, k; |
755 | 755 |
|
756 |
- float (*H11)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H11; |
|
757 |
- float (*H12)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H12; |
|
758 |
- float (*H21)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H21; |
|
759 |
- float (*H22)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H22; |
|
756 |
+ INTFLOAT (*H11)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H11; |
|
757 |
+ INTFLOAT (*H12)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H12; |
|
758 |
+ INTFLOAT (*H21)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H21; |
|
759 |
+ INTFLOAT (*H22)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H22; |
|
760 | 760 |
int8_t *opd_hist = ps->opd_hist; |
761 | 761 |
int8_t *ipd_hist = ps->ipd_hist; |
762 | 762 |
int8_t iid_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; |
... | ... |
@@ -768,7 +840,7 @@ static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2 |
768 | 768 |
int8_t (*ipd_mapped)[PS_MAX_NR_IIDICC] = ipd_mapped_buf; |
769 | 769 |
int8_t (*opd_mapped)[PS_MAX_NR_IIDICC] = opd_mapped_buf; |
770 | 770 |
const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20; |
771 |
- TABLE_CONST float (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB; |
|
771 |
+ TABLE_CONST INTFLOAT (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB; |
|
772 | 772 |
|
773 | 773 |
//Remapping |
774 | 774 |
if (ps->num_env_old) { |
... | ... |
@@ -823,7 +895,7 @@ static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2 |
823 | 823 |
//Mixing |
824 | 824 |
for (e = 0; e < ps->num_env; e++) { |
825 | 825 |
for (b = 0; b < NR_PAR_BANDS[is34]; b++) { |
826 |
- float h11, h12, h21, h22; |
|
826 |
+ INTFLOAT h11, h12, h21, h22; |
|
827 | 827 |
h11 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][0]; |
828 | 828 |
h12 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][1]; |
829 | 829 |
h21 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][2]; |
... | ... |
@@ -832,27 +904,27 @@ static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2 |
832 | 832 |
if (!PS_BASELINE && ps->enable_ipdopd && b < NR_IPDOPD_BANDS[is34]) { |
833 | 833 |
//The spec say says to only run this smoother when enable_ipdopd |
834 | 834 |
//is set but the reference decoder appears to run it constantly |
835 |
- float h11i, h12i, h21i, h22i; |
|
836 |
- float ipd_adj_re, ipd_adj_im; |
|
835 |
+ INTFLOAT h11i, h12i, h21i, h22i; |
|
836 |
+ INTFLOAT ipd_adj_re, ipd_adj_im; |
|
837 | 837 |
int opd_idx = opd_hist[b] * 8 + opd_mapped[e][b]; |
838 | 838 |
int ipd_idx = ipd_hist[b] * 8 + ipd_mapped[e][b]; |
839 |
- float opd_re = pd_re_smooth[opd_idx]; |
|
840 |
- float opd_im = pd_im_smooth[opd_idx]; |
|
841 |
- float ipd_re = pd_re_smooth[ipd_idx]; |
|
842 |
- float ipd_im = pd_im_smooth[ipd_idx]; |
|
839 |
+ INTFLOAT opd_re = pd_re_smooth[opd_idx]; |
|
840 |
+ INTFLOAT opd_im = pd_im_smooth[opd_idx]; |
|
841 |
+ INTFLOAT ipd_re = pd_re_smooth[ipd_idx]; |
|
842 |
+ INTFLOAT ipd_im = pd_im_smooth[ipd_idx]; |
|
843 | 843 |
opd_hist[b] = opd_idx & 0x3F; |
844 | 844 |
ipd_hist[b] = ipd_idx & 0x3F; |
845 | 845 |
|
846 |
- ipd_adj_re = opd_re*ipd_re + opd_im*ipd_im; |
|
847 |
- ipd_adj_im = opd_im*ipd_re - opd_re*ipd_im; |
|
848 |
- h11i = h11 * opd_im; |
|
849 |
- h11 = h11 * opd_re; |
|
850 |
- h12i = h12 * ipd_adj_im; |
|
851 |
- h12 = h12 * ipd_adj_re; |
|
852 |
- h21i = h21 * opd_im; |
|
853 |
- h21 = h21 * opd_re; |
|
854 |
- h22i = h22 * ipd_adj_im; |
|
855 |
- h22 = h22 * ipd_adj_re; |
|
846 |
+ ipd_adj_re = AAC_MADD30(opd_re, ipd_re, opd_im, ipd_im); |
|
847 |
+ ipd_adj_im = AAC_MSUB30(opd_im, ipd_re, opd_re, ipd_im); |
|
848 |
+ h11i = AAC_MUL30(h11, opd_im); |
|
849 |
+ h11 = AAC_MUL30(h11, opd_re); |
|
850 |
+ h12i = AAC_MUL30(h12, ipd_adj_im); |
|
851 |
+ h12 = AAC_MUL30(h12, ipd_adj_re); |
|
852 |
+ h21i = AAC_MUL30(h21, opd_im); |
|
853 |
+ h21 = AAC_MUL30(h21, opd_re); |
|
854 |
+ h22i = AAC_MUL30(h22, ipd_adj_im); |
|
855 |
+ h22 = AAC_MUL30(h22, ipd_adj_re); |
|
856 | 856 |
H11[1][e+1][b] = h11i; |
857 | 857 |
H12[1][e+1][b] = h12i; |
858 | 858 |
H21[1][e+1][b] = h21i; |
... | ... |
@@ -864,11 +936,14 @@ static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2 |
864 | 864 |
H22[0][e+1][b] = h22; |
865 | 865 |
} |
866 | 866 |
for (k = 0; k < NR_BANDS[is34]; k++) { |
867 |
- float h[2][4]; |
|
868 |
- float h_step[2][4]; |
|
867 |
+ INTFLOAT h[2][4]; |
|
868 |
+ INTFLOAT h_step[2][4]; |
|
869 | 869 |
int start = ps->border_position[e]; |
870 | 870 |
int stop = ps->border_position[e+1]; |
871 |
- float width = 1.f / (stop - start); |
|
871 |
+ INTFLOAT width = Q30(1.f) / (stop - start); |
|
872 |
+#if USE_FIXED |
|
873 |
+ width <<= 1; |
|
874 |
+#endif |
|
872 | 875 |
b = k_to_i[k]; |
873 | 876 |
h[0][0] = H11[0][e][b]; |
874 | 877 |
h[0][1] = H12[0][e][b]; |
... | ... |
@@ -889,15 +964,15 @@ static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2 |
889 | 889 |
} |
890 | 890 |
} |
891 | 891 |
//Interpolation |
892 |
- h_step[0][0] = (H11[0][e+1][b] - h[0][0]) * width; |
|
893 |
- h_step[0][1] = (H12[0][e+1][b] - h[0][1]) * width; |
|
894 |
- h_step[0][2] = (H21[0][e+1][b] - h[0][2]) * width; |
|
895 |
- h_step[0][3] = (H22[0][e+1][b] - h[0][3]) * width; |
|
892 |
+ h_step[0][0] = AAC_MSUB31_V3(H11[0][e+1][b], h[0][0], width); |
|
893 |
+ h_step[0][1] = AAC_MSUB31_V3(H12[0][e+1][b], h[0][1], width); |
|
894 |
+ h_step[0][2] = AAC_MSUB31_V3(H21[0][e+1][b], h[0][2], width); |
|
895 |
+ h_step[0][3] = AAC_MSUB31_V3(H22[0][e+1][b], h[0][3], width); |
|
896 | 896 |
if (!PS_BASELINE && ps->enable_ipdopd) { |
897 |
- h_step[1][0] = (H11[1][e+1][b] - h[1][0]) * width; |
|
898 |
- h_step[1][1] = (H12[1][e+1][b] - h[1][1]) * width; |
|
899 |
- h_step[1][2] = (H21[1][e+1][b] - h[1][2]) * width; |
|
900 |
- h_step[1][3] = (H22[1][e+1][b] - h[1][3]) * width; |
|
897 |
+ h_step[1][0] = AAC_MSUB31_V3(H11[1][e+1][b], h[1][0], width); |
|
898 |
+ h_step[1][1] = AAC_MSUB31_V3(H12[1][e+1][b], h[1][1], width); |
|
899 |
+ h_step[1][2] = AAC_MSUB31_V3(H21[1][e+1][b], h[1][2], width); |
|
900 |
+ h_step[1][3] = AAC_MSUB31_V3(H22[1][e+1][b], h[1][3], width); |
|
901 | 901 |
} |
902 | 902 |
ps->dsp.stereo_interpolate[!PS_BASELINE && ps->enable_ipdopd]( |
903 | 903 |
l[k] + start + 1, r[k] + start + 1, |
... | ... |
@@ -906,10 +981,10 @@ static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2 |
906 | 906 |
} |
907 | 907 |
} |
908 | 908 |
|
909 |
-int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float R[2][38][64], int top) |
|
909 |
+int AAC_RENAME(ff_ps_apply)(AVCodecContext *avctx, PSContext *ps, INTFLOAT L[2][38][64], INTFLOAT R[2][38][64], int top) |
|
910 | 910 |
{ |
911 |
- float (*Lbuf)[32][2] = ps->Lbuf; |
|
912 |
- float (*Rbuf)[32][2] = ps->Rbuf; |
|
911 |
+ INTFLOAT (*Lbuf)[32][2] = ps->Lbuf; |
|
912 |
+ INTFLOAT (*Rbuf)[32][2] = ps->Rbuf; |
|
913 | 913 |
const int len = 32; |
914 | 914 |
int is34 = ps->is34bands; |
915 | 915 |
|
... | ... |
@@ -919,7 +994,7 @@ int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float |
919 | 919 |
memset(ps->ap_delay + top, 0, (NR_ALLPASS_BANDS[is34] - top)*sizeof(ps->ap_delay[0])); |
920 | 920 |
|
921 | 921 |
hybrid_analysis(&ps->dsp, Lbuf, ps->in_buf, L, is34, len); |
922 |
- decorrelation(ps, Rbuf, (const float (*)[32][2]) Lbuf, is34); |
|
922 |
+ decorrelation(ps, Rbuf, (const INTFLOAT (*)[32][2]) Lbuf, is34); |
|
923 | 923 |
stereo_processing(ps, Lbuf, Rbuf, is34); |
924 | 924 |
hybrid_synthesis(&ps->dsp, L, Lbuf, is34, len); |
925 | 925 |
hybrid_synthesis(&ps->dsp, R, Rbuf, is34, len); |
... | ... |
@@ -936,7 +1011,7 @@ int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float |
936 | 936 |
#define PS_VLC_ROW(name) \ |
937 | 937 |
{ name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) } |
938 | 938 |
|
939 |
-av_cold void ff_ps_init(void) { |
|
939 |
+av_cold void AAC_RENAME(ff_ps_init)(void) { |
|
940 | 940 |
// Syntax initialization |
941 | 941 |
static const struct { |
942 | 942 |
const void *ps_codes, *ps_bits; |
... | ... |
@@ -968,7 +1043,7 @@ av_cold void ff_ps_init(void) { |
968 | 968 |
ps_tableinit(); |
969 | 969 |
} |
970 | 970 |
|
971 |
-av_cold void ff_ps_ctx_init(PSContext *ps) |
|
971 |
+av_cold void AAC_RENAME(ff_ps_ctx_init)(PSContext *ps) |
|
972 | 972 |
{ |
973 |
- ff_psdsp_init(&ps->dsp); |
|
973 |
+ AAC_RENAME(ff_psdsp_init)(&ps->dsp); |
|
974 | 974 |
} |
... | ... |
@@ -61,26 +61,26 @@ typedef struct PSContext { |
61 | 61 |
int is34bands; |
62 | 62 |
int is34bands_old; |
63 | 63 |
|
64 |
- DECLARE_ALIGNED(16, float, in_buf)[5][44][2]; |
|
65 |
- DECLARE_ALIGNED(16, float, delay)[PS_MAX_SSB][PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2]; |
|
66 |
- DECLARE_ALIGNED(16, float, ap_delay)[PS_MAX_AP_BANDS][PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2]; |
|
67 |
- DECLARE_ALIGNED(16, float, peak_decay_nrg)[34]; |
|
68 |
- DECLARE_ALIGNED(16, float, power_smooth)[34]; |
|
69 |
- DECLARE_ALIGNED(16, float, peak_decay_diff_smooth)[34]; |
|
70 |
- DECLARE_ALIGNED(16, float, H11)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; |
|
71 |
- DECLARE_ALIGNED(16, float, H12)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; |
|
72 |
- DECLARE_ALIGNED(16, float, H21)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; |
|
73 |
- DECLARE_ALIGNED(16, float, H22)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; |
|
74 |
- DECLARE_ALIGNED(16, float, Lbuf)[91][32][2]; |
|
75 |
- DECLARE_ALIGNED(16, float, Rbuf)[91][32][2]; |
|
64 |
+ DECLARE_ALIGNED(16, INTFLOAT, in_buf)[5][44][2]; |
|
65 |
+ DECLARE_ALIGNED(16, INTFLOAT, delay)[PS_MAX_SSB][PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2]; |
|
66 |
+ DECLARE_ALIGNED(16, INTFLOAT, ap_delay)[PS_MAX_AP_BANDS][PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2]; |
|
67 |
+ DECLARE_ALIGNED(16, INTFLOAT, peak_decay_nrg)[34]; |
|
68 |
+ DECLARE_ALIGNED(16, INTFLOAT, power_smooth)[34]; |
|
69 |
+ DECLARE_ALIGNED(16, INTFLOAT, peak_decay_diff_smooth)[34]; |
|
70 |
+ DECLARE_ALIGNED(16, INTFLOAT, H11)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; |
|
71 |
+ DECLARE_ALIGNED(16, INTFLOAT, H12)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; |
|
72 |
+ DECLARE_ALIGNED(16, INTFLOAT, H21)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; |
|
73 |
+ DECLARE_ALIGNED(16, INTFLOAT, H22)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; |
|
74 |
+ DECLARE_ALIGNED(16, INTFLOAT, Lbuf)[91][32][2]; |
|
75 |
+ DECLARE_ALIGNED(16, INTFLOAT, Rbuf)[91][32][2]; |
|
76 | 76 |
int8_t opd_hist[PS_MAX_NR_IIDICC]; |
77 | 77 |
int8_t ipd_hist[PS_MAX_NR_IIDICC]; |
78 | 78 |
PSDSPContext dsp; |
79 | 79 |
} PSContext; |
80 | 80 |
|
81 |
-void ff_ps_init(void); |
|
82 |
-void ff_ps_ctx_init(PSContext *ps); |
|
83 |
-int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, int bits_left); |
|
84 |
-int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float R[2][38][64], int top); |
|
81 |
+void AAC_RENAME(ff_ps_init)(void); |
|
82 |
+void AAC_RENAME(ff_ps_ctx_init)(PSContext *ps); |
|
83 |
+int AAC_RENAME(ff_ps_read_data)(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, int bits_left); |
|
84 |
+int AAC_RENAME(ff_ps_apply)(AVCodecContext *avctx, PSContext *ps, INTFLOAT L[2][38][64], INTFLOAT R[2][38][64], int top); |
|
85 | 85 |
|
86 | 86 |
#endif /* AVCODEC_PS_H */ |
87 | 87 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,24 @@ |
0 |
+/* |
|
1 |
+ * MPEG-4 Parametric Stereo decoding functions |
|
2 |
+ * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> |
|
3 |
+ * |
|
4 |
+ * This file is part of FFmpeg. |
|
5 |
+ * |
|
6 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
7 |
+ * modify it under the terms of the GNU Lesser General Public |
|
8 |
+ * License as published by the Free Software Foundation; either |
|
9 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
+ * Lesser General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU Lesser General Public |
|
17 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
+ */ |
|
20 |
+ |
|
21 |
+#define USE_FIXED 1 |
|
22 |
+ |
|
23 |
+#include "aacps.c" |
... | ... |
@@ -288,7 +288,7 @@ static void ps_tableinit(void) |
288 | 288 |
int im_smooth = pd0_im + pd1_im + pd2_im; |
289 | 289 |
|
290 | 290 |
SoftFloat pd_mag = av_int2sf(((ipdopd_cos[(pd0-pd1)&7]+8)>>4) + ((ipdopd_cos[(pd0-pd2)&7]+4)>>3) + |
291 |
- ((ipdopd_cos[(pd1-pd2)&7]+2)>>2) + 0x15000000, 2); |
|
291 |
+ ((ipdopd_cos[(pd1-pd2)&7]+2)>>2) + 0x15000000, 28); |
|
292 | 292 |
pd_mag = av_div_sf(FLOAT_1, av_sqrt_sf(pd_mag)); |
293 | 293 |
shift = 30 - pd_mag.exp; |
294 | 294 |
round = 1 << (shift-1); |
295 | 295 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,24 @@ |
0 |
+/* |
|
1 |
+ * MPEG-4 Parametric Stereo decoding functions |
|
2 |
+ * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> |
|
3 |
+ * |
|
4 |
+ * This file is part of FFmpeg. |
|
5 |
+ * |
|
6 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
7 |
+ * modify it under the terms of the GNU Lesser General Public |
|
8 |
+ * License as published by the Free Software Foundation; either |
|
9 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
+ * Lesser General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU Lesser General Public |
|
17 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
+ */ |
|
20 |
+ |
|
21 |
+#define USE_FIXED 0 |
|
22 |
+ |
|
23 |
+#include "aacps.c" |
... | ... |
@@ -157,7 +157,7 @@ static const int8_t k_to_i_34[] = { |
157 | 157 |
33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 |
158 | 158 |
}; |
159 | 159 |
|
160 |
-static const float g1_Q2[] = { |
|
161 |
- 0.0f, 0.01899487526049f, 0.0f, -0.07293139167538f, |
|
162 |
- 0.0f, 0.30596630545168f, 0.5f |
|
160 |
+static const INTFLOAT g1_Q2[] = { |
|
161 |
+ Q31(0.0f), Q31(0.01899487526049f), Q31(0.0f), Q31(-0.07293139167538f), |
|
162 |
+ Q31(0.0f), Q31(0.30596630545168f), Q31(0.5f) |
|
163 | 163 |
}; |
164 | 164 |
deleted file mode 100644 |
... | ... |
@@ -1,216 +0,0 @@ |
1 |
-/* |
|
2 |
- * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> |
|
3 |
- * |
|
4 |
- * This file is part of FFmpeg. |
|
5 |
- * |
|
6 |
- * FFmpeg is free software; you can redistribute it and/or |
|
7 |
- * modify it under the terms of the GNU Lesser General Public |
|
8 |
- * License as published by the Free Software Foundation; either |
|
9 |
- * version 2.1 of the License, or (at your option) any later version. |
|
10 |
- * |
|
11 |
- * FFmpeg is distributed in the hope that it will be useful, |
|
12 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
- * Lesser General Public License for more details. |
|
15 |
- * |
|
16 |
- * You should have received a copy of the GNU Lesser General Public |
|
17 |
- * License along with FFmpeg; if not, write to the Free Software |
|
18 |
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
- */ |
|
20 |
- |
|
21 |
-#include "config.h" |
|
22 |
-#include "libavutil/attributes.h" |
|
23 |
-#include "aacpsdsp.h" |
|
24 |
- |
|
25 |
-static void ps_add_squares_c(float *dst, const float (*src)[2], int n) |
|
26 |
-{ |
|
27 |
- int i; |
|
28 |
- for (i = 0; i < n; i++) |
|
29 |
- dst[i] += src[i][0] * src[i][0] + src[i][1] * src[i][1]; |
|
30 |
-} |
|
31 |
- |
|
32 |
-static void ps_mul_pair_single_c(float (*dst)[2], float (*src0)[2], float *src1, |
|
33 |
- int n) |
|
34 |
-{ |
|
35 |
- int i; |
|
36 |
- for (i = 0; i < n; i++) { |
|
37 |
- dst[i][0] = src0[i][0] * src1[i]; |
|
38 |
- dst[i][1] = src0[i][1] * src1[i]; |
|
39 |
- } |
|
40 |
-} |
|
41 |
- |
|
42 |
-static void ps_hybrid_analysis_c(float (*out)[2], float (*in)[2], |
|
43 |
- const float (*filter)[8][2], |
|
44 |
- int stride, int n) |
|
45 |
-{ |
|
46 |
- int i, j; |
|
47 |
- |
|
48 |
- for (i = 0; i < n; i++) { |
|
49 |
- float sum_re = filter[i][6][0] * in[6][0]; |
|
50 |
- float sum_im = filter[i][6][0] * in[6][1]; |
|
51 |
- |
|
52 |
- for (j = 0; j < 6; j++) { |
|
53 |
- float in0_re = in[j][0]; |
|
54 |
- float in0_im = in[j][1]; |
|
55 |
- float in1_re = in[12-j][0]; |
|
56 |
- float in1_im = in[12-j][1]; |
|
57 |
- sum_re += filter[i][j][0] * (in0_re + in1_re) - |
|
58 |
- filter[i][j][1] * (in0_im - in1_im); |
|
59 |
- sum_im += filter[i][j][0] * (in0_im + in1_im) + |
|
60 |
- filter[i][j][1] * (in0_re - in1_re); |
|
61 |
- } |
|
62 |
- out[i * stride][0] = sum_re; |
|
63 |
- out[i * stride][1] = sum_im; |
|
64 |
- } |
|
65 |
-} |
|
66 |
- |
|
67 |
-static void ps_hybrid_analysis_ileave_c(float (*out)[32][2], float L[2][38][64], |
|
68 |
- int i, int len) |
|
69 |
-{ |
|
70 |
- int j; |
|
71 |
- |
|
72 |
- for (; i < 64; i++) { |
|
73 |
- for (j = 0; j < len; j++) { |
|
74 |
- out[i][j][0] = L[0][j][i]; |
|
75 |
- out[i][j][1] = L[1][j][i]; |
|
76 |
- } |
|
77 |
- } |
|
78 |
-} |
|
79 |
- |
|
80 |
-static void ps_hybrid_synthesis_deint_c(float out[2][38][64], |
|
81 |
- float (*in)[32][2], |
|
82 |
- int i, int len) |
|
83 |
-{ |
|
84 |
- int n; |
|
85 |
- |
|
86 |
- for (; i < 64; i++) { |
|
87 |
- for (n = 0; n < len; n++) { |
|
88 |
- out[0][n][i] = in[i][n][0]; |
|
89 |
- out[1][n][i] = in[i][n][1]; |
|
90 |
- } |
|
91 |
- } |
|
92 |
-} |
|
93 |
- |
|
94 |
-static void ps_decorrelate_c(float (*out)[2], float (*delay)[2], |
|
95 |
- float (*ap_delay)[PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2], |
|
96 |
- const float phi_fract[2], const float (*Q_fract)[2], |
|
97 |
- const float *transient_gain, |
|
98 |
- float g_decay_slope, |
|
99 |
- int len) |
|
100 |
-{ |
|
101 |
- static const float a[] = { 0.65143905753106f, |
|
102 |
- 0.56471812200776f, |
|
103 |
- 0.48954165955695f }; |
|
104 |
- float ag[PS_AP_LINKS]; |
|
105 |
- int m, n; |
|
106 |
- |
|
107 |
- for (m = 0; m < PS_AP_LINKS; m++) |
|
108 |
- ag[m] = a[m] * g_decay_slope; |
|
109 |
- |
|
110 |
- for (n = 0; n < len; n++) { |
|
111 |
- float in_re = delay[n][0] * phi_fract[0] - delay[n][1] * phi_fract[1]; |
|
112 |
- float in_im = delay[n][0] * phi_fract[1] + delay[n][1] * phi_fract[0]; |
|
113 |
- for (m = 0; m < PS_AP_LINKS; m++) { |
|
114 |
- float a_re = ag[m] * in_re; |
|
115 |
- float a_im = ag[m] * in_im; |
|
116 |
- float link_delay_re = ap_delay[m][n+2-m][0]; |
|
117 |
- float link_delay_im = ap_delay[m][n+2-m][1]; |
|
118 |
- float fractional_delay_re = Q_fract[m][0]; |
|
119 |
- float fractional_delay_im = Q_fract[m][1]; |
|
120 |
- float apd_re = in_re; |
|
121 |
- float apd_im = in_im; |
|
122 |
- in_re = link_delay_re * fractional_delay_re - |
|
123 |
- link_delay_im * fractional_delay_im - a_re; |
|
124 |
- in_im = link_delay_re * fractional_delay_im + |
|
125 |
- link_delay_im * fractional_delay_re - a_im; |
|
126 |
- ap_delay[m][n+5][0] = apd_re + ag[m] * in_re; |
|
127 |
- ap_delay[m][n+5][1] = apd_im + ag[m] * in_im; |
|
128 |
- } |
|
129 |
- out[n][0] = transient_gain[n] * in_re; |
|
130 |
- out[n][1] = transient_gain[n] * in_im; |
|
131 |
- } |
|
132 |
-} |
|
133 |
- |
|
134 |
-static void ps_stereo_interpolate_c(float (*l)[2], float (*r)[2], |
|
135 |
- float h[2][4], float h_step[2][4], |
|
136 |
- int len) |
|
137 |
-{ |
|
138 |
- float h0 = h[0][0]; |
|
139 |
- float h1 = h[0][1]; |
|
140 |
- float h2 = h[0][2]; |
|
141 |
- float h3 = h[0][3]; |
|
142 |
- float hs0 = h_step[0][0]; |
|
143 |
- float hs1 = h_step[0][1]; |
|
144 |
- float hs2 = h_step[0][2]; |
|
145 |
- float hs3 = h_step[0][3]; |
|
146 |
- int n; |
|
147 |
- |
|
148 |
- for (n = 0; n < len; n++) { |
|
149 |
- //l is s, r is d |
|
150 |
- float l_re = l[n][0]; |
|
151 |
- float l_im = l[n][1]; |
|
152 |
- float r_re = r[n][0]; |
|
153 |
- float r_im = r[n][1]; |
|
154 |
- h0 += hs0; |
|
155 |
- h1 += hs1; |
|
156 |
- h2 += hs2; |
|
157 |
- h3 += hs3; |
|
158 |
- l[n][0] = h0 * l_re + h2 * r_re; |
|
159 |
- l[n][1] = h0 * l_im + h2 * r_im; |
|
160 |
- r[n][0] = h1 * l_re + h3 * r_re; |
|
161 |
- r[n][1] = h1 * l_im + h3 * r_im; |
|
162 |
- } |
|
163 |
-} |
|
164 |
- |
|
165 |
-static void ps_stereo_interpolate_ipdopd_c(float (*l)[2], float (*r)[2], |
|
166 |
- float h[2][4], float h_step[2][4], |
|
167 |
- int len) |
|
168 |
-{ |
|
169 |
- float h00 = h[0][0], h10 = h[1][0]; |
|
170 |
- float h01 = h[0][1], h11 = h[1][1]; |
|
171 |
- float h02 = h[0][2], h12 = h[1][2]; |
|
172 |
- float h03 = h[0][3], h13 = h[1][3]; |
|
173 |
- float hs00 = h_step[0][0], hs10 = h_step[1][0]; |
|
174 |
- float hs01 = h_step[0][1], hs11 = h_step[1][1]; |
|
175 |
- float hs02 = h_step[0][2], hs12 = h_step[1][2]; |
|
176 |
- float hs03 = h_step[0][3], hs13 = h_step[1][3]; |
|
177 |
- int n; |
|
178 |
- |
|
179 |
- for (n = 0; n < len; n++) { |
|
180 |
- //l is s, r is d |
|
181 |
- float l_re = l[n][0]; |
|
182 |
- float l_im = l[n][1]; |
|
183 |
- float r_re = r[n][0]; |
|
184 |
- float r_im = r[n][1]; |
|
185 |
- h00 += hs00; |
|
186 |
- h01 += hs01; |
|
187 |
- h02 += hs02; |
|
188 |
- h03 += hs03; |
|
189 |
- h10 += hs10; |
|
190 |
- h11 += hs11; |
|
191 |
- h12 += hs12; |
|
192 |
- h13 += hs13; |
|
193 |
- |
|
194 |
- l[n][0] = h00 * l_re + h02 * r_re - h10 * l_im - h12 * r_im; |
|
195 |
- l[n][1] = h00 * l_im + h02 * r_im + h10 * l_re + h12 * r_re; |
|
196 |
- r[n][0] = h01 * l_re + h03 * r_re - h11 * l_im - h13 * r_im; |
|
197 |
- r[n][1] = h01 * l_im + h03 * r_im + h11 * l_re + h13 * r_re; |
|
198 |
- } |
|
199 |
-} |
|
200 |
- |
|
201 |
-av_cold void ff_psdsp_init(PSDSPContext *s) |
|
202 |
-{ |
|
203 |
- s->add_squares = ps_add_squares_c; |
|
204 |
- s->mul_pair_single = ps_mul_pair_single_c; |
|
205 |
- s->hybrid_analysis = ps_hybrid_analysis_c; |
|
206 |
- s->hybrid_analysis_ileave = ps_hybrid_analysis_ileave_c; |
|
207 |
- s->hybrid_synthesis_deint = ps_hybrid_synthesis_deint_c; |
|
208 |
- s->decorrelate = ps_decorrelate_c; |
|
209 |
- s->stereo_interpolate[0] = ps_stereo_interpolate_c; |
|
210 |
- s->stereo_interpolate[1] = ps_stereo_interpolate_ipdopd_c; |
|
211 |
- |
|
212 |
- if (ARCH_ARM) |
|
213 |
- ff_psdsp_init_arm(s); |
|
214 |
- if (ARCH_MIPS) |
|
215 |
- ff_psdsp_init_mips(s); |
|
216 |
-} |
... | ... |
@@ -21,33 +21,35 @@ |
21 | 21 |
#ifndef LIBAVCODEC_AACPSDSP_H |
22 | 22 |
#define LIBAVCODEC_AACPSDSP_H |
23 | 23 |
|
24 |
+#include "aac_defines.h" |
|
25 |
+ |
|
24 | 26 |
#define PS_QMF_TIME_SLOTS 32 |
25 | 27 |
#define PS_AP_LINKS 3 |
26 | 28 |
#define PS_MAX_AP_DELAY 5 |
27 | 29 |
|
28 | 30 |
typedef struct PSDSPContext { |
29 |
- void (*add_squares)(float *dst, const float (*src)[2], int n); |
|
30 |
- void (*mul_pair_single)(float (*dst)[2], float (*src0)[2], float *src1, |
|
31 |
+ void (*add_squares)(INTFLOAT *dst, const INTFLOAT (*src)[2], int n); |
|
32 |
+ void (*mul_pair_single)(INTFLOAT (*dst)[2], INTFLOAT (*src0)[2], INTFLOAT *src1, |
|
31 | 33 |
int n); |
32 |
- void (*hybrid_analysis)(float (*out)[2], float (*in)[2], |
|
33 |
- const float (*filter)[8][2], |
|
34 |
+ void (*hybrid_analysis)(INTFLOAT (*out)[2], INTFLOAT (*in)[2], |
|
35 |
+ const INTFLOAT (*filter)[8][2], |
|
34 | 36 |
int stride, int n); |
35 |
- void (*hybrid_analysis_ileave)(float (*out)[32][2], float L[2][38][64], |
|
37 |
+ void (*hybrid_analysis_ileave)(INTFLOAT (*out)[32][2], INTFLOAT L[2][38][64], |
|
36 | 38 |
int i, int len); |
37 |
- void (*hybrid_synthesis_deint)(float out[2][38][64], float (*in)[32][2], |
|
39 |
+ void (*hybrid_synthesis_deint)(INTFLOAT out[2][38][64], INTFLOAT (*in)[32][2], |
|
38 | 40 |
int i, int len); |
39 |
- void (*decorrelate)(float (*out)[2], float (*delay)[2], |
|
40 |
- float (*ap_delay)[PS_QMF_TIME_SLOTS+PS_MAX_AP_DELAY][2], |
|
41 |
- const float phi_fract[2], const float (*Q_fract)[2], |
|
42 |
- const float *transient_gain, |
|
43 |
- float g_decay_slope, |
|
41 |
+ void (*decorrelate)(INTFLOAT (*out)[2], INTFLOAT (*delay)[2], |
|
42 |
+ INTFLOAT (*ap_delay)[PS_QMF_TIME_SLOTS+PS_MAX_AP_DELAY][2], |
|
43 |
+ const INTFLOAT phi_fract[2], const INTFLOAT (*Q_fract)[2], |
|
44 |
+ const INTFLOAT *transient_gain, |
|
45 |
+ INTFLOAT g_decay_slope, |
|
44 | 46 |
int len); |
45 |
- void (*stereo_interpolate[2])(float (*l)[2], float (*r)[2], |
|
46 |
- float h[2][4], float h_step[2][4], |
|
47 |
+ void (*stereo_interpolate[2])(INTFLOAT (*l)[2], INTFLOAT (*r)[2], |
|
48 |
+ INTFLOAT h[2][4], INTFLOAT h_step[2][4], |
|
47 | 49 |
int len); |
48 | 50 |
} PSDSPContext; |
49 | 51 |
|
50 |
-void ff_psdsp_init(PSDSPContext *s); |
|
52 |
+void AAC_RENAME(ff_psdsp_init)(PSDSPContext *s); |
|
51 | 53 |
void ff_psdsp_init_arm(PSDSPContext *s); |
52 | 54 |
void ff_psdsp_init_mips(PSDSPContext *s); |
53 | 55 |
|
54 | 56 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,23 @@ |
0 |
+/* |
|
1 |
+ * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> |
|
2 |
+ * |
|
3 |
+ * This file is part of FFmpeg. |
|
4 |
+ * |
|
5 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
6 |
+ * modify it under the terms of the GNU Lesser General Public |
|
7 |
+ * License as published by the Free Software Foundation; either |
|
8 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
9 |
+ * |
|
10 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
11 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 |
+ * Lesser General Public License for more details. |
|
14 |
+ * |
|
15 |
+ * You should have received a copy of the GNU Lesser General Public |
|
16 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
17 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
18 |
+ */ |
|
19 |
+ |
|
20 |
+#define USE_FIXED 1 |
|
21 |
+ |
|
22 |
+#include "aacpsdsp_template.c" |
0 | 23 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,23 @@ |
0 |
+/* |
|
1 |
+ * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> |
|
2 |
+ * |
|
3 |
+ * This file is part of FFmpeg. |
|
4 |
+ * |
|
5 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
6 |
+ * modify it under the terms of the GNU Lesser General Public |
|
7 |
+ * License as published by the Free Software Foundation; either |
|
8 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
9 |
+ * |
|
10 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
11 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 |
+ * Lesser General Public License for more details. |
|
14 |
+ * |
|
15 |
+ * You should have received a copy of the GNU Lesser General Public |
|
16 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
17 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
18 |
+ */ |
|
19 |
+ |
|
20 |
+#define USE_FIXED 0 |
|
21 |
+ |
|
22 |
+#include "aacpsdsp_template.c" |
0 | 23 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,228 @@ |
0 |
+/* |
|
1 |
+ * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> |
|
2 |
+ * |
|
3 |
+ * This file is part of FFmpeg. |
|
4 |
+ * |
|
5 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
6 |
+ * modify it under the terms of the GNU Lesser General Public |
|
7 |
+ * License as published by the Free Software Foundation; either |
|
8 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
9 |
+ * |
|
10 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
11 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 |
+ * Lesser General Public License for more details. |
|
14 |
+ * |
|
15 |
+ * You should have received a copy of the GNU Lesser General Public |
|
16 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
17 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
18 |
+ * |
|
19 |
+ * Note: Rounding-to-nearest used unless otherwise stated |
|
20 |
+ * |
|
21 |
+ */ |
|
22 |
+#include <stdint.h> |
|
23 |
+ |
|
24 |
+#include "config.h" |
|
25 |
+#include "libavutil/attributes.h" |
|
26 |
+#include "aacpsdsp.h" |
|
27 |
+ |
|
28 |
+static void ps_add_squares_c(INTFLOAT *dst, const INTFLOAT (*src)[2], int n) |
|
29 |
+{ |
|
30 |
+ int i; |
|
31 |
+ for (i = 0; i < n; i++) |
|
32 |
+ dst[i] += AAC_MADD28(src[i][0], src[i][0], src[i][1], src[i][1]); |
|
33 |
+} |
|
34 |
+ |
|
35 |
+static void ps_mul_pair_single_c(INTFLOAT (*dst)[2], INTFLOAT (*src0)[2], INTFLOAT *src1, |
|
36 |
+ int n) |
|
37 |
+{ |
|
38 |
+ int i; |
|
39 |
+ for (i = 0; i < n; i++) { |
|
40 |
+ dst[i][0] = AAC_MUL16(src0[i][0], src1[i]); |
|
41 |
+ dst[i][1] = AAC_MUL16(src0[i][1], src1[i]); |
|
42 |
+ } |
|
43 |
+} |
|
44 |
+ |
|
45 |
+static void ps_hybrid_analysis_c(INTFLOAT (*out)[2], INTFLOAT (*in)[2], |
|
46 |
+ const INTFLOAT (*filter)[8][2], |
|
47 |
+ int stride, int n) |
|
48 |
+{ |
|
49 |
+ int i, j; |
|
50 |
+ |
|
51 |
+ for (i = 0; i < n; i++) { |
|
52 |
+ INT64FLOAT sum_re = (INT64FLOAT)filter[i][6][0] * in[6][0]; |
|
53 |
+ INT64FLOAT sum_im = (INT64FLOAT)filter[i][6][0] * in[6][1]; |
|
54 |
+ |
|
55 |
+ for (j = 0; j < 6; j++) { |
|
56 |
+ INTFLOAT in0_re = in[j][0]; |
|
57 |
+ INTFLOAT in0_im = in[j][1]; |
|
58 |
+ INTFLOAT in1_re = in[12-j][0]; |
|
59 |
+ INTFLOAT in1_im = in[12-j][1]; |
|
60 |
+ sum_re += (INT64FLOAT)filter[i][j][0] * (in0_re + in1_re) - |
|
61 |
+ (INT64FLOAT)filter[i][j][1] * (in0_im - in1_im); |
|
62 |
+ sum_im += (INT64FLOAT)filter[i][j][0] * (in0_im + in1_im) + |
|
63 |
+ (INT64FLOAT)filter[i][j][1] * (in0_re - in1_re); |
|
64 |
+ } |
|
65 |
+#if USE_FIXED |
|
66 |
+ out[i * stride][0] = (int)((sum_re + 0x40000000) >> 31); |
|
67 |
+ out[i * stride][1] = (int)((sum_im + 0x40000000) >> 31); |
|
68 |
+#else |
|
69 |
+ out[i * stride][0] = sum_re; |
|
70 |
+ out[i * stride][1] = sum_im; |
|
71 |
+#endif /* USE_FIXED */ |
|
72 |
+ } |
|
73 |
+} |
|
74 |
+static void ps_hybrid_analysis_ileave_c(INTFLOAT (*out)[32][2], INTFLOAT L[2][38][64], |
|
75 |
+ int i, int len) |
|
76 |
+{ |
|
77 |
+ int j; |
|
78 |
+ |
|
79 |
+ for (; i < 64; i++) { |
|
80 |
+ for (j = 0; j < len; j++) { |
|
81 |
+ out[i][j][0] = L[0][j][i]; |
|
82 |
+ out[i][j][1] = L[1][j][i]; |
|
83 |
+ } |
|
84 |
+ } |
|
85 |
+} |
|
86 |
+ |
|
87 |
+static void ps_hybrid_synthesis_deint_c(INTFLOAT out[2][38][64], |
|
88 |
+ INTFLOAT (*in)[32][2], |
|
89 |
+ int i, int len) |
|
90 |
+{ |
|
91 |
+ int n; |
|
92 |
+ |
|
93 |
+ for (; i < 64; i++) { |
|
94 |
+ for (n = 0; n < len; n++) { |
|
95 |
+ out[0][n][i] = in[i][n][0]; |
|
96 |
+ out[1][n][i] = in[i][n][1]; |
|
97 |
+ } |
|
98 |
+ } |
|
99 |
+} |
|
100 |
+ |
|
101 |
+static void ps_decorrelate_c(INTFLOAT (*out)[2], INTFLOAT (*delay)[2], |
|
102 |
+ INTFLOAT (*ap_delay)[PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2], |
|
103 |
+ const INTFLOAT phi_fract[2], const INTFLOAT (*Q_fract)[2], |
|
104 |
+ const INTFLOAT *transient_gain, |
|
105 |
+ INTFLOAT g_decay_slope, |
|
106 |
+ int len) |
|
107 |
+{ |
|
108 |
+ static const INTFLOAT a[] = { Q31(0.65143905753106f), |
|
109 |
+ Q31(0.56471812200776f), |
|
110 |
+ Q31(0.48954165955695f) }; |
|
111 |
+ INTFLOAT ag[PS_AP_LINKS]; |
|
112 |
+ int m, n; |
|
113 |
+ |
|
114 |
+ for (m = 0; m < PS_AP_LINKS; m++) |
|
115 |
+ ag[m] = AAC_MUL30(a[m], g_decay_slope); |
|
116 |
+ |
|
117 |
+ for (n = 0; n < len; n++) { |
|
118 |
+ INTFLOAT in_re = AAC_MSUB30(delay[n][0], phi_fract[0], delay[n][1], phi_fract[1]); |
|
119 |
+ INTFLOAT in_im = AAC_MADD30(delay[n][0], phi_fract[1], delay[n][1], phi_fract[0]); |
|
120 |
+ for (m = 0; m < PS_AP_LINKS; m++) { |
|
121 |
+ INTFLOAT a_re = AAC_MUL31(ag[m], in_re); |
|
122 |
+ INTFLOAT a_im = AAC_MUL31(ag[m], in_im); |
|
123 |
+ INTFLOAT link_delay_re = ap_delay[m][n+2-m][0]; |
|
124 |
+ INTFLOAT link_delay_im = ap_delay[m][n+2-m][1]; |
|
125 |
+ INTFLOAT fractional_delay_re = Q_fract[m][0]; |
|
126 |
+ INTFLOAT fractional_delay_im = Q_fract[m][1]; |
|
127 |
+ INTFLOAT apd_re = in_re; |
|
128 |
+ INTFLOAT apd_im = in_im; |
|
129 |
+ in_re = AAC_MSUB30(link_delay_re, fractional_delay_re, |
|
130 |
+ link_delay_im, fractional_delay_im); |
|
131 |
+ in_re -= a_re; |
|
132 |
+ in_im = AAC_MADD30(link_delay_re, fractional_delay_im, |
|
133 |
+ link_delay_im, fractional_delay_re); |
|
134 |
+ in_im -= a_im; |
|
135 |
+ ap_delay[m][n+5][0] = apd_re + AAC_MUL31(ag[m], in_re); |
|
136 |
+ ap_delay[m][n+5][1] = apd_im + AAC_MUL31(ag[m], in_im); |
|
137 |
+ } |
|
138 |
+ out[n][0] = AAC_MUL16(transient_gain[n], in_re); |
|
139 |
+ out[n][1] = AAC_MUL16(transient_gain[n], in_im); |
|
140 |
+ } |
|
141 |
+} |
|
142 |
+ |
|
143 |
+static void ps_stereo_interpolate_c(INTFLOAT (*l)[2], INTFLOAT (*r)[2], |
|
144 |
+ INTFLOAT h[2][4], INTFLOAT h_step[2][4], |
|
145 |
+ int len) |
|
146 |
+{ |
|
147 |
+ INTFLOAT h0 = h[0][0]; |
|
148 |
+ INTFLOAT h1 = h[0][1]; |
|
149 |
+ INTFLOAT h2 = h[0][2]; |
|
150 |
+ INTFLOAT h3 = h[0][3]; |
|
151 |
+ INTFLOAT hs0 = h_step[0][0]; |
|
152 |
+ INTFLOAT hs1 = h_step[0][1]; |
|
153 |
+ INTFLOAT hs2 = h_step[0][2]; |
|
154 |
+ INTFLOAT hs3 = h_step[0][3]; |
|
155 |
+ int n; |
|
156 |
+ |
|
157 |
+ for (n = 0; n < len; n++) { |
|
158 |
+ //l is s, r is d |
|
159 |
+ INTFLOAT l_re = l[n][0]; |
|
160 |
+ INTFLOAT l_im = l[n][1]; |
|
161 |
+ INTFLOAT r_re = r[n][0]; |
|
162 |
+ INTFLOAT r_im = r[n][1]; |
|
163 |
+ h0 += hs0; |
|
164 |
+ h1 += hs1; |
|
165 |
+ h2 += hs2; |
|
166 |
+ h3 += hs3; |
|
167 |
+ l[n][0] = AAC_MADD30(h0, l_re, h2, r_re); |
|
168 |
+ l[n][1] = AAC_MADD30(h0, l_im, h2, r_im); |
|
169 |
+ r[n][0] = AAC_MADD30(h1, l_re, h3, r_re); |
|
170 |
+ r[n][1] = AAC_MADD30(h1, l_im, h3, r_im); |
|
171 |
+ } |
|
172 |
+} |
|
173 |
+ |
|
174 |
+static void ps_stereo_interpolate_ipdopd_c(INTFLOAT (*l)[2], INTFLOAT (*r)[2], |
|
175 |
+ INTFLOAT h[2][4], INTFLOAT h_step[2][4], |
|
176 |
+ int len) |
|
177 |
+{ |
|
178 |
+ INTFLOAT h00 = h[0][0], h10 = h[1][0]; |
|
179 |
+ INTFLOAT h01 = h[0][1], h11 = h[1][1]; |
|
180 |
+ INTFLOAT h02 = h[0][2], h12 = h[1][2]; |
|
181 |
+ INTFLOAT h03 = h[0][3], h13 = h[1][3]; |
|
182 |
+ INTFLOAT hs00 = h_step[0][0], hs10 = h_step[1][0]; |
|
183 |
+ INTFLOAT hs01 = h_step[0][1], hs11 = h_step[1][1]; |
|
184 |
+ INTFLOAT hs02 = h_step[0][2], hs12 = h_step[1][2]; |
|
185 |
+ INTFLOAT hs03 = h_step[0][3], hs13 = h_step[1][3]; |
|
186 |
+ int n; |
|
187 |
+ |
|
188 |
+ for (n = 0; n < len; n++) { |
|
189 |
+ //l is s, r is d |
|
190 |
+ INTFLOAT l_re = l[n][0]; |
|
191 |
+ INTFLOAT l_im = l[n][1]; |
|
192 |
+ INTFLOAT r_re = r[n][0]; |
|
193 |
+ INTFLOAT r_im = r[n][1]; |
|
194 |
+ h00 += hs00; |
|
195 |
+ h01 += hs01; |
|
196 |
+ h02 += hs02; |
|
197 |
+ h03 += hs03; |
|
198 |
+ h10 += hs10; |
|
199 |
+ h11 += hs11; |
|
200 |
+ h12 += hs12; |
|
201 |
+ h13 += hs13; |
|
202 |
+ |
|
203 |
+ l[n][0] = AAC_MSUB30_V8(h00, l_re, h02, r_re, h10, l_im, h12, r_im); |
|
204 |
+ l[n][1] = AAC_MADD30_V8(h00, l_im, h02, r_im, h10, l_re, h12, r_re); |
|
205 |
+ r[n][0] = AAC_MSUB30_V8(h01, l_re, h03, r_re, h11, l_im, h13, r_im); |
|
206 |
+ r[n][1] = AAC_MADD30_V8(h01, l_im, h03, r_im, h11, l_re, h13, r_re); |
|
207 |
+ } |
|
208 |
+} |
|
209 |
+ |
|
210 |
+av_cold void AAC_RENAME(ff_psdsp_init)(PSDSPContext *s) |
|
211 |
+{ |
|
212 |
+ s->add_squares = ps_add_squares_c; |
|
213 |
+ s->mul_pair_single = ps_mul_pair_single_c; |
|
214 |
+ s->hybrid_analysis = ps_hybrid_analysis_c; |
|
215 |
+ s->hybrid_analysis_ileave = ps_hybrid_analysis_ileave_c; |
|
216 |
+ s->hybrid_synthesis_deint = ps_hybrid_synthesis_deint_c; |
|
217 |
+ s->decorrelate = ps_decorrelate_c; |
|
218 |
+ s->stereo_interpolate[0] = ps_stereo_interpolate_c; |
|
219 |
+ s->stereo_interpolate[1] = ps_stereo_interpolate_ipdopd_c; |
|
220 |
+ |
|
221 |
+#if !USE_FIXED |
|
222 |
+ if (ARCH_ARM) |
|
223 |
+ ff_psdsp_init_arm(s); |
|
224 |
+ if (ARCH_MIPS) |
|
225 |
+ ff_psdsp_init_mips(s); |
|
226 |
+#endif /* !USE_FIXED */ |
|
227 |
+} |
... | ... |
@@ -64,7 +64,7 @@ av_cold void AAC_RENAME(ff_aac_sbr_init)(void) |
64 | 64 |
|
65 | 65 |
aacsbr_tableinit(); |
66 | 66 |
|
67 |
- ff_ps_init(); |
|
67 |
+ AAC_RENAME(ff_ps_init)(); |
|
68 | 68 |
} |
69 | 69 |
|
70 | 70 |
/** Places SBR in pure upsampling mode. */ |
... | ... |
@@ -91,7 +91,7 @@ av_cold void AAC_RENAME(ff_aac_sbr_ctx_init)(AACContext *ac, SpectralBandReplica |
91 | 91 |
* and scale back down at synthesis. */ |
92 | 92 |
AAC_RENAME_32(ff_mdct_init)(&sbr->mdct, 7, 1, 1.0 / (64 * 32768.0)); |
93 | 93 |
AAC_RENAME_32(ff_mdct_init)(&sbr->mdct_ana, 7, 1, -2.0 * 32768.0); |
94 |
- ff_ps_ctx_init(&sbr->ps); |
|
94 |
+ AAC_RENAME(ff_ps_ctx_init)(&sbr->ps); |
|
95 | 95 |
AAC_RENAME(ff_sbrdsp_init)(&sbr->dsp); |
96 | 96 |
aacsbr_func_ptr_init(&sbr->c); |
97 | 97 |
} |
... | ... |
@@ -945,7 +945,7 @@ static void read_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, |
945 | 945 |
*num_bits_left = 0; |
946 | 946 |
} else { |
947 | 947 |
#if 1 |
948 |
- *num_bits_left -= ff_ps_read_data(ac->avctx, gb, &sbr->ps, *num_bits_left); |
|
948 |
+ *num_bits_left -= AAC_RENAME(ff_ps_read_data)(ac->avctx, gb, &sbr->ps, *num_bits_left); |
|
949 | 949 |
ac->avctx->profile = FF_PROFILE_AAC_HE_V2; |
950 | 950 |
#else |
951 | 951 |
avpriv_report_missing_feature(ac->avctx, "Parametric Stereo"); |
... | ... |
@@ -1501,7 +1501,7 @@ void AAC_RENAME(ff_sbr_apply)(AACContext *ac, SpectralBandReplication *sbr, int |
1501 | 1501 |
|
1502 | 1502 |
if (ac->oc[1].m4ac.ps == 1) { |
1503 | 1503 |
if (sbr->ps.start) { |
1504 |
- ff_ps_apply(ac->avctx, &sbr->ps, sbr->X[0], sbr->X[1], sbr->kx[1] + sbr->m[1]); |
|
1504 |
+ AAC_RENAME(ff_ps_apply)(ac->avctx, &sbr->ps, sbr->X[0], sbr->X[1], sbr->kx[1] + sbr->m[1]); |
|
1505 | 1505 |
} else { |
1506 | 1506 |
memcpy(sbr->X[1], sbr->X[0], sizeof(sbr->X[0])); |
1507 | 1507 |
} |