📄 test.asm
字号:
IF TEST_8x8_SSE2
ITST = ITST+1
bt cpu, 26
jnc @CatStr(Next,%ITST)
DBG "8x8 SSE2"
mov [Ctx].RetIdct, @CatStr(RetIdct,%ITST)
mov ebx, 100
@CatStr(T,%ITST):
lea esi, In8x8
mov edi, esp
mov ecx, 8*8
rep movsd
lea eax, Quant
lea edi, Out8x8
jmp IDCT_8x8_SSE2
@CatStr(RetIdct,%ITST):
mov ecx, -8*8
lea edi, Out8x8
emms
@@:
fld OutRef8x8[4*ecx+4*8*8]
fsub DPTR [edi][4*ecx+4*8*8]
fabs
fstp DPTR [edi][4*ecx+4*8*8]
inc ecx
jnz @B
DBG "Diff :"
pushad
mov ecx, 8
mov edx, 8
call DBG_DumpNxMFloats
popad
dec ebx
jnz @CatStr(T,%ITST)
@CatStr(Next,%ITST):
ENDIF
IF TEST_16x16_SSE2
ITST = ITST+1
bt cpu, 26
jnc @CatStr(Next,%ITST)
DBG "16x16 SSE2"
mov [Ctx].RetIdct, @CatStr(RetIdct,%ITST)
mov ebx, 100
@CatStr(T,%ITST):
lea esi, In8x8
mov edi, esp
mov ecx, 8*8
rep movsd
lea eax, Quant
lea edi, Out16x16
jmp IDCT_16x16_SSE2
@CatStr(RetIdct,%ITST):
mov ecx, -16*16*4
lea edi, Out16x16
emms
@@:
IF TEST_ROWONLY EQ 0
fld OutRef16x16[ecx+16*16*4]
ELSE
fld OutRow16x16[ecx+16*16*4]
ENDIF
fsub DPTR [edi][ecx+16*16*4]
fabs
fstp DPTR [edi][ecx+16*16*4]
add ecx, 4
jnz @B
DBG "Diff :"
pushad
mov ecx, 16
mov edx, 16
call DBG_DumpNxMFloats
popad
dec ebx
jnz @CatStr(T,%ITST)
@CatStr(Next,%ITST):
ENDIF
Done:
mov eax, Ctx
call MEM_Free
DBGSTOP
mov esp, espsav
popad
ret
TEST_IDCT ENDP
;//=========================================================================
;// Test SOF marker
;//=========================================================================
;// declare a word MSB first
WMSB MACRO w
byte (w) SHR 8
byte (w) AND 255
ENDM
;// generate a start of frame segment
GEN_SOF_SEG MACRO P,X,Y,H0,V0,H1,V1,H2,V2
LOCAL adr,Nf
IFNB <H1>
Nf = 3
ELSE
Nf = 1
ENDIF
adr label byte
WMSB 8+3*Nf
byte P
WMSB Y
WMSB X
byte Nf
byte 0
byte 16*H0 + V0
byte 0
IF (Nf EQ 3)
byte 0
byte 16*H1 + V1
byte 0
byte 0
byte 16*H2 + V2
byte 0
ENDIF
EXITM <adr>
ENDM
TEST_SOFM MACRO t, res
mov esi, t
movzx ecx, WPTR [esi]
ror cx, 8
call BS_Init
call JPG_SOF
cmp al, res
jne @CatStr(<e>,t)
ENDM
.DATA
;// 8x8 -> 8x8
P = 8
X = 8
Y = 8
H0 = 1
V0 = 1
H1 = 1
V1 = 1
H2 = 1
V2 = 1
Test8x8 dword GEN_SOF_SEG(P,X,Y,H0,V0,H1,V1,H2,V2)
;// 8x8 -> 16x16
P = 8
X = 16
Y = 16
H0 = 2
V0 = 2
H1 = 1
V1 = 1
H2 = 1
V2 = 1
Test16x16 dword GEN_SOF_SEG(P,X,Y,H0,V0,H1,V1,H2,V2)
;// 8x8 -> 8x16
P = 8
X = 16
Y = 16
H0 = 2
V0 = 2
H1 = 2
V1 = 1
H2 = 2
V2 = 1
Test8x16 dword GEN_SOF_SEG(P,X,Y,H0,V0,H1,V1,H2,V2)
;// 8x8 -> 16x8
P = 8
X = 16
Y = 16
H0 = 2
V0 = 2
H1 = 1
V1 = 2
H2 = 1
V2 = 2
Test16x8 dword GEN_SOF_SEG(P,X,Y,H0,V0,H1,V1,H2,V2)
;// Grayscale
P = 8
X = 16
Y = 16
H0 = 1
V0 = 1
TestGray dword GEN_SOF_SEG(P,X,Y,H0,V0)
;// Limit case
P = 12
X = 16352
Y = 16352
H0 = 4
V0 = 4
H1 = 4
V1 = 4
H2 = 4
V2 = 4
TestLimitXY dword GEN_SOF_SEG(P,X,Y,H0,V0,H1,V1,H2,V2)
;// Limit X
P = 12
X = 65535
Y = 1
H0 = 4
V0 = 4
H1 = 4
V1 = 4
H2 = 4
V2 = 4
TestLimitX dword GEN_SOF_SEG(P,X,Y,H0,V0,H1,V1,H2,V2)
;// Limit Y
P = 12
X = 1
Y = 65535
H0 = 4
V0 = 4
H1 = 4
V1 = 4
H2 = 4
V2 = 4
TestLimitY dword GEN_SOF_SEG(P,X,Y,H0,V0,H1,V1,H2,V2)
;// 1x1
P = 12
X = 1
Y = 1
H0 = 4
V0 = 4
H1 = 4
V1 = 4
H2 = 4
V2 = 4
TestLimit1x1 dword GEN_SOF_SEG(P,X,Y,H0,V0,H1,V1,H2,V2)
;// Not supported (precision)
P = 3
X = 16
Y = 16
H0 = 2
V0 = 2
TestBadPrec dword GEN_SOF_SEG(P,X,Y,H0,V0,H1,V1,H2,V2)
;// Not supported (fractional sampling factor)
P = 8
X = 16
Y = 16
H0 = 1
V0 = 2
H1 = 15
V1 = 4
H2 = 10
V2 = 7
TestFracSampl dword GEN_SOF_SEG(P,X,Y,H0,V0,H1,V1,H2,V2)
;// Not supported (sampling factor to big)
P = 8
X = 16
Y = 16
H0 = 1
V0 = 1
H1 = 3
V1 = 1
H2 = 1
V2 = 0
TestBigSampl dword GEN_SOF_SEG(P,X,Y,H0,V0,H1,V1,H2,V2)
;// Dimension too big
P = 12
X = 65535
Y = 65535
H0 = 4
V0 = 4
H1 = 4
V1 = 4
H2 = 4
V2 = 4
TestBigDim dword GEN_SOF_SEG(P,X,Y,H0,V0,H1,V1,H2,V2)
JPG_SOF PROTO
.CODE
IF 0
TEST_SOF PROTO
call TEST_SOF
ret 4*4
ENDIF
TEST_SOF PROC
pushad
pushfd
DBGSTART
mov eax, sizeof(DECODER)
call MEM_Alloc
mov Ctx, eax
call CPUID_Init
call RGB_Init
call IDCT_Init
TEST_SOFM Test8x8, 1
TEST_SOFM Test16x16, 1
TEST_SOFM Test8x16, 1
TEST_SOFM Test16x8, 1
TEST_SOFM TestGray, 1
TEST_SOFM TestLimitX, 1
TEST_SOFM TestLimitY, 1
TEST_SOFM TestLimit1x1, 1
TEST_SOFM TestLimitXY, 0
TEST_SOFM TestBadPrec, 0
TEST_SOFM TestFracSampl, 0
TEST_SOFM TestBigSampl, 0
TEST_SOFM TestBigDim, 0
Done:
push Ctx
call JPEG_Free
DBGSTOP
popfd
popad
ret
eTest8x8:int 3
eTest16x16:int 3
eTest8x16:int 3
eTest16x8:int 3
eTestGray:int 3
eTestLimit:int 3
eTestBadPrec:int 3
eTestFracSampl:int 3
eTestBigSampl:int 3
eTestBigDim:int 3
eTestLimit1x1:int 3
eTestLimitX:int 3
eTestLimitXY:int 3
eTestLimitY:int 3
TEST_SOF ENDP
;//=========================================================================
;// Test RGB conversion
;//=========================================================================
RGB_Input8x8 real4 114.0, 121.0, 133.0, 174.0, 174.0, 180.0, 172.0, 186.0
real4 64.0, 76.0, 97.0, 137.0, 160.0, 172.0, 157.0, 146.0
real4 112.0, 141.0, 164.0, 145.0, 122.0, 104.0, 112.0, 118.0
real4 176.0, 198.0, 228.0, 203.0, 177.0, 126.0, 112.0, 99.0
real4 186.0, 201.0, 232.0, 215.0, 186.0, 130.0, 128.0, 135.0
real4 157.0, 167.0, 183.0, 164.0, 123.0, 85.0, 109.0, 149.0
real4 111.0, 109.0, 108.0, 122.0, 119.0, 115.0, 102.0, 101.0
real4 104.0, 113.0, 104.0, 111.0, 99.0, 115.0, 106.0, 105.0
real4 104.0, 105.0, 108.0, 110.0, 114.0, 116.0, 118.0, 119.0
real4 103.0, 104.0, 107.0, 110.0, 114.0, 118.0, 121.0, 123.0
real4 100.0, 101.0, 105.0, 110.0, 116.0, 122.0, 127.0, 130.0
real4 102.0, 104.0, 109.0, 114.0, 121.0, 129.0, 136.0, 139.0
real4 111.0, 113.0, 118.0, 124.0, 131.0, 139.0, 147.0, 150.0
real4 124.0, 126.0, 130.0, 136.0, 143.0, 149.0, 157.0, 160.0
real4 141.0, 142.0, 146.0, 150.0, 155.0, 160.0, 166.0, 168.0
real4 149.0, 150.0, 154.0, 157.0, 162.0, 166.0, 170.0, 172.0
real4 166.0, 165.0, 163.0, 160.0, 157.0, 153.0, 151.0, 149.0
real4 160.0, 159.0, 157.0, 154.0, 150.0, 146.0, 143.0, 141.0
real4 148.0, 147.0, 144.0, 140.0, 136.0, 132.0, 128.0, 126.0
real4 142.0, 140.0, 137.0, 133.0, 128.0, 123.0, 118.0, 115.0
real4 141.0, 139.0, 135.0, 131.0, 125.0, 119.0, 114.0, 110.0
real4 133.0, 131.0, 128.0, 123.0, 117.0, 111.0, 104.0, 101.0
real4 118.0, 116.0, 113.0, 108.0, 102.0, 96.0, 90.0, 87.0
real4 111.0, 109.0, 106.0, 101.0, 95.0, 89.0, 83.0, 80.0
;// Output R,G,B
RGB_Output8x8 byte 167,95,71, 173,102,80, 182,115,98, 219,157,142, 215,158,149, 215,166,159, 204,159,154, 215,174,170
byte 109,50,20, 119,62,33, 138,84,60, 173,125,105, 191,149,135, 197,163,154, 178,149,145, 164,138,137
byte 140,107,62, 168,137,93, 186,160,123, 162,143,113, 133,120,101, 110,103,93, 112,112,110, 115,119,122
byte 196,175,130, 215,198,155, 241,228,194, 210,204,178, 177,179,165, 119,129,128, 98,116,126, 81,104,118
byte 204,183,156, 216,198,174, 242,230,214, 219,214,208, 182,187,191, 117,133,149, 108,131,162, 110,140,174
byte 164,155,150, 171,166,163, 183,182,187, 157,165,178, 108,126,150, 61,90,122, 75,116,160, 111,157,206
byte 97,114,134, 92,113,134, 87,113,140, 94,129,161, 83,128,167, 70,127,172, 49,116,169, 44,117,172
byte 80,109,141, 86,119,152, 73,111,150, 73,120,162, 53,111,159, 60,130,182, 43,124,180, 38,124,183
IF 0
TEST_ConvRGB PROTO
call TEST_ConvRGB
ret 4*4
ENDIF
TEST_ConvRGB PROC
pushad
pushfd
sub esp, 4
I TEXTEQU <DPTR [esp]>
DBGSTART
mov eax, sizeof(DECODER)
call MEM_Alloc
mov Ctx, eax
call CPUID_Init
call RGB_Init
call IDCT_Init
TEST_SOFM Test8x8, 1
;// fill sample buffer
mov edi, [Ctx].Mem
lea esi, RGB_Input8x8
mov ecx, 4*8*8*4
rep movsb
call [Ctx].FrameInfo.RGBConv
mov esi, [Ctx].Image.pRGB
lea edi, RGB_Output8x8
mov I, 8*8
ASSUME esi:ptr byte
ASSUME edi:ptr byte
@@:
movzx eax, [esi]
movzx edx, [edi+2]
sub eax, edx
movzx ebx, [esi+1]
movzx edx, [edi+1]
sub ebx, edx
movzx ecx, [esi+2]
movzx edx, [edi]
sub ecx, edx
DBG "%d,%d,%d, ", eax, ebx, ecx
add esi, 4
add edi, 3
dec I
jnz @B
Done:
push Ctx
call JPEG_Free
DBGSTOP
add esp, 4
popfd
popad
ret
eTest8x8: int 3
TEST_ConvRGB ENDP
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -