[Mplayer-cvslog] CVS: main/libac3/mmx imdct512_kni.S,NONE,1.1 imdct_kni.c,NONE,1.1 srfft_kni.S,NONE,1.1 srfft_kni_c.c,NONE,1.1

Atmosfear atmos4 at mplayer.dev.hu
Tue Jul 10 10:27:51 CEST 2001


Update of /cvsroot/mplayer/main/libac3/mmx
In directory mplayer:/var/tmp.root/cvs-serv2164/mmx

Added Files:
	imdct512_kni.S imdct_kni.c srfft_kni.S srfft_kni_c.c 
Log Message:
More optimized SSE code for libac3, give 10-15% speedup on PIII Cu-Mine.


--- NEW FILE ---
/* 
 *  imdct512_kni.S
 *
 *  Copyright (C) Yuqing Deng <Yuqing_Deng at brown.edu> - October 2000
 *
 *
 *  imdct512_kni.S is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *
 *  imdct512_kni.S is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with GNU Make; see the file COPYING.  If not, write to
 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *  Modified for using with mplayer by Nick Kurshev <nickols_k at mail.ru>
 */

.text
	.align 4
.global imdct512_pre_ifft_twiddle_kni
	.type imdct512_pre_ifft_twiddle_kni, @function
imdct512_pre_ifft_twiddle_kni:
	
	pushl %ebp
	movl  %esp, %ebp
	addl  $-4, %esp /* local variable, loop counter */
	
	pushl %eax
	pushl %ebx
	pushl %ecx
	pushl %edx
	pushl %edi
	pushl %esi

	movl 8(%ebp), %eax  	/* pmt */
	movl 12(%ebp), %ebx	/* buf */
	movl 16(%ebp), %ecx	/* data */
	movl 20(%ebp), %edx 	/* xcos_sin_sse */
	movl $64, -4(%ebp)
	
	
.loop:
	movl (%eax), %esi
	movl 4(%eax), %edi
	movss (%ecx, %esi, 8), %xmm1 /* 2j */
	movss (%ecx, %edi, 8), %xmm3 /* 2(j+1) */

	shll $1, %esi
	shll $1, %edi

	movaps (%edx, %esi, 8), %xmm0; /* -c_j | -s_j | -s_j | c_j */
	movaps (%edx, %edi, 8), %xmm2; /* -c_j+1 | -s_j+1 | -s_j+1 | c_j+1 */

	negl %esi
	negl %edi

	movss 1020(%ecx, %esi, 4), %xmm4 /* 255-2j */
	addl $8, %eax
	movss 1020(%ecx, %edi, 4), %xmm5 /* 255-2(j+1) */

	shufps $0, %xmm1, %xmm4 /* 2j | 2j | 255-2j | 255-2j */
	shufps $0, %xmm3, %xmm5 /* 2(j+1) | 2(j+1) | 255-2(j+1) | 255-2(j+1) */
	mulps %xmm4, %xmm0
	mulps %xmm5, %xmm2
	movhlps %xmm0, %xmm1
	movhlps %xmm2, %xmm3
	addl $16, %ebx
	addps %xmm1, %xmm0
	addps %xmm3, %xmm2
	movlhps %xmm2, %xmm0
	movaps %xmm0, -16(%ebx)
	decl -4(%ebp)
     	jnz .loop

	popl %esi
	popl %edi
	popl %edx
	popl %ecx
	popl %ebx
	popl %eax

	addl $4, %esp
	popl %ebp

	ret
	.p2align 4,0

.global imdct512_post_ifft_twiddle_kni
	.type imdct512_post_ifft_twiddle_kni, @function
imdct512_post_ifft_twiddle_kni:
	
	pushl %ebp
	movl  %esp, %ebp
	
	pushl %eax
	pushl %ebx
	pushl %ecx

	movl 8(%ebp), %eax /* buf[] */
	movl 12(%ebp), %ebx /* xcos_sin_sse[] */
	movl $32, %ecx /* loop counter */

.loop1:
	movaps	(%eax), %xmm0  /*  im1 | re1 | im0 | re0 */

	movaps  (%ebx), %xmm2  /* -c | -s | -s | c */
	movhlps  %xmm0, %xmm1  /* im1 | re1 */
	movaps  16(%ebx), %xmm3  /* -c1 | -s1 | -s1 | c1 */

	shufps $0x50, %xmm0, %xmm0 /* im0 | im0 | re0 | re0 */
	shufps $0x50, %xmm1, %xmm1 /* im1 | im1 | re1 | re1 */

	movaps  16(%eax), %xmm4 /* im3 | re3 | im2 | re2 */

	shufps $0x27, %xmm2, %xmm2 /* c | -s | -s | -c */
	movhlps  %xmm4, %xmm5 /* im3 | re3 */
	shufps $0x27, %xmm3, %xmm3 /* c1 | -s1 | -s1 | -c1 */

	movaps  32(%ebx), %xmm6   /* -c2 | -s2 | -s2 | c2 */
	movaps  48(%ebx), %xmm7   /* -c3 | -s3 | -s3 | c3 */

	shufps $0x50, %xmm4, %xmm4 /* im2 | im2 | re2 | re2 */
	shufps $0x50, %xmm5, %xmm5 /* im3 | im3 | re3 | re3 */

	mulps %xmm2, %xmm0
	mulps %xmm3, %xmm1

	shufps $0x27, %xmm6, %xmm6 /* c2 | -s2 | -s2 | -c2 */
	shufps $0x27, %xmm7, %xmm7 /* c3 | -s3 | -s3 | -c3 */

	movhlps %xmm0, %xmm2
	movhlps %xmm1, %xmm3

	mulps %xmm6, %xmm4
	mulps %xmm7, %xmm5

	addps %xmm2, %xmm0
	addps %xmm3, %xmm1

	movhlps %xmm4, %xmm6
	movhlps %xmm5, %xmm7

	addps %xmm6, %xmm4
	addps %xmm7, %xmm5

	movlhps %xmm1, %xmm0
	movlhps %xmm5, %xmm4

	movaps %xmm0, (%eax)
	movaps %xmm4, 16(%eax)
	addl $64, %ebx
	addl $32, %eax
	decl %ecx
	jnz .loop1

	popl %ecx
	popl %ebx
	popl %eax

	leave
	ret
	.p2align 4,0

.global imdct512_window_delay_kni
	.type imdct512_window_delay_kni, @function
imdct512_window_delay_kni:
	
	pushl %ebp
	movl  %esp, %ebp
	
	pushl %eax
	pushl %ebx
	pushl %ecx
	pushl %edx
	pushl %esi
	pushl %edi

	movl 20(%ebp), %ebx /* delay */
	movl 16(%ebp), %edx /* window */

	movl 8(%ebp), %eax  /* buf */
	movl $16, %ecx /* loop count */
	leal 516(%eax), %esi /* buf[64].im */
	leal 504(%eax), %edi /* buf[63].re */ 
	movl 12(%ebp), %eax /* data */
