?? yuv12-rgb16.s
字號:
?
+
;-------------------------------------------------------------------------
; cxm12161 -- This function performs YUV12-to-RGB16 color conversion for H26x.
; It handles any format in which there are three fields, the low
; order field being B and fully contained in the low order byte, the
; second field being G and being somewhere in bits 4 through 11,
; and the high order field being R and fully contained in the high
; order byte.
;
; The YUV12 input is planar, 8 bits per pel. The Y plane may have
; a pitch of up to 768. It may have a width less than or equal
; to the pitch. It must be DWORD aligned, and preferably QWORD
; aligned. Pitch and Width must be a multiple of four. For best
; performance, Pitch should not be 4 more than a multiple of 32.
; Height may be any amount, but must be a multiple of two. The U
; and V planes may have a different pitch than the Y plane, subject
; to the same limitations.
;
;include iammx.inc
;include locals.inc
RGB_formats:
dd RGB565
dd RGB555
dd RGB664
dd RGB655
Minusg: dd 00800080h, 00800080h
Yadd: dd 10101010h, 10101010h
VtR: dd 00660066h, 00660066h ;01990199h,01990199h
VtG: dd 00340034h, 00340034h ;00d000d0h,00d000d0h
UtG: dd 00190019h, 00190019h ;00640064h,00640064h
UtB: dd 00810081h, 00810081h ;02050205h,02050205h
Ymul: dd 004a004ah, 004a004ah ;012a012ah,012a012ah
UVtG: dd 00340019h, 00340019h ;00d00064h,00d00064h
VtRUtB: dd 01990205h, 01990205h
fourbitu: dd 0f0f0f0f0h, 0f0f0f0f0h
fivebitu: dd 0e0e0e0e0h, 0e0e0e0e0h
sixbitu: dd 0c0c0c0c0h, 0c0c0c0c0h
%assign LocalFrameSize 156
%assign RegisterStorageSize 16
; Arguments:
%assign YPlane LocalFrameSize + RegisterStorageSize + 4
%assign UPlane LocalFrameSize + RegisterStorageSize + 8
%assign VPlane LocalFrameSize + RegisterStorageSize + 12
%assign FrameWidth LocalFrameSize + RegisterStorageSize + 16
%assign FrameHeight LocalFrameSize + RegisterStorageSize + 20
%assign YPitch LocalFrameSize + RegisterStorageSize + 24
%assign ChromaPitch LocalFrameSize + RegisterStorageSize + 28
%assign AspectAdjustmentCount LocalFrameSize + RegisterStorageSize + 32
%assign ColorConvertedFrame LocalFrameSize + RegisterStorageSize + 36
%assign DCIOffset LocalFrameSize + RegisterStorageSize + 40
%assign CCOffsetToLine0 LocalFrameSize + RegisterStorageSize + 44
%assign CCOPitch LocalFrameSize + RegisterStorageSize + 48
%assign CCType LocalFrameSize + RegisterStorageSize + 52
%assign EndOfArgList LocalFrameSize + RegisterStorageSize + 56
; Locals (on local stack frame)
%assign CCOCursor 0
%assign CCOSkipDistance 4
%assign ChromaLineLen 8
%assign YCursor 12
%assign DistanceFromVToU 16
%assign EndOfChromaLine 20
%assign AspectCount 24
%assign AspectBaseCount 28
%assign tmpYCursorEven 32
%assign tmpYCursorOdd 36
%assign tmpCCOPitch 40
%assign temp_mmx 44 ; note it is 48 bytes
%assign RLeftShift 92
%assign GLeftShift 100
%assign RRightShift 108
%assign GRightShift 116
%assign BRightShift 124
%assign RUpperLimit 132
%assign GUpperLimit 140
%assign BUpperLimit 148
; extern void C MMX_YUV12ToRGB16 (
; U8* YPlane,
; U8* UPlane,
; U8* VPlane,
; UN FrameWidth,
; UN FrameHeight,
; UN YPitch,
; UN VPitch,
; UN AspectAdjustmentCount,
; U8* ColorConvertedFrame,
; U32 DCIOffset,
; U32 CCOffsetToLine0,
; IN CCOPitch,
; IN CCType)
;
; The local variables are on the stack,
; The tables are in the one and only data segment.
;
; CCOffsetToLine0 is relative to ColorConvertedFrame.
; CCType used by RGB color convertors to determine the exact conversion type.
; RGB565 = 0
; RGB555 = 1
; RGB664 = 2
; RGB655 = 3
global yuv_2_rgb
yuv_2_rgb:
push esi
push edi
push ebp
push ebx
sub esp, LocalFrameSize
mov eax, [esp+CCType]
cmp eax,4
jae near finish
jmp [RGB_formats+eax*4]
RGB555:
xor eax, eax
mov ebx, 2 ; 10-8 for byte shift
mov [esp+RLeftShift], ebx
mov [esp+RLeftShift+4], eax
mov ebx, 5
mov [esp+GLeftShift], ebx
mov [esp+GLeftShift+4], eax
mov ebx, 9
mov [esp+RRightShift], ebx
mov [esp+RRightShift+4], eax
mov [esp+GRightShift], ebx
mov [esp+GRightShift+4], eax
mov [esp+BRightShift], ebx
mov [esp+BRightShift+4], eax
movq mm0, [fivebitu]
movq [esp+RUpperLimit], mm0
movq [esp+GUpperLimit], mm0
movq [esp+BUpperLimit], mm0
jmp RGBEND
RGB664:
xor eax, eax
mov ebx, 2 ; 8-6
mov [esp+RLeftShift], ebx
mov [esp+RLeftShift+4], eax
mov ebx, 4
mov [esp+GLeftShift], ebx
mov [esp+GLeftShift+4], eax
mov ebx, 8
mov [esp+RRightShift], ebx
mov [esp+RRightShift+4], eax
mov [esp+GRightShift], ebx
mov [esp+GRightShift+4], eax
mov ebx, 10
mov [esp+BRightShift], ebx
mov [esp+BRightShift+4], eax
movq mm0, [sixbitu]
movq [esp+RUpperLimit], mm0
movq [esp+GUpperLimit], mm0
movq mm0, [fourbitu]
movq [esp+BUpperLimit], mm0
jmp RGBEND
RGB655:
xor eax, eax
mov ebx, 2 ; 8-6
mov [esp+RLeftShift], ebx
mov [esp+RLeftShift+4], eax
mov ebx, 5
mov [esp+GLeftShift], ebx
mov [esp+GLeftShift+4], eax
mov ebx, 8
mov [esp+RRightShift], ebx
mov [esp+RRightShift+4], eax
mov ebx, 9
mov [esp+GRightShift], ebx
mov [esp+GRightShift+4], eax
mov [esp+BRightShift], ebx
mov [esp+BRightShift+4], eax
movq mm0, [sixbitu]
movq [esp+RUpperLimit], mm0
movq mm0, [fivebitu]
movq [esp+GUpperLimit], mm0
movq [esp+BUpperLimit], mm0
jmp RGBEND
RGB565:
xor eax, eax
mov ebx, 3 ; 8-5
mov [esp+RLeftShift], ebx
mov [esp+RLeftShift+4], eax
mov ebx, 5
mov [esp+GLeftShift], ebx
mov [esp+GLeftShift+4], eax
mov ebx, 9
mov [esp+RRightShift], ebx
mov [esp+RRightShift+4], eax
mov [esp+BRightShift], ebx
mov [esp+BRightShift+4], eax
mov ebx, 8
mov [esp+GRightShift], ebx
mov [esp+GRightShift+4], eax
movq mm0, [fivebitu]
movq [esp+RUpperLimit], mm0
movq [esp+BUpperLimit], mm0
movq mm0, [sixbitu]
movq [esp+GUpperLimit], mm0
; jmp RGBEND
RGBEND:
mov ebx, [esp+VPlane]
mov ecx, [esp+UPlane]
sub ecx, ebx
mov [esp+DistanceFromVToU], ecx
mov eax, [esp+ColorConvertedFrame]
add eax, [esp+DCIOffset]
add eax, [esp+CCOffsetToLine0]
mov [esp+CCOCursor], eax
mov ecx,[esp+YPitch]
mov ebx,[esp+FrameWidth]
mov eax,[esp+CCOPitch]
sub eax, ebx ; CCOPitch-FrameWidth
sub eax, ebx ; CCOPitch-2*FrameWidth
sar ebx, 1 ; FrameWidth/2
mov esi,[esp+YPlane] ; Fetch cursor over luma plane.
mov [esp+ChromaLineLen],ebx ; FrameWidth/2
mov [esp+ CCOSkipDistance],eax ; CCOPitch-3*FrameWidth
mov [esp+YCursor],esi
mov edx,[esp+AspectAdjustmentCount]
mov esi,[esp+VPlane]
cmp edx,1
je near finish
mov [esp+AspectCount],edx
mov [esp+AspectBaseCount],edx
xor eax, eax
mov edi,[esp+ChromaLineLen]
mov [esp+EndOfChromaLine],edi
mov edi,[esp+CCOCursor]
mov edx,[esp+DistanceFromVToU]
mov ebp,[esp+YCursor] ; Fetch Y Pitch.
mov ebx,[esp+FrameWidth]
add ebp, ebx
mov [esp+tmpYCursorEven],ebp
mov eax,[esp+YPitch]
add ebp, eax
mov [esp+tmpYCursorOdd],ebp
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -