Removed unused VideoCaptureCapability parameters.
[chromium-blink-merge.git] / media / base / simd / scale_yuv_to_rgb_sse2_x64.asm
blobd6786875a312da3dc72545ee14c45956d6a00d64
1 ; Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 ; Use of this source code is governed by a BSD-style license that can be
3 ; found in the LICENSE file.
5 %include "media/base/simd/media_export.asm"
6 %include "third_party/x86inc/x86inc.asm"
9 ; This file uses MMX, SSE2 and instructions.
11 SECTION_TEXT
12 CPU SSE2
14 ; void ScaleYUVToRGB32Row_SSE2_X64(const uint8* y_buf,
15 ; const uint8* u_buf,
16 ; const uint8* v_buf,
17 ; uint8* rgb_buf,
18 ; ptrdiff_t width,
19 ; ptrdiff_t source_dx);
20 %define SYMBOL ScaleYUVToRGB32Row_SSE2_X64
21 EXPORT SYMBOL
22 align function_align
24 mangle(SYMBOL):
25 %assign stack_offset 0
26 extern mangle(kCoefficientsRgbY)
28 ; Parameters are in the following order:
29 ; 1. Y plane
30 ; 2. U plane
31 ; 3. V plane
32 ; 4. ARGB frame
33 ; 5. Width
34 ; 6. Source dx
36 PROLOGUE 6, 7, 3, Y, U, V, ARGB, WIDTH, SOURCE_DX, COMP
38 %define TABLEq r10
39 %define Xq r11
40 %define INDEXq r12
41 PUSH r10
42 PUSH r11
43 PUSH r12
45 LOAD_SYM TABLEq, mangle(kCoefficientsRgbY)
47 ; Set Xq index to 0.
48 xor Xq, Xq
49 jmp .scaleend
51 .scaleloop:
52 ; Read UV pixels.
53 mov INDEXq, Xq
54 sar INDEXq, 17
55 movzx COMPd, BYTE [Uq + INDEXq]
56 movq xmm0, [TABLEq + 2048 + 8 * COMPq]
57 movzx COMPd, BYTE [Vq + INDEXq]
58 movq xmm1, [TABLEq + 4096 + 8 * COMPq]
60 ; Read first Y pixel.
61 lea INDEXq, [Xq + SOURCE_DXq] ; INDEXq nows points to next pixel.
62 sar Xq, 16
63 movzx COMPd, BYTE [Yq + Xq]
64 paddsw xmm0, xmm1 ; Hide a ADD after memory load.
65 movq xmm1, [TABLEq + 8 * COMPq]
67 ; Read next Y pixel.
68 lea Xq, [INDEXq + SOURCE_DXq] ; Xq now points to next pixel.
69 sar INDEXq, 16
70 movzx COMPd, BYTE [Yq + INDEXq]
71 movq xmm2, [TABLEq + 8 * COMPq]
72 paddsw xmm1, xmm0
73 paddsw xmm2, xmm0
74 shufps xmm1, xmm2, 0x44 ; Join two pixels into one XMM register
75 psraw xmm1, 6
76 packuswb xmm1, xmm1
77 movq QWORD [ARGBq], xmm1
78 add ARGBq, 8
80 .scaleend:
81 sub WIDTHq, 2
82 jns .scaleloop
84 and WIDTHq, 1 ; odd number of pixels?
85 jz .scaledone
87 ; Read U V components.
88 mov INDEXq, Xq
89 sar INDEXq, 17
90 movzx COMPd, BYTE [Uq + INDEXq]
91 movq xmm0, [TABLEq + 2048 + 8 * COMPq]
92 movzx COMPd, BYTE [Vq + INDEXq]
93 movq xmm1, [TABLEq + 4096 + 8 * COMPq]
94 paddsw xmm0, xmm1
96 ; Read one Y component.
97 mov INDEXq, Xq
98 sar INDEXq, 16
99 movzx COMPd, BYTE [Yq + INDEXq]
100 movq xmm1, [TABLEq + 8 * COMPq]
101 paddsw xmm1, xmm0
102 psraw xmm1, 6
103 packuswb xmm1, xmm1
104 movd DWORD [ARGBq], xmm1
106 .scaledone:
107 POP r12
108 POP r11
109 POP r10