Coverage Report

Created: 2026-09-03 07:17

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libavc/common/x86/ih264_weighted_pred_sse42.c
Line
Count
Source
1
/******************************************************************************
2
 *
3
 * Copyright (C) 2015 The Android Open Source Project
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at:
8
 *
9
 * http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 *****************************************************************************
18
 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19
*/
20
/*****************************************************************************/
21
/*                                                                           */
22
/*  File Name         : ih264_weighted_pred_intr_sse42.c                     */
23
/*                                                                           */
24
/*  Description       : Contains function definitions for weighted           */
25
/*                      prediction functions in x86 sse4 intrinsics          */
26
/*                                                                           */
27
/*  List of Functions : ih264_default_weighted_pred_luma_sse42()             */
28
/*                      ih264_default_weighted_pred_chroma_sse42()           */
29
/*                      ih264_weighted_pred_luma_sse42()                     */
30
/*                      ih264_weighted_pred_chroma_sse42()                   */
31
/*                      ih264_weighted_bipred_luma_sse42()                   */
32
/*                      ih264_weighted_bipred_chroma_sse42()                 */
33
/*                                                                           */
34
/*  Issues / Problems : None                                                 */
35
/*                                                                           */
36
/*  Revision History  :                                                      */
37
/*                                                                           */
38
/*         DD MM YYYY   Author(s)       Changes                              */
39
/*         30 01 2015   Kaushik         Initial version                      */
40
/*                      Senthoor                                             */
41
/*                                                                           */
42
/*****************************************************************************/
43
/*****************************************************************************/
44
/* File Includes                                                             */
45
/*****************************************************************************/
46
47
#include <immintrin.h>
48
#include "ih264_typedefs.h"
49
#include "ih264_macros.h"
50
#include "ih264_platform_macros.h"
51
#include "ih264_weighted_pred.h"
52
53
/*****************************************************************************/
54
/*  Function definitions .                                                   */
55
/*****************************************************************************/
56
/*****************************************************************************/
57
/*                                                                           */
58
/*  Function Name : ih264_default_weighted_pred_luma_sse42                   */
59
/*                                                                           */
60
/*  Description   : This function performs the default weighted prediction   */
61
/*                  as described in sec 8.4.2.3.1 titled "Default weighted   */
62
/*                  sample prediction process" for luma. The function gets   */
63
/*                  two ht x wd blocks, calculates their rounded-average and */
64
/*                  stores it in the destination block. (ht,wd) can be       */
65
/*                  (4,4), (8,4), (4,8), (8,8), (16,8), (8,16) or (16,16).   */
66
/*                                                                           */
67
/*  Inputs        : pu1_src1  - Pointer to source 1                          */
68
/*                  pu1_src2  - Pointer to source 2                          */
69
/*                  pu1_dst   - Pointer to destination                       */
70
/*                  src_strd1 - stride for source 1                          */
71
/*                  src_strd1 - stride for source 2                          */
72
/*                  dst_strd  - stride for destination                       */
73
/*                  ht        - height of the block                          */
74
/*                  wd        - width of the block                           */
75
/*                                                                           */
76
/*  Issues        : None                                                     */
77
/*                                                                           */
78
/*  Revision History:                                                        */
79
/*                                                                           */
80
/*         DD MM YYYY   Author(s)       Changes                              */
81
/*         04 02 2015   Kaushik         Initial Version                      */
82
/*                      Senthoor                                             */
83
/*                                                                           */
84
/*****************************************************************************/
85
void ih264_default_weighted_pred_luma_sse42(UWORD8 *pu1_src1,
86
                                            UWORD8 *pu1_src2,
87
                                            UWORD8 *pu1_dst,
88
                                            WORD32 src_strd1,
89
                                            WORD32 src_strd2,
90
                                            WORD32 dst_strd,
91
                                            WORD32 ht,
92
                                            WORD32 wd)
93
1.04M
{
94
1.04M
    __m128i y0_0_16x8b, y0_1_16x8b, y0_2_16x8b, y0_3_16x8b;
95
1.04M
    __m128i y1_0_16x8b, y1_1_16x8b, y1_2_16x8b, y1_3_16x8b;
96
97
1.04M
    if(wd == 4)
98
6.42k
    {
99
6.42k
        do
100
9.07k
        {
101
9.07k
            y0_0_16x8b = _mm_loadl_epi64((__m128i *)pu1_src1);
102
9.07k
            y0_1_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src1 + src_strd1));
103
9.07k
            y0_2_16x8b = _mm_loadl_epi64(
104
9.07k
                            (__m128i *)(pu1_src1 + (src_strd1 << 1)));
105
9.07k
            y0_3_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src1 + src_strd1 * 3));
106
107
9.07k
            y1_0_16x8b = _mm_loadl_epi64((__m128i *)pu1_src2);
108
9.07k
            y1_1_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src2 + src_strd2));
109
9.07k
            y1_2_16x8b = _mm_loadl_epi64(
110
9.07k
                            (__m128i *)(pu1_src2 + (src_strd2 << 1)));
111
9.07k
            y1_3_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src2 + src_strd2 * 3));
112
113
9.07k
            y0_0_16x8b = _mm_avg_epu8(y0_0_16x8b, y1_0_16x8b);
114
9.07k
            y0_1_16x8b = _mm_avg_epu8(y0_1_16x8b, y1_1_16x8b);
115
9.07k
            y0_2_16x8b = _mm_avg_epu8(y0_2_16x8b, y1_2_16x8b);
116
9.07k
            y0_3_16x8b = _mm_avg_epu8(y0_3_16x8b, y1_3_16x8b);
117
118
9.07k
            *((WORD32 *)(pu1_dst)) = _mm_cvtsi128_si32(y0_0_16x8b);
119
9.07k
            *((WORD32 *)(pu1_dst + dst_strd)) = _mm_cvtsi128_si32(y0_1_16x8b);
120
9.07k
            *((WORD32 *)(pu1_dst + (dst_strd << 1))) = _mm_cvtsi128_si32(y0_2_16x8b);
121
9.07k
            *((WORD32 *)(pu1_dst + dst_strd * 3)) = _mm_cvtsi128_si32(y0_3_16x8b);
122
123
9.07k
            ht -= 4;
124
9.07k
            pu1_src1 += src_strd1 << 2;
125
9.07k
            pu1_src2 += src_strd2 << 2;
126
9.07k
            pu1_dst += dst_strd << 2;
127
9.07k
        }
128
9.07k
        while(ht > 0);
129
6.42k
    }
130
1.04M
    else if(wd == 8)
131
35.7k
    {
132
35.7k
        do
133
91.9k
        {
134
91.9k
            y0_0_16x8b = _mm_loadl_epi64((__m128i *)pu1_src1);
135
91.9k
            y0_1_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src1 + src_strd1));
136
91.9k
            y0_2_16x8b = _mm_loadl_epi64(
137
91.9k
                            (__m128i *)(pu1_src1 + (src_strd1 << 1)));
138
91.9k
            y0_3_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src1 + src_strd1 * 3));
139
140
91.9k
            y1_0_16x8b = _mm_loadl_epi64((__m128i *)pu1_src2);
141
91.9k
            y1_1_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src2 + src_strd2));
142
91.9k
            y1_2_16x8b = _mm_loadl_epi64(
143
91.9k
                            (__m128i *)(pu1_src2 + (src_strd2 << 1)));
144
91.9k
            y1_3_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src2 + src_strd2 * 3));
145
146
91.9k
            y0_0_16x8b = _mm_avg_epu8(y0_0_16x8b, y1_0_16x8b);
147
91.9k
            y0_1_16x8b = _mm_avg_epu8(y0_1_16x8b, y1_1_16x8b);
148
91.9k
            y0_2_16x8b = _mm_avg_epu8(y0_2_16x8b, y1_2_16x8b);
149
91.9k
            y0_3_16x8b = _mm_avg_epu8(y0_3_16x8b, y1_3_16x8b);
150
151
91.9k
            _mm_storel_epi64((__m128i *)pu1_dst, y0_0_16x8b);
152
91.9k
            _mm_storel_epi64((__m128i *)(pu1_dst + dst_strd), y0_1_16x8b);
153
91.9k
            _mm_storel_epi64((__m128i *)(pu1_dst + (dst_strd << 1)), y0_2_16x8b);
154
91.9k
            _mm_storel_epi64((__m128i *)(pu1_dst + dst_strd * 3), y0_3_16x8b);
155
156
91.9k
            ht -= 4;
157
91.9k
            pu1_src1 += src_strd1 << 2;
158
91.9k
            pu1_src2 += src_strd2 << 2;
159
91.9k
            pu1_dst += dst_strd << 2;
160
91.9k
        }
161
91.9k
        while(ht > 0);
162
35.7k
    }
163
1.00M
    else // wd == 16
