add stream_encoder_asm.nasm
authorJosh Coalson <jcoalson@users.sourceforce.net>
Wed, 4 Apr 2007 01:01:28 +0000 (01:01 +0000)
committerJosh Coalson <jcoalson@users.sourceforce.net>
Wed, 4 Apr 2007 01:01:28 +0000 (01:01 +0000)
src/libFLAC/Makefile.lite
src/libFLAC/ia32/Makefile.am
src/libFLAC/ia32/stream_encoder_asm.nasm [new file with mode: 0644]
src/libFLAC/libFLAC_dynamic.dsp
src/libFLAC/libFLAC_dynamic.vcproj
src/libFLAC/libFLAC_static.dsp
src/libFLAC/libFLAC_static.vcproj

index 5418845..8ea37f8 100644 (file)
@@ -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
 
index 476633f..04a5b98 100644 (file)
@@ -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 (file)
index 0000000..1799067
--- /dev/null
@@ -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
index 924164c..b3f340c 100644 (file)
@@ -211,6 +211,35 @@ InputPath=.\ia32\lpc_asm.nasm
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\ia32\stream_encoder_asm.nasm\r
+\r
+!IF  "$(CFG)" == "libFLAC_dynamic - Win32 Release"\r
+\r
+USERDEP__CPU_A="ia32/stream_encoder_asm.nasm"  \r
+# Begin Custom Build\r
+InputPath=.\ia32\stream_encoder_asm.nasm\r
+\r
+"ia32/stream_encoder_asm.obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+       nasmw.exe -f win32 -d OBJ_FORMAT_win32 -i ia32/ ia32/stream_encoder_asm.nasm -o ia32/stream_encoder_asm.obj\r
+\r
+# End Custom Build\r
+\r
+!ELSEIF  "$(CFG)" == "libFLAC_dynamic - Win32 Debug"\r
+\r
+USERDEP__CPU_A="ia32/stream_encoder_asm.nasm"  \r
+# Begin Custom Build\r
+InputPath=.\ia32\stream_encoder_asm.nasm\r
+\r
+"ia32/stream_encoder_asm.obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+       nasmw.exe -f win32 -d OBJ_FORMAT_win32 -i ia32/ ia32/stream_encoder_asm.nasm -o ia32/stream_encoder_asm.obj\r
+\r
+# End Custom Build\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\ia32\nasm.h\r
 # End Source File\r
 # End Group\r
index 0fa150c..33af403 100644 (file)
                                />\r
                        </FileConfiguration>\r
                </File>\r
+               <File\r
+                       RelativePath=".\ia32\stream_encoder_asm.nasm"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCustomBuildTool"\r
+                                       CommandLine="nasmw.exe -f win32 -d OBJ_FORMAT_win32 -i ia32/ ia32/stream_encoder_asm.nasm -o ia32/stream_encoder_asm.obj&#x0D;&#x0A;"\r
+                                       AdditionalDependencies="ia32/stream_encoder_asm.nasm;ia32/nasm.h"\r
+                                       Outputs="ia32/stream_encoder_asm.obj"\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCustomBuildTool"\r
+                                       CommandLine="nasmw.exe -f win32 -d OBJ_FORMAT_win32 -i ia32/ ia32/stream_encoder_asm.nasm -o ia32/stream_encoder_asm.obj&#x0D;&#x0A;"\r
+                                       AdditionalDependencies="ia32/stream_encoder_asm.nasm;ia32/nasm.h"\r
+                                       Outputs="ia32/stream_encoder_asm.obj"\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
        </Files>\r
        <Globals>\r
        </Globals>\r
index a71dad5..321b132 100644 (file)
@@ -204,6 +204,35 @@ InputPath=.\ia32\lpc_asm.nasm
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\ia32\stream_encoder_asm.nasm\r
+\r
+!IF  "$(CFG)" == "libFLAC_static - Win32 Release"\r
+\r
+USERDEP__CPU_A="ia32/stream_encoder_asm.nasm"  \r
+# Begin Custom Build\r
+InputPath=.\ia32\stream_encoder_asm.nasm\r
+\r
+"ia32/stream_encoder_asm.obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+       nasmw.exe -f win32 -d OBJ_FORMAT_win32 -i ia32/ ia32/stream_encoder_asm.nasm -o ia32/stream_encoder_asm.obj\r
+\r
+# End Custom Build\r
+\r
+!ELSEIF  "$(CFG)" == "libFLAC_static - Win32 Debug"\r
+\r
+USERDEP__CPU_A="ia32/stream_encoder_asm.nasm"  \r
+# Begin Custom Build\r
+InputPath=.\ia32\stream_encoder_asm.nasm\r
+\r
+"ia32/stream_encoder_asm.obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+       nasmw.exe -f win32 -d OBJ_FORMAT_win32 -i ia32/ ia32/stream_encoder_asm.nasm -o ia32/stream_encoder_asm.obj\r
+\r
+# End Custom Build\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\ia32\nasm.h\r
 # End Source File\r
 # End Group\r
index 07712dc..f6e86b5 100644 (file)
                                />\r
                        </FileConfiguration>\r
                </File>\r
+               <File\r
+                       RelativePath=".\ia32\stream_encoder_asm.nasm"\r
+                       >\r
+                       <FileConfiguration\r
+                               Name="Debug|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCustomBuildTool"\r
+                                       CommandLine="nasmw.exe -f win32 -d OBJ_FORMAT_win32 -i ia32/ ia32/stream_encoder_asm.nasm -o ia32/stream_encoder_asm.obj&#x0D;&#x0A;"\r
+                                       AdditionalDependencies="ia32/stream_encoder_asm.nasm;ia32/nasm.h"\r
+                                       Outputs="ia32/stream_encoder_asm.obj"\r
+                               />\r
+                       </FileConfiguration>\r
+                       <FileConfiguration\r
+                               Name="Release|Win32"\r
+                               >\r
+                               <Tool\r
+                                       Name="VCCustomBuildTool"\r
+                                       CommandLine="nasmw.exe -f win32 -d OBJ_FORMAT_win32 -i ia32/ ia32/stream_encoder_asm.nasm -o ia32/stream_encoder_asm.obj&#x0D;&#x0A;"\r
+                                       AdditionalDependencies="ia32/stream_encoder_asm.nasm;ia32/nasm.h"\r
+                                       Outputs="ia32/stream_encoder_asm.obj"\r
+                               />\r
+                       </FileConfiguration>\r
+               </File>\r
        </Files>\r
        <Globals>\r
        </Globals>\r