.first_128_samples:

	movss (%esi), %xmm0
	movss 8(%esi), %xmm2
	movss (%edi), %xmm1
	movss -8(%edi), %xmm3

	movlhps %xmm2, %xmm0 /* 0.0 | im1 | 0.0 | im0 */
	movlhps %xmm3, %xmm1 /* 0.0 | re1 | 0.0 | re0 */

	movaps (%edx), %xmm4 /* w3 | w2 | w1 | w0 */
	movaps (%ebx), %xmm5 /* d3 | d2 | d1 | d0 */
	shufps $0xb1, %xmm1, %xmm1 /* re1 | 0.0 | re0 | 0.0 */

	movss 16(%esi), %xmm6 /* im2 */
	movss 24(%esi), %xmm7 /* im3 */
	subps %xmm1, %xmm0  /* -re1 | im1 | -re0 | im0 */
	movss -16(%edi), %xmm2 /* re2 */
	movss -24(%edi), %xmm3 /* re3 */
	mulps %xmm4, %xmm0
	movlhps %xmm7, %xmm6 /* 0.0 | im3 | 0.0 | im2 */
	movlhps %xmm3, %xmm2 /* 0.0 | re3 | 0.0 | re2 */
	addps %xmm5, %xmm0
	shufps $0xb1, %xmm2, %xmm2 /* re3 | 0.0 | re2 | 0.0 */
	movaps 16(%edx), %xmm4 /* w7 | w6 | w5 | w4 */
	movaps 16(%ebx), %xmm5 /* d7 | d6 | d5 | d4 */
	subps %xmm2, %xmm6 /* -re3 | im3 | -re2 | im2 */
	addl $32, %edx
	movaps %xmm0, (%eax)
	addl $32, %ebx
	mulps %xmm4, %xmm6
	addl $32, %esi
	addl $32, %eax
	addps %xmm5, %xmm6
	addl $-32, %edi
	movaps %xmm6, -16(%eax)
	decl %ecx
	jnz .first_128_samples

	movl 8(%ebp), %esi  /* buf[0].re */
	leal 1020(%esi), %edi /* buf[127].im */ 
	movl $16, %ecx /* loop count */
.second_128_samples:

	movss (%esi), %xmm0 /* buf[i].re */
	movss 8(%esi), %xmm2 /* re1 */
	movss (%edi), %xmm1 /* buf[127-i].im */
	movss -8(%edi), %xmm3 /* im1 */

	movlhps %xmm2, %xmm0 /* 0.0 | re1 | 0.0 | re0 */
	movlhps %xmm3, %xmm1 /* 0.0 | im1 | 0.0 | im1 */
	
	movaps (%edx), %xmm4 /* w3 | w2 | w1 | w0 */
	movaps (%ebx), %xmm5 /* d3 | d2 | d1 | d0 */

	shufps $0xb1, %xmm1, %xmm1 /* im1 | 0.0 | im0 | 0.0 */
	movss 16(%esi), %xmm6 /* re2 */
	movss 24(%esi), %xmm7 /* re3 */
	movss -16(%edi), %xmm2 /* im2 */
	movss -24(%edi), %xmm3 /* im3 */
	subps %xmm1, %xmm0 /* -im1 | re1 | -im0 | re0 */
	movlhps %xmm7, %xmm6 /* 0.0 | re3 | 0.0 | re2 */
	movlhps %xmm3, %xmm2 /* 0.0 | im3 | 0.0 | im2 */
	mulps %xmm4, %xmm0
	shufps $0xb1, %xmm2, %xmm2 /* im3 | 0.0 | im2 | 0.0 */
	movaps 16(%edx), %xmm4 /* w7 | w6 | w5 | w4 */
	addl $32, %esi
	subps %xmm2, %xmm6 /* -im3 | re3 | -im2 | re2 */
	addps %xmm5, %xmm0
	mulps %xmm4, %xmm6
	addl $-32, %edi
	movaps 16(%ebx), %xmm5 /* d7 | d6 | d5 | d4 */
	movaps %xmm0, (%eax)
	addps %xmm5, %xmm6
	addl $32, %edx
	addl $32, %eax
	addl $32, %ebx
	movaps %xmm6, -16(%eax)
	decl %ecx
	jnz .second_128_samples

	movl 8(%ebp), %eax
	leal 512(%eax), %esi /* buf[64].re */
	leal 508(%eax), %edi /* buf[63].im */ 
	movl $16, %ecx /* loop count */
	movl 20(%ebp), %eax /* delay */
.first_128_delay:

	movss (%esi), %xmm0
	movss 8(%esi), %xmm2
	movss (%edi), %xmm1
	movss -8(%edi), %xmm3

	movlhps %xmm2, %xmm0 /* 0.0 | re1 | 0.0 | re0 */
	movlhps %xmm3, %xmm1 /* 0.0 | im1 | 0.0 | im0 */

	movaps -16(%edx), %xmm4 /* w3 | w2 | w1 | w0 */
	shufps $0xb1, %xmm1, %xmm1 /* im1 | 0.0 | im0 | 0.0 */
	movss 16(%esi), %xmm6 /* re2 */
	movss 24(%esi), %xmm7 /* re3 */
	movss -16(%edi), %xmm2 /* im2 */
	movss -24(%edi), %xmm3 /* im3 */
	subps %xmm1, %xmm0 /* -im1 | re1 | -im0 | re0 */
	addl $-32, %edx
	movlhps %xmm7, %xmm6 /* 0.0 | re3 | 0.0 | re2 */
	movlhps %xmm3, %xmm2 /* 0.0 | im3 | 0.0 | im2 */
	mulps %xmm4, %xmm0
	movaps (%edx), %xmm5 /* w7 | w6 | w5 | w4 */
	shufps $0xb1, %xmm2, %xmm2 /* im3 | 0.0 | im2 | 0.0 */
	movaps %xmm0, (%eax)
	addl $32, %esi
	subps %xmm2, %xmm6 /* -im3 | re3 | -im2 | re2 */
	addl $-32, %edi
	mulps %xmm5, %xmm6
	addl $32, %eax
	movaps %xmm6, -16(%eax)
	decl %ecx
	jnz .first_128_delay

	movl 8(%ebp), %ebx
	leal 4(%ebx), %esi /* buf[0].im */
	leal 1016(%ebx), %edi /* buf[127].re */ 
	movl $16, %ecx /* loop count */