164
1.00M
    {
165
1.00M
        __m128i y0_4_16x8b, y0_5_16x8b, y0_6_16x8b, y0_7_16x8b;
166
1.00M
        __m128i y1_4_16x8b, y1_5_16x8b, y1_6_16x8b, y1_7_16x8b;
167
168
1.00M
        do
169
1.99M
        {
170
1.99M
            y0_0_16x8b = _mm_loadu_si128((__m128i *)pu1_src1);
171
1.99M
            y0_1_16x8b = _mm_loadu_si128((__m128i *)(pu1_src1 + src_strd1));
172
1.99M
            y0_2_16x8b = _mm_loadu_si128(
173
1.99M
                            (__m128i *)(pu1_src1 + (src_strd1 << 1)));
174
1.99M
            y0_3_16x8b = _mm_loadu_si128((__m128i *)(pu1_src1 + src_strd1 * 3));
175
1.99M
            y0_4_16x8b = _mm_loadu_si128(
176
1.99M
                            (__m128i *)(pu1_src1 + (src_strd1 << 2)));
177
1.99M
            y0_5_16x8b = _mm_loadu_si128((__m128i *)(pu1_src1 + src_strd1 * 5));
178
1.99M
            y0_6_16x8b = _mm_loadu_si128((__m128i *)(pu1_src1 + src_strd1 * 6));
179
1.99M
            y0_7_16x8b = _mm_loadu_si128((__m128i *)(pu1_src1 + src_strd1 * 7));
180
181
1.99M
            y1_0_16x8b = _mm_loadu_si128((__m128i *)pu1_src2);
182
1.99M
            y1_1_16x8b = _mm_loadu_si128((__m128i *)(pu1_src2 + src_strd2));
183
1.99M
            y1_2_16x8b = _mm_loadu_si128(
184
1.99M
                            (__m128i *)(pu1_src2 + (src_strd2 << 1)));
185
1.99M
            y1_3_16x8b = _mm_loadu_si128((__m128i *)(pu1_src2 + src_strd2 * 3));
186
1.99M
            y1_4_16x8b = _mm_loadu_si128(
187
1.99M
                            (__m128i *)(pu1_src2 + (src_strd2 << 2)));
188
1.99M
            y1_5_16x8b = _mm_loadu_si128((__m128i *)(pu1_src2 + src_strd2 * 5));
189
1.99M
            y1_6_16x8b = _mm_loadu_si128((__m128i *)(pu1_src2 + src_strd2 * 6));
190
1.99M
            y1_7_16x8b = _mm_loadu_si128((__m128i *)(pu1_src2 + src_strd2 * 7));
191
192
1.99M
            y0_0_16x8b = _mm_avg_epu8(y0_0_16x8b, y1_0_16x8b);
193
1.99M
            y0_1_16x8b = _mm_avg_epu8(y0_1_16x8b, y1_1_16x8b);
194
1.99M
            y0_2_16x8b = _mm_avg_epu8(y0_2_16x8b, y1_2_16x8b);
195
1.99M
            y0_3_16x8b = _mm_avg_epu8(y0_3_16x8b, y1_3_16x8b);
196
1.99M
            y0_4_16x8b = _mm_avg_epu8(y0_4_16x8b, y1_4_16x8b);
197
1.99M
            y0_5_16x8b = _mm_avg_epu8(y0_5_16x8b, y1_5_16x8b);
198
1.99M
            y0_6_16x8b = _mm_avg_epu8(y0_6_16x8b, y1_6_16x8b);
199
1.99M
            y0_7_16x8b = _mm_avg_epu8(y0_7_16x8b, y1_7_16x8b);
200
201
1.99M
            _mm_storeu_si128((__m128i *)pu1_dst, y0_0_16x8b);
202
1.99M
            _mm_storeu_si128((__m128i *)(pu1_dst + dst_strd), y0_1_16x8b);
203
1.99M
            _mm_storeu_si128((__m128i *)(pu1_dst + (dst_strd << 1)), y0_2_16x8b);
204
1.99M
            _mm_storeu_si128((__m128i *)(pu1_dst + dst_strd * 3), y0_3_16x8b);
205
1.99M
            _mm_storeu_si128((__m128i *)(pu1_dst + (dst_strd << 2)), y0_4_16x8b);
206
1.99M
            _mm_storeu_si128((__m128i *)(pu1_dst + dst_strd * 5), y0_5_16x8b);
207
1.99M
            _mm_storeu_si128((__m128i *)(pu1_dst + dst_strd * 6), y0_6_16x8b);
208
1.99M
            _mm_storeu_si128((__m128i *)(pu1_dst + dst_strd * 7), y0_7_16x8b);
209
210
1.99M
            ht -= 8;
211
1.99M
            pu1_src1 += src_strd1 << 3;
212
1.99M
            pu1_src2 += src_strd2 << 3;
213
1.99M
            pu1_dst += dst_strd << 3;
214
1.99M
        }
215
1.99M
        while(ht > 0);
216
1.00M
    }
217
1.04M
}
218
219
/*****************************************************************************/
220
/*                                                                           */
221
/*  Function Name : ih264_default_weighted_pred_chroma_sse42                 */
222
/*                                                                           */
223
/*  Description   : This function performs the default weighted prediction   */
224
/*                  as described in sec 8.4.2.3.1 titled "Default weighted   */
225
/*                  sample prediction process" for chroma. The function gets */
226
/*                  two ht x wd blocks, calculates their rounded-average and */
227
/*                  stores it in the destination block. (ht,wd) can be       */
228
/*                  (2,2), (4,2) , (2,4), (4,4), (8,4), (4,8) or (8,8).      */
229
/*                                                                           */
230
/*  Inputs        : pu1_src1  - Pointer to source 1                          */
231
/*                  pu1_src2  - Pointer to source 2                          */
232
/*                  pu1_dst   - Pointer to destination                       */
233
/*                  src_strd1 - stride for source 1                          */
234
/*                  src_strd1 - stride for source 2                          */
235
/*                  dst_strd  - stride for destination                       */
236
/*                  ht        - height of the block                          */
237
/*                  wd        - width of the block                           */
238
/*                                                                           */
239
/*  Issues        : None                                                     */
240
/*                                                                           */
241
/*  Revision History:                                                        */
242
/*                                                                           */
243
/*         DD MM YYYY   Author(s)       Changes                              */
244
/*         04 02 2015   Kaushik         Initial Version                      */
245
/*                      Senthoor                                             */
246
/*                                                                           */
247
/*****************************************************************************/
248
void ih264_default_weighted_pred_chroma_sse42(UWORD8 *pu1_src1,
249
                                              UWORD8 *pu1_src2,
250
                                              UWORD8 *pu1_dst,
251
                                              WORD32 src_strd1,
252
                                              WORD32 src_strd2,
253
                                              WORD32 dst_strd,
254
                                              WORD32 ht,
255
                                              WORD32 wd)
256
1.04M
{
257
1.04M
    __m128i uv0_0_16x8b, uv0_1_16x8b;
258
1.04M
    __m128i uv1_0_16x8b, uv1_1_16x8b;
259
260
1.04M
    if(wd == 2)
261
6.42k
    {
262
6.42k
        do
263
9.07k
        {
264
9.07k
            uv0_0_16x8b = _mm_loadl_epi64((__m128i *)pu1_src1);
265
9.07k
            uv0_1_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src1 + src_strd1));
266
267
9.07k
            uv1_0_16x8b = _mm_loadl_epi64((__m128i *)pu1_src2);
268
9.07k
            uv1_1_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src2 + src_strd2));
269
270
9.07k
            uv0_0_16x8b = _mm_avg_epu8(uv0_0_16x8b, uv1_0_16x8b);
271
9.07k
            uv0_1_16x8b = _mm_avg_epu8(uv0_1_16x8b, uv1_1_16x8b);
272
273
9.07k
            *((WORD32 *)(pu1_dst)) = _mm_cvtsi128_si32(uv0_0_16x8b);
274
9.07k
            *((WORD32 *)(pu1_dst + dst_strd)) = _mm_cvtsi128_si32(uv0_1_16x8b);
275
276
9.07k
            ht -= 2;
277
9.07k
            pu1_src1 += src_strd1 << 1;
278
9.07k
            pu1_src2 += src_strd2 << 1;
279
9.07k
            pu1_dst += dst_strd << 1;
280
9.07k
        }
281
9.07k
        while(ht > 0);
282
6.42k
    }
283
1.04M
    else if(wd == 4)
284
35.7k
    {
285
35.7k
        do
286
91.9k
        {
287
91.9k
            uv0_0_16x8b = _mm_loadl_epi64((__m128i *)pu1_src1);
288
91.9k
            uv0_1_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src1 + src_strd1));
289
290
91.9k
            uv1_0_16x8b = _mm_loadl_epi64((__m128i *)pu1_src2);
291
91.9k
            uv1_1_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src2 + src_strd2));
292
293
91.9k
            uv0_0_16x8b = _mm_avg_epu8(uv0_0_16x8b, uv1_0_16x8b);
294
91.9k
            uv0_1_16x8b = _mm_avg_epu8(uv0_1_16x8b, uv1_1_16x8b);
295
296
91.9k
            _mm_storel_epi64((__m128i *)pu1_dst, uv0_0_16x8b);
297
91.9k
            _mm_storel_epi64((__m128i *)(pu1_dst + dst_strd), uv0_1_16x8b);
298
299
91.9k
            ht -= 2;
300
91.9k
            pu1_src1 += src_strd1 << 1;
301
91.9k
            pu1_src2 += src_strd2 << 1;
302
91.9k
            pu1_dst += dst_strd << 1;
303
91.9k
        }
304
91.9k
        while(ht > 0);
305
35.7k
    }
306
1.00M
    else // wd == 8
307
1.00M
    {
308
1.00M
        __m128i uv0_2_16x8b, uv0_3_16x8b;
309
1.00M
        __m128i uv1_2_16x8b, uv1_3_16x8b;
310
311
1.00M
        do
312
1.99M
        {
313
1.99M
            uv0_0_16x8b = _mm_loadu_si128((__m128i *)pu1_src1);
314
1.99M
            uv0_1_16x8b = _mm_loadu_si128((__m128i *)(pu1_src1 + src_strd1));
315
1.99M
            uv0_2_16x8b = _mm_loadu_si128(
316
1.99M
                            (__m128i *)(pu1_src1 + (src_strd1 << 1)));
317
1.99M
            uv0_3_16x8b = _mm_loadu_si128(
318
1.99M
                            (__m128i *)(pu1_src1 + src_strd1 * 3));
319
320
1.99M
            uv1_0_16x8b = _mm_loadu_si128((__m128i *)pu1_src2);
321
1.99M
            uv1_1_16x8b = _mm_loadu_si128((__m128i *)(pu1_src2 + src_strd2));
322
1.99M
            uv1_2_16x8b = _mm_loadu_si128(
323
1.99M
                            (__m128i *)(pu1_src2 + (src_strd2 << 1)));
324
1.99M
            uv1_3_16x8b = _mm_loadu_si128(
325
1.99M
                            (__m128i *)(pu1_src2 + src_strd2 * 3));
326
327
1.99M
            uv0_0_16x8b = _mm_avg_epu8(uv0_0_16x8b, uv1_0_16x8b);
328
1.99M
            uv0_1_16x8b = _mm_avg_epu8(uv0_1_16x8b, uv1_1_16x8b);
329
1.99M
            uv0_2_16x8b = _mm_avg_epu8(uv0_2_16x8b, uv1_2_16x8b);
330
1.99M
            uv0_3_16x8b = _mm_avg_epu8(uv0_3_16x8b, uv1_3_16x8b);
331
332
1.99M
            _mm_storeu_si128((__m128i *)pu1_dst, uv0_0_16x8b);
333
1.99M
            _mm_storeu_si128((__m128i *)(pu1_dst + dst_strd), uv0_1_16x8b);
334
1.99M
            _mm_storeu_si128(
335
1.99M
                            (__m128i *)(pu1_dst + (dst_strd << 1)), uv0_2_16x8b);
336
1.99M
            _mm_storeu_si128((__m128i *)(pu1_dst + dst_strd * 3), uv0_3_16x8b);
337
338
1.99M
            ht -= 4;
339
1.99M
            pu1_src1 += src_strd1 << 2;
340
1.99M
            pu1_src2 += src_strd2 << 2;
341
1.99M
            pu1_dst += dst_strd << 2;
342
1.99M
        }
343
1.99M
        while(ht > 0);
344
1.00M
    }
345
1.04M
}
346
347
/*****************************************************************************/
348
/*                                                                           */
349
/*  Function Name : ih264_weighted_pred_luma_sse42                           */
350
/*                                                                           */
351
/*  Description   : This function performs the weighted prediction as        */
352
/*                  described in sec 8.4.2.3.2 titled "Weighted sample       */
353
/*                  prediction process" for luma. The function gets one      */
354
/*                  ht x wd block, weights it, rounds it off, offsets it,    */
355
/*                  saturates it to unsigned 8-bit and stores it in the      */
356
/*                  destination block. (ht,wd) can be (4,4), (8,4), (4,8),   */
357
/*                  (8,8), (16,8), (8,16) or (16,16).                        */
358
/*                                                                           */
359
/*  Inputs        : pu1_src  - Pointer to source                             */
360
/*                  pu1_dst  - Pointer to destination                        */
361
/*                  src_strd - stride for source                             */
362
/*                  dst_strd - stride for destination                        */
363
/*                  log_wd   - number of bits to be rounded off              */
364
/*                  wt       - weight value                                  */
365
/*                  ofst     - offset value                                  */
366
/*                  ht       - height of the block                           */
367
/*                  wd       - width of the block                            */
368
/*                                                                           */
369
/*  Issues        : None                                                     */
370
/*                                                                           */
371
/*  Revision History:                                                        */
372
/*                                                                           */
373
/*         DD MM YYYY   Author(s)       Changes                              */
374
/*         04 02 2015   Kaushik         Initial Version                      */
375
/*                      Senthoor                                             */
376
/*                                                                           */
377
/*****************************************************************************/
378
void ih264_weighted_pred_luma_sse42(UWORD8 *pu1_src,
379
                                    UWORD8 *pu1_dst,
380
                                    WORD32 src_strd,
381
                                    WORD32 dst_strd,
382
                                    WORD32 log_wd,
383
                                    WORD32 wt,
384
                                    WORD32 ofst,
385
                                    WORD32 ht,
386
                                    WORD32 wd)
387
10.8M
{
388
10.8M
    __m128i y_0_16x8b, y_1_16x8b, y_2_16x8b, y_3_16x8b;
389
390
10.8M
    __m128i wt_8x16b, round_8x16b, ofst_8x16b;
391
392
10.8M
    WORD32 round_val;
393
394
10.8M
    wt = (WORD16)(wt & 0xffff);
395
10.8M
    round_val = 1 << (log_wd - 1);
396
10.8M
    ofst = (WORD8)(ofst & 0xff);
397
398
10.8M
    wt_8x16b = _mm_set1_epi16(wt);
399
10.8M
    round_8x16b = _mm_set1_epi16(round_val);
400
10.8M
    ofst_8x16b = _mm_set1_epi16(ofst);
401
402
10.8M
    if(wd == 4)
403
79.8k
    {
404
79.8k
        __m128i y_0_8x16b, y_2_8x16b;
405
406
79.8k
        do
407
128k
        {
408
128k
            y_0_16x8b = _mm_loadl_epi64((__m128i *)pu1_src);
409
128k
            y_1_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src + src_strd));
410
128k
            y_2_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src + (src_strd << 1)));
411
128k
            y_3_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src + src_strd * 3));
412
413
128k
            y_0_16x8b = _mm_unpacklo_epi32(y_0_16x8b, y_1_16x8b);
414
128k
            y_2_16x8b = _mm_unpacklo_epi32(y_2_16x8b, y_3_16x8b);
415
416
128k
            y_0_8x16b = _mm_cvtepu8_epi16(y_0_16x8b);
417
128k
            y_2_8x16b = _mm_cvtepu8_epi16(y_2_16x8b);
418
419
128k
            y_0_8x16b = _mm_mullo_epi16(y_0_8x16b, wt_8x16b);
420
128k
            y_2_8x16b = _mm_mullo_epi16(y_2_8x16b, wt_8x16b);
421
422
128k
            y_0_8x16b = _mm_adds_epi16(round_8x16b, y_0_8x16b);
423
128k
            y_2_8x16b = _mm_adds_epi16(round_8x16b, y_2_8x16b);
424
425
128k
            y_0_8x16b = _mm_srai_epi16(y_0_8x16b, log_wd);
426
128k
            y_2_8x16b = _mm_srai_epi16(y_2_8x16b, log_wd);
427
428
128k
            y_0_8x16b = _mm_adds_epi16(ofst_8x16b, y_0_8x16b);
429
128k
            y_2_8x16b = _mm_adds_epi16(ofst_8x16b, y_2_8x16b);
430
431
128k
            y_0_16x8b = _mm_packus_epi16(y_0_8x16b, y_2_8x16b);
432
128k
            y_1_16x8b = _mm_srli_si128(y_0_16x8b, 4);
433
128k
            y_2_16x8b = _mm_srli_si128(y_0_16x8b, 8);
434
128k
            y_3_16x8b = _mm_srli_si128(y_0_16x8b, 12);
435
436
128k
            *((WORD32 *)(pu1_dst)) = _mm_cvtsi128_si32(y_0_16x8b);
437
128k
            *((WORD32 *)(pu1_dst + dst_strd)) = _mm_cvtsi128_si32(y_1_16x8b);
438
128k
            *((WORD32 *)(pu1_dst + (dst_strd << 1))) = _mm_cvtsi128_si32(y_2_16x8b);
439
128k
            *((WORD32 *)(pu1_dst + dst_strd * 3)) = _mm_cvtsi128_si32(y_3_16x8b);
440
441
128k
            ht -= 4;
442
128k
            pu1_src += src_strd << 2;
443
128k
            pu1_dst += dst_strd << 2;
444
128k
        }
445
128k
        while(ht > 0);
446
79.8k
    }
447
10.7M
    else if(wd == 8)
448
80.4k
    {
449
80.4k
        __m128i y_0_8x16b, y_1_8x16b, y_2_8x16b, y_3_8x16b;
450
451
80.4k
        do
452
190k
        {
453
190k
            y_0_16x8b = _mm_loadl_epi64((__m128i *)pu1_src);
454
190k
            y_1_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src + src_strd));
455
190k
            y_2_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src + (src_strd << 1)));
456
190k
            y_3_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src + src_strd * 3));
457
458
190k
            y_0_8x16b = _mm_cvtepu8_epi16(y_0_16x8b);
459
190k
            y_1_8x16b = _mm_cvtepu8_epi16(y_1_16x8b);
460
190k
            y_2_8x16b = _mm_cvtepu8_epi16(y_2_16x8b);
461
190k
            y_3_8x16b = _mm_cvtepu8_epi16(y_3_16x8b);
462
463
190k
            y_0_8x16b = _mm_mullo_epi16(y_0_8x16b, wt_8x16b);
464
190k
            y_1_8x16b = _mm_mullo_epi16(y_1_8x16b, wt_8x16b);
465
190k
            y_2_8x16b = _mm_mullo_epi16(y_2_8x16b, wt_8x16b);
466
190k
            y_3_8x16b = _mm_mullo_epi16(y_3_8x16b, wt_8x16b);
467
468
190k
            y_0_8x16b = _mm_adds_epi16(round_8x16b, y_0_8x16b);
469
190k
            y_1_8x16b = _mm_adds_epi16(round_8x16b, y_1_8x16b);
470
190k
            y_2_8x16b = _mm_adds_epi16(round_8x16b, y_2_8x16b);
471
190k
            y_3_8x16b = _mm_adds_epi16(round_8x16b, y_3_8x16b);
472
473
190k
            y_0_8x16b = _mm_srai_epi16(y_0_8x16b, log_wd);
474
190k
            y_1_8x16b = _mm_srai_epi16(y_1_8x16b, log_wd);
475
190k
            y_2_8x16b = _mm_srai_epi16(y_2_8x16b, log_wd);
476
190k
            y_3_8x16b = _mm_srai_epi16(y_3_8x16b, log_wd);
477
478
190k
            y_0_8x16b = _mm_adds_epi16(ofst_8x16b, y_0_8x16b);
479
190k
            y_1_8x16b = _mm_adds_epi16(ofst_8x16b, y_1_8x16b);
480
190k
            y_2_8x16b = _mm_adds_epi16(ofst_8x16b, y_2_8x16b);
481
190k
            y_3_8x16b = _mm_adds_epi16(ofst_8x16b, y_3_8x16b);
482
483
190k
            y_0_16x8b = _mm_packus_epi16(y_0_8x16b, y_1_8x16b);
484
190k
            y_2_16x8b = _mm_packus_epi16(y_2_8x16b, y_3_8x16b);
485
190k
            y_1_16x8b = _mm_srli_si128(y_0_16x8b, 8);
486
190k
            y_3_16x8b = _mm_srli_si128(y_2_16x8b, 8);
487
488
190k
            _mm_storel_epi64((__m128i *)pu1_dst, y_0_16x8b);
489
190k
            _mm_storel_epi64((__m128i *)(pu1_dst + dst_strd), y_1_16x8b);
490
190k
            _mm_storel_epi64((__m128i *)(pu1_dst + (dst_strd << 1)), y_2_16x8b);
491
190k
            _mm_storel_epi64((__m128i *)(pu1_dst + dst_strd * 3), y_3_16x8b);
492
493
190k
            ht -= 4;
494
190k
            pu1_src += src_strd << 2;
495
190k
            pu1_dst += dst_strd << 2;
496
190k
        }
497
190k
        while(ht > 0);
498
80.4k
    }
499
10.6M
    else // wd == 16
500
10.6M
    {
501
10.6M
        __m128i y_0L_8x16b, y_1L_8x16b, y_2L_8x16b, y_3L_8x16b;
502
10.6M
        __m128i y_0H_8x16b, y_1H_8x16b, y_2H_8x16b, y_3H_8x16b;
503
504
10.6M
        __m128i zero_16x8b;
505
10.6M
        zero_16x8b = _mm_set1_epi8(0);
506
507
10.6M
        do
508
42.4M
        {
509
42.4M
            y_0_16x8b = _mm_loadu_si128((__m128i *)pu1_src);
510
42.4M
            y_1_16x8b = _mm_loadu_si128((__m128i *)(pu1_src + src_strd));
511
42.4M
            y_2_16x8b = _mm_loadu_si128((__m128i *)(pu1_src + (src_strd << 1)));
512
42.4M
            y_3_16x8b = _mm_loadu_si128((__m128i *)(pu1_src + src_strd * 3));
513
514
42.4M
            y_0L_8x16b = _mm_cvtepu8_epi16(y_0_16x8b);
515
42.4M
            y_0H_8x16b = _mm_unpackhi_epi8(y_0_16x8b, zero_16x8b);
516
42.4M
            y_1L_8x16b = _mm_cvtepu8_epi16(y_1_16x8b);
517
42.4M
            y_1H_8x16b = _mm_unpackhi_epi8(y_1_16x8b, zero_16x8b);
518
42.4M
            y_2L_8x16b = _mm_cvtepu8_epi16(y_2_16x8b);
519
42.4M
            y_2H_8x16b = _mm_unpackhi_epi8(y_2_16x8b, zero_16x8b);
520
42.4M
            y_3L_8x16b = _mm_cvtepu8_epi16(y_3_16x8b);
521
42.4M
            y_3H_8x16b = _mm_unpackhi_epi8(y_3_16x8b, zero_16x8b);
522
523
42.4M
            y_0L_8x16b = _mm_mullo_epi16(y_0L_8x16b, wt_8x16b);
524
42.4M
            y_0H_8x16b = _mm_mullo_epi16(y_0H_8x16b, wt_8x16b);
525
42.4M
            y_1L_8x16b = _mm_mullo_epi16(y_1L_8x16b, wt_8x16b);
526
42.4M
            y_1H_8x16b = _mm_mullo_epi16(y_1H_8x16b, wt_8x16b);
527
42.4M
            y_2L_8x16b = _mm_mullo_epi16(y_2L_8x16b, wt_8x16b);
528
42.4M
            y_2H_8x16b = _mm_mullo_epi16(y_2H_8x16b, wt_8x16b);
529
42.4M
            y_3L_8x16b = _mm_mullo_epi16(y_3L_8x16b, wt_8x16b);
530
42.4M
            y_3H_8x16b = _mm_mullo_epi16(y_3H_8x16b, wt_8x16b);
531
532
42.4M
            y_0L_8x16b = _mm_adds_epi16(round_8x16b, y_0L_8x16b);
533
42.4M
            y_0H_8x16b = _mm_adds_epi16(round_8x16b, y_0H_8x16b);
534
42.4M
            y_1L_8x16b = _mm_adds_epi16(round_8x16b, y_1L_8x16b);
535
42.4M
            y_1H_8x16b = _mm_adds_epi16(round_8x16b, y_1H_8x16b);
536
42.4M
            y_2L_8x16b = _mm_adds_epi16(round_8x16b, y_2L_8x16b);
537
42.4M
            y_2H_8x16b = _mm_adds_epi16(round_8x16b, y_2H_8x16b);
538
42.4M
            y_3L_8x16b = _mm_adds_epi16(round_8x16b, y_3L_8x16b);
539
42.4M
            y_3H_8x16b = _mm_adds_epi16(round_8x16b, y_3H_8x16b);
540
541
42.4M
            y_0L_8x16b = _mm_srai_epi16(y_0L_8x16b, log_wd);
542
42.4M
            y_0H_8x16b = _mm_srai_epi16(y_0H_8x16b, log_wd);
543
42.4M
            y_1L_8x16b = _mm_srai_epi16(y_1L_8x16b, log_wd);
544
42.4M
            y_1H_8x16b = _mm_srai_epi16(y_1H_8x16b, log_wd);
545
42.4M
            y_2L_8x16b = _mm_srai_epi16(y_2L_8x16b, log_wd);
546
42.4M
            y_2H_8x16b = _mm_srai_epi16(y_2H_8x16b, log_wd);
547
42.4M
            y_3L_8x16b = _mm_srai_epi16(y_3L_8x16b, log_wd);
548
42.4M
            y_3H_8x16b = _mm_srai_epi16(y_3H_8x16b, log_wd);
549
550
42.4M
            y_0L_8x16b = _mm_adds_epi16(ofst_8x16b, y_0L_8x16b);
551
42.4M
            y_0H_8x16b = _mm_adds_epi16(ofst_8x16b, y_0H_8x16b);
552
42.4M
            y_1L_8x16b = _mm_adds_epi16(ofst_8x16b, y_1L_8x16b);
553
42.4M
            y_1H_8x16b = _mm_adds_epi16(ofst_8x16b, y_1H_8x16b);
554
42.4M
            y_2L_8x16b = _mm_adds_epi16(ofst_8x16b, y_2L_8x16b);
555
42.4M
            y_2H_8x16b = _mm_adds_epi16(ofst_8x16b, y_2H_8x16b);
556
42.4M
            y_3L_8x16b = _mm_adds_epi16(ofst_8x16b, y_3L_8x16b);
557
42.4M
            y_3H_8x16b = _mm_adds_epi16(ofst_8x16b, y_3H_8x16b);
558
559
42.4M
            y_0_16x8b = _mm_packus_epi16(y_0L_8x16b, y_0H_8x16b);
560
42.4M
            y_1_16x8b = _mm_packus_epi16(y_1L_8x16b, y_1H_8x16b);
561
42.4M
            y_2_16x8b = _mm_packus_epi16(y_2L_8x16b, y_2H_8x16b);
562
42.4M
            y_3_16x8b = _mm_packus_epi16(y_3L_8x16b, y_3H_8x16b);
563
564
42.4M
            _mm_storeu_si128((__m128i *)pu1_dst, y_0_16x8b);
565
42.4M
            _mm_storeu_si128((__m128i *)(pu1_dst + dst_strd), y_1_16x8b);
566
42.4M
            _mm_storeu_si128((__m128i *)(pu1_dst + (dst_strd << 1)), y_2_16x8b);
567
42.4M
            _mm_storeu_si128((__m128i *)(pu1_dst + dst_strd * 3), y_3_16x8b);
568
569
42.4M
            ht -= 4;
570
42.4M
            pu1_src += src_strd << 2;
571
42.4M
            pu1_dst += dst_strd << 2;
572
42.4M
        }
573
42.4M
        while(ht > 0);
574
10.6M
    }
575
10.8M
}
576
577
/*****************************************************************************/
578
/*                                                                           */
579
/*  Function Name : ih264_weighted_pred_chroma_sse42                         */
580
/*                                                                           */
581
/*  Description   : This function performs the weighted prediction as        */
582
/*                  described in sec 8.4.2.3.2 titled "Weighted sample       */
583
/*                  prediction process" for chroma. The function gets one    */
584
/*                  ht x wd block, weights it, rounds it off, offsets it,    */
585
/*                  saturates it to unsigned 8-bit and stores it in the      */
586
/*                  destination block. (ht,wd) can be (2,2), (4,2), (2,4),   */
587
/*                  (4,4), (8,4), (4,8) or (8,8).                            */
588
/*                                                                           */
589
/*  Inputs        : pu1_src  - Pointer to source                             */
590
/*                  pu1_dst  - Pointer to destination                        */
591
/*                  src_strd - stride for source                             */
592
/*                  dst_strd - stride for destination                        */
593
/*                  log_wd   - number of bits to be rounded off              */
594
/*                  wt       - weight values for u and v                     */
595
/*                  ofst     - offset values for u and v                     */
596
/*                  ht       - height of the block                           */
597
/*                  wd       - width of the block                            */
598
/*                                                                           */
599
/*  Issues        : None                                                     */
600
/*                                                                           */
601
/*  Revision History:                                                        */
602
/*                                                                           */
603
/*         DD MM YYYY   Author(s)       Changes                              */
604
/*         04 02 2015   Kaushik         Initial Version                      */
605
/*                      Senthoor                                             */
606
/*                                                                           */
607
/*****************************************************************************/
608
void ih264_weighted_pred_chroma_sse42(UWORD8 *pu1_src,
609
                                      UWORD8 *pu1_dst,
610
                                      WORD32 src_strd,
611
                                      WORD32 dst_strd,
612
                                      WORD32 log_wd,
613
                                      WORD32 wt,
614
                                      WORD32 ofst,
615
                                      WORD32 ht,
616
                                      WORD32 wd)
617
10.8M
{
618
10.8M
    __m128i y_0_16x8b, y_1_16x8b;
619
620
10.8M
    __m128i wt_8x16b, round_8x16b, ofst_8x16b;
621
622
10.8M
    WORD32 ofst_u, ofst_v;
623
10.8M
    WORD32 round_val;
624
625
10.8M
    ofst_u = (WORD8)(ofst & 0xff);
626
10.8M
    ofst_v = (WORD8)(ofst >> 8);
627
10.8M
    round_val = 1 << (log_wd - 1);
628
10.8M
    ofst = (ofst_u & 0xffff) | (ofst_v << 16);
629
630
10.8M
    wt_8x16b = _mm_set1_epi32(wt);
631
10.8M
    round_8x16b = _mm_set1_epi16(round_val);
632
10.8M
    ofst_8x16b = _mm_set1_epi32(ofst);
633
634
10.8M
    if(wd == 2)
635
79.8k
    {
636
79.8k
        __m128i y_0_8x16b;
637
638
79.8k
        do
639
128k
        {
640
128k
            y_0_16x8b = _mm_loadl_epi64((__m128i *)pu1_src);
641
128k
            y_1_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src + src_strd));
642
643
128k
            y_0_16x8b = _mm_unpacklo_epi32(y_0_16x8b, y_1_16x8b);
644
645
128k
            y_0_8x16b = _mm_cvtepu8_epi16(y_0_16x8b);
646
647
128k
            y_0_8x16b = _mm_mullo_epi16(y_0_8x16b, wt_8x16b);
648
649
128k
            y_0_8x16b = _mm_adds_epi16(round_8x16b, y_0_8x16b);
650
651
128k
            y_0_8x16b = _mm_srai_epi16(y_0_8x16b, log_wd);
652
653
128k
            y_0_8x16b = _mm_adds_epi16(ofst_8x16b, y_0_8x16b);
654
655
128k
            y_0_16x8b = _mm_packus_epi16(y_0_8x16b, y_0_8x16b);
656
128k
            y_1_16x8b = _mm_srli_si128(y_0_16x8b, 4);
657
658
128k
            *((WORD32 *)(pu1_dst)) = _mm_cvtsi128_si32(y_0_16x8b);
659
128k
            *((WORD32 *)(pu1_dst + dst_strd)) = _mm_cvtsi128_si32(y_1_16x8b);
660
661
128k
            ht -= 2;
662
128k
            pu1_src += src_strd << 1;
663
128k
            pu1_dst += dst_strd << 1;
664
128k
        }
665
128k
        while(ht > 0);
666
79.8k
    }
667
10.7M
    else if(wd == 4)
668
80.4k
    {
669
80.4k
        __m128i y_0_8x16b, y_1_8x16b;
670
671
80.4k
        do
672
190k
        {
673
190k
            y_0_16x8b = _mm_loadl_epi64((__m128i *)pu1_src);
674
190k
            y_1_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src + src_strd));
675
676
190k
            y_0_8x16b = _mm_cvtepu8_epi16(y_0_16x8b);
677
190k
            y_1_8x16b = _mm_cvtepu8_epi16(y_1_16x8b);
678
679
190k
            y_0_8x16b = _mm_mullo_epi16(y_0_8x16b, wt_8x16b);
680
190k
            y_1_8x16b = _mm_mullo_epi16(y_1_8x16b, wt_8x16b);
681
682
190k
            y_0_8x16b = _mm_adds_epi16(round_8x16b, y_0_8x16b);
683
190k
            y_1_8x16b = _mm_adds_epi16(round_8x16b, y_1_8x16b);
684
685
190k
            y_0_8x16b = _mm_srai_epi16(y_0_8x16b, log_wd);
686
190k
            y_1_8x16b = _mm_srai_epi16(y_1_8x16b, log_wd);
687
688
190k
            y_0_8x16b = _mm_adds_epi16(ofst_8x16b, y_0_8x16b);
689
190k
            y_1_8x16b = _mm_adds_epi16(ofst_8x16b, y_1_8x16b);
690
691
190k
            y_0_16x8b = _mm_packus_epi16(y_0_8x16b, y_1_8x16b);
692
190k
            y_1_16x8b = _mm_srli_si128(y_0_16x8b, 8);
693
694
190k
            _mm_storel_epi64((__m128i *)pu1_dst, y_0_16x8b);
695
190k
            _mm_storel_epi64((__m128i *)(pu1_dst + dst_strd), y_1_16x8b);
696
697
190k
            ht -= 2;
698
190k
            pu1_src += src_strd << 1;
699
190k
            pu1_dst += dst_strd << 1;
700
190k
        }
701
190k
        while(ht > 0);
702
80.4k
    }
703
10.6M
    else // wd == 16
704
10.6M
    {
705
10.6M
        __m128i y_2_16x8b, y_3_16x8b;
706
10.6M
        __m128i y_0L_8x16b, y_1L_8x16b, y_2L_8x16b, y_3L_8x16b;
707
10.6M
        __m128i y_0H_8x16b, y_1H_8x16b, y_2H_8x16b, y_3H_8x16b;
708
709
10.6M
        __m128i zero_16x8b;
710
10.6M
        zero_16x8b = _mm_set1_epi8(0);
711
712
10.6M
        do
713
21.2M
        {
714
21.2M
            y_0_16x8b = _mm_loadu_si128((__m128i *)pu1_src);
715
21.2M
            y_1_16x8b = _mm_loadu_si128((__m128i *)(pu1_src + src_strd));
716
21.2M
            y_2_16x8b = _mm_loadu_si128((__m128i *)(pu1_src + (src_strd << 1)));
717
21.2M
            y_3_16x8b = _mm_loadu_si128((__m128i *)(pu1_src + src_strd * 3));
718
719
21.2M
            y_0L_8x16b = _mm_cvtepu8_epi16(y_0_16x8b);
720
21.2M
            y_0H_8x16b = _mm_unpackhi_epi8(y_0_16x8b, zero_16x8b);
721
21.2M
            y_1L_8x16b = _mm_cvtepu8_epi16(y_1_16x8b);
722
21.2M
            y_1H_8x16b = _mm_unpackhi_epi8(y_1_16x8b, zero_16x8b);
723
21.2M
            y_2L_8x16b = _mm_cvtepu8_epi16(y_2_16x8b);
724
21.2M
            y_2H_8x16b = _mm_unpackhi_epi8(y_2_16x8b, zero_16x8b);
725
21.2M
            y_3L_8x16b = _mm_cvtepu8_epi16(y_3_16x8b);
726
21.2M
            y_3H_8x16b = _mm_unpackhi_epi8(y_3_16x8b, zero_16x8b);
727
728
21.2M
            y_0L_8x16b = _mm_mullo_epi16(y_0L_8x16b, wt_8x16b);
729
21.2M
            y_0H_8x16b = _mm_mullo_epi16(y_0H_8x16b, wt_8x16b);
730
21.2M
            y_1L_8x16b = _mm_mullo_epi16(y_1L_8x16b, wt_8x16b);
731
21.2M
            y_1H_8x16b = _mm_mullo_epi16(y_1H_8x16b, wt_8x16b);
732
21.2M
            y_2L_8x16b = _mm_mullo_epi16(y_2L_8x16b, wt_8x16b);
733
21.2M
            y_2H_8x16b = _mm_mullo_epi16(y_2H_8x16b, wt_8x16b);
734
21.2M
            y_3L_8x16b = _mm_mullo_epi16(y_3L_8x16b, wt_8x16b);
735
21.2M
            y_3H_8x16b = _mm_mullo_epi16(y_3H_8x16b, wt_8x16b);
736
737
21.2M
            y_0L_8x16b = _mm_adds_epi16(round_8x16b, y_0L_8x16b);
738
21.2M
            y_0H_8x16b = _mm_adds_epi16(round_8x16b, y_0H_8x16b);
739
21.2M
            y_1L_8x16b = _mm_adds_epi16(round_8x16b, y_1L_8x16b);
740
21.2M
            y_1H_8x16b = _mm_adds_epi16(round_8x16b, y_1H_8x16b);
741
21.2M
            y_2L_8x16b = _mm_adds_epi16(round_8x16b, y_2L_8x16b);
742
21.2M
            y_2H_8x16b = _mm_adds_epi16(round_8x16b, y_2H_8x16b);
743
21.2M
            y_3L_8x16b = _mm_adds_epi16(round_8x16b, y_3L_8x16b);
744
21.2M
            y_3H_8x16b = _mm_adds_epi16(round_8x16b, y_3H_8x16b);
745
746
21.2M
            y_0L_8x16b = _mm_srai_epi16(y_0L_8x16b, log_wd);
747
21.2M
            y_0H_8x16b = _mm_srai_epi16(y_0H_8x16b, log_wd);
748
21.2M
            y_1L_8x16b = _mm_srai_epi16(y_1L_8x16b, log_wd);
749
21.2M
            y_1H_8x16b = _mm_srai_epi16(y_1H_8x16b, log_wd);
750
21.2M
            y_2L_8x16b = _mm_srai_epi16(y_2L_8x16b, log_wd);
751
21.2M
            y_2H_8x16b = _mm_srai_epi16(y_2H_8x16b, log_wd);
752
21.2M
            y_3L_8x16b = _mm_srai_epi16(y_3L_8x16b, log_wd);
753
21.2M
            y_3H_8x16b = _mm_srai_epi16(y_3H_8x16b, log_wd);
754
755
21.2M
            y_0L_8x16b = _mm_adds_epi16(ofst_8x16b, y_0L_8x16b);
756
21.2M
            y_0H_8x16b = _mm_adds_epi16(ofst_8x16b, y_0H_8x16b);
757
21.2M
            y_1L_8x16b = _mm_adds_epi16(ofst_8x16b, y_1L_8x16b);
758
21.2M
            y_1H_8x16b = _mm_adds_epi16(ofst_8x16b, y_1H_8x16b);
759
21.2M
            y_2L_8x16b = _mm_adds_epi16(ofst_8x16b, y_2L_8x16b);
760
21.2M
            y_2H_8x16b = _mm_adds_epi16(ofst_8x16b, y_2H_8x16b);
761
21.2M
            y_3L_8x16b = _mm_adds_epi16(ofst_8x16b, y_3L_8x16b);
762
21.2M
            y_3H_8x16b = _mm_adds_epi16(ofst_8x16b, y_3H_8x16b);
763
764
21.2M
            y_0_16x8b = _mm_packus_epi16(y_0L_8x16b, y_0H_8x16b);
765
21.2M
            y_1_16x8b = _mm_packus_epi16(y_1L_8x16b, y_1H_8x16b);
766
21.2M
            y_2_16x8b = _mm_packus_epi16(y_2L_8x16b, y_2H_8x16b);
767
21.2M
            y_3_16x8b = _mm_packus_epi16(y_3L_8x16b, y_3H_8x16b);
768
769
21.2M
            _mm_storeu_si128((__m128i *)pu1_dst, y_0_16x8b);
770
21.2M
            _mm_storeu_si128((__m128i *)(pu1_dst + dst_strd), y_1_16x8b);
771
21.2M
            _mm_storeu_si128((__m128i *)(pu1_dst + (dst_strd << 1)), y_2_16x8b);
772
21.2M
            _mm_storeu_si128((__m128i *)(pu1_dst + dst_strd * 3), y_3_16x8b);
773
774
21.2M
            ht -= 4;
775
21.2M
            pu1_src += src_strd << 2;
776
21.2M
            pu1_dst += dst_strd << 2;
777
21.2M
        }
778
21.2M
        while(ht > 0);
779
10.6M
    }
780
10.8M
}
781
782
/*****************************************************************************/
783
/*                                                                           */
784
/*  Function Name : ih264_weighted_bi_pred_luma_sse42                        */
785
/*                                                                           */
786
/*  Description   : This function performs the weighted biprediction as      */
787
/*                  described in sec 8.4.2.3.2 titled "Weighted sample       */
788
/*                  prediction process" for luma. The function gets two      */
789
/*                  ht x wd blocks, weights them, adds them, rounds off the  */
790
/*                  sum, offsets it, saturates it to unsigned 8-bit and      */
791
/*                  stores it in the destination block. (ht,wd) can be       */
792
/*                  (4,4), (8,4), (4,8), (8,8), (16,8), (8,16) or (16,16).   */
793
/*                                                                           */
794
/*  Inputs        : pu1_src1  - Pointer to source 1                          */
795
/*                  pu1_src2  - Pointer to source 2                          */
796
/*                  pu1_dst   - Pointer to destination                       */
797
/*                  src_strd1 - stride for source 1                          */
798
/*                  src_strd2 - stride for source 2                          */
799
/*                  dst_strd2 - stride for destination                       */
800
/*                  log_wd    - number of bits to be rounded off             */
801
/*                  wt1       - weight value for source 1                    */
802
/*                  wt2       - weight value for source 2                    */
803
/*                  ofst1     - offset value for source 1                    */
804
/*                  ofst2     - offset value for source 2                    */
805
/*                  ht        - height of the block                          */
806
/*                  wd        - width of the block                           */
807
/*                                                                           */
808
/*  Issues        : None                                                     */
809
/*                                                                           */
810
/*  Revision History:                                                        */
811
/*                                                                           */
812
/*         DD MM YYYY   Author(s)       Changes                              */
813
/*         04 02 2015   Kaushik         Initial Version                      */
814
/*                      Senthoor                                             */
815
/*                                                                           */
816
/*****************************************************************************/
817
void ih264_weighted_bi_pred_luma_sse42(UWORD8 *pu1_src1,
818
                                       UWORD8 *pu1_src2,
819
                                       UWORD8 *pu1_dst,
820
                                       WORD32 src_strd1,
821
                                       WORD32 src_strd2,
822
                                       WORD32 dst_strd,
823
                                       WORD32 log_wd,
824
                                       WORD32 wt1,
825
                                       WORD32 wt2,
826
                                       WORD32 ofst1,
827
                                       WORD32 ofst2,
828
                                       WORD32 ht,
829
                                       WORD32 wd)
830
2.89M
{
831
2.89M
    __m128i y1_0_16x8b, y1_1_16x8b;
832
2.89M
    __m128i y2_0_16x8b, y2_1_16x8b;
833
834
2.89M
    __m128i wt1_8x16b, wt2_8x16b;
835
2.89M
    __m128i ofst_8x16b, round_8x16b;
836
837
2.89M
    WORD32 ofst;
838
2.89M
    WORD32 round_val, shft;
839
840
2.89M
    wt1 = (WORD16)(wt1 & 0xffff);
841
2.89M
    wt2 = (WORD16)(wt2 & 0xffff);
842
2.89M
    round_val = 1 << log_wd;
843
2.89M
    shft = log_wd + 1;
844
2.89M
    ofst1 = (WORD8)(ofst1 & 0xff);
845
2.89M
    ofst2 = (WORD8)(ofst2 & 0xff);
846
2.89M
    ofst = (ofst1 + ofst2 + 1) >> 1;
847
848
2.89M
    wt1_8x16b = _mm_set1_epi16(wt1);
849
2.89M
    wt2_8x16b = _mm_set1_epi16(wt2);
850
2.89M
    round_8x16b = _mm_set1_epi16(round_val);
851
2.89M
    ofst_8x16b = _mm_set1_epi16(ofst);
852
853
2.89M
    if(wd == 4)
854
6.35k
    {
855
6.35k
        __m128i y1_2_16x8b, y1_3_16x8b;
856
6.35k
        __m128i y2_2_16x8b, y2_3_16x8b;
857
858
6.35k
        __m128i y1_0_8x16b, y1_2_8x16b;
859
6.35k
        __m128i y2_0_8x16b, y2_2_8x16b;
860
861
6.35k
        do
862
7.82k
        {
863
7.82k
            y1_0_16x8b = _mm_loadl_epi64((__m128i *)pu1_src1);
864
7.82k
            y1_1_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src1 + src_strd1));
865
7.82k
            y1_2_16x8b = _mm_loadl_epi64(
866
7.82k
                            (__m128i *)(pu1_src1 + (src_strd1 << 1)));
867
7.82k
            y1_3_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src1 + src_strd1 * 3));
