Floating point mixer. Powered by the Dark side. (see USE_SSE2_MIXER. SSE2 required)

git-svn-id: svn://kolibrios.org@694 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2008-01-12 07:54:11 +00:00
parent 76aa52dd6b
commit 71f27df7b3
3 changed files with 111 additions and 14 deletions

View File

@ -1,12 +1,12 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2006-2008. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; (C) copyright Serge 2006
; email: infinity_sound@mail.ru
; Serge 2006-2008
; email: infinity_sound@mail.ru
format MS COFF
@ -27,9 +27,12 @@ include 'imports.inc'
FORCE_MMX equ 0 ;set to 1 to force use mmx or
FORCE_MMX_128 equ 0 ;integer sse2 extensions
;and reduce driver size
;and reduce driver size
;USE_SSE equ 0
USE_SSE2_MIXER equ 0 ;floating point mixer. Disabled by default
DEBUG equ 1
@ -897,6 +900,7 @@ proc set_vol_param stdcall, l_vol:dword,r_vol:dword,pan:dword
call .calc
fistp word [edx+STREAM.l_amp]
fstp dword [edx+STREAM.l_amp_f]
fstp st0
fild word [r_vol]
@ -904,6 +908,7 @@ proc set_vol_param stdcall, l_vol:dword,r_vol:dword,pan:dword
call .calc
fistp word [edx+STREAM.r_amp]
fstp dword [edx+STREAM.r_amp_f]
fstp st0
fnclex
@ -923,6 +928,7 @@ proc set_vol_param stdcall, l_vol:dword,r_vol:dword,pan:dword
fld1
faddp st1, st0
fscale
fld st0
fimul dword [_32767]
ret 0
endp
@ -1064,12 +1070,20 @@ do_mix_list:
.add_buff:
mov ecx, [ebx+STREAM.out_rp]
mov [eax],ecx
if USE_SSE2_MIXER
mov edi, dword [ebx+STREAM.l_amp_f]
mov [eax+4], edi
mov edi, dword [ebx+STREAM.r_amp_f]
mov [eax+8], edi
else
mov edi, dword [ebx+STREAM.l_amp]
mov [eax+4], edi
end if
add [ebx+STREAM.out_rp], 512
sub [ebx+STREAM.out_count], 512
add eax, 8
add eax, 12
inc edx
.next:
mov ebx, [ebx+STREAM.str_fd]

View File

@ -1,12 +1,12 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2006-2008. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; (C) copyright Serge 2006-2007
; email: infinity_sound@mail.ru
; Serge 2006-2008
; email: infinity_sound@mail.ru
PLAY_SYNC equ 0x80000000
@ -111,7 +111,7 @@ struc STREAM
.out_wp dd ?
.out_rp dd ?
.out_count dd ?
.out_top dd ?
.out_top dd ? ;16*4
.r_size dd ?
.r_dt dd ?
@ -122,6 +122,8 @@ struc STREAM
.l_amp dw ?
.r_amp dw ?
.pan dd ?
.l_amp_f dd ? ;float point left
.r_amp_f dd ? ;float point right
.in_base dd ?
.in_size dd ?
@ -135,7 +137,7 @@ struc STREAM
.notify_id dd ?
}
STREAM_SIZE equ 34*4
STREAM_SIZE equ 36*4
FD_OFFSET equ 24
virtual at 0

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2006-2008. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -9,10 +9,9 @@
; email: infinity_sound@mail.ru
align 4
mix_list rq 32
mix_list rd 32*3
align 4
proc new_mix stdcall, output:dword
@ -252,6 +251,83 @@ proc refill_ring stdcall, str:dword
ret
endp
if USE_SSE2_MIXER
align 4
proc mix_all stdcall, dest:dword, list:dword, count:dword
mov edi, [dest]
mov ebx, 32
.mix:
mov edx, [list]
mov ecx, [count]
mov eax, [edx]
movdqa xmm1, [eax]
movss xmm2, [edx+4]
movss xmm3, [edx+8]
punpcklwd xmm0, xmm1
punpckhwd xmm1, xmm1
shufps xmm2, xmm3, 0
shufps xmm2, xmm2, 0x88
psrad xmm0, 16
psrad xmm1, 16
cvtdq2ps xmm0, xmm0 ;time to use all power
cvtdq2ps xmm1, xmm1 ;of the dark side
mulps xmm0, xmm2
mulps xmm1, xmm2
.mix_loop:
add dword [edx], 16
add edx, 12
dec ecx
jz @F
mov eax, [edx]
movdqa xmm3, [eax]
movss xmm4, [edx+4]
movss xmm5, [edx+8]
punpcklwd xmm2, xmm3
punpckhwd xmm3, xmm3
shufps xmm4, xmm5, 0
shufps xmm4, xmm4, 0x88
psrad xmm2, 16
psrad xmm3, 16
cvtdq2ps xmm2, xmm2
cvtdq2ps xmm3, xmm3
mulps xmm2, xmm4
mulps xmm3, xmm4
addps xmm0, xmm2
addps xmm1, xmm3
jmp .mix_loop
@@:
cvtps2dq xmm0, xmm0
cvtps2dq xmm1, xmm1
packssdw xmm0, xmm0
packssdw xmm1, xmm1
punpcklqdq xmm0, xmm1
movntdq [edi], xmm0
add edi, 16
dec ebx
jnz .mix
ret
endp
else ; fixed point mmx version
align 4
proc mix_all stdcall, dest:dword, list:dword, count:dword
@ -262,7 +338,9 @@ proc mix_all stdcall, dest:dword, list:dword, count:dword
mov ecx, [count]
mov eax, [edx]
movq mm0, [eax]
movd mm1, [edx+4]
punpckldq mm1,mm1
pmulhw mm0, mm1
@ -270,7 +348,7 @@ proc mix_all stdcall, dest:dword, list:dword, count:dword
.mix_loop:
add dword [edx], 8
add edx, 8
add edx, 12
dec ecx
jz @F
@ -291,6 +369,9 @@ proc mix_all stdcall, dest:dword, list:dword, count:dword
ret
endp
end if
align 4
proc resample_1 stdcall, dest:dword,src:dword,\
r_dt:dword, r_size:dword,r_end:dword