.second_128_delay:

	movss (%esi), %xmm0
	movss 8(%esi), %xmm2
	movss (%edi), %xmm1
	movss -8(%edi), %xmm3

	movlhps %xmm2, %xmm0 /* 0.0 | im1 | 0.0 | im0 */
	movlhps %xmm3, %xmm1 /* 0.0 | re1 | 0.0 | re0 */

	movaps -16(%edx), %xmm4 /* w3 | w2 | w1 | w0 */
	shufps $0xb1, %xmm1, %xmm1 /* re1 | 0.0 | re0 | 0.0 */
	movss 16(%esi), %xmm6 /* im2 */
	movss 24(%esi), %xmm7 /* im3 */
	movss -16(%edi), %xmm2 /* re2 */
	movss -24(%edi), %xmm3 /* re3 */
	subps %xmm0, %xmm1 /* re1 | -im1 | re0 | -im0 */
	addl $-32, %edx
	movlhps %xmm7, %xmm6 /* 0.0 | im3 | 0.0 | im2 */
	movlhps %xmm3, %xmm2 /* 0.0 | re3 | 0.0 | re2 */
	mulps %xmm4, %xmm1
	movaps (%edx), %xmm5 /* w7 | w6 | w5 | w4 */
	shufps $0xb1, %xmm2, %xmm2 /* re3 | 0.0 | re2 | 0.0 */
	movaps %xmm1, (%eax)
	addl $32, %esi
	subps %xmm6, %xmm2 /* re | -im3 | re | -im2 */
	addl $-32, %edi
	mulps %xmm5, %xmm2
	addl $32, %eax
	movaps %xmm2, -16(%eax)
	decl %ecx
	jnz .second_128_delay

	popl %edi
	popl %esi
	popl %edx
	popl %ecx
	popl %ebx
	popl %eax
	
	leave
	ret
	.p2align 4,0
	
.global imdct512_window_delay_nol_kni
	.type imdct512_window_delay_nol_kni, @function
imdct512_window_delay_nol_kni:
	
	pushl %ebp
	movl  %esp, %ebp
	
	pushl %eax
	pushl %ebx
	pushl %ecx
	pushl %edx
	pushl %esi
	pushl %edi

	/* movl 20(%ebp), %ebx delay */
	movl 16(%ebp), %edx /* window */

	movl 8(%ebp), %eax  /* buf */
	movl $16, %ecx /* loop count */
	leal 516(%eax), %esi /* buf[64].im */
	leal 504(%eax), %edi /* buf[63].re */ 
	movl 12(%ebp), %eax /* data */
.first_128_sample:

	movss (%esi), %xmm0
	movss 8(%esi), %xmm2
	movss (%edi), %xmm1
	movss -8(%edi), %xmm3

	movlhps %xmm2, %xmm0 /* 0.0 | im1 | 0.0 | im0 */
	movlhps %xmm3, %xmm1 /* 0.0 | re1 | 0.0 | re0 */

	movaps (%edx), %xmm4 /* w3 | w2 | w1 | w0 */
	/* movaps (%ebx), %xmm5 d3 | d2 | d1 | d0 */
	shufps $0xb1, %xmm1, %xmm1 /* re1 | 0.0 | re0 | 0.0 */

	movss 16(%esi), %xmm6 /* im2 */
	movss 24(%esi), %xmm7 /* im3 */
	subps %xmm1, %xmm0  /* -re1 | im1 | -re0 | im0 */
	movss -16(%edi), %xmm2 /* re2 */
	movss -24(%edi), %xmm3 /* re3 */
	mulps %xmm4, %xmm0
	movlhps %xmm7, %xmm6 /* 0.0 | im3 | 0.0 | im2 */
	movlhps %xmm3, %xmm2 /* 0.0 | re3 | 0.0 | re2 */
	/* addps %xmm5, %xmm0 */
	shufps $0xb1, %xmm2, %xmm2 /* re3 | 0.0 | re2 | 0.0 */
	movaps 16(%edx), %xmm4 /* w7 | w6 | w5 | w4 */
	/* movaps 16(%ebx), %xmm5  d7 | d6 | d5 | d4 */
	subps %xmm2, %xmm6 /* -re3 | im3 | -re2 | im2 */
	addl $32, %edx
	movaps %xmm0, (%eax)
	/* addl $32, %ebx */
	mulps %xmm4, %xmm6
	addl $32, %esi
	addl $32, %eax
	/* addps %xmm5, %xmm6 */
	addl $-32, %edi
	movaps %xmm6, -16(%eax)
	decl %ecx
	jnz .first_128_sample

	movl 8(%ebp), %esi  /* buf[0].re */
	leal 1020(%esi), %edi /* buf[127].im */ 
	movl $16, %ecx /* loop count */
.second_128_sample:

	movss (%esi), %xmm0 /* buf[i].re */
	movss 8(%esi), %xmm2 /* re1 */
	movss (%edi), %xmm1 /* buf[127-i].im */
	movss -8(%edi), %xmm3 /* im1 */

	movlhps %xmm2, %xmm0 /* 0.0 | re1 | 0.0 | re0 */
	movlhps %xmm3, %xmm1 /* 0.0 | im1 | 0.0 | im1 */
	
	movaps (%edx), %xmm4 /* w3 | w2 | w1 | w0 */
	/* movaps (%ebx), %xmm5 d3 | d2 | d1 | d0 */

	shufps $0xb1, %xmm1, %xmm1 /* im1 | 0.0 | im0 | 0.0 */
	movss 16(%esi), %xmm6 /* re2 */
	movss 24(%esi), %xmm7 /* re3 */
	movss -16(%edi), %xmm2 /* im2 */
	movss -24(%edi), %xmm3 /* im3 */
	subps %xmm1, %xmm0 /* -im1 | re1 | -im0 | re0 */
	movlhps %xmm7, %xmm6 /* 0.0 | re3 | 0.0 | re2 */
	movlhps %xmm3, %xmm2 /* 0.0 | im3 | 0.0 | im2 */
	mulps %xmm4, %xmm0
	shufps $0xb1, %xmm2, %xmm2 /* im3 | 0.0 | im2 | 0.0 */
	movaps 16(%edx), %xmm4 /* w7 | w6 | w5 | w4 */
	addl $32, %esi
	subps %xmm2, %xmm6 /* -im3 | re3 | -im2 | re2 */
	/* addps %xmm5, %xmm0 */
	mulps %xmm4, %xmm6
	addl $-32, %edi
	/* movaps 16(%ebx), %xmm5  d7 | d6 | d5 | d4 */
	movaps %xmm0, (%eax)
	/* addps %xmm5, %xmm6 */
	addl $32, %edx
	addl $32, %eax
	/* addl $32, %ebx */
	movaps %xmm6, -16(%eax)
	decl %ecx
	jnz .second_128_sample

	movl 8(%ebp), %eax
	leal 512(%eax), %esi /* buf[64].re */
	leal 508(%eax), %edi /* buf[63].im */ 
	movl $16, %ecx /* loop count */
	movl 20(%ebp), %eax /* delay */