868
869
7.82k
            y2_0_16x8b = _mm_loadl_epi64((__m128i *)pu1_src2);
870
7.82k
            y2_1_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src2 + src_strd2));
871
7.82k
            y2_2_16x8b = _mm_loadl_epi64(
872
7.82k
                            (__m128i *)(pu1_src2 + (src_strd2 << 1)));
873
7.82k
            y2_3_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src2 + src_strd2 * 3));
874
875
7.82k
            y1_0_16x8b = _mm_unpacklo_epi32(y1_0_16x8b, y1_1_16x8b);
876
7.82k
            y1_2_16x8b = _mm_unpacklo_epi32(y1_2_16x8b, y1_3_16x8b);
877
7.82k
            y2_0_16x8b = _mm_unpacklo_epi32(y2_0_16x8b, y2_1_16x8b);
878
7.82k
            y2_2_16x8b = _mm_unpacklo_epi32(y2_2_16x8b, y2_3_16x8b);
879
880
7.82k
            y1_0_8x16b = _mm_cvtepu8_epi16(y1_0_16x8b);
881
7.82k
            y1_2_8x16b = _mm_cvtepu8_epi16(y1_2_16x8b);
882
7.82k
            y2_0_8x16b = _mm_cvtepu8_epi16(y2_0_16x8b);
883
7.82k
            y2_2_8x16b = _mm_cvtepu8_epi16(y2_2_16x8b);
884
885
7.82k
            y1_0_8x16b = _mm_mullo_epi16(y1_0_8x16b, wt1_8x16b);
886
7.82k
            y2_0_8x16b = _mm_mullo_epi16(y2_0_8x16b, wt2_8x16b);
887
7.82k
            y1_2_8x16b = _mm_mullo_epi16(y1_2_8x16b, wt1_8x16b);
888
7.82k
            y2_2_8x16b = _mm_mullo_epi16(y2_2_8x16b, wt2_8x16b);
889
890
7.82k
            y1_0_8x16b = _mm_adds_epi16(y1_0_8x16b, y2_0_8x16b);
891
7.82k
            y1_2_8x16b = _mm_adds_epi16(y1_2_8x16b, y2_2_8x16b);
892
893
7.82k
            y1_0_8x16b = _mm_adds_epi16(round_8x16b, y1_0_8x16b);
894
7.82k
            y1_2_8x16b = _mm_adds_epi16(round_8x16b, y1_2_8x16b);
895
896
7.82k
            y1_0_8x16b = _mm_srai_epi16(y1_0_8x16b, shft);
897
7.82k
            y1_2_8x16b = _mm_srai_epi16(y1_2_8x16b, shft);
898
899
7.82k
            y1_0_8x16b = _mm_adds_epi16(ofst_8x16b, y1_0_8x16b);
900
7.82k
            y1_2_8x16b = _mm_adds_epi16(ofst_8x16b, y1_2_8x16b);
901
902
7.82k
            y1_0_16x8b = _mm_packus_epi16(y1_0_8x16b, y1_2_8x16b);
903
7.82k
            y1_1_16x8b = _mm_srli_si128(y1_0_16x8b, 4);
904
7.82k
            y1_2_16x8b = _mm_srli_si128(y1_0_16x8b, 8);
905
7.82k
            y1_3_16x8b = _mm_srli_si128(y1_0_16x8b, 12);
906
907
7.82k
            *((WORD32 *)(pu1_dst)) = _mm_cvtsi128_si32(y1_0_16x8b);
908
7.82k
            *((WORD32 *)(pu1_dst + dst_strd)) = _mm_cvtsi128_si32(y1_1_16x8b);
909
7.82k
            *((WORD32 *)(pu1_dst + (dst_strd << 1))) = _mm_cvtsi128_si32(y1_2_16x8b);
910
7.82k
            *((WORD32 *)(pu1_dst + dst_strd * 3)) = _mm_cvtsi128_si32(y1_3_16x8b);
911
912
913
7.82k
            ht -= 4;
914
7.82k
            pu1_src1 += src_strd1 << 2;
915
7.82k
            pu1_src2 += src_strd2 << 2;
916
7.82k
            pu1_dst += dst_strd << 2;
917
7.82k
        }
918
7.82k
        while(ht > 0);
919
6.35k
    }
920
2.88M
    else if(wd == 8)
921
28.2k
    {
922
28.2k
        __m128i y1_2_16x8b, y1_3_16x8b;
923
28.2k
        __m128i y2_2_16x8b, y2_3_16x8b;
924
925
28.2k
        __m128i y1_0_8x16b, y1_1_8x16b, y1_2_8x16b, y1_3_8x16b;
926
28.2k
        __m128i y2_0_8x16b, y2_1_8x16b, y2_2_8x16b, y2_3_8x16b;
927
928
28.2k
        do
929
71.7k
        {
930
71.7k
            y1_0_16x8b = _mm_loadl_epi64((__m128i *)pu1_src1);
931
71.7k
            y1_1_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src1 + src_strd1));
932
71.7k
            y1_2_16x8b = _mm_loadl_epi64(
933
71.7k
                            (__m128i *)(pu1_src1 + (src_strd1 << 1)));
934
71.7k
            y1_3_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src1 + src_strd1 * 3));
935
936
71.7k
            y2_0_16x8b = _mm_loadl_epi64((__m128i *)pu1_src2);
937
71.7k
            y2_1_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src2 + src_strd2));
938
71.7k
            y2_2_16x8b = _mm_loadl_epi64(
939
71.7k
                            (__m128i *)(pu1_src2 + (src_strd2 << 1)));
940
71.7k
            y2_3_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src2 + src_strd2 * 3));
941
942
71.7k
            y1_0_8x16b = _mm_cvtepu8_epi16(y1_0_16x8b);
943
71.7k
            y1_1_8x16b = _mm_cvtepu8_epi16(y1_1_16x8b);
944
71.7k
            y1_2_8x16b = _mm_cvtepu8_epi16(y1_2_16x8b);
945
71.7k
            y1_3_8x16b = _mm_cvtepu8_epi16(y1_3_16x8b);
946
947
71.7k
            y2_0_8x16b = _mm_cvtepu8_epi16(y2_0_16x8b);
948
71.7k
            y2_1_8x16b = _mm_cvtepu8_epi16(y2_1_16x8b);
949
71.7k
            y2_2_8x16b = _mm_cvtepu8_epi16(y2_2_16x8b);
950
71.7k
            y2_3_8x16b = _mm_cvtepu8_epi16(y2_3_16x8b);
951
952
71.7k
            y1_0_8x16b = _mm_mullo_epi16(y1_0_8x16b, wt1_8x16b);
953
71.7k
            y2_0_8x16b = _mm_mullo_epi16(y2_0_8x16b, wt2_8x16b);
954
71.7k
            y1_1_8x16b = _mm_mullo_epi16(y1_1_8x16b, wt1_8x16b);
955
71.7k
            y2_1_8x16b = _mm_mullo_epi16(y2_1_8x16b, wt2_8x16b);
956
957
71.7k
            y1_2_8x16b = _mm_mullo_epi16(y1_2_8x16b, wt1_8x16b);
958
71.7k
            y2_2_8x16b = _mm_mullo_epi16(y2_2_8x16b, wt2_8x16b);
959
71.7k
            y1_3_8x16b = _mm_mullo_epi16(y1_3_8x16b, wt1_8x16b);
960
71.7k
            y2_3_8x16b = _mm_mullo_epi16(y2_3_8x16b, wt2_8x16b);
961
962
71.7k
            y1_0_8x16b = _mm_adds_epi16(y1_0_8x16b, y2_0_8x16b);
963
71.7k
            y1_1_8x16b = _mm_adds_epi16(y1_1_8x16b, y2_1_8x16b);
964
71.7k
            y1_2_8x16b = _mm_adds_epi16(y1_2_8x16b, y2_2_8x16b);
965
71.7k
            y1_3_8x16b = _mm_adds_epi16(y1_3_8x16b, y2_3_8x16b);
966
967
71.7k
            y1_0_8x16b = _mm_adds_epi16(round_8x16b, y1_0_8x16b);
968
71.7k
            y1_1_8x16b = _mm_adds_epi16(round_8x16b, y1_1_8x16b);
969
71.7k
            y1_2_8x16b = _mm_adds_epi16(round_8x16b, y1_2_8x16b);
970
71.7k
            y1_3_8x16b = _mm_adds_epi16(round_8x16b, y1_3_8x16b);
971
972
71.7k
            y1_0_8x16b = _mm_srai_epi16(y1_0_8x16b, shft);
973
71.7k
            y1_1_8x16b = _mm_srai_epi16(y1_1_8x16b, shft);
974
71.7k
            y1_2_8x16b = _mm_srai_epi16(y1_2_8x16b, shft);
975
71.7k
            y1_3_8x16b = _mm_srai_epi16(y1_3_8x16b, shft);
976
977
71.7k
            y1_0_8x16b = _mm_adds_epi16(ofst_8x16b, y1_0_8x16b);
978
71.7k
            y1_1_8x16b = _mm_adds_epi16(ofst_8x16b, y1_1_8x16b);
979
71.7k
            y1_2_8x16b = _mm_adds_epi16(ofst_8x16b, y1_2_8x16b);
980
71.7k
            y1_3_8x16b = _mm_adds_epi16(ofst_8x16b, y1_3_8x16b);
981
982
71.7k
            y1_0_16x8b = _mm_packus_epi16(y1_0_8x16b, y1_1_8x16b);
983
71.7k
            y1_2_16x8b = _mm_packus_epi16(y1_2_8x16b, y1_3_8x16b);
984
71.7k
            y1_1_16x8b = _mm_srli_si128(y1_0_16x8b, 8);
985
71.7k
            y1_3_16x8b = _mm_srli_si128(y1_2_16x8b, 8);
986
987
71.7k
            _mm_storel_epi64((__m128i *)pu1_dst, y1_0_16x8b);
988
71.7k
            _mm_storel_epi64((__m128i *)(pu1_dst + dst_strd), y1_1_16x8b);
989
71.7k
            _mm_storel_epi64((__m128i *)(pu1_dst + (dst_strd << 1)), y1_2_16x8b);
990
71.7k
            _mm_storel_epi64((__m128i *)(pu1_dst + dst_strd * 3), y1_3_16x8b);
991
992
71.7k
            ht -= 4;
993
71.7k
            pu1_src1 += src_strd1 << 2;
994
71.7k
            pu1_src2 += src_strd2 << 2;
995
71.7k
            pu1_dst += dst_strd << 2;
996
71.7k
        }
997
71.7k
        while(ht > 0);
998
28.2k
    }
999
2.85M
    else // wd == 16
