Rev 1905 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1905 | Rev 3960 | ||
---|---|---|---|
Line 8... | Line 8... | ||
8 | 8 | ||
9 | #include "mpg123lib_intern.h" |
9 | #include "mpg123lib_intern.h" |
10 | #include "sample.h" |
10 | #include "sample.h" |
Line 11... | Line -... | ||
11 | #include "debug.h" |
- | |
12 | - | ||
13 | /* Stereo-related synth, wrapping over _some_ plain synth. */ |
- | |
14 | int synth_stereo_wrap(real *bandPtr_l, real *bandPtr_r, mpg123_handle *fr) |
- | |
15 | { |
- | |
16 | int clip; |
- | |
17 | clip = (fr->synth)(bandPtr_l, 0, fr, 0); |
- | |
18 | clip += (fr->synth)(bandPtr_r, 1, fr, 1); |
- | |
19 | return clip; |
- | |
20 | } |
11 | #include "debug.h" |
21 | 12 | ||
22 | /* |
13 | /* |
23 | Part 1: All synth functions that produce signed short. |
14 | Part 1: All synth functions that produce signed short. |
24 | That is: |
15 | That is: |
25 | - synth_1to1 with cpu-specific variants (synth_1to1_i386, synth_1to1_i586 ...) |
16 | - synth_1to1 with cpu-specific variants (synth_1to1_i386, synth_1to1_i586 ...) |
26 | - synth_1to1_mono and synth_1to1_mono2stereo; which use fr->synths.plain[r_1to1][f_16]. |
17 | - synth_1to1_mono and synth_1to1_m2s; which use fr->synths.plain[r_1to1][f_16]. |
Line 27... | Line 18... | ||
27 | Nearly every decoder variant has it's own synth_1to1, while the mono conversion is shared. |
18 | Nearly every decoder variant has it's own synth_1to1, while the mono conversion is shared. |
28 | */ |
19 | */ |
Line 38... | Line 29... | ||
38 | #undef SYNTH_NAME |
29 | #undef SYNTH_NAME |
Line 39... | Line 30... | ||
39 | 30 | ||
40 | /* Mono-related synths; they wrap over _some_ synth_1to1. */ |
31 | /* Mono-related synths; they wrap over _some_ synth_1to1. */ |
41 | #define SYNTH_NAME fr->synths.plain[r_1to1][f_16] |
32 | #define SYNTH_NAME fr->synths.plain[r_1to1][f_16] |
42 | #define MONO_NAME synth_1to1_mono |
33 | #define MONO_NAME synth_1to1_mono |
43 | #define MONO2STEREO_NAME synth_1to1_mono2stereo |
34 | #define MONO2STEREO_NAME synth_1to1_m2s |
44 | #include "synth_mono.h" |
35 | #include "synth_mono.h" |
45 | #undef SYNTH_NAME |
36 | #undef SYNTH_NAME |
46 | #undef MONO_NAME |
37 | #undef MONO_NAME |
Line 150... | Line 141... | ||
150 | 141 | ||
151 | #ifdef OPT_SSE |
142 | #ifdef OPT_SSE |
152 | #ifdef ACCURATE_ROUNDING |
143 | #ifdef ACCURATE_ROUNDING |
153 | /* This is defined in assembler. */ |
144 | /* This is defined in assembler. */ |
154 | int synth_1to1_sse_accurate_asm(real *window, real *b0, short *samples, int bo1); |
145 | int synth_1to1_sse_accurate_asm(real *window, real *b0, short *samples, int bo1); |
155 | int synth_1to1_stereo_sse_accurate_asm(real *window, real *b0l, real *b0r, short *samples, int bo1); |
146 | int synth_1to1_s_sse_accurate_asm(real *window, real *b0l, real *b0r, short *samples, int bo1); |
156 | void dct64_real_sse(real *out0, real *out1, real *samples); |
147 | void dct64_real_sse(real *out0, real *out1, real *samples); |
157 | /* This is just a hull to use the mpg123 handle. */ |
148 | /* This is just a hull to use the mpg123 handle. */ |
158 | int synth_1to1_sse(real *bandPtr,int channel, mpg123_handle *fr, int final) |
149 | int synth_1to1_sse(real *bandPtr,int channel, mpg123_handle *fr, int final) |
159 | { |
150 | { |
Line 230... | Line 221... | ||
230 | bo1 = fr->bo+1; |
221 | bo1 = fr->bo+1; |
231 | dct64_real_sse(bufl[0]+fr->bo,bufl[1]+fr->bo+1,bandPtr_l); |
222 | dct64_real_sse(bufl[0]+fr->bo,bufl[1]+fr->bo+1,bandPtr_l); |
232 | dct64_real_sse(bufr[0]+fr->bo,bufr[1]+fr->bo+1,bandPtr_r); |
223 | dct64_real_sse(bufr[0]+fr->bo,bufr[1]+fr->bo+1,bandPtr_r); |
233 | } |
224 | } |
Line 234... | Line 225... | ||
234 | 225 | ||
Line 235... | Line 226... | ||
235 | clip = synth_1to1_stereo_sse_accurate_asm(fr->decwin, b0l, b0r, samples, bo1); |
226 | clip = synth_1to1_s_sse_accurate_asm(fr->decwin, b0l, b0r, samples, bo1); |
Line 236... | Line 227... | ||
236 | 227 | ||
237 | fr->buffer.fill += 128; |
228 | fr->buffer.fill += 128; |
Line 269... | Line 260... | ||
269 | 260 | ||
270 | #ifdef OPT_X86_64 |
261 | #ifdef OPT_X86_64 |
271 | #ifdef ACCURATE_ROUNDING |
262 | #ifdef ACCURATE_ROUNDING |
272 | /* Assembler routines. */ |
263 | /* Assembler routines. */ |
273 | int synth_1to1_x86_64_accurate_asm(real *window, real *b0, short *samples, int bo1); |
264 | int synth_1to1_x86_64_accurate_asm(real *window, real *b0, short *samples, int bo1); |
274 | int synth_1to1_stereo_x86_64_accurate_asm(real *window, real *b0l, real *b0r, short *samples, int bo1); |
265 | int synth_1to1_s_x86_64_accurate_asm(real *window, real *b0l, real *b0r, short *samples, int bo1); |
275 | void dct64_real_x86_64(real *out0, real *out1, real *samples); |
266 | void dct64_real_x86_64(real *out0, real *out1, real *samples); |
276 | /* Hull for C mpg123 API */ |
267 | /* Hull for C mpg123 API */ |
277 | int synth_1to1_x86_64(real *bandPtr,int channel, mpg123_handle *fr, int final) |
268 | int synth_1to1_x86_64(real *bandPtr,int channel, mpg123_handle *fr, int final) |
278 | { |
269 | { |
Line 350... | Line 341... | ||
350 | bo1 = fr->bo+1; |
341 | bo1 = fr->bo+1; |
351 | dct64_real_x86_64(bufl[0]+fr->bo,bufl[1]+fr->bo+1,bandPtr_l); |
342 | dct64_real_x86_64(bufl[0]+fr->bo,bufl[1]+fr->bo+1,bandPtr_l); |
352 | dct64_real_x86_64(bufr[0]+fr->bo,bufr[1]+fr->bo+1,bandPtr_r); |
343 | dct64_real_x86_64(bufr[0]+fr->bo,bufr[1]+fr->bo+1,bandPtr_r); |
353 | } |
344 | } |
Line 354... | Line 345... | ||
354 | 345 | ||
Line 355... | Line 346... | ||
355 | clip = synth_1to1_stereo_x86_64_accurate_asm(fr->decwin, b0l, b0r, samples, bo1); |
346 | clip = synth_1to1_s_x86_64_accurate_asm(fr->decwin, b0l, b0r, samples, bo1); |
Line 356... | Line 347... | ||
356 | 347 | ||
357 | fr->buffer.fill += 128; |
348 | fr->buffer.fill += 128; |
358 | 349 | ||
359 | return clip; |
350 | return clip; |
360 | } |
351 | } |
361 | #else |
352 | #else |
362 | /* This is defined in assembler. */ |
353 | /* This is defined in assembler. */ |
363 | int synth_1to1_x86_64_asm(short *window, short *b0, short *samples, int bo1); |
354 | int synth_1to1_x86_64_asm(short *window, short *b0, short *samples, int bo1); |
364 | int synth_1to1_stereo_x86_64_asm(short *window, short *b0l, short *b0r, short *samples, int bo1); |
355 | int synth_1to1_s_x86_64_asm(short *window, short *b0l, short *b0r, short *samples, int bo1); |
365 | void dct64_x86_64(short *out0, short *out1, real *samples); |
356 | void dct64_x86_64(short *out0, short *out1, real *samples); |
366 | /* This is just a hull to use the mpg123 handle. */ |
357 | /* This is just a hull to use the mpg123 handle. */ |
Line 438... | Line 429... | ||
438 | bo1 = fr->bo+1; |
429 | bo1 = fr->bo+1; |
439 | dct64_x86_64(bufl[0]+fr->bo,bufl[1]+fr->bo+1,bandPtr_l); |
430 | dct64_x86_64(bufl[0]+fr->bo,bufl[1]+fr->bo+1,bandPtr_l); |
440 | dct64_x86_64(bufr[0]+fr->bo,bufr[1]+fr->bo+1,bandPtr_r); |
431 | dct64_x86_64(bufr[0]+fr->bo,bufr[1]+fr->bo+1,bandPtr_r); |
441 | } |
432 | } |
Line 442... | Line 433... | ||
442 | 433 | ||
Line 443... | Line 434... | ||
443 | clip = synth_1to1_stereo_x86_64_asm((short *)fr->decwins, b0l, b0r, samples, bo1); |
434 | clip = synth_1to1_s_x86_64_asm((short *)fr->decwins, b0l, b0r, samples, bo1); |
Line 444... | Line 435... | ||
444 | 435 | ||
445 | fr->buffer.fill += 128; |
436 | fr->buffer.fill += 128; |
Line 541... | Line 532... | ||
541 | return clip; |
532 | return clip; |
542 | } |
533 | } |
543 | #endif |
534 | #endif |
544 | #endif |
535 | #endif |
Line -... | Line 536... | ||
- | 536 | ||
- | 537 | #ifdef OPT_NEON |
|
- | 538 | #ifdef ACCURATE_ROUNDING |
|
- | 539 | /* This is defined in assembler. */ |
|
- | 540 | int synth_1to1_neon_accurate_asm(real *window, real *b0, short *samples, int bo1); |
|
- | 541 | int synth_1to1_s_neon_accurate_asm(real *window, real *b0l, real *b0r, short *samples, int bo1); |
|
- | 542 | void dct64_real_neon(real *out0, real *out1, real *samples); |
|
- | 543 | /* Hull for C mpg123 API */ |
|
- | 544 | int synth_1to1_neon(real *bandPtr,int channel, mpg123_handle *fr, int final) |
|
- | 545 | { |
|
- | 546 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
|
- | 547 | ||
- | 548 | real *b0, **buf; |
|
- | 549 | int bo1; |
|
- | 550 | int clip; |
|
- | 551 | ||
- | 552 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
|
- | 553 | ||
- | 554 | if(!channel) |
|
- | 555 | { |
|
- | 556 | fr->bo--; |
|
- | 557 | fr->bo &= 0xf; |
|
- | 558 | buf = fr->real_buffs[0]; |
|
- | 559 | } |
|
- | 560 | else |
|
- | 561 | { |
|
- | 562 | samples++; |
|
- | 563 | buf = fr->real_buffs[1]; |
|
- | 564 | } |
|
- | 565 | ||
- | 566 | if(fr->bo & 0x1) |
|
- | 567 | { |
|
- | 568 | b0 = buf[0]; |
|
- | 569 | bo1 = fr->bo; |
|
- | 570 | dct64_real_neon(buf[1]+((fr->bo+1)&0xf),buf[0]+fr->bo,bandPtr); |
|
- | 571 | } |
|
- | 572 | else |
|
- | 573 | { |
|
- | 574 | b0 = buf[1]; |
|
- | 575 | bo1 = fr->bo+1; |
|
- | 576 | dct64_real_neon(buf[0]+fr->bo,buf[1]+fr->bo+1,bandPtr); |
|
- | 577 | } |
|
- | 578 | ||
- | 579 | clip = synth_1to1_neon_accurate_asm(fr->decwin, b0, samples, bo1); |
|
- | 580 | ||
- | 581 | if(final) fr->buffer.fill += 128; |
|
- | 582 | ||
- | 583 | return clip; |
|
- | 584 | } |
|
- | 585 | ||
- | 586 | int synth_1to1_stereo_neon(real *bandPtr_l, real *bandPtr_r, mpg123_handle *fr) |
|
- | 587 | { |
|
- | 588 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
|
- | 589 | ||
- | 590 | real *b0l, *b0r, **bufl, **bufr; |
|
- | 591 | int bo1; |
|
- | 592 | int clip; |
|
- | 593 | ||
- | 594 | if(fr->have_eq_settings) |
|
- | 595 | { |
|
- | 596 | do_equalizer(bandPtr_l,0,fr->equalizer); |
|
- | 597 | do_equalizer(bandPtr_r,1,fr->equalizer); |
|
- | 598 | } |
|
- | 599 | ||
- | 600 | fr->bo--; |
|
- | 601 | fr->bo &= 0xf; |
|
- | 602 | bufl = fr->real_buffs[0]; |
|
- | 603 | bufr = fr->real_buffs[1]; |
|
- | 604 | ||
- | 605 | if(fr->bo & 0x1) |
|
- | 606 | { |
|
- | 607 | b0l = bufl[0]; |
|
- | 608 | b0r = bufr[0]; |
|
- | 609 | bo1 = fr->bo; |
|
- | 610 | dct64_real_neon(bufl[1]+((fr->bo+1)&0xf),bufl[0]+fr->bo,bandPtr_l); |
|
- | 611 | dct64_real_neon(bufr[1]+((fr->bo+1)&0xf),bufr[0]+fr->bo,bandPtr_r); |
|
- | 612 | } |
|
- | 613 | else |
|
- | 614 | { |
|
- | 615 | b0l = bufl[1]; |
|
- | 616 | b0r = bufr[1]; |
|
- | 617 | bo1 = fr->bo+1; |
|
- | 618 | dct64_real_neon(bufl[0]+fr->bo,bufl[1]+fr->bo+1,bandPtr_l); |
|
- | 619 | dct64_real_neon(bufr[0]+fr->bo,bufr[1]+fr->bo+1,bandPtr_r); |
|
- | 620 | } |
|
- | 621 | ||
- | 622 | clip = synth_1to1_s_neon_accurate_asm(fr->decwin, b0l, b0r, samples, bo1); |
|
- | 623 | ||
- | 624 | fr->buffer.fill += 128; |
|
- | 625 | ||
- | 626 | return clip; |
|
- | 627 | } |
|
- | 628 | #else |
|
- | 629 | /* This is defined in assembler. */ |
|
- | 630 | int synth_1to1_neon_asm(short *window, short *b0, short *samples, int bo1); |
|
- | 631 | int synth_1to1_s_neon_asm(short *window, short *b0l, short *b0r, short *samples, int bo1); |
|
- | 632 | void dct64_neon(short *out0, short *out1, real *samples); |
|
- | 633 | /* Hull for C mpg123 API */ |
|
- | 634 | int synth_1to1_neon(real *bandPtr,int channel, mpg123_handle *fr, int final) |
|
- | 635 | { |
|
- | 636 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
|
- | 637 | short *b0, **buf; |
|
- | 638 | int clip; |
|
- | 639 | int bo1; |
|
- | 640 | ||
- | 641 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
|
- | 642 | ||
- | 643 | if(!channel) |
|
- | 644 | { |
|
- | 645 | fr->bo--; |
|
- | 646 | fr->bo &= 0xf; |
|
- | 647 | buf = fr->short_buffs[0]; |
|
- | 648 | } |
|
- | 649 | else |
|
- | 650 | { |
|
- | 651 | samples++; |
|
- | 652 | buf = fr->short_buffs[1]; |
|
- | 653 | } |
|
- | 654 | ||
- | 655 | if(fr->bo & 0x1) |
|
- | 656 | { |
|
- | 657 | b0 = buf[0]; |
|
- | 658 | bo1 = fr->bo; |
|
- | 659 | dct64_neon(buf[1]+((fr->bo+1)&0xf),buf[0]+fr->bo,bandPtr); |
|
- | 660 | } |
|
- | 661 | else |
|
- | 662 | { |
|
- | 663 | b0 = buf[1]; |
|
- | 664 | bo1 = fr->bo+1; |
|
- | 665 | dct64_neon(buf[0]+fr->bo,buf[1]+fr->bo+1,bandPtr); |
|
- | 666 | } |
|
- | 667 | ||
- | 668 | clip = synth_1to1_neon_asm((short *)fr->decwins, b0, samples, bo1); |
|
- | 669 | ||
- | 670 | if(final) fr->buffer.fill += 128; |
|
- | 671 | ||
- | 672 | return clip; |
|
- | 673 | } |
|
- | 674 | ||
- | 675 | int synth_1to1_stereo_neon(real *bandPtr_l,real *bandPtr_r, mpg123_handle *fr) |
|
- | 676 | { |
|
- | 677 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
|
- | 678 | short *b0l, *b0r, **bufl, **bufr; |
|
- | 679 | int clip; |
|
- | 680 | int bo1; |
|
- | 681 | ||
- | 682 | if(fr->have_eq_settings) |
|
- | 683 | { |
|
- | 684 | do_equalizer(bandPtr_l,0,fr->equalizer); |
|
- | 685 | do_equalizer(bandPtr_r,1,fr->equalizer); |
|
- | 686 | } |
|
- | 687 | ||
- | 688 | fr->bo--; |
|
- | 689 | fr->bo &= 0xf; |
|
- | 690 | bufl = fr->short_buffs[0]; |
|
- | 691 | bufr = fr->short_buffs[1]; |
|
- | 692 | ||
- | 693 | if(fr->bo & 0x1) |
|
- | 694 | { |
|
- | 695 | b0l = bufl[0]; |
|
- | 696 | b0r = bufr[0]; |
|
- | 697 | bo1 = fr->bo; |
|
- | 698 | dct64_neon(bufl[1]+((fr->bo+1)&0xf),bufl[0]+fr->bo,bandPtr_l); |
|
- | 699 | dct64_neon(bufr[1]+((fr->bo+1)&0xf),bufr[0]+fr->bo,bandPtr_r); |
|
- | 700 | } |
|
- | 701 | else |
|
- | 702 | { |
|
- | 703 | b0l = bufl[1]; |
|
- | 704 | b0r = bufr[1]; |
|
- | 705 | bo1 = fr->bo+1; |
|
- | 706 | dct64_neon(bufl[0]+fr->bo,bufl[1]+fr->bo+1,bandPtr_l); |
|
- | 707 | dct64_neon(bufr[0]+fr->bo,bufr[1]+fr->bo+1,bandPtr_r); |
|
- | 708 | } |
|
- | 709 | ||
- | 710 | clip = synth_1to1_s_neon_asm((short *)fr->decwins, b0l, b0r, samples, bo1); |
|
- | 711 | ||
- | 712 | fr->buffer.fill += 128; |
|
- | 713 | ||
- | 714 | return clip; |
|
- | 715 | } |
|
- | 716 | #endif |
|
- | 717 | #endif |
|
545 | 718 | ||
Line 546... | Line 719... | ||
546 | #ifndef NO_DOWNSAMPLE |
719 | #ifndef NO_DOWNSAMPLE |
547 | 720 | ||
548 | /* |
721 | /* |
Line 563... | Line 736... | ||
563 | #undef SYNTH_NAME |
736 | #undef SYNTH_NAME |
564 | #endif |
737 | #endif |
Line 565... | Line 738... | ||
565 | 738 | ||
566 | #define SYNTH_NAME fr->synths.plain[r_2to1][f_16] |
739 | #define SYNTH_NAME fr->synths.plain[r_2to1][f_16] |
567 | #define MONO_NAME synth_2to1_mono |
740 | #define MONO_NAME synth_2to1_mono |
568 | #define MONO2STEREO_NAME synth_2to1_mono2stereo |
741 | #define MONO2STEREO_NAME synth_2to1_m2s |
569 | #include "synth_mono.h" |
742 | #include "synth_mono.h" |
570 | #undef SYNTH_NAME |
743 | #undef SYNTH_NAME |
571 | #undef MONO_NAME |
744 | #undef MONO_NAME |
Line 600... | Line 773... | ||
600 | #undef SYNTH_NAME |
773 | #undef SYNTH_NAME |
601 | #endif |
774 | #endif |
Line 602... | Line 775... | ||
602 | 775 | ||
603 | #define SYNTH_NAME fr->synths.plain[r_4to1][f_16] /* This is just for the _i386 one... gotta check if it is really useful... */ |
776 | #define SYNTH_NAME fr->synths.plain[r_4to1][f_16] /* This is just for the _i386 one... gotta check if it is really useful... */ |
604 | #define MONO_NAME synth_4to1_mono |
777 | #define MONO_NAME synth_4to1_mono |
605 | #define MONO2STEREO_NAME synth_4to1_mono2stereo |
778 | #define MONO2STEREO_NAME synth_4to1_m2s |
606 | #include "synth_mono.h" |
779 | #include "synth_mono.h" |
607 | #undef SYNTH_NAME |
780 | #undef SYNTH_NAME |
608 | #undef MONO_NAME |
781 | #undef MONO_NAME |
Line 628... | Line 801... | ||
628 | */ |
801 | */ |
Line 629... | Line 802... | ||
629 | 802 | ||
630 | /* These are all in one header, there's no flexibility to gain. */ |
803 | /* These are all in one header, there's no flexibility to gain. */ |
631 | #define SYNTH_NAME synth_ntom |
804 | #define SYNTH_NAME synth_ntom |
632 | #define MONO_NAME synth_ntom_mono |
805 | #define MONO_NAME synth_ntom_mono |
633 | #define MONO2STEREO_NAME synth_ntom_mono2stereo |
806 | #define MONO2STEREO_NAME synth_ntom_m2s |
634 | #include "synth_ntom.h" |
807 | #include "synth_ntom.h" |
635 | #undef SYNTH_NAME |
808 | #undef SYNTH_NAME |
636 | #undef MONO_NAME |
809 | #undef MONO_NAME |