.first_128_delays:

	movss (%esi), %xmm0
	movss 8(%esi), %xmm2
	movss (%edi), %xmm1
	movss -8(%edi), %xmm3

	movlhps %xmm2, %xmm0 /* 0.0 | re1 | 0.0 | re0 */
	movlhps %xmm3, %xmm1 /* 0.0 | im1 | 0.0 | im0 */

	movaps -16(%edx), %xmm4 /* w3 | w2 | w1 | w0 */
	shufps $0xb1, %xmm1, %xmm1 /* im1 | 0.0 | im0 | 0.0 */
	movss 16(%esi), %xmm6 /* re2 */
	movss 24(%esi), %xmm7 /* re3 */
	movss -16(%edi), %xmm2 /* im2 */
	movss -24(%edi), %xmm3 /* im3 */
	subps %xmm1, %xmm0 /* -im1 | re1 | -im0 | re0 */
	addl $-32, %edx
	movlhps %xmm7, %xmm6 /* 0.0 | re3 | 0.0 | re2 */
	movlhps %xmm3, %xmm2 /* 0.0 | im3 | 0.0 | im2 */
	mulps %xmm4, %xmm0
	movaps (%edx), %xmm5 /* w7 | w6 | w5 | w4 */
	shufps $0xb1, %xmm2, %xmm2 /* im3 | 0.0 | im2 | 0.0 */
	movaps %xmm0, (%eax)
	addl $32, %esi
	subps %xmm2, %xmm6 /* -im3 | re3 | -im2 | re2 */
	addl $-32, %edi
	mulps %xmm5, %xmm6
	addl $32, %eax
	movaps %xmm6, -16(%eax)
	decl %ecx
	jnz .first_128_delays

	movl 8(%ebp), %ebx
	leal 4(%ebx), %esi /* buf[0].im */
	leal 1016(%ebx), %edi /* buf[127].re */ 
	movl $16, %ecx /* loop count */
.second_128_delays:

	movss (%esi), %xmm0
	movss 8(%esi), %xmm2
	movss (%edi), %xmm1
	movss -8(%edi), %xmm3

	movlhps %xmm2, %xmm0 /* 0.0 | im1 | 0.0 | im0 */
	movlhps %xmm3, %xmm1 /* 0.0 | re1 | 0.0 | re0 */

	movaps -16(%edx), %xmm4 /* w3 | w2 | w1 | w0 */
	shufps $0xb1, %xmm1, %xmm1 /* re1 | 0.0 | re0 | 0.0 */
	movss 16(%esi), %xmm6 /* im2 */
	movss 24(%esi), %xmm7 /* im3 */
	movss -16(%edi), %xmm2 /* re2 */
	movss -24(%edi), %xmm3 /* re3 */
	subps %xmm0, %xmm1 /* re1 | -im1 | re0 | -im0 */
	addl $-32, %edx
	movlhps %xmm7, %xmm6 /* 0.0 | im3 | 0.0 | im2 */
	movlhps %xmm3, %xmm2 /* 0.0 | re3 | 0.0 | re2 */
	mulps %xmm4, %xmm1
	movaps (%edx), %xmm5 /* w7 | w6 | w5 | w4 */
	shufps $0xb1, %xmm2, %xmm2 /* re3 | 0.0 | re2 | 0.0 */
	movaps %xmm1, (%eax)
	addl $32, %esi
	subps %xmm6, %xmm2 /* re | -im3 | re | -im2 */
	addl $-32, %edi
	mulps %xmm5, %xmm2
	addl $32, %eax
	movaps %xmm2, -16(%eax)
	decl %ecx
	jnz .second_128_delays

	popl %edi
	popl %esi
	popl %edx
	popl %ecx
	popl %ebx
	popl %eax
	
	leave
	ret
	.p2align 4,0

--- NEW FILE ---
/* 
 *  imdct_kni.c
 *
 *	Copyright (C) Aaron Holtzman - May 1999
 *
 *  This file is part of ac3dec, a free Dolby AC-3 stream decoder.
 *	
 *  ac3dec is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *   
 *  ac3dec is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *   
 *  You should have received a copy of the GNU General Public License
 *  along with GNU Make; see the file COPYING.  If not, write to
 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
 *
 *  Modified for using with mplayer by Nick Kurshev <nickols_k at mail.ru>
 */
 
extern void fft_128p_kni(complex_t *);
extern void fft_64p_kni(complex_t *);

/* Delay buffer for time domain interleaving */
static float xcos_sin_sse[128 * 4] __attribute__((aligned(16)));

extern void imdct512_pre_ifft_twiddle_kni(const int *pmt, complex_t *buf, float *data, float *xcos_sin_sse);
extern void imdct512_post_ifft_twiddle_kni(complex_t *buf, float *xcos_sin_sse);
extern void imdct512_window_delay_kni(complex_t *buf, float *data_ptr, float *window_prt, float *delay_prt);
extern void imdct512_window_delay_nol_kni(complex_t *buf, float *data_ptr, float *window_prt, float *delay_prt);

void imdct_init (void)
{
  int i;
  float scale = 255.99609372;

  for (i=0; i < 128; i++) {
	float xcos_i = cos(2.0f * M_PI * (8*i+1)/(8*N)) * scale;
       	float xsin_i = sin(2.0f * M_PI * (8*i+1)/(8*N)) * scale;
       	xcos_sin_sse[i * 4] = xcos_i;
       	xcos_sin_sse[i * 4 + 1] = -xsin_i;
       	xcos_sin_sse[i * 4 + 2] = -xsin_i;
       	xcos_sin_sse[i * 4 + 3] = -xcos_i;
  }
}


static void imdct_do_512 (float data[], float delay[])
{
	imdct512_pre_ifft_twiddle_kni (pm128, buf, data, xcos_sin_sse);
	fft_128p_kni (buf);
	imdct512_post_ifft_twiddle_kni (buf, xcos_sin_sse);
	imdct512_window_delay_kni (buf, data, window, delay);
}


static void imdct_do_512_nol (float data[], float delay[])
{
	imdct512_pre_ifft_twiddle_kni (pm128, buf, data, xcos_sin_sse);  
	fft_128p_kni (buf);
	imdct512_post_ifft_twiddle_kni (buf, xcos_sin_sse);
	imdct512_window_delay_nol_kni (buf, data, window, delay);
}