1000
2.85M
    {
1001
2.85M
        __m128i y1_0L_8x16b, y1_0H_8x16b, y1_1L_8x16b, y1_1H_8x16b;
1002
2.85M
        __m128i y2_0L_8x16b, y2_0H_8x16b, y2_1L_8x16b, y2_1H_8x16b;
1003
1004
2.85M
        __m128i zero_16x8b;
1005
2.85M
        zero_16x8b = _mm_set1_epi8(0);
1006
1007
2.85M
        do
1008
22.8M
        {
1009
22.8M
            y1_0_16x8b = _mm_loadu_si128((__m128i *)pu1_src1);
1010
22.8M
            y1_1_16x8b = _mm_loadu_si128((__m128i *)(pu1_src1 + src_strd1));
1011
22.8M
            y2_0_16x8b = _mm_loadu_si128((__m128i *)pu1_src2);
1012
22.8M
            y2_1_16x8b = _mm_loadu_si128((__m128i *)(pu1_src2 + src_strd2));
1013
1014
22.8M
            y1_0L_8x16b = _mm_cvtepu8_epi16(y1_0_16x8b);
1015
22.8M
            y1_0H_8x16b = _mm_unpackhi_epi8(y1_0_16x8b, zero_16x8b);
1016
22.8M
            y1_1L_8x16b = _mm_cvtepu8_epi16(y1_1_16x8b);
1017
22.8M
            y1_1H_8x16b = _mm_unpackhi_epi8(y1_1_16x8b, zero_16x8b);
1018
1019
22.8M
            y2_0L_8x16b = _mm_cvtepu8_epi16(y2_0_16x8b);
1020
22.8M
            y2_0H_8x16b = _mm_unpackhi_epi8(y2_0_16x8b, zero_16x8b);
1021
22.8M
            y2_1L_8x16b = _mm_cvtepu8_epi16(y2_1_16x8b);
1022
22.8M
            y2_1H_8x16b = _mm_unpackhi_epi8(y2_1_16x8b, zero_16x8b);
1023
1024
22.8M
            y1_0L_8x16b = _mm_mullo_epi16(y1_0L_8x16b, wt1_8x16b);
1025
22.8M
            y1_0H_8x16b = _mm_mullo_epi16(y1_0H_8x16b, wt1_8x16b);
1026
22.8M
            y1_1L_8x16b = _mm_mullo_epi16(y1_1L_8x16b, wt1_8x16b);
1027
22.8M
            y1_1H_8x16b = _mm_mullo_epi16(y1_1H_8x16b, wt1_8x16b);
1028
1029
22.8M
            y2_0L_8x16b = _mm_mullo_epi16(y2_0L_8x16b, wt2_8x16b);
1030
22.8M
            y2_0H_8x16b = _mm_mullo_epi16(y2_0H_8x16b, wt2_8x16b);
1031
22.8M
            y2_1L_8x16b = _mm_mullo_epi16(y2_1L_8x16b, wt2_8x16b);
1032
22.8M
            y2_1H_8x16b = _mm_mullo_epi16(y2_1H_8x16b, wt2_8x16b);
1033
1034
22.8M
            y1_0L_8x16b = _mm_adds_epi16(y1_0L_8x16b, y2_0L_8x16b);
1035
22.8M
            y1_0H_8x16b = _mm_adds_epi16(y1_0H_8x16b, y2_0H_8x16b);
1036
22.8M
            y1_1L_8x16b = _mm_adds_epi16(y1_1L_8x16b, y2_1L_8x16b);
1037
22.8M
            y1_1H_8x16b = _mm_adds_epi16(y1_1H_8x16b, y2_1H_8x16b);
1038
1039
22.8M
            y1_0L_8x16b = _mm_adds_epi16(round_8x16b, y1_0L_8x16b);
1040
22.8M
            y1_0H_8x16b = _mm_adds_epi16(round_8x16b, y1_0H_8x16b);
1041
22.8M
            y1_1L_8x16b = _mm_adds_epi16(round_8x16b, y1_1L_8x16b);
1042
22.8M
            y1_1H_8x16b = _mm_adds_epi16(round_8x16b, y1_1H_8x16b);
1043
1044
22.8M
            y1_0L_8x16b = _mm_srai_epi16(y1_0L_8x16b, shft);
1045
22.8M
            y1_0H_8x16b = _mm_srai_epi16(y1_0H_8x16b, shft);
1046
22.8M
            y1_1L_8x16b = _mm_srai_epi16(y1_1L_8x16b, shft);
1047
22.8M
            y1_1H_8x16b = _mm_srai_epi16(y1_1H_8x16b, shft);
1048
1049
22.8M
            y1_0L_8x16b = _mm_adds_epi16(ofst_8x16b, y1_0L_8x16b);
1050
22.8M
            y1_0H_8x16b = _mm_adds_epi16(ofst_8x16b, y1_0H_8x16b);
1051
22.8M
            y1_1L_8x16b = _mm_adds_epi16(ofst_8x16b, y1_1L_8x16b);
1052
22.8M
            y1_1H_8x16b = _mm_adds_epi16(ofst_8x16b, y1_1H_8x16b);
1053
1054
22.8M
            y1_0_16x8b = _mm_packus_epi16(y1_0L_8x16b, y1_0H_8x16b);
1055
22.8M
            y1_1_16x8b = _mm_packus_epi16(y1_1L_8x16b, y1_1H_8x16b);
1056
1057
22.8M
            _mm_storeu_si128((__m128i *)pu1_dst, y1_0_16x8b);
1058
22.8M
            _mm_storeu_si128((__m128i *)(pu1_dst + dst_strd), y1_1_16x8b);
1059
1060
22.8M
            ht -= 2;
1061
22.8M
            pu1_src1 += src_strd1 << 1;
1062
22.8M
            pu1_src2 += src_strd2 << 1;
1063
22.8M
            pu1_dst += dst_strd << 1;
1064
22.8M
        }
1065
22.8M
        while(ht > 0);
1066
2.85M
    }
1067
2.89M
}
1068
1069
/*****************************************************************************/
1070
/*                                                                           */
1071
/*  Function Name : ih264_weighted_bi_pred_chroma_sse42                      */
1072
/*                                                                           */
1073
/*  Description   : This function performs the weighted biprediction as      */
1074
/*                  described in sec 8.4.2.3.2 titled "Weighted sample       */
1075
/*                  prediction process" for chroma. The function gets two    */
1076
/*                  ht x wd blocks, weights them, adds them, rounds off the  */
1077
/*                  sum, offsets it, saturates it to unsigned 8-bit and      */
1078
/*                  stores it in the destination block. (ht,wd) can be       */
1079
/*                  (2,2), (4,2), (2,4), (4,4), (8,4), (4,8) or (8,8).       */
1080
/*                                                                           */
1081
/*  Inputs        : pu1_src1  - Pointer to source 1                          */
1082
/*                  pu1_src2  - Pointer to source 2                          */
1083
/*                  pu1_dst   - Pointer to destination                       */
1084
/*                  src_strd1 - stride for source 1                          */
1085
/*                  src_strd2 - stride for source 2                          */
1086
/*                  dst_strd2 - stride for destination                       */
1087
/*                  log_wd    - number of bits to be rounded off             */
1088
/*                  wt1       - weight values for u and v in source 1        */
1089
/*                  wt2       - weight values for u and v in source 2        */
1090
/*                  ofst1     - offset value for u and v in source 1         */
1091
/*                  ofst2     - offset value for u and v in source 2         */
1092
/*                  ht        - height of the block                          */
1093
/*                  wd        - width of the block                           */
1094
/*                                                                           */
1095
/*  Issues        : None                                                     */
1096
/*                                                                           */
1097
/*  Revision History:                                                        */
1098
/*                                                                           */
1099
/*         DD MM YYYY   Author(s)       Changes                              */
1100
/*         04 02 2015   Kaushik         Initial Version                      */
1101
/*                      Senthoor                                             */
1102
/*                                                                           */
1103
/*****************************************************************************/
1104
void ih264_weighted_bi_pred_chroma_sse42(UWORD8 *pu1_src1,
1105
                                         UWORD8 *pu1_src2,
1106
                                         UWORD8 *pu1_dst,
1107
                                         WORD32 src_strd1,
1108
                                         WORD32 src_strd2,
1109
                                         WORD32 dst_strd,
1110
                                         WORD32 log_wd,
1111
                                         WORD32 wt1,
1112
                                         WORD32 wt2,
1113
                                         WORD32 ofst1,
1114
                                         WORD32 ofst2,
1115
                                         WORD32 ht,
1116
                                         WORD32 wd)
1117
2.89M
{
1118
2.89M
    __m128i y1_0_16x8b, y1_1_16x8b;
1119
2.89M
    __m128i y2_0_16x8b, y2_1_16x8b;
1120
1121
2.89M
    __m128i wt1_8x16b, wt2_8x16b;
1122
2.89M
    __m128i ofst_8x16b, round_8x16b;
1123
1124
2.89M
    WORD32 ofst1_u, ofst2_u, ofst_u;
1125
2.89M
    WORD32 ofst1_v, ofst2_v, ofst_v;
1126
2.89M
    WORD32 round_val, shft, ofst_val;
1127
1128
2.89M
    round_val = 1 << log_wd;
1129
2.89M
    shft = log_wd + 1;
1130
1131
2.89M
    ofst1_u = (WORD8)(ofst1 & 0xff);
1132
2.89M
    ofst1_v = (WORD8)(ofst1 >> 8);
1133
2.89M
    ofst2_u = (WORD8)(ofst2 & 0xff);
1134
2.89M
    ofst2_v = (WORD8)(ofst2 >> 8);
1135
1136
2.89M
    wt1_8x16b = _mm_set1_epi32(wt1);
1137
2.89M
    wt2_8x16b = _mm_set1_epi32(wt2);
1138
1139
2.89M
    ofst_u = (ofst1_u + ofst2_u + 1) >> 1;
1140
2.89M
    ofst_v = (ofst1_v + ofst2_v + 1) >> 1;
1141
2.89M
    ofst_val = (ofst_u & 0xffff) | (ofst_v << 16);
1142
1143
2.89M
    round_8x16b = _mm_set1_epi16(round_val);
1144
2.89M
    ofst_8x16b = _mm_set1_epi32(ofst_val);
1145
1146
2.89M
    if(wd == 2)
1147
6.35k
    {
1148
6.35k
        __m128i y1_0_8x16b, y2_0_8x16b;
1149
1150
6.35k
        do
1151
7.82k
        {
1152
7.82k
            y1_0_16x8b = _mm_loadl_epi64((__m128i *)pu1_src1);
1153
7.82k
            y1_1_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src1 + src_strd1));
1154
1155
7.82k
            y2_0_16x8b = _mm_loadl_epi64((__m128i *)pu1_src2);
1156
7.82k
            y2_1_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src2 + src_strd2));
1157
1158
7.82k
            y1_0_16x8b = _mm_unpacklo_epi32(y1_0_16x8b, y1_1_16x8b);
1159
7.82k
            y2_0_16x8b = _mm_unpacklo_epi32(y2_0_16x8b, y2_1_16x8b);
1160
1161
7.82k
            y1_0_8x16b = _mm_cvtepu8_epi16(y1_0_16x8b);
1162
7.82k
            y2_0_8x16b = _mm_cvtepu8_epi16(y2_0_16x8b);
