| OLD | NEW |
| (Empty) | |
| 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. |
| 4 |
| 5 global mangle(SYMBOL) PRIVATE |
| 6 align function_align |
| 7 |
| 8 mangle(SYMBOL): |
| 9 %assign stack_offset 0 |
| 10 |
| 11 extern mangle(kCoefficientsRgbY) |
| 12 |
| 13 ; Parameters are in the following order: |
| 14 ; 1. Y plane |
| 15 ; 2. U plane |
| 16 ; 3. V plane |
| 17 ; 4. ARGB frame |
| 18 ; 5. Width |
| 19 ; 6. Source dx |
| 20 |
| 21 PROLOGUE 6, 7, 3, Y, R0, R1, ARGB, R2, R3, TEMP |
| 22 |
| 23 %if gprsize == 8 |
| 24 %define WORD_SIZE QWORD |
| 25 %else |
| 26 %define WORD_SIZE DWORD |
| 27 %endif |
| 28 |
| 29 ; Define register aliases. |
| 30 %define Xq R1q ; Current X position |
| 31 %define COMPLq R2q ; Component A value |
| 32 %define COMPLd R2d ; Component A value |
| 33 %define U_ARG_REGq R0q ; U plane address argument |
| 34 %define V_ARG_REGq R1q ; V plane address argument |
| 35 %define SOURCE_DX_ARG_REGq R3q ; Source dx argument |
| 36 %define WIDTH_ARG_REGq R2q ; Width argument |
| 37 |
| 38 %ifdef PIC |
| 39 ; PIC code shared COMPR, U and V with the same register. Need to be careful in t
he |
| 40 ; code they don't mix up. This allows R3q to be used for YUV table. |
| 41 %define COMPRq R0q ; Component B value |
| 42 %define COMPRd R0d ; Component B value |
| 43 %define Uq R0q ; U plane address |
| 44 %define Vq R0q ; V plane address |
| 45 %define U_PLANE WORD_SIZE [rsp + 3 * gprsize] |
| 46 %define TABLE R3q ; Address of the table |
| 47 %else |
| 48 ; Non-PIC code defines. |
| 49 %define COMPRq R3q ; Component B value |
| 50 %define COMPRd R3d ; Component B value |
| 51 %define Uq R0q ; U plane address |
| 52 %define Vq R3q ; V plane address |
| 53 %define TABLE mangle(kCoefficientsRgbY) |
| 54 %endif |
| 55 |
| 56 ; Defines for stack variables. These are used in both PIC and non-PIC code. |
| 57 %define V_PLANE WORD_SIZE [rsp + 2 * gprsize] |
| 58 %define SOURCE_DX WORD_SIZE [rsp + gprsize] |
| 59 %define SOURCE_WIDTH WORD_SIZE [rsp] |
| 60 |
| 61 ; Handle stack variables differently for PIC and non-PIC code. |
| 62 |
| 63 %ifdef PIC |
| 64 ; Define stack usage for PIC code. PIC code push U plane onto stack. |
| 65 PUSH U_ARG_REGq |
| 66 PUSH V_ARG_REGq |
| 67 PUSH SOURCE_DX_ARG_REGq |
| 68 imul WIDTH_ARG_REGq, SOURCE_DX_ARG_REGq ; source_width = width * source_
dx |
| 69 PUSH WIDTH_ARG_REGq |
| 70 |
| 71 ; Load the address of kCoefficientsRgbY into TABLE |
| 72 mov TEMPq, SOURCE_DX_ARG_REGq ; Need to save source_dx first |
| 73 LOAD_SYM TABLE, mangle(kCoefficientsRgbY) |
| 74 %define SOURCE_DX_ARG_REGq TEMPq ; Overwrite SOURCE_DX_ARG_REGq to TEMPq |
| 75 %else |
| 76 ; Define stack usage. Non-PIC code just push 3 registers to stack. |
| 77 PUSH V_ARG_REGq |
| 78 PUSH SOURCE_DX_ARG_REGq |
| 79 imul WIDTH_ARG_REGq, SOURCE_DX_ARG_REGq ; source_width = width * source_
dx |
| 80 PUSH WIDTH_ARG_REGq |
| 81 %endif |
| 82 |
| 83 %macro EPILOGUE 0 |
| 84 %ifdef PIC |
| 85 ADD rsp, 4 * gprsize |
| 86 %else |
| 87 ADD rsp, 3 * gprsize |
| 88 %endif |
| 89 %endmacro |
| 90 |
| 91 xor Xq, Xq ; x = 0 |
| 92 cmp SOURCE_DX_ARG_REGq, 0x20000 |
| 93 jl .lscaleend |
| 94 mov Xq, 0x8000 ; x = 0.5 for 1/2 or less |
| 95 jmp .lscaleend |
| 96 |
| 97 .lscaleloop: |
| 98 %ifdef PIC |
| 99 mov Uq, U_PLANE ; PIC code saves U_PLANE on stack. |
| 100 %endif |
| 101 |
| 102 ; Define macros for scaling YUV components since they are reused. |
| 103 %macro SCALEUV 1 |
| 104 mov TEMPq, Xq |
| 105 sar TEMPq, 0x11 |
| 106 movzx COMPLd, BYTE [%1 + TEMPq] |
| 107 movzx COMPRd, BYTE [%1 + TEMPq + 1] |
| 108 mov TEMPq, Xq |
| 109 and TEMPq, 0x1fffe |
| 110 imul COMPRq, TEMPq |
| 111 xor TEMPq, 0x1fffe |
| 112 imul COMPLq, TEMPq |
| 113 add COMPLq, COMPRq |
| 114 shr COMPLq, 17 |
| 115 %endmacro |
| 116 SCALEUV Uq ; Use the above macro to scale U |
| 117 movq mm0, [TABLE + 2048 + 8 * COMPLq] |
| 118 |
| 119 mov Vq, V_PLANE ; Read V address from stack |
| 120 SCALEUV Vq ; Use the above macro to scale V |
| 121 paddsw mm0, [TABLE + 4096 + 8 * COMPLq] |
| 122 |
| 123 %macro SCALEY 0 |
| 124 mov TEMPq, Xq |
| 125 sar TEMPq, 0x10 |
| 126 movzx COMPLd, BYTE [Yq + TEMPq] |
| 127 movzx COMPRd, BYTE [Yq + TEMPq + 1] |
| 128 mov TEMPq, Xq |
| 129 add Xq, SOURCE_DX ; Add source_dx from stack |
| 130 and TEMPq, 0xffff |
| 131 imul COMPRq, TEMPq |
| 132 xor TEMPq, 0xffff |
| 133 imul COMPLq, TEMPq |
| 134 add COMPLq, COMPRq |
| 135 shr COMPLq, 16 |
| 136 %endmacro |
| 137 SCALEY ; Use the above macro to scale Y1 |
| 138 movq mm1, [TABLE + 8 * COMPLq] |
| 139 |
| 140 cmp Xq, SOURCE_WIDTH ; Compare source_width from stack |
| 141 jge .lscalelastpixel |
| 142 |
| 143 SCALEY ; Use the above macro to sacle Y2 |
| 144 movq mm2, [TABLE + 8 * COMPLq] |
| 145 |
| 146 paddsw mm1, mm0 |
| 147 paddsw mm2, mm0 |
| 148 psraw mm1, 0x6 |
| 149 psraw mm2, 0x6 |
| 150 packuswb mm1, mm2 |
| 151 MOVQ [ARGBq], mm1 |
| 152 add ARGBq, 0x8 |
| 153 |
| 154 .lscaleend: |
| 155 cmp Xq, SOURCE_WIDTH ; Compare source_width from stack |
| 156 jl .lscaleloop |
| 157 EPILOGUE |
| 158 RET |
| 159 |
| 160 .lscalelastpixel: |
| 161 paddsw mm1, mm0 |
| 162 psraw mm1, 6 |
| 163 packuswb mm1, mm1 |
| 164 movd [ARGBq], mm1 |
| 165 EPILOGUE |
| 166 RET |
| OLD | NEW |