static void imdct_do_256 (float data[],float delay[])
{
	int i, j, k;
	int p, q;

	float tmp_a_i;
	float tmp_a_r;

	float *data_ptr;
	float *delay_ptr;
	float *window_ptr;

	complex_t *buf1, *buf2;

	buf1 = &buf[0];
	buf2 = &buf[64];

// Pre IFFT complex multiply plus IFFT complex conjugate
	for (k=0; k<64; k++) { 
		/* X1[k] = X[2*k]	*/
		/* X2[k] = X[2*k+1]	*/

		j = pm64[k];
		p = 2 * (128-2*j-1);
		q = 2 * (2 * j);

		/* Z1[k] = (X1[128-2*k-1] + j * X1[2*k]) * (xcos2[k] + j * xsin2[k]); */
		buf1[k].re =         data[p] * xcos2[j] - data[q] * xsin2[j];
		buf1[k].im = -1.0f * (data[q] * xcos2[j] + data[p] * xsin2[j]);
		/* Z2[k] = (X2[128-2*k-1] + j * X2[2*k]) * (xcos2[k] + j * xsin2[k]); */
		buf2[k].re =          data[p + 1] * xcos2[j] - data[q + 1] * xsin2[j];
		buf2[k].im = -1.0f * ( data[q + 1] * xcos2[j] + data[p + 1] * xsin2[j]);
	}

	fft_64p_kni(&buf1[0]);
	fft_64p_kni(&buf2[0]);

#ifdef DEBUG
       //DEBUG FFT
#if 0
	printf ("Post FFT, buf1\n");
	for (i=0; i < 64; i++)
		printf("%d %f %f\n", i, buf_1[i].re, buf_1[i].im);
	printf ("Post FFT, buf2\n");
	for (i=0; i < 64; i++)
		printf("%d %f %f\n", i, buf_2[i].re, buf_2[i].im);
#endif
#endif


	// Post IFFT complex multiply 
	for( i=0; i < 64; i++) {
		tmp_a_r =  buf1[i].re;
		tmp_a_i = -buf1[i].im;
		buf1[i].re =(tmp_a_r * xcos2[i])  -  (tmp_a_i  * xsin2[i]);
		buf1[i].im =(tmp_a_r * xsin2[i])  +  (tmp_a_i  * xcos2[i]);
		tmp_a_r =  buf2[i].re;
		tmp_a_i = -buf2[i].im;
		buf2[i].re =(tmp_a_r * xcos2[i])  -  (tmp_a_i  * xsin2[i]);
		buf2[i].im =(tmp_a_r * xsin2[i])  +  (tmp_a_i  * xcos2[i]);
	}
	
	data_ptr = data;
	delay_ptr = delay;
	window_ptr = window;

	/* Window and convert to real valued signal */
	for(i=0; i< 64; i++) { 
		*data_ptr++  = -buf1[i].im      * *window_ptr++ + *delay_ptr++;
		*data_ptr++  =  buf1[64-i-1].re * *window_ptr++ + *delay_ptr++;
	}

	for(i=0; i< 64; i++) {
		*data_ptr++  = -buf1[i].re      * *window_ptr++ + *delay_ptr++;
		*data_ptr++  =  buf1[64-i-1].im * *window_ptr++ + *delay_ptr++;
	}
	
	delay_ptr = delay;

	for(i=0; i< 64; i++) {
		*delay_ptr++ = -buf2[i].re      * *--window_ptr;
		*delay_ptr++ =  buf2[64-i-1].im * *--window_ptr;
	}

	for(i=0; i< 64; i++) {
		*delay_ptr++ =  buf2[i].im      * *--window_ptr;
		*delay_ptr++ = -buf2[64-i-1].re * *--window_ptr;
	}
}


/**
 *
 **/

static void imdct_do_256_nol (float data[], float delay[])
{
	int i, j, k;
	int p, q;

	float tmp_a_i;
	float tmp_a_r;

	float *data_ptr;
	float *delay_ptr;
	float *window_ptr;

	complex_t *buf1, *buf2;

	buf1 = &buf[0];
	buf2 = &buf[64];

       /* Pre IFFT complex multiply plus IFFT cmplx conjugate */
	for(k=0; k<64; k++) {
               /* X1[k] = X[2*k]  */
               /* X2[k] = X[2*k+1]     */
               j = pm64[k];
               p = 2 * (128-2*j-1);
               q = 2 * (2 * j);

               /* Z1[k] = (X1[128-2*k-1] + j * X1[2*k]) * (xcos2[k] + j * xsin2[k]); */
               buf1[k].re =         data[p] * xcos2[j] - data[q] * xsin2[j];
               buf1[k].im = -1.0f * (data[q] * xcos2[j] + data[p] * xsin2[j]);
               /* Z2[k] = (X2[128-2*k-1] + j * X2[2*k]) * (xcos2[k] + j * xsin2[k]); */
               buf2[k].re =          data[p + 1] * xcos2[j] - data[q + 1] * xsin2[j];
               buf2[k].im = -1.0f * ( data[q + 1] * xcos2[j] + data[p + 1] * xsin2[j]);
       }


       fft_64p_kni(&buf1[0]);
       fft_64p_kni(&buf2[0]);

#ifdef DEBUG
	//DEBUG FFT
#if 0
       printf("Post FFT, buf1\n");
       for (i=0; i < 64; i++)
               printf("%d %f %f\n", i, buf_1[i].re, buf_1[i].im);
       printf("Post FFT, buf2\n");
       for (i=0; i < 64; i++)
               printf("%d %f %f\n", i, buf_2[i].re, buf_2[i].im);
#endif
#endif

       /* Post IFFT complex multiply */
       for( i=0; i < 64; i++) {
               /* y1[n] = z1[n] * (xcos2[n] + j * xs in2[n]) ; */
               tmp_a_r =  buf1[i].re;
               tmp_a_i = -buf1[i].im;
               buf1[i].re =(tmp_a_r * xcos2[i])  -  (tmp_a_i  * xsin2[i]);
               buf1[i].im =(tmp_a_r * xsin2[i])  +  (tmp_a_i  * xcos2[i]);
               /* y2[n] = z2[n] * (xcos2[n] + j * xsin2[n]) ; */
               tmp_a_r =  buf2[i].re;
               tmp_a_i = -buf2[i].im;
               buf2[i].re =(tmp_a_r * xcos2[i])  -  (tmp_a_i  * xsin2[i]);
               buf2[i].im =(tmp_a_r * xsin2[i])  +  (tmp_a_i  * xcos2[i]);
       }
      
       data_ptr = data;
       delay_ptr = delay;
       window_ptr = window;

       /* Window and convert to real valued signal, no overlap */
       for(i=0; i< 64; i++) {
               *data_ptr++  = -buf1[i].im      * *window_ptr++;
               *data_ptr++  =  buf1[64-i-1].re * *window_ptr++;
       }

       for(i=0; i< 64; i++) {
               *data_ptr++  = -buf1[i].re      * *window_ptr++ + *delay_ptr++;
               *data_ptr++  =  buf1[64-i-1].im * *window_ptr++ + *delay_ptr++;
       }

       delay_ptr = delay;

       for(i=0; i< 64; i++) {
               *delay_ptr++ = -buf2[i].re      * *--window_ptr;
               *delay_ptr++ =  buf2[64-i-1].im * *--window_ptr;
       }

       for(i=0; i< 64; i++) {
               *delay_ptr++ =  buf2[i].im      * *--window_ptr;
               *delay_ptr++ = -buf2[64-i-1].re * *--window_ptr;
	}
}