1163
1164
7.82k
            y1_0_8x16b = _mm_mullo_epi16(y1_0_8x16b, wt1_8x16b);
1165
7.82k
            y2_0_8x16b = _mm_mullo_epi16(y2_0_8x16b, wt2_8x16b);
1166
1167
7.82k
            y1_0_8x16b = _mm_adds_epi16(y1_0_8x16b, y2_0_8x16b);
1168
7.82k
            y1_0_8x16b = _mm_adds_epi16(round_8x16b, y1_0_8x16b);
1169
1170
7.82k
            y1_0_8x16b = _mm_srai_epi16(y1_0_8x16b, shft);
1171
7.82k
            y1_0_8x16b = _mm_adds_epi16(ofst_8x16b, y1_0_8x16b);
1172
1173
7.82k
            y1_0_16x8b = _mm_packus_epi16(y1_0_8x16b, y1_0_8x16b);
1174
7.82k
            y1_1_16x8b = _mm_srli_si128(y1_0_16x8b, 4);
1175
1176
7.82k
            *((WORD32 *)(pu1_dst)) = _mm_cvtsi128_si32(y1_0_16x8b);
1177
7.82k
            *((WORD32 *)(pu1_dst + dst_strd)) = _mm_cvtsi128_si32(y1_1_16x8b);
1178
1179
7.82k
            ht -= 2;
1180
7.82k
            pu1_src1 += src_strd1 << 1;
1181
7.82k
            pu1_src2 += src_strd2 << 1;
1182
7.82k
            pu1_dst += dst_strd << 1;
1183
7.82k
        }
1184
7.82k
        while(ht > 0);
1185
6.35k
    }
1186
2.88M
    else if(wd == 4)
1187
28.2k
    {
1188
28.2k
        __m128i y1_0_8x16b, y1_1_8x16b;
1189
28.2k
        __m128i y2_0_8x16b, y2_1_8x16b;
1190
1191
28.2k
        do
1192
71.7k
        {
1193
71.7k
            y1_0_16x8b = _mm_loadl_epi64((__m128i *)pu1_src1);
1194
71.7k
            y1_1_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src1 + src_strd1));
1195
1196
71.7k
            y2_0_16x8b = _mm_loadl_epi64((__m128i *)pu1_src2);
1197
71.7k
            y2_1_16x8b = _mm_loadl_epi64((__m128i *)(pu1_src2 + src_strd2));
1198
1199
71.7k
            y1_0_8x16b = _mm_cvtepu8_epi16(y1_0_16x8b);
1200
71.7k
            y1_1_8x16b = _mm_cvtepu8_epi16(y1_1_16x8b);
1201
1202
71.7k
            y2_0_8x16b = _mm_cvtepu8_epi16(y2_0_16x8b);
1203
71.7k
            y2_1_8x16b = _mm_cvtepu8_epi16(y2_1_16x8b);
1204
1205
71.7k
            y1_0_8x16b = _mm_mullo_epi16(y1_0_8x16b, wt1_8x16b);
1206
71.7k
            y2_0_8x16b = _mm_mullo_epi16(y2_0_8x16b, wt2_8x16b);
1207
71.7k
            y1_1_8x16b = _mm_mullo_epi16(y1_1_8x16b, wt1_8x16b);
1208
71.7k
            y2_1_8x16b = _mm_mullo_epi16(y2_1_8x16b, wt2_8x16b);
1209
1210
71.7k
            y1_0_8x16b = _mm_adds_epi16(y1_0_8x16b, y2_0_8x16b);
1211
71.7k
            y1_1_8x16b = _mm_adds_epi16(y1_1_8x16b, y2_1_8x16b);
1212
1213
71.7k
            y1_0_8x16b = _mm_adds_epi16(round_8x16b, y1_0_8x16b);
1214
71.7k
            y1_1_8x16b = _mm_adds_epi16(round_8x16b, y1_1_8x16b);
1215
1216
71.7k
            y1_0_8x16b = _mm_srai_epi16(y1_0_8x16b, shft);
1217
71.7k
            y1_1_8x16b = _mm_srai_epi16(y1_1_8x16b, shft);
1218
1219
71.7k
            y1_0_8x16b = _mm_adds_epi16(ofst_8x16b, y1_0_8x16b);
1220
71.7k
            y1_1_8x16b = _mm_adds_epi16(ofst_8x16b, y1_1_8x16b);
1221
1222
71.7k
            y1_0_16x8b = _mm_packus_epi16(y1_0_8x16b, y1_1_8x16b);
1223
71.7k
            y1_1_16x8b = _mm_srli_si128(y1_0_16x8b, 8);
1224
1225
71.7k
            _mm_storel_epi64((__m128i *)pu1_dst, y1_0_16x8b);
1226
71.7k
            _mm_storel_epi64((__m128i *)(pu1_dst + dst_strd), y1_1_16x8b);
1227
1228
71.7k
            ht -= 2;
1229
71.7k
            pu1_src1 += src_strd1 << 1;
1230
71.7k
            pu1_src2 += src_strd2 << 1;
1231
71.7k
            pu1_dst += dst_strd << 1;
1232
71.7k
        }
1233
71.7k
        while(ht > 0);
1234
28.2k
    }
1235
2.85M
    else // wd == 8
1236
2.85M
    {
1237
2.85M
        __m128i y1_0L_8x16b, y1_0H_8x16b, y1_1L_8x16b, y1_1H_8x16b;
1238
2.85M
        __m128i y2_0L_8x16b, y2_0H_8x16b, y2_1L_8x16b, y2_1H_8x16b;
1239
1240
2.85M
        __m128i zero_16x8b;
1241
2.85M
        zero_16x8b = _mm_set1_epi8(0);
1242
1243
2.85M
        do
1244
11.4M
        {
1245
11.4M
            y1_0_16x8b = _mm_loadu_si128((__m128i *)pu1_src1);
1246
11.4M
            y1_1_16x8b = _mm_loadu_si128((__m128i *)(pu1_src1 + src_strd1));
1247
11.4M
            y2_0_16x8b = _mm_loadu_si128((__m128i *)pu1_src2);
1248
11.4M
            y2_1_16x8b = _mm_loadu_si128((__m128i *)(pu1_src2 + src_strd2));
1249
1250
11.4M
            y1_0L_8x16b = _mm_cvtepu8_epi16(y1_0_16x8b);
1251
11.4M
            y1_0H_8x16b = _mm_unpackhi_epi8(y1_0_16x8b, zero_16x8b);
1252
11.4M
            y1_1L_8x16b = _mm_cvtepu8_epi16(y1_1_16x8b);
1253
11.4M
            y1_1H_8x16b = _mm_unpackhi_epi8(y1_1_16x8b, zero_16x8b);
1254
1255
11.4M
            y2_0L_8x16b = _mm_cvtepu8_epi16(y2_0_16x8b);
1256
11.4M
            y2_0H_8x16b = _mm_unpackhi_epi8(y2_0_16x8b, zero_16x8b);
1257
11.4M
            y2_1L_8x16b = _mm_cvtepu8_epi16(y2_1_16x8b);
1258
11.4M
            y2_1H_8x16b = _mm_unpackhi_epi8(y2_1_16x8b, zero_16x8b);
1259
1260
11.4M
            y1_0L_8x16b = _mm_mullo_epi16(y1_0L_8x16b, wt1_8x16b);
1261
11.4M
            y1_0H_8x16b = _mm_mullo_epi16(y1_0H_8x16b, wt1_8x16b);
1262
11.4M
            y1_1L_8x16b = _mm_mullo_epi16(y1_1L_8x16b, wt1_8x16b);
1263
11.4M
            y1_1H_8x16b = _mm_mullo_epi16(y1_1H_8x16b, wt1_8x16b);
1264
1265
11.4M
            y2_0L_8x16b = _mm_mullo_epi16(y2_0L_8x16b, wt2_8x16b);
1266
11.4M
            y2_0H_8x16b = _mm_mullo_epi16(y2_0H_8x16b, wt2_8x16b);
1267
11.4M
            y2_1L_8x16b = _mm_mullo_epi16(y2_1L_8x16b, wt2_8x16b);
1268
11.4M
            y2_1H_8x16b = _mm_mullo_epi16(y2_1H_8x16b, wt2_8x16b);
1269
1270
11.4M
            y1_0L_8x16b = _mm_adds_epi16(y1_0L_8x16b, y2_0L_8x16b);
1271
11.4M
            y1_0H_8x16b = _mm_adds_epi16(y1_0H_8x16b, y2_0H_8x16b);
1272
11.4M
            y1_1L_8x16b = _mm_adds_epi16(y1_1L_8x16b, y2_1L_8x16b);
1273
11.4M
            y1_1H_8x16b = _mm_adds_epi16(y1_1H_8x16b, y2_1H_8x16b);
1274
1275
11.4M
            y1_0L_8x16b = _mm_adds_epi16(round_8x16b, y1_0L_8x16b);
1276
11.4M
            y1_0H_8x16b = _mm_adds_epi16(round_8x16b, y1_0H_8x16b);
1277
11.4M
            y1_1L_8x16b = _mm_adds_epi16(round_8x16b, y1_1L_8x16b);
1278
11.4M
            y1_1H_8x16b = _mm_adds_epi16(round_8x16b, y1_1H_8x16b);
1279
1280
11.4M
            y1_0L_8x16b = _mm_srai_epi16(y1_0L_8x16b, shft);
1281
11.4M
            y1_0H_8x16b = _mm_srai_epi16(y1_0H_8x16b, shft);
1282
11.4M
            y1_1L_8x16b = _mm_srai_epi16(y1_1L_8x16b, shft);
1283
11.4M
            y1_1H_8x16b = _mm_srai_epi16(y1_1H_8x16b, shft);
1284
1285
11.4M
            y1_0L_8x16b = _mm_adds_epi16(ofst_8x16b, y1_0L_8x16b);
1286
11.4M
            y1_0H_8x16b = _mm_adds_epi16(ofst_8x16b, y1_0H_8x16b);
1287
11.4M
            y1_1L_8x16b = _mm_adds_epi16(ofst_8x16b, y1_1L_8x16b);
1288
11.4M
            y1_1H_8x16b = _mm_adds_epi16(ofst_8x16b, y1_1H_8x16b);
1289
1290
11.4M
            y1_0_16x8b = _mm_packus_epi16(y1_0L_8x16b, y1_0H_8x16b);
1291
11.4M
            y1_1_16x8b = _mm_packus_epi16(y1_1L_8x16b, y1_1H_8x16b);
1292
1293
11.4M
            _mm_storeu_si128((__m128i *)pu1_dst, y1_0_16x8b);
1294
11.4M
            _mm_storeu_si128((__m128i *)(pu1_dst + dst_strd), y1_1_16x8b);
1295
1296
11.4M
            ht -= 2;
1297
11.4M
            pu1_src1 += src_strd1 << 1;
1298
11.4M
            pu1_src2 += src_strd2 << 1;
1299
11.4M
            pu1_dst += dst_strd << 1;
1300
11.4M
        }
1301
11.4M
        while(ht > 0);
1302
2.85M
    }
1303
2.89M
}