2 synth_s32.c: The functions for synthesizing real (float) samples, at the end of decoding.
4 copyright 1995-2008 by the mpg123 project - free software under the terms of the LGPL 2.1
5 see COPYING and AUTHORS files in distribution or http://mpg123.org
6 initially written by Michael Hipp, heavily dissected and rearranged by Thomas Orgis
9 #include "mpg123lib_intern.h"
14 #error "Do not build this file with fixed point math!"
17 Part 4: All synth functions that produce signed 32 bit output.
18 What we need is just a special WRITE_SAMPLE.
21 #define SAMPLE_T int32_t
22 #define WRITE_SAMPLE(samples,sum,clip) WRITE_S32_SAMPLE(samples,sum,clip)
24 /* Part 4a: All straight 1to1 decoding functions */
25 #define BLOCK 0x40 /* One decoding block is 64 samples. */
27 #define SYNTH_NAME INT123_synth_1to1_s32
31 /* Mono-related synths; they wrap over _some_ INT123_synth_1to1_s32 (could be generic, could be i386). */
32 #define SYNTH_NAME fr->synths.plain[r_1to1][f_32]
33 #define MONO_NAME INT123_synth_1to1_s32_mono
34 #define MONO2STEREO_NAME INT123_synth_1to1_s32_m2s
35 #include "synth_mono.h"
38 #undef MONO2STEREO_NAME
41 #define NO_AUTOINCREMENT
42 #define SYNTH_NAME INT123_synth_1to1_s32_i386
45 /* i386 uses the normal mono functions. */
46 #undef NO_AUTOINCREMENT
50 /* Assembler routines. */
51 int INT123_synth_1to1_s32_x86_64_asm(real
*window
, real
*b0
, int32_t *samples
, int bo1
);
52 int INT123_synth_1to1_s32_s_x86_64_asm(real
*window
, real
*b0l
, real
*b0r
, int32_t *samples
, int bo1
);
53 void INT123_dct64_real_x86_64(real
*out0
, real
*out1
, real
*samples
);
54 /* Hull for C mpg123 API */
55 int INT123_synth_1to1_s32_x86_64(real
*bandPtr
,int channel
, mpg123_handle
*fr
, int final
)
57 int32_t *samples
= (int32_t *) (fr
->buffer
.data
+fr
->buffer
.fill
);
63 if(fr
->have_eq_settings
) INT123_do_equalizer(bandPtr
,channel
,fr
->equalizer
);
69 buf
= fr
->real_buffs
[0];
74 buf
= fr
->real_buffs
[1];
81 INT123_dct64_real_x86_64(buf
[1]+((fr
->bo
+1)&0xf),buf
[0]+fr
->bo
,bandPtr
);
87 INT123_dct64_real_x86_64(buf
[0]+fr
->bo
,buf
[1]+fr
->bo
+1,bandPtr
);
90 clip
= INT123_synth_1to1_s32_x86_64_asm(fr
->decwin
, b0
, samples
, bo1
);
92 if(final
) fr
->buffer
.fill
+= 256;
98 int INT123_synth_1to1_s32_stereo_x86_64(real
*bandPtr_l
, real
*bandPtr_r
, mpg123_handle
*fr
)
100 int32_t *samples
= (int32_t *) (fr
->buffer
.data
+fr
->buffer
.fill
);
102 real
*b0l
, *b0r
, **bufl
, **bufr
;
106 if(fr
->have_eq_settings
)
108 INT123_do_equalizer(bandPtr_l
,0,fr
->equalizer
);
109 INT123_do_equalizer(bandPtr_r
,1,fr
->equalizer
);
114 bufl
= fr
->real_buffs
[0];
115 bufr
= fr
->real_buffs
[1];
122 INT123_dct64_real_x86_64(bufl
[1]+((fr
->bo
+1)&0xf),bufl
[0]+fr
->bo
,bandPtr_l
);
123 INT123_dct64_real_x86_64(bufr
[1]+((fr
->bo
+1)&0xf),bufr
[0]+fr
->bo
,bandPtr_r
);
130 INT123_dct64_real_x86_64(bufl
[0]+fr
->bo
,bufl
[1]+fr
->bo
+1,bandPtr_l
);
131 INT123_dct64_real_x86_64(bufr
[0]+fr
->bo
,bufr
[1]+fr
->bo
+1,bandPtr_r
);
134 clip
= INT123_synth_1to1_s32_s_x86_64_asm(fr
->decwin
, b0l
, b0r
, samples
, bo1
);
136 fr
->buffer
.fill
+= 256;
143 /* Assembler routines. */
145 int INT123_synth_1to1_s32_x86_64_asm(real
*window
, real
*b0
, int32_t *samples
, int bo1
);
147 int INT123_synth_1to1_s32_s_avx_asm(real
*window
, real
*b0l
, real
*b0r
, int32_t *samples
, int bo1
);
148 void INT123_dct64_real_avx(real
*out0
, real
*out1
, real
*samples
);
149 /* Hull for C mpg123 API */
150 int INT123_synth_1to1_s32_avx(real
*bandPtr
,int channel
, mpg123_handle
*fr
, int final
)
152 int32_t *samples
= (int32_t *) (fr
->buffer
.data
+fr
->buffer
.fill
);
158 if(fr
->have_eq_settings
) INT123_do_equalizer(bandPtr
,channel
,fr
->equalizer
);
164 buf
= fr
->real_buffs
[0];
169 buf
= fr
->real_buffs
[1];
176 INT123_dct64_real_avx(buf
[1]+((fr
->bo
+1)&0xf),buf
[0]+fr
->bo
,bandPtr
);
182 INT123_dct64_real_avx(buf
[0]+fr
->bo
,buf
[1]+fr
->bo
+1,bandPtr
);
185 clip
= INT123_synth_1to1_s32_x86_64_asm(fr
->decwin
, b0
, samples
, bo1
);
187 if(final
) fr
->buffer
.fill
+= 256;
193 int INT123_synth_1to1_s32_stereo_avx(real
*bandPtr_l
, real
*bandPtr_r
, mpg123_handle
*fr
)
195 int32_t *samples
= (int32_t *) (fr
->buffer
.data
+fr
->buffer
.fill
);
197 real
*b0l
, *b0r
, **bufl
, **bufr
;
201 if(fr
->have_eq_settings
)
203 INT123_do_equalizer(bandPtr_l
,0,fr
->equalizer
);
204 INT123_do_equalizer(bandPtr_r
,1,fr
->equalizer
);
209 bufl
= fr
->real_buffs
[0];
210 bufr
= fr
->real_buffs
[1];
217 INT123_dct64_real_avx(bufl
[1]+((fr
->bo
+1)&0xf),bufl
[0]+fr
->bo
,bandPtr_l
);
218 INT123_dct64_real_avx(bufr
[1]+((fr
->bo
+1)&0xf),bufr
[0]+fr
->bo
,bandPtr_r
);
225 INT123_dct64_real_avx(bufl
[0]+fr
->bo
,bufl
[1]+fr
->bo
+1,bandPtr_l
);
226 INT123_dct64_real_avx(bufr
[0]+fr
->bo
,bufr
[1]+fr
->bo
+1,bandPtr_r
);
229 clip
= INT123_synth_1to1_s32_s_avx_asm(fr
->decwin
, b0l
, b0r
, samples
, bo1
);
231 fr
->buffer
.fill
+= 256;
237 #if defined(OPT_SSE) || defined(OPT_SSE_VINTAGE)
238 /* Assembler routines. */
239 int INT123_synth_1to1_s32_sse_asm(real
*window
, real
*b0
, int32_t *samples
, int bo1
);
240 int INT123_synth_1to1_s32_s_sse_asm(real
*window
, real
*b0l
, real
*b0r
, int32_t *samples
, int bo1
);
241 void INT123_dct64_real_sse(real
*out0
, real
*out1
, real
*samples
);
242 /* Hull for C mpg123 API */
243 int INT123_synth_1to1_s32_sse(real
*bandPtr
,int channel
, mpg123_handle
*fr
, int final
)
245 int32_t *samples
= (int32_t *) (fr
->buffer
.data
+fr
->buffer
.fill
);
251 if(fr
->have_eq_settings
) INT123_do_equalizer(bandPtr
,channel
,fr
->equalizer
);
257 buf
= fr
->real_buffs
[0];
262 buf
= fr
->real_buffs
[1];
269 INT123_dct64_real_sse(buf
[1]+((fr
->bo
+1)&0xf),buf
[0]+fr
->bo
,bandPtr
);
275 INT123_dct64_real_sse(buf
[0]+fr
->bo
,buf
[1]+fr
->bo
+1,bandPtr
);
278 clip
= INT123_synth_1to1_s32_sse_asm(fr
->decwin
, b0
, samples
, bo1
);
280 if(final
) fr
->buffer
.fill
+= 256;
286 int INT123_synth_1to1_s32_stereo_sse(real
*bandPtr_l
, real
*bandPtr_r
, mpg123_handle
*fr
)
288 int32_t *samples
= (int32_t *) (fr
->buffer
.data
+fr
->buffer
.fill
);
290 real
*b0l
, *b0r
, **bufl
, **bufr
;
294 if(fr
->have_eq_settings
)
296 INT123_do_equalizer(bandPtr_l
,0,fr
->equalizer
);
297 INT123_do_equalizer(bandPtr_r
,1,fr
->equalizer
);
302 bufl
= fr
->real_buffs
[0];
303 bufr
= fr
->real_buffs
[1];
310 INT123_dct64_real_sse(bufl
[1]+((fr
->bo
+1)&0xf),bufl
[0]+fr
->bo
,bandPtr_l
);
311 INT123_dct64_real_sse(bufr
[1]+((fr
->bo
+1)&0xf),bufr
[0]+fr
->bo
,bandPtr_r
);
318 INT123_dct64_real_sse(bufl
[0]+fr
->bo
,bufl
[1]+fr
->bo
+1,bandPtr_l
);
319 INT123_dct64_real_sse(bufr
[0]+fr
->bo
,bufr
[1]+fr
->bo
+1,bandPtr_r
);
322 clip
= INT123_synth_1to1_s32_s_sse_asm(fr
->decwin
, b0l
, b0r
, samples
, bo1
);
324 fr
->buffer
.fill
+= 256;
331 /* Assembler routines. */
332 int INT123_synth_1to1_s32_neon_asm(real
*window
, real
*b0
, int32_t *samples
, int bo1
);
333 int INT123_synth_1to1_s32_s_neon_asm(real
*window
, real
*b0l
, real
*b0r
, int32_t *samples
, int bo1
);
334 void INT123_dct64_real_neon(real
*out0
, real
*out1
, real
*samples
);
335 /* Hull for C mpg123 API */
336 int INT123_synth_1to1_s32_neon(real
*bandPtr
,int channel
, mpg123_handle
*fr
, int final
)
338 int32_t *samples
= (int32_t *) (fr
->buffer
.data
+fr
->buffer
.fill
);
344 if(fr
->have_eq_settings
) INT123_do_equalizer(bandPtr
,channel
,fr
->equalizer
);
350 buf
= fr
->real_buffs
[0];
355 buf
= fr
->real_buffs
[1];
362 INT123_dct64_real_neon(buf
[1]+((fr
->bo
+1)&0xf),buf
[0]+fr
->bo
,bandPtr
);
368 INT123_dct64_real_neon(buf
[0]+fr
->bo
,buf
[1]+fr
->bo
+1,bandPtr
);
371 clip
= INT123_synth_1to1_s32_neon_asm(fr
->decwin
, b0
, samples
, bo1
);
373 if(final
) fr
->buffer
.fill
+= 256;
378 int INT123_synth_1to1_s32_stereo_neon(real
*bandPtr_l
, real
*bandPtr_r
, mpg123_handle
*fr
)
380 int32_t *samples
= (int32_t *) (fr
->buffer
.data
+fr
->buffer
.fill
);
382 real
*b0l
, *b0r
, **bufl
, **bufr
;
386 if(fr
->have_eq_settings
)
388 INT123_do_equalizer(bandPtr_l
,0,fr
->equalizer
);
389 INT123_do_equalizer(bandPtr_r
,1,fr
->equalizer
);
394 bufl
= fr
->real_buffs
[0];
395 bufr
= fr
->real_buffs
[1];
402 INT123_dct64_real_neon(bufl
[1]+((fr
->bo
+1)&0xf),bufl
[0]+fr
->bo
,bandPtr_l
);
403 INT123_dct64_real_neon(bufr
[1]+((fr
->bo
+1)&0xf),bufr
[0]+fr
->bo
,bandPtr_r
);
410 INT123_dct64_real_neon(bufl
[0]+fr
->bo
,bufl
[1]+fr
->bo
+1,bandPtr_l
);
411 INT123_dct64_real_neon(bufr
[0]+fr
->bo
,bufr
[1]+fr
->bo
+1,bandPtr_r
);
414 clip
= INT123_synth_1to1_s32_s_neon_asm(fr
->decwin
, b0l
, b0r
, samples
, bo1
);
416 fr
->buffer
.fill
+= 256;
423 /* Assembler routines. */
424 int INT123_synth_1to1_s32_neon64_asm(real
*window
, real
*b0
, int32_t *samples
, int bo1
);
425 int INT123_synth_1to1_s32_s_neon64_asm(real
*window
, real
*b0l
, real
*b0r
, int32_t *samples
, int bo1
);
426 void INT123_dct64_real_neon64(real
*out0
, real
*out1
, real
*samples
);
427 /* Hull for C mpg123 API */
428 int INT123_synth_1to1_s32_neon64(real
*bandPtr
,int channel
, mpg123_handle
*fr
, int final
)
430 int32_t *samples
= (int32_t *) (fr
->buffer
.data
+fr
->buffer
.fill
);
436 if(fr
->have_eq_settings
) INT123_do_equalizer(bandPtr
,channel
,fr
->equalizer
);
442 buf
= fr
->real_buffs
[0];
447 buf
= fr
->real_buffs
[1];
454 INT123_dct64_real_neon64(buf
[1]+((fr
->bo
+1)&0xf),buf
[0]+fr
->bo
,bandPtr
);
460 INT123_dct64_real_neon64(buf
[0]+fr
->bo
,buf
[1]+fr
->bo
+1,bandPtr
);
463 clip
= INT123_synth_1to1_s32_neon64_asm(fr
->decwin
, b0
, samples
, bo1
);
465 if(final
) fr
->buffer
.fill
+= 256;
470 int INT123_synth_1to1_s32st_neon64(real
*bandPtr_l
, real
*bandPtr_r
, mpg123_handle
*fr
)
472 int32_t *samples
= (int32_t *) (fr
->buffer
.data
+fr
->buffer
.fill
);
474 real
*b0l
, *b0r
, **bufl
, **bufr
;
478 if(fr
->have_eq_settings
)
480 INT123_do_equalizer(bandPtr_l
,0,fr
->equalizer
);
481 INT123_do_equalizer(bandPtr_r
,1,fr
->equalizer
);
486 bufl
= fr
->real_buffs
[0];
487 bufr
= fr
->real_buffs
[1];
494 INT123_dct64_real_neon64(bufl
[1]+((fr
->bo
+1)&0xf),bufl
[0]+fr
->bo
,bandPtr_l
);
495 INT123_dct64_real_neon64(bufr
[1]+((fr
->bo
+1)&0xf),bufr
[0]+fr
->bo
,bandPtr_r
);
502 INT123_dct64_real_neon64(bufl
[0]+fr
->bo
,bufl
[1]+fr
->bo
+1,bandPtr_l
);
503 INT123_dct64_real_neon64(bufr
[0]+fr
->bo
,bufr
[1]+fr
->bo
+1,bandPtr_r
);
506 clip
= INT123_synth_1to1_s32_s_neon64_asm(fr
->decwin
, b0l
, b0r
, samples
, bo1
);
508 fr
->buffer
.fill
+= 256;
516 #ifndef NO_DOWNSAMPLE
519 Part 4b: 2to1 synth. Only generic and i386.
521 #define BLOCK 0x20 /* One decoding block is 32 samples. */
523 #define SYNTH_NAME INT123_synth_2to1_s32
527 /* Mono-related synths; they wrap over _some_ INT123_synth_2to1_s32 (could be generic, could be i386). */
528 #define SYNTH_NAME fr->synths.plain[r_2to1][f_32]
529 #define MONO_NAME INT123_synth_2to1_s32_mono
530 #define MONO2STEREO_NAME INT123_synth_2to1_s32_m2s
531 #include "synth_mono.h"
534 #undef MONO2STEREO_NAME
537 #define NO_AUTOINCREMENT
538 #define SYNTH_NAME INT123_synth_2to1_s32_i386
541 /* i386 uses the normal mono functions. */
542 #undef NO_AUTOINCREMENT
548 Part 4c: 4to1 synth. Only generic and i386.
550 #define BLOCK 0x10 /* One decoding block is 16 samples. */
552 #define SYNTH_NAME INT123_synth_4to1_s32
556 /* Mono-related synths; they wrap over _some_ INT123_synth_4to1_s32 (could be generic, could be i386). */
557 #define SYNTH_NAME fr->synths.plain[r_4to1][f_32]
558 #define MONO_NAME INT123_synth_4to1_s32_mono
559 #define MONO2STEREO_NAME INT123_synth_4to1_s32_m2s
560 #include "synth_mono.h"
563 #undef MONO2STEREO_NAME
566 #define NO_AUTOINCREMENT
567 #define SYNTH_NAME INT123_synth_4to1_s32_i386
570 /* i386 uses the normal mono functions. */
571 #undef NO_AUTOINCREMENT
576 #endif /* NO_DOWNSAMPLE */
581 Same procedure as above... Just no extra play anymore, straight synth that may use an optimized INT123_dct64.
584 /* These are all in one header, there's no flexibility to gain. */
585 #define SYNTH_NAME INT123_synth_ntom_s32
586 #define MONO_NAME INT123_synth_ntom_s32_mono
587 #define MONO2STEREO_NAME INT123_synth_ntom_s32_m2s
588 #include "synth_ntom.h"
591 #undef MONO2STEREO_NAME
598 #endif /* non-fixed type */