--- NEW FILE ---
/* 
 *  srfft_kni.S
 *
 *  Copyright (C) Yuqing Deng <Yuqing_Deng at brown.edu> - October 2000
 *
 *
 *  srfft_kni.S is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *
 *  srfft_kni.S is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with GNU Make; see the file COPYING.  If not, write to
 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *  Modified for using with mplayer by Nick Kurshev <nickols_k at mail.ru>
 */

.section	.rodata
	.align 16
hsqrt2:	 .float 0f0.707106781188
	 .float 0f0.707106781188
	 .float 0f-0.707106781188
	 .float 0f-0.707106781188
C_1:	 .float 0f-1.0
	 .float 0f1.0
	 .float 0f-1.0
	 .float 0f1.0
	
.text
	.align 4
.global fft_4_kni
	.type fft_4_kni, @function
fft_4_kni:
	pushl %ebp
	movl %esp, %ebp
	movl 8(%ebp), %eax		/* complex_t * */
	
	movaps (%eax), %xmm0		/* x[1] | x[0] */
	movaps 16(%eax), %xmm2		/* x[3] | x[2] */
	movaps %xmm0, %xmm1		/* x[1] | x[0] */
	addps %xmm2, %xmm0		/* x[1] + x[3] | x[0] + x[2] */
	subps %xmm2, %xmm1		/* x[1] - x[3] | x[0] - x[2] */
	xorps %xmm6, %xmm6
	movhlps %xmm1, %xmm4		/* x[1] - x[3] */
	movhlps %xmm0, %xmm3		/* x[1] + x[3] */
	subss %xmm4, %xmm6		/* -(x[1] - x[3]).re */
	movlhps %xmm1, %xmm0		/* x[0] - x[2] | x[0] + x[2] */
	movss %xmm6, %xmm4		/* (x[1] - x[3]).im | (x[3]-x[1]).re */
	movaps %xmm0, %xmm2		/* x[0] - x[2] | x[0] + x[2] */
	shufps $0x14, %xmm4, %xmm3	/* -i*(x[2] - x[3] | x[2] + x[3] */
	addps %xmm3, %xmm0
	subps %xmm3, %xmm2
	movaps %xmm0, (%eax)
	movaps %xmm2, 16(%eax)

	leave
	ret
	

	.align 4
.global fft_8_kni
	.type fft_8_kni, @function
fft_8_kni:
	pushl %ebp
	movl %esp, %ebp
	movl 8(%ebp), %eax		/* complext_t */

	pushl %ebx
	movlps (%eax), %xmm0		/* x[0] */
	movlps 32(%eax), %xmm1		/* x[4] */
	movhps 16(%eax), %xmm0		/* x[2] | x[0] */
	movhps 48(%eax), %xmm1		/* x[6] | x[4] */
	movaps %xmm0, %xmm2		/* x[2] | x[0] */
	xorps %xmm3, %xmm3
	addps %xmm1, %xmm0		/* x[2] + x[6] | x[0] + x[4] */
	subps %xmm1, %xmm2		/* x[2] - x[6] | x[0] - x[4] */
	movhlps %xmm0, %xmm5		/* x[2] + x[6] */
	movhlps %xmm2, %xmm4
	movlhps %xmm2, %xmm0		/* x[0] - x[4] | x[0] + x[4] */
	subss %xmm4, %xmm3		/* -(x[2]-x[6]).re */
	movaps %xmm0, %xmm7		/* x[0] - x[4] | x[0] + x[4] */
	movss %xmm3, %xmm4		/* (x[2]-x[6]).im | -(x[2]-x[6]).re */
	movlps 8(%eax), %xmm1		/* x[1] */
	shufps $0x14, %xmm4, %xmm5	/* -i*(x[2] - x[6]) | x[2] + x[6] */

	addps %xmm5, %xmm0		/* yt */
	subps %xmm5, %xmm7		/* yb */

	movhps 24(%eax), %xmm1		/* x[3] | x[1] */
	movl $hsqrt2, %ebx
	movlps 40(%eax), %xmm2		/* x[5] */
	movhps 56(%eax), %xmm2		/* /x[7] | x[5] */
	movaps %xmm1, %xmm3		/* x[3] | x[1] */
	addps %xmm2, %xmm1		/* x[3] + x[7] | x[1] + x[5] */
	subps %xmm2, %xmm3		/* x[3] - x[7] | x[1] - x[5] */
	movaps (%ebx), %xmm4		/* -1/sqrt2 | -1/sqrt2 | 1/sqrt2 | 1/sqrt2 */
	movaps %xmm3, %xmm6		/* x[3] - x[7] | x[1] - x[5] */
	mulps %xmm4, %xmm3
	shufps $0xc8, %xmm4, %xmm4	/* -1/sqrt2 | 1/sqrt2 | -1/sqrt2 | 1/sqrt2 */
	shufps $0xb1, %xmm6, %xmm6
	mulps %xmm4, %xmm6
	addps %xmm3, %xmm6		/* (-1-i)/sqrt2 * (x[3]-x[7]) | (1-i)/sqrt2 * (x[1] - x[5] */
	movhlps %xmm1, %xmm5		/* x[3] + x[7] */
	movlhps %xmm6, %xmm1		/* (1+i)/sqrt2 * (x[1]-x[5]) | x[1]+x[5] */
	shufps $0xe4, %xmm6, %xmm5	/* (-1-i)/sqrt2 * (x[3]-x[7]) | x[3]+x[7] */
	movaps %xmm1, %xmm3		/* (1-i)/sqrt2 * (x[1]-x[5]) | x[1]+x[5] */
	movl $C_1, %ebx
	addps %xmm5, %xmm1		/* u */
	subps %xmm5, %xmm3		/* v */
	movaps %xmm0, %xmm2		/* yb */
	movaps %xmm7, %xmm4		/* yt */
	movaps (%ebx), %xmm5
	mulps %xmm5, %xmm3
	addps %xmm1, %xmm0		/* yt + u */
	subps %xmm1, %xmm2		/* yt - u */
	shufps $0xb1, %xmm3, %xmm3		/* -i * v */
	movaps %xmm0, (%eax)
	movaps %xmm2, 32(%eax)
	addps %xmm3, %xmm4		/* yb - i*v */
	subps %xmm3, %xmm7		/* yb + i*v */
	movaps %xmm4, 16(%eax)
	movaps %xmm7, 48(%eax)

	popl %ebx
	leave
	ret

	.align 4
