comparison mpegaudiodec.c @ 7256:7c13d54f389d libavcodec

mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
author mru
date Sun, 13 Jul 2008 12:23:02 +0000
parents e943e1409077
children 104a00d9abfa
comparison
equal deleted inserted replaced
7255:84dd52687931 7256:7c13d54f389d
764 #define MACS(rt, ra, rb) MAC16(rt, ra, rb) 764 #define MACS(rt, ra, rb) MAC16(rt, ra, rb)
765 765
766 /* signed 16x16 -> 32 multiply */ 766 /* signed 16x16 -> 32 multiply */
767 #define MULS(ra, rb) MUL16(ra, rb) 767 #define MULS(ra, rb) MUL16(ra, rb)
768 768
769 #define MLSS(rt, ra, rb) MLS16(rt, ra, rb)
770
769 #else 771 #else
770 772
771 static inline int round_sample(int64_t *sum) 773 static inline int round_sample(int64_t *sum)
772 { 774 {
773 int sum1; 775 int sum1;
779 sum1 = OUT_MAX; 781 sum1 = OUT_MAX;
780 return sum1; 782 return sum1;
781 } 783 }
782 784
783 # define MULS(ra, rb) MUL64(ra, rb) 785 # define MULS(ra, rb) MUL64(ra, rb)
784 #endif 786 # define MACS(rt, ra, rb) MAC64(rt, ra, rb)
785 787 # define MLSS(rt, ra, rb) MLS64(rt, ra, rb)
786 #define SUM8(sum, op, w, p) \ 788 #endif
787 { \ 789
788 sum op MULS((w)[0 * 64], p[0 * 64]);\ 790 #define SUM8(op, sum, w, p) \
789 sum op MULS((w)[1 * 64], p[1 * 64]);\ 791 { \
790 sum op MULS((w)[2 * 64], p[2 * 64]);\ 792 op(sum, (w)[0 * 64], p[0 * 64]); \
791 sum op MULS((w)[3 * 64], p[3 * 64]);\ 793 op(sum, (w)[1 * 64], p[1 * 64]); \
792 sum op MULS((w)[4 * 64], p[4 * 64]);\ 794 op(sum, (w)[2 * 64], p[2 * 64]); \
793 sum op MULS((w)[5 * 64], p[5 * 64]);\ 795 op(sum, (w)[3 * 64], p[3 * 64]); \
794 sum op MULS((w)[6 * 64], p[6 * 64]);\ 796 op(sum, (w)[4 * 64], p[4 * 64]); \
795 sum op MULS((w)[7 * 64], p[7 * 64]);\ 797 op(sum, (w)[5 * 64], p[5 * 64]); \
798 op(sum, (w)[6 * 64], p[6 * 64]); \
799 op(sum, (w)[7 * 64], p[7 * 64]); \
796 } 800 }
797 801
798 #define SUM8P2(sum1, op1, sum2, op2, w1, w2, p) \ 802 #define SUM8P2(sum1, op1, sum2, op2, w1, w2, p) \
799 { \ 803 { \
800 int tmp;\ 804 int tmp;\
801 tmp = p[0 * 64];\ 805 tmp = p[0 * 64];\
802 sum1 op1 MULS((w1)[0 * 64], tmp);\ 806 op1(sum1, (w1)[0 * 64], tmp);\
803 sum2 op2 MULS((w2)[0 * 64], tmp);\ 807 op2(sum2, (w2)[0 * 64], tmp);\
804 tmp = p[1 * 64];\ 808 tmp = p[1 * 64];\
805 sum1 op1 MULS((w1)[1 * 64], tmp);\ 809 op1(sum1, (w1)[1 * 64], tmp);\
806 sum2 op2 MULS((w2)[1 * 64], tmp);\ 810 op2(sum2, (w2)[1 * 64], tmp);\
807 tmp = p[2 * 64];\ 811 tmp = p[2 * 64];\
808 sum1 op1 MULS((w1)[2 * 64], tmp);\ 812 op1(sum1, (w1)[2 * 64], tmp);\
809 sum2 op2 MULS((w2)[2 * 64], tmp);\ 813 op2(sum2, (w2)[2 * 64], tmp);\
810 tmp = p[3 * 64];\ 814 tmp = p[3 * 64];\
811 sum1 op1 MULS((w1)[3 * 64], tmp);\ 815 op1(sum1, (w1)[3 * 64], tmp);\
812 sum2 op2 MULS((w2)[3 * 64], tmp);\ 816 op2(sum2, (w2)[3 * 64], tmp);\
813 tmp = p[4 * 64];\ 817 tmp = p[4 * 64];\
814 sum1 op1 MULS((w1)[4 * 64], tmp);\ 818 op1(sum1, (w1)[4 * 64], tmp);\
815 sum2 op2 MULS((w2)[4 * 64], tmp);\ 819 op2(sum2, (w2)[4 * 64], tmp);\
816 tmp = p[5 * 64];\ 820 tmp = p[5 * 64];\
817 sum1 op1 MULS((w1)[5 * 64], tmp);\ 821 op1(sum1, (w1)[5 * 64], tmp);\
818 sum2 op2 MULS((w2)[5 * 64], tmp);\ 822 op2(sum2, (w2)[5 * 64], tmp);\
819 tmp = p[6 * 64];\ 823 tmp = p[6 * 64];\
820 sum1 op1 MULS((w1)[6 * 64], tmp);\ 824 op1(sum1, (w1)[6 * 64], tmp);\
821 sum2 op2 MULS((w2)[6 * 64], tmp);\ 825 op2(sum2, (w2)[6 * 64], tmp);\
822 tmp = p[7 * 64];\ 826 tmp = p[7 * 64];\
823 sum1 op1 MULS((w1)[7 * 64], tmp);\ 827 op1(sum1, (w1)[7 * 64], tmp);\
824 sum2 op2 MULS((w2)[7 * 64], tmp);\ 828 op2(sum2, (w2)[7 * 64], tmp);\
825 } 829 }
826 830
827 void ff_mpa_synth_init(MPA_INT *window) 831 void ff_mpa_synth_init(MPA_INT *window)
828 { 832 {
829 int i; 833 int i;
883 w = window; 887 w = window;
884 w2 = window + 31; 888 w2 = window + 31;
885 889
886 sum = *dither_state; 890 sum = *dither_state;
887 p = synth_buf + 16; 891 p = synth_buf + 16;
888 SUM8(sum, +=, w, p); 892 SUM8(MACS, sum, w, p);
889 p = synth_buf + 48; 893 p = synth_buf + 48;
890 SUM8(sum, -=, w + 32, p); 894 SUM8(MLSS, sum, w + 32, p);
891 *samples = round_sample(&sum); 895 *samples = round_sample(&sum);
892 samples += incr; 896 samples += incr;
893 w++; 897 w++;
894 898
895 /* we calculate two samples at the same time to avoid one memory 899 /* we calculate two samples at the same time to avoid one memory
896 access per two sample */ 900 access per two sample */
897 for(j=1;j<16;j++) { 901 for(j=1;j<16;j++) {
898 sum2 = 0; 902 sum2 = 0;
899 p = synth_buf + 16 + j; 903 p = synth_buf + 16 + j;
900 SUM8P2(sum, +=, sum2, -=, w, w2, p); 904 SUM8P2(sum, MACS, sum2, MLSS, w, w2, p);
901 p = synth_buf + 48 - j; 905 p = synth_buf + 48 - j;
902 SUM8P2(sum, -=, sum2, -=, w + 32, w2 + 32, p); 906 SUM8P2(sum, MLSS, sum2, MLSS, w + 32, w2 + 32, p);
903 907
904 *samples = round_sample(&sum); 908 *samples = round_sample(&sum);
905 samples += incr; 909 samples += incr;
906 sum += sum2; 910 sum += sum2;
907 *samples2 = round_sample(&sum); 911 *samples2 = round_sample(&sum);
909 w++; 913 w++;
910 w2--; 914 w2--;
911 } 915 }
912 916
913 p = synth_buf + 32; 917 p = synth_buf + 32;
914 SUM8(sum, -=, w + 32, p); 918 SUM8(MLSS, sum, w + 32, p);
915 *samples = round_sample(&sum); 919 *samples = round_sample(&sum);
916 *dither_state= sum; 920 *dither_state= sum;
917 921
918 offset = (offset - 32) & 511; 922 offset = (offset - 32) & 511;
919 *synth_buf_offset = offset; 923 *synth_buf_offset = offset;