From: Josh Coalson Date: Wed, 4 Apr 2007 01:01:28 +0000 (+0000) Subject: add stream_encoder_asm.nasm X-Git-Tag: 1.2.0~79 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=717ea8c39834f170094ae4363ff4fe3e66089c5b;p=platform%2Fupstream%2Fflac.git add stream_encoder_asm.nasm --- diff --git a/src/libFLAC/Makefile.lite b/src/libFLAC/Makefile.lite index 5418845..8ea37f8 100644 --- a/src/libFLAC/Makefile.lite +++ b/src/libFLAC/Makefile.lite @@ -57,7 +57,8 @@ SRCS_NASM = \ ia32/bitreader_asm.nasm \ ia32/cpu_asm.nasm \ ia32/fixed_asm.nasm \ - ia32/lpc_asm.nasm + ia32/lpc_asm.nasm \ + ia32/stream_encoder_asm.nasm endif endif diff --git a/src/libFLAC/ia32/Makefile.am b/src/libFLAC/ia32/Makefile.am index 476633f..04a5b98 100644 --- a/src/libFLAC/ia32/Makefile.am +++ b/src/libFLAC/ia32/Makefile.am @@ -41,4 +41,5 @@ libFLAC_asm_la_SOURCES = \ cpu_asm.nasm \ fixed_asm.nasm \ lpc_asm.nasm \ - nasm.h + nasm.h \ + stream_encoder_asm.nasm diff --git a/src/libFLAC/ia32/stream_encoder_asm.nasm b/src/libFLAC/ia32/stream_encoder_asm.nasm new file mode 100644 index 0000000..1799067 --- /dev/null +++ b/src/libFLAC/ia32/stream_encoder_asm.nasm @@ -0,0 +1,158 @@ +; vim:filetype=nasm ts=8 + +; libFLAC - Free Lossless Audio Codec library +; Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; - Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; +; - Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; +; - Neither the name of the Xiph.org Foundation nor the names of its +; contributors may be used to endorse or promote products derived from +; this software without specific prior written permission. +; +; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +; ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR +; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +%include "nasm.h" + + data_section + +cglobal precompute_partition_info_sums_32bit_asm_ia32_ + + code_section + + +; ********************************************************************** +; +; void FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], unsigned nvals, unsigned parameter) +; void precompute_partition_info_sums_32bit_( +; const FLAC__int32 residual[], +; FLAC__uint64 abs_residual_partition_sums[], +; unsigned blocksize, +; unsigned predictor_order, +; unsigned min_partition_order, +; unsigned max_partition_order +; ) +; + ALIGN 16 +cident precompute_partition_info_sums_32bit_asm_ia32_ + + ;; peppered throughout the code at major checkpoints are keys like this as to where things are at that point in time + ;; [esp + 4] const FLAC__int32 residual[] + ;; [esp + 8] FLAC__uint64 abs_residual_partition_sums[] + ;; [esp + 12] unsigned blocksize + ;; [esp + 16] unsigned predictor_order + ;; [esp + 20] unsigned min_partition_order + ;; [esp + 24] unsigned max_partition_order + push ebp + push ebx + push esi + push edi + sub esp, 8 + ;; [esp + 28] const FLAC__int32 residual[] + ;; [esp + 32] FLAC__uint64 abs_residual_partition_sums[] + ;; [esp + 36] unsigned blocksize + ;; [esp + 40] unsigned predictor_order + ;; [esp + 44] unsigned min_partition_order + ;; [esp + 48] unsigned max_partition_order + ;; [esp] partitions + ;; [esp + 4] default_partition_samples + + mov ecx, [esp + 48] + mov eax, 1 + shl eax, cl + mov [esp], eax ; [esp] <- partitions = 1u << max_partition_order; + mov eax, [esp + 36] + shr eax, cl + mov [esp + 4], eax ; [esp + 4] <- default_partition_samples = blocksize >> max_partition_order; + + ; + ; first do max_partition_order + ; + mov edi, [esp + 40] + neg edi ; edi <- end = (unsigned)(-(int)predictor_order) + xor ecx, ecx ; ecx <- partition = 0 + mov ebp, [esp + 28] ; ebp <- residual[] + xor esi, esi ; esi <- residual_sample = 0 + ALIGN 16 +.loop0: ; for(partition = residual_sample = 0; partition < partitions; partition++) { + cmp ecx, [esp] + jae .next0 + add edi, [esp + 4] ; end += default_partition_samples; + xor ebx, ebx ; abs_residual_partition_sum = 0; + ALIGN 16;@@@ OPT: remove? +.loop1: ; for( ; residual_sample < end; residual_sample++) + cmp esi, edi + jae .next1 + mov eax, [ebp + esi * 4] + cdq + xor eax, edx + sub eax, edx + add ebx, eax ; abs_residual_partition_sum += abs(residual[residual_sample]); + add esi, byte 1 + jmp .loop1 +.next1: + mov eax, [esp + 32] + mov [eax + ecx * 8], ebx ; abs_residual_partition_sums[partition] = abs_residual_partition_sum; + mov [eax + ecx * 8 + 4], dword 0 + add ecx, byte 1 + jmp .loop0 +.next0: ; } + ; + ; now merge partitions for lower orders + ; + mov esi, [esp + 32] ; esi <- abs_residual_partition_sums[from_partition==0]; + mov eax, [esp] + lea edi, [esi + eax * 8] ; edi <- abs_residual_partition_sums[to_partition==partitions]; + mov ecx, [esp + 48] + sub ecx, byte 1 ; ecx <- partition_order = (int)max_partition_order - 1; + ALIGN 16 +.loop2: ; for(; partition_order >= (int)min_partition_order; partition_order--) { + cmp ecx, [esp + 44] + jl .next2 + mov edx, 1 + shl edx, cl ; const unsigned partitions = 1u << partition_order; + ALIGN 16;@@@ OPT: remove? +.loop3: ; for(i = 0; i < partitions; i++) { + mov eax, [esi] + mov [edi + 4], dword 0 + mov [edi], eax + mov ebx, [esi + 8] + add [edi], ebx ; a_r_p_s[to_partition] = a_r_p_s[from_partition] + a_r_p_s[from_partition+1]; + add esi, byte 16 + add edi, byte 8 + sub edx, byte 1 + jnz .loop3 ; } + sub ecx, byte 1 + jmp .loop2 ; } +.next2: + + add esp, 8 + pop edi + pop esi + pop ebx + pop ebp + ret + +end + +%ifdef OBJ_FORMAT_elf + section .note.GNU-stack noalloc +%endif diff --git a/src/libFLAC/libFLAC_dynamic.dsp b/src/libFLAC/libFLAC_dynamic.dsp index 924164c..b3f340c 100644 --- a/src/libFLAC/libFLAC_dynamic.dsp +++ b/src/libFLAC/libFLAC_dynamic.dsp @@ -211,6 +211,35 @@ InputPath=.\ia32\lpc_asm.nasm # End Source File # Begin Source File +SOURCE=.\ia32\stream_encoder_asm.nasm + +!IF "$(CFG)" == "libFLAC_dynamic - Win32 Release" + +USERDEP__CPU_A="ia32/stream_encoder_asm.nasm" +# Begin Custom Build +InputPath=.\ia32\stream_encoder_asm.nasm + +"ia32/stream_encoder_asm.obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + nasmw.exe -f win32 -d OBJ_FORMAT_win32 -i ia32/ ia32/stream_encoder_asm.nasm -o ia32/stream_encoder_asm.obj + +# End Custom Build + +!ELSEIF "$(CFG)" == "libFLAC_dynamic - Win32 Debug" + +USERDEP__CPU_A="ia32/stream_encoder_asm.nasm" +# Begin Custom Build +InputPath=.\ia32\stream_encoder_asm.nasm + +"ia32/stream_encoder_asm.obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + nasmw.exe -f win32 -d OBJ_FORMAT_win32 -i ia32/ ia32/stream_encoder_asm.nasm -o ia32/stream_encoder_asm.obj + +# End Custom Build + +!ENDIF + +# End Source File +# Begin Source File + SOURCE=.\ia32\nasm.h # End Source File # End Group diff --git a/src/libFLAC/libFLAC_dynamic.vcproj b/src/libFLAC/libFLAC_dynamic.vcproj index 0fa150c..33af403 100644 --- a/src/libFLAC/libFLAC_dynamic.vcproj +++ b/src/libFLAC/libFLAC_dynamic.vcproj @@ -502,6 +502,30 @@ /> + + + + + + + + diff --git a/src/libFLAC/libFLAC_static.dsp b/src/libFLAC/libFLAC_static.dsp index a71dad5..321b132 100644 --- a/src/libFLAC/libFLAC_static.dsp +++ b/src/libFLAC/libFLAC_static.dsp @@ -204,6 +204,35 @@ InputPath=.\ia32\lpc_asm.nasm # End Source File # Begin Source File +SOURCE=.\ia32\stream_encoder_asm.nasm + +!IF "$(CFG)" == "libFLAC_static - Win32 Release" + +USERDEP__CPU_A="ia32/stream_encoder_asm.nasm" +# Begin Custom Build +InputPath=.\ia32\stream_encoder_asm.nasm + +"ia32/stream_encoder_asm.obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + nasmw.exe -f win32 -d OBJ_FORMAT_win32 -i ia32/ ia32/stream_encoder_asm.nasm -o ia32/stream_encoder_asm.obj + +# End Custom Build + +!ELSEIF "$(CFG)" == "libFLAC_static - Win32 Debug" + +USERDEP__CPU_A="ia32/stream_encoder_asm.nasm" +# Begin Custom Build +InputPath=.\ia32\stream_encoder_asm.nasm + +"ia32/stream_encoder_asm.obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + nasmw.exe -f win32 -d OBJ_FORMAT_win32 -i ia32/ ia32/stream_encoder_asm.nasm -o ia32/stream_encoder_asm.obj + +# End Custom Build + +!ENDIF + +# End Source File +# Begin Source File + SOURCE=.\ia32\nasm.h # End Source File # End Group diff --git a/src/libFLAC/libFLAC_static.vcproj b/src/libFLAC/libFLAC_static.vcproj index 07712dc..f6e86b5 100644 --- a/src/libFLAC/libFLAC_static.vcproj +++ b/src/libFLAC/libFLAC_static.vcproj @@ -468,6 +468,30 @@ /> + + + + + + + +