.global fft_asmb_kni 
	.type fft_asmb, @function
fft_asmb_kni:
	pushl %ebp
	movl %esp, %ebp

	subl $4, %esp
		
	pushl %eax
	pushl %ebx
	pushl %ecx
	pushl %edx
	pushl %esi
	pushl %edi

	movl 8(%ebp),  %ecx		/* k */
	movl 12(%ebp), %eax		/* x */
	movl %ecx, -4(%ebp)		/* k */
	movl 16(%ebp), %ebx		/* wT */
	movl 20(%ebp), %edx		/* d */
	movl 24(%ebp), %esi		/* d3 */
	shll $4, %ecx			/* 16k */
	addl $8, %edx
	leal (%eax, %ecx, 2), %edi
	addl $8, %esi
	
	/* TRANSZERO and TRANS */
	movaps (%eax), %xmm0		/* x[1] | x[0] */
	movaps (%ebx), %xmm1		/* wT[1] | wT[0] */
	movaps (%ebx, %ecx), %xmm2	/* wB[1] | wB[0] */
	movlps (%edx), %xmm3		/* d */
	movlps (%esi), %xmm4		/* d3 */
	movhlps %xmm1, %xmm5		/* wT[1] */
	movhlps %xmm2, %xmm6		/* wB[1] */
	shufps $0x50, %xmm3, %xmm3	/* d[1].im | d[1].im | d[1].re | d[1].re */
	shufps $0x50, %xmm4, %xmm4	/* d3[1].im | d3[1].im | d3[i].re | d3[i].re */
	movlhps %xmm5, %xmm5		/* wT[1] | wT[1] */
	movlhps %xmm6, %xmm6		/* wB[1] | wB[1] */
	mulps %xmm3, %xmm5
	mulps %xmm4, %xmm6
	movhlps %xmm5, %xmm7		/* wT[1].im * d[1].im | wT[1].re * d[1].im */
	movlhps %xmm6, %xmm5		/* wB[1].im * d3[1].re | wB[1].re * d3[1].re | wT[1].im * d[1].re | wT[1].re * d[1].re */
	shufps $0xb1, %xmm6, %xmm7	/* wB[1].re * d3[1].im | wB[i].im * d3[1].im | wT[1].re * d[1].im | wT[1].im * d[1].im */
	movl $C_1, %edi
	movaps (%edi), %xmm4
	mulps %xmm4, %xmm7
	addps %xmm7, %xmm5		/* wB[1] * d3[1] | wT[1] * d[1] */
	movlhps %xmm5, %xmm1		/* d[1] * wT[1] | wT[0] */
	shufps $0xe4, %xmm5, %xmm2	/* d3[1] * wB[1] | wB[0] */
	movaps %xmm1, %xmm3		/* d[1] * wT[1] | wT[0] */
	leal (%eax, %ecx, 2), %edi
	addps %xmm2, %xmm1		/* u */
	subps %xmm2, %xmm3		/* v */
	mulps %xmm4, %xmm3
	movaps (%eax, %ecx), %xmm5	/* xk[1] | xk[0] */
	shufps $0xb1, %xmm3, %xmm3	/* -i * v */
	movaps %xmm0, %xmm2		/* x[1] | x[0] */
	movaps %xmm5, %xmm6		/* xk[1] | xk[0] */
	addps %xmm1, %xmm0
	subps %xmm1, %xmm2
	addps %xmm3, %xmm5
	subps %xmm3, %xmm6
	movaps %xmm0, (%eax)
	movaps %xmm2, (%edi)
	movaps %xmm5, (%eax, %ecx)
	movaps %xmm6, (%edi, %ecx)
	addl $16, %eax
	addl $16, %ebx
	addl $8, %edx
	addl $8, %esi
	decl -4(%ebp)

