Commit 717ea8c3 authored by Josh Coalson's avatar Josh Coalson
Browse files

add stream_encoder_asm.nasm

parent 4a040f6b
......@@ -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
......
......@@ -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
; 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
......@@ -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
......
......@@ -502,6 +502,30 @@
/>
</FileConfiguration>
</File>
<File
RelativePath=".\ia32\stream_encoder_asm.nasm"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
CommandLine="nasmw.exe -f win32 -d OBJ_FORMAT_win32 -i ia32/ ia32/stream_encoder_asm.nasm -o ia32/stream_encoder_asm.obj&#x0D;&#x0A;"
AdditionalDependencies="ia32/stream_encoder_asm.nasm;ia32/nasm.h"
Outputs="ia32/stream_encoder_asm.obj"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
CommandLine="nasmw.exe -f win32 -d OBJ_FORMAT_win32 -i ia32/ ia32/stream_encoder_asm.nasm -o ia32/stream_encoder_asm.obj&#x0D;&#x0A;"
AdditionalDependencies="ia32/stream_encoder_asm.nasm;ia32/nasm.h"
Outputs="ia32/stream_encoder_asm.obj"
/>
</FileConfiguration>
</File>
</Files>
<Globals>
</Globals>
......
......@@ -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
......
......@@ -468,6 +468,30 @@
/>
</FileConfiguration>
</File>
<File
RelativePath=".\ia32\stream_encoder_asm.nasm"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
CommandLine="nasmw.exe -f win32 -d OBJ_FORMAT_win32 -i ia32/ ia32/stream_encoder_asm.nasm -o ia32/stream_encoder_asm.obj&#x0D;&#x0A;"
AdditionalDependencies="ia32/stream_encoder_asm.nasm;ia32/nasm.h"
Outputs="ia32/stream_encoder_asm.obj"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
CommandLine="nasmw.exe -f win32 -d OBJ_FORMAT_win32 -i ia32/ ia32/stream_encoder_asm.nasm -o ia32/stream_encoder_asm.obj&#x0D;&#x0A;"
AdditionalDependencies="ia32/stream_encoder_asm.nasm;ia32/nasm.h"
Outputs="ia32/stream_encoder_asm.obj"
/>
</FileConfiguration>
</File>
</Files>
<Globals>
</Globals>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment