Procházet zdrojové kódy

optimize value clamping in PCM downsampler

Michael Panzlaff před 6 roky
rodič
revize
d7d2a65d56
1 změnil soubory, kde provedl 25 přidání a 42 odebrání
  1. 25
    42
      src/music/main_mixer.s

+ 25
- 42
src/music/main_mixer.s Zobrazit soubor

@@ -890,78 +890,61 @@ C_downsampler:
890 890
     LDR     R9, [SP, #ARG_BUFFER_POS]
891 891
     LDR     R10, hq_buffer
892 892
     MOV     R11, #0xFF000000
893
-    MOV     LR, #0x007F0000
893
+    MOV     LR, #0xC0000000
894 894
 
895 895
 C_downsampler_loop:
896 896
         LDMIA   R10, {R0, R1, R2, R3}
897
-
898 897
         ADD     R12, R4, R0         @ left sample #1
899
-        CMP     R12, #0x3FC00000
900
-        MOVGE   R12, #0x3FC00000
901
-        CMP     R12, #-0x40000000
902
-        MOVLT   R12, #-0x40000000
903
-        AND     R4, LR, R12
898
+        ADDS    R4, R12, R12
899
+        EORVS   R12, LR, R4, ASR#31
900
+        AND     R4, R12, #0x007F0000
904 901
         AND     R6, R11, R12, LSL#1
905 902
 
906 903
         ADD     R0, R5, R0, LSL#16  @ right
907
-        CMP     R0, #0x3FC00000
908
-        MOVGE   R0, #0x3FC00000
909
-        CMP     R0, #-0x40000000
910
-        MOVLT   R0, #-0x40000000
911
-        AND     R5, LR, R0
904
+        ADDS    R5, R0, R0
905
+        EORVS   R0, LR, R5, ASR#31
906
+        AND     R5, R0, #0x007F0000
912 907
         AND     R7, R11, R0, LSL#1
913 908
 
914 909
         ADD     R12, R4, R1         @ left sample #2
915
-        CMP     R12, #0x3FC00000
916
-        MOVGE   R12, #0x3FC00000
917
-        CMP     R12, #-0x40000000
918
-        MOVLT   R12, #-0x40000000
919
-        AND     R4, LR, R12
910
+        ADDS    R4, R12, R12
911
+        EORVS   R12, LR, R4, ASR#31
912
+        AND     R4, R12, #0x007F0000
920 913
         AND     R12, R11, R12, LSL#1
921 914
         ORR     R6, R12, R6, LSR#8
922 915
 
923 916
         ADD     R1, R5, R1, LSL#16  @ right
924
-        CMP     R1, #0x3FC00000
925
-        MOVGE   R1, #0x3FC00000
926
-        CMP     R1, #-0x40000000
927
-        MOVLT   R1, #-0x40000000
928
-        AND     R5, LR, R1
917
+        ADDS    R5, R1, R1
918
+        EORVS   R1, LR, R5, ASR#31
919
+        AND     R5, R1, #0x007F0000
929 920
         AND     R1, R11, R1, LSL#1
930 921
         ORR     R7, R1, R7, LSR#8
931 922
 
932 923
         ADD     R12, R4, R2         @ left sample #3
933
-        CMP     R12, #0x3FC00000
934
-        MOVGE   R12, #0x3FC00000
935
-        CMP     R12, #-0x40000000
936
-        MOVLT   R12, #-0x40000000
937
-        AND     R4, LR, R12
924
+        ADDS    R4, R12, R12
925
+        EORVS   R12, LR, R4, ASR#31
926
+        AND     R4, R12, #0x007F0000
938 927
         AND     R12, R11, R12, LSL#1
939 928
         ORR     R6, R12, R6, LSR#8
940 929
 
941 930
         ADD     R2, R5, R2, LSL#16  @ right
942
-        CMP     R2, #0x3FC00000
943
-        MOVGE   R2, #0x3FC00000
944
-        CMP     R2, #-0x40000000
945
-        MOVLT   R2, #-0x40000000
946
-        AND     R5, LR, R2
931
+        ADDS    R5, R2, R2
932
+        EORVS   R2, LR, R5, ASR#31
933
+        AND     R5, R2, #0x007F0000
947 934
         AND     R2, R11, R2, LSL#1
948 935
         ORR     R7, R2, R7, LSR#8
949 936
 
950 937
         ADD     R12, R4, R3         @ left sample #4
951
-        CMP     R12, #0x3FC00000
952
-        MOVGE   R12, #0x3FC00000
953
-        CMP     R12, #-0x40000000
954
-        MOVLT   R12, #-0x40000000
955
-        AND     R4, LR, R12
938
+        ADDS    R4, R12, R12
939
+        EORVS   R12, LR, R4, ASR#31
940
+        AND     R4, R12, #0x007F0000
956 941
         AND     R12, R11, R12, LSL#1
957 942
         ORR     R6, R12, R6, LSR#8
958 943
 
959 944
         ADD     R3, R5, R3, LSL#16  @ right
960
-        CMP     R3, #0x3FC00000
961
-        MOVGE   R3, #0x3FC00000
962
-        CMP     R3, #-0x40000000
963
-        MOVLT   R3, #-0x40000000
964
-        AND     R5, LR, R3
945
+        ADDS    R5, R3, R3
946
+        EORVS   R3, LR, R5, ASR#31
947
+        AND     R5, R3, #0x007F0000
965 948
         AND     R3, R11, R3, LSL#1
966 949
         ORR     R7, R3, R7, LSR#8
967 950