.loop:
	movaps (%ebx), %xmm0		/* wT[1] | wT[0] */
	movaps (%edx), %xmm1		/* d[1] | d[0] */

	movaps (%ebx, %ecx), %xmm4	/* wB[1] | wB[0] */
	movaps (%esi), %xmm5		/* d3[1] | d3[0] */

	movhlps %xmm0, %xmm2		/* wT[1] */
	movhlps %xmm1, %xmm3		/* d[1] */

	movhlps %xmm4, %xmm6		/* wB[1] */
	movhlps %xmm5, %xmm7		/* d3[1] */

	shufps $0x50, %xmm1, %xmm1	/* d[0].im | d[0].im | d[0].re | d[0].re */
	shufps $0x50, %xmm3, %xmm3	/* d[1].im | d[1].im | d[1].re | d[1].re */

	movlhps %xmm0, %xmm0		/* wT[0] | wT[0] */
	shufps $0x50, %xmm5, %xmm5	/* d3[0].im | d3[0].im | d3[0].re | d3[0].re */
	movlhps %xmm2, %xmm2		/* wT[1] | wT[1] */
	shufps $0x50, %xmm7, %xmm7	/* d3[1].im | d3[1].im | d3[1].re | d3[1].re */

	mulps %xmm1, %xmm0		/* d[0].im * wT[0].im | d[0].im * wT[0].re | d[0].re * wT[0].im | d[0].re * wT[0].re */
	mulps %xmm3, %xmm2		/* d[1].im * wT[1].im | d[1].im * wT[1].re | d[1].re * wT[1].im | d[1].re * wT[1].re */
	movlhps %xmm4, %xmm4		/* wB[0] | wB[0] */
	movlhps %xmm6, %xmm6		/* wB[1] | wB[1] */

	movhlps %xmm0, %xmm1		/* d[0].im * wT[0].im | d[0].im * wT[0].re */
	movlhps %xmm2, %xmm0		/* d[1].re * wT[1].im | d[1].re * wT[1].re | d[0].re * wT[0].im | d[0].re * wT[0].re */
	mulps %xmm5, %xmm4		/* wB[0].im * d3[0].im | wB[0].re * d3[0].im | wB[0].im * d3[0].re | wB[0].re * d3[0].re */
	mulps %xmm7, %xmm6		/* wB[1].im * d3[1].im | wB[1].re * d3[1].im | wB[1].im * d3[1].re | wB[1].re * d3[1].re */
	shufps $0xb1, %xmm2, %xmm1	/* d[1].im * wT[1].re | d[1].im * wT[1].im | d[0].im * wT[0].re | d[0].im * wT[0].im */
	movl $C_1, %edi
	movaps (%edi), %xmm3		/* 1.0 | -1.0 | 1.0 | -1.0 */

	movhlps %xmm4, %xmm5		/* wB[0].im * d3[0].im | wB[0].re * d3[0].im */
	mulps %xmm3, %xmm1		/* d[1].im * wT[1].re | -d[1].im * wT[1].im | d[0].im * wT[0].re | -d[0].im * wT[0].im */
	movlhps %xmm6, %xmm4		/* wB[1].im * d3[1].re | wB[1].re * d3[1].re | wB[0].im * d3[0].re | wB[0].im * d3[0].re */
	addps %xmm1, %xmm0		/* wT[1] * d[1] | wT[0] * d[0] */

	shufps $0xb1, %xmm6, %xmm5	/* wB[1].re * d3[1].im | wB[1].im * d3[1].im | wB[0].re * d3[0].im | wB[0].im * d3[0].im */
	mulps %xmm3, %xmm5		/* wB[1].re * d3[1].im | -wB[1].im * d3[1].im | wB[0].re * d3[0].im | -wB[0].im * d3[0].im */
	addps %xmm5, %xmm4		/* wB[1] * d3[1] | wB[0] * d3[0] */

	movaps %xmm0, %xmm1		/* wT[1] * d[1] | wT[0] * d[0] */
	addps %xmm4, %xmm0		/* u */
	subps %xmm4, %xmm1		/* v */
	movaps (%eax), %xmm6		/* x[1] | x[0] */
	leal (%eax, %ecx, 2), %edi
	mulps %xmm3, %xmm1
	addl $16, %ebx
	addl $16, %esi
	shufps $0xb1, %xmm1, %xmm1	/* -i * v */
	movaps (%eax, %ecx), %xmm7	/* xk[1] | xk[0] */
	movaps %xmm6, %xmm2
	movaps %xmm7, %xmm4
	addps %xmm0, %xmm6
	subps %xmm0, %xmm2
	movaps %xmm6, (%eax)
	movaps %xmm2, (%edi)
	addps %xmm1, %xmm7
	subps %xmm1, %xmm4
	addl $16, %edx
	movaps %xmm7, (%eax, %ecx)
	movaps %xmm4, (%edi, %ecx)

	addl $16, %eax
	decl -4(%ebp)
	jnz .loop

.end:		
	popl %edi	
	popl %esi
	popl %edx
	popl %ecx
	popl %ebx
	popl %eax
	
	addl $4, %esp
		
	leave
	ret

--- NEW FILE ---
/* 
 *  srfft_kni.c
 *
 *  Copyright (C) Yuqing Deng <Yuqing_Deng at brown.edu> - April 2000
 *
 *  64 and 128 point split radix fft for ac3dec
 *
 *  The algorithm is desribed in the book:
 *  "Computational Frameworks of the Fast Fourier Transform".
 *
 *  The ideas and the the organization of code borrowed from djbfft written by
 *  D. J. Bernstein <djb at cr.py.to>.  djbff can be found at 
 *  http://cr.yp.to/djbfft.html.
 *
 *  srfft.c is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *
 *  srfft.c is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with GNU Make; see the file COPYING.  If not, write to
 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *  Modified for using with mplayer by Nick Kurshev <nickols_k at mail.ru>
 */
 
extern void fft_4_kni (complex_t *);
extern void fft_8_kni (complex_t *);
extern void fft_asmb_kni (int, complex_t*, complex_t *, complex_t *, complex_t*);

void fft_64p_kni(complex_t *a)
{
	fft_8_kni(&a[0]); fft_4_kni(&a[8]); fft_4_kni(&a[12]);
	fft_asmb_kni(2, &a[0], &a[8], &delta16[0], &delta16_3[0]);
  
	fft_8_kni(&a[16]), fft_8_kni(&a[24]);
	fft_asmb_kni(4, &a[0], &a[16],&delta32[0], &delta32_3[0]);

	fft_8_kni(&a[32]); fft_4_kni(&a[40]); fft_4_kni(&a[44]);
	fft_asmb_kni(2, &a[32], &a[40], &delta16[0], &delta16_3[0]);

	fft_8_kni(&a[48]); fft_4_kni(&a[56]); fft_4_kni(&a[60]);
	fft_asmb_kni(2, &a[48], &a[56], &delta16[0], &delta16_3[0]);

	fft_asmb_kni(8, &a[0], &a[32],&delta64[0], &delta64_3[0]);
}


void fft_128p_kni(complex_t *a)
{
	fft_8_kni(&a[0]); fft_4_kni(&a[8]); fft_4_kni(&a[12]);
	fft_asmb_kni(2, &a[0], &a[8], &delta16[0], &delta16_3[0]);
  
	fft_8_kni(&a[16]), fft_8_kni(&a[24]);
	fft_asmb_kni(4, &a[0], &a[16],&delta32[0], &delta32_3[0]);

	fft_8_kni(&a[32]); fft_4_kni(&a[40]); fft_4_kni(&a[44]);
	fft_asmb_kni(2, &a[32], &a[40], &delta16[0], &delta16_3[0]);

	fft_8_kni(&a[48]); fft_4_kni(&a[56]); fft_4_kni(&a[60]);
	fft_asmb_kni(2, &a[48], &a[56], &delta16[0], &delta16_3[0]);

	fft_asmb_kni(8, &a[0], &a[32],&delta64[0], &delta64_3[0]);

	fft_8_kni(&a[64]); fft_4_kni(&a[72]); fft_4_kni(&a[76]);
	/* fft_16(&a[64]); */
	fft_asmb_kni(2, &a[64], &a[72], &delta16[0], &delta16_3[0]);

	fft_8_kni(&a[80]); fft_8_kni(&a[88]);
  
	/* fft_32(&a[64]); */
	fft_asmb_kni(4, &a[64], &a[80],&delta32[0], &delta32_3[0]);

	fft_8_kni(&a[96]); fft_4_kni(&a[104]), fft_4_kni(&a[108]);
	/* fft_16(&a[96]); */
	fft_asmb_kni(2, &a[96], &a[104], &delta16[0], &delta16_3[0]);

	fft_8_kni(&a[112]), fft_8_kni(&a[120]);
	/* fft_32(&a[96]); */
	fft_asmb_kni(4, &a[96], &a[112], &delta32[0], &delta32_3[0]);
  
	/* fft_128(&a[0]); */
	fft_asmb_kni(16, &a[0], &a[64], &delta128[0], &delta128_3[0]);
}




More information about the MPlayer-cvslog mailing list