25 #define YUV2RGB_LOAD_COE \
27 __m256i y_offset = __lasx_xvreplgr2vr_d(c->yOffset); \
28 __m256i u_offset = __lasx_xvreplgr2vr_d(c->uOffset); \
29 __m256i v_offset = __lasx_xvreplgr2vr_d(c->vOffset); \
31 __m256i ug_coeff = __lasx_xvreplgr2vr_d(c->ugCoeff); \
32 __m256i vg_coeff = __lasx_xvreplgr2vr_d(c->vgCoeff); \
33 __m256i y_coeff = __lasx_xvreplgr2vr_d(c->yCoeff); \
34 __m256i ub_coeff = __lasx_xvreplgr2vr_d(c->ubCoeff); \
35 __m256i vr_coeff = __lasx_xvreplgr2vr_d(c->vrCoeff); \
38 m_y1 = __lasx_xvld(py_1, 0); \
39 m_y2 = __lasx_xvld(py_2, 0); \
40 m_u = __lasx_xvldrepl_d(pu, 0); \
41 m_v = __lasx_xvldrepl_d(pv, 0); \
42 m_u = __lasx_xvilvl_b(m_u, m_u); \
43 m_v = __lasx_xvilvl_b(m_v, m_v); \
44 DUP4_ARG1(__lasx_vext2xv_hu_bu, m_y1, m_y2, m_u, m_v, \
45 m_y1, m_y2, m_u, m_v); \
58 m_y1 = __lasx_xvslli_h(m_y1, 3); \
59 m_y2 = __lasx_xvslli_h(m_y2, 3); \
60 m_u = __lasx_xvslli_h(m_u, 3); \
61 m_v = __lasx_xvslli_h(m_v, 3); \
62 m_y1 = __lasx_xvsub_h(m_y1, y_offset); \
63 m_y2 = __lasx_xvsub_h(m_y2, y_offset); \
64 m_u = __lasx_xvsub_h(m_u, u_offset); \
65 m_v = __lasx_xvsub_h(m_v, v_offset); \
66 y_1 = __lasx_xvmuh_h(m_y1, y_coeff); \
67 y_2 = __lasx_xvmuh_h(m_y2, y_coeff); \
68 u2g = __lasx_xvmuh_h(m_u, ug_coeff); \
69 u2b = __lasx_xvmuh_h(m_u, ub_coeff); \
70 v2r = __lasx_xvmuh_h(m_v, vr_coeff); \
71 v2g = __lasx_xvmuh_h(m_v, vg_coeff); \
72 r1 = __lasx_xvsadd_h(y_1, v2r); \
73 v2g = __lasx_xvsadd_h(v2g, u2g); \
74 g1 = __lasx_xvsadd_h(y_1, v2g); \
75 b1 = __lasx_xvsadd_h(y_1, u2b); \
76 r2 = __lasx_xvsadd_h(y_2, v2r); \
77 g2 = __lasx_xvsadd_h(y_2, v2g); \
78 b2 = __lasx_xvsadd_h(y_2, u2b); \
79 DUP4_ARG1(__lasx_xvclip255_h, r1, g1, b1, r2, r1, g1, b1, r2); \
80 DUP2_ARG1(__lasx_xvclip255_h, g2, b2, g2, b2); \
83 m_y1 = __lasx_xvldrepl_d(py_1, 0); \
84 m_y2 = __lasx_xvldrepl_d(py_2, 0); \
85 m_u = __lasx_xvldrepl_w(pu, 0); \
86 m_v = __lasx_xvldrepl_w(pv, 0); \
87 m_y1 = __lasx_xvilvl_d(m_y2, m_y1); \
88 m_u = __lasx_xvilvl_b(m_u, m_u); \
89 m_v = __lasx_xvilvl_b(m_v, m_v); \
90 m_y1 = __lasx_vext2xv_hu_bu(m_y1); \
91 m_u = __lasx_vext2xv_hu_bu(m_u); \
92 m_v = __lasx_vext2xv_hu_bu(m_v); \
93 m_y1 = __lasx_xvslli_h(m_y1, 3); \
94 m_u = __lasx_xvslli_h(m_u, 3); \
95 m_v = __lasx_xvslli_h(m_v, 3); \
96 m_y1 = __lasx_xvsub_h(m_y1, y_offset); \
97 m_u = __lasx_xvsub_h(m_u, u_offset); \
98 m_v = __lasx_xvsub_h(m_v, v_offset); \
99 y_1 = __lasx_xvmuh_h(m_y1, y_coeff); \
100 u2g = __lasx_xvmuh_h(m_u, ug_coeff); \
101 u2b = __lasx_xvmuh_h(m_u, ub_coeff); \
102 v2r = __lasx_xvmuh_h(m_v, vr_coeff); \
103 v2g = __lasx_xvmuh_h(m_v, vg_coeff); \
104 r1 = __lasx_xvsadd_h(y_1, v2r); \
105 v2g = __lasx_xvsadd_h(v2g, u2g); \
106 g1 = __lasx_xvsadd_h(y_1, v2g); \
107 b1 = __lasx_xvsadd_h(y_1, u2b); \
108 r1 = __lasx_xvclip255_h(r1); \
109 g1 = __lasx_xvclip255_h(g1); \
110 b1 = __lasx_xvclip255_h(b1); \
112 #define RGB_PACK(r, g, b, rgb_l, rgb_h) \
115 rg = __lasx_xvpackev_b(g, r); \
116 DUP2_ARG3(__lasx_xvshuf_b, b, rg, shuf2, b, rg, shuf3, rgb_l, rgb_h); \
119 #define RGB32_PACK(a, r, g, b, rgb_l, rgb_h) \
121 __m256i ra, bg, tmp0, tmp1; \
122 ra = __lasx_xvpackev_b(r, a); \
123 bg = __lasx_xvpackev_b(b, g); \
124 tmp0 = __lasx_xvilvl_h(bg, ra); \
125 tmp1 = __lasx_xvilvh_h(bg, ra); \
126 rgb_l = __lasx_xvpermi_q(tmp1, tmp0, 0x20); \
127 rgb_h = __lasx_xvpermi_q(tmp1, tmp0, 0x31); \
130 #define RGB_STORE_RES(rgb_l, rgb_h, image_1, image_2) \
132 __lasx_xvstelm_d(rgb_l, image_1, 0, 0); \
133 __lasx_xvstelm_d(rgb_l, image_1, 8, 1); \
134 __lasx_xvstelm_d(rgb_h, image_1, 16, 0); \
135 __lasx_xvstelm_d(rgb_l, image_2, 0, 2); \
136 __lasx_xvstelm_d(rgb_l, image_2, 8, 3); \
137 __lasx_xvstelm_d(rgb_h, image_2, 16, 2); \
140 #define RGB_STORE(rgb_l, rgb_h, image) \
142 __lasx_xvstelm_d(rgb_l, image, 0, 0); \
143 __lasx_xvstelm_d(rgb_l, image, 8, 1); \
144 __lasx_xvstelm_d(rgb_h, image, 16, 0); \
145 __lasx_xvstelm_d(rgb_l, image, 24, 2); \
146 __lasx_xvstelm_d(rgb_l, image, 32, 3); \
147 __lasx_xvstelm_d(rgb_h, image, 40, 2); \
150 #define RGB32_STORE(rgb_l, rgb_h, image) \
152 __lasx_xvst(rgb_l, image, 0); \
153 __lasx_xvst(rgb_h, image, 32); \
156 #define RGB32_STORE_RES(rgb_l, rgb_h, image_1, image_2) \
158 __lasx_xvst(rgb_l, image_1, 0); \
159 __lasx_xvst(rgb_h, image_2, 0); \
162 #define YUV2RGBFUNC(func_name, dst_type, alpha) \
163 int func_name(SwsContext *c, const uint8_t *src[], \
164 int srcStride[], int srcSliceY, int srcSliceH, \
165 uint8_t *dst[], int dstStride[]) \
167 int x, y, h_size, vshift, res; \
168 __m256i m_y1, m_y2, m_u, m_v; \
169 __m256i y_1, y_2, u2g, v2g, u2b, v2r, rgb1_l, rgb1_h; \
170 __m256i rgb2_l, rgb2_h, r1, g1, b1, r2, g2, b2; \
171 __m256i shuf2 = {0x0504120302100100, 0x0A18090816070614, \
172 0x0504120302100100, 0x0A18090816070614}; \
173 __m256i shuf3 = {0x1E0F0E1C0D0C1A0B, 0x0101010101010101, \
174 0x1E0F0E1C0D0C1A0B, 0x0101010101010101}; \
176 y = (c->dstW + 7) & ~7; \
180 vshift = c->srcFormat != AV_PIX_FMT_YUV422P; \
181 for (y = 0; y < srcSliceH; y += 2) { \
182 dst_type *image1 = (dst_type *)(dst[0] + (y + srcSliceY) * dstStride[0]);\
183 dst_type *image2 = (dst_type *)(image1 + dstStride[0]);\
184 const uint8_t *py_1 = src[0] + y * srcStride[0]; \
185 const uint8_t *py_2 = py_1 + srcStride[0]; \
186 const uint8_t *pu = src[1] + (y >> vshift) * srcStride[1]; \
187 const uint8_t *pv = src[2] + (y >> vshift) * srcStride[2]; \
188 for(x = 0; x < h_size; x++) { \
190 #define YUV2RGBFUNC32(func_name, dst_type, alpha) \
191 int func_name(SwsContext *c, const uint8_t *src[], \
192 int srcStride[], int srcSliceY, int srcSliceH, \
193 uint8_t *dst[], int dstStride[]) \
195 int x, y, h_size, vshift, res; \
196 __m256i m_y1, m_y2, m_u, m_v; \
197 __m256i y_1, y_2, u2g, v2g, u2b, v2r, rgb1_l, rgb1_h; \
198 __m256i rgb2_l, rgb2_h, r1, g1, b1, r2, g2, b2; \
199 __m256i a = __lasx_xvldi(0xFF); \
202 y = (c->dstW + 7) & ~7; \
206 vshift = c->srcFormat != AV_PIX_FMT_YUV422P; \
207 for (y = 0; y < srcSliceH; y += 2) { \
208 int yd = y + srcSliceY; \
209 dst_type av_unused *r, *g, *b; \
210 dst_type *image1 = (dst_type *)(dst[0] + (yd) * dstStride[0]); \
211 dst_type *image2 = (dst_type *)(dst[0] + (yd + 1) * dstStride[0]); \
212 const uint8_t *py_1 = src[0] + y * srcStride[0]; \
213 const uint8_t *py_2 = py_1 + srcStride[0]; \
214 const uint8_t *pu = src[1] + (y >> vshift) * srcStride[1]; \
215 const uint8_t *pv = src[2] + (y >> vshift) * srcStride[2]; \
216 for(x = 0; x < h_size; x++) { \
218 #define DEALYUV2RGBREMAIN \
228 #define DEALYUV2RGBREMAIN32 \