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 *******************************************************************************
23 * @file
24 * impeg2_mem_func_sse42_intr.c
25 *
26 * @brief
27 * Contains utility function definitions for MPEG2 codec
28 *
29 * @author
30 * Mohit [100664]
31 *
32 * @par List of Functions:
33 * - impeg2_memset0_16bit_8x8_linear_block_sse42()
34 * - impeg2_memset_8bit_8x8_block_sse42()
35 *
36 * @remarks
37 * None
38 *
39 *******************************************************************************
40 */
41 #include <stdio.h>
42 #include <string.h>
43 #include "iv_datatypedef.h"
44 #include "impeg2_defs.h"
45
46 #include <immintrin.h>
47 #include <emmintrin.h>
48 #include <smmintrin.h>
49 #include <tmmintrin.h>
50
51 /*******************************************************************************
52 * Function Name : impeg2_memset0_16bit_8x8_linear_block
53 *
54 * Description : memsets resudial buf to 0
55 *
56 * Arguments : destination buffer
57 *
58 * Values Returned : None
59 *******************************************************************************/
60
61
impeg2_memset0_16bit_8x8_linear_block_sse42(WORD16 * buf)62 void impeg2_memset0_16bit_8x8_linear_block_sse42 (WORD16 *buf)
63 {
64 __m128i zero_8x8_16b = _mm_set1_epi16(0);
65 _mm_storeu_si128((__m128i *) buf, zero_8x8_16b);
66 _mm_storeu_si128((__m128i *) (buf + 8), zero_8x8_16b);
67 _mm_storeu_si128((__m128i *) (buf + 16), zero_8x8_16b);
68 _mm_storeu_si128((__m128i *) (buf + 24), zero_8x8_16b);
69 _mm_storeu_si128((__m128i *) (buf + 32), zero_8x8_16b);
70 _mm_storeu_si128((__m128i *) (buf + 40), zero_8x8_16b);
71 _mm_storeu_si128((__m128i *) (buf + 48), zero_8x8_16b);
72 _mm_storeu_si128((__m128i *) (buf + 56), zero_8x8_16b);
73 }
74
75
76
77 /*******************************************************************************
78 * Function Name : impeg2_memset_8bit_8x8_block
79 *
80 * Description : memsets residual buf to value
81 *
82 * Arguments : destination buffer, value and stride
83 *
84 * Values Returned : None
85 *******************************************************************************/
86
87
impeg2_memset_8bit_8x8_block_sse42(UWORD8 * dst,WORD32 dc_val,WORD32 dst_wd)88 void impeg2_memset_8bit_8x8_block_sse42(UWORD8 *dst, WORD32 dc_val, WORD32 dst_wd)
89 {
90 __m128i value = _mm_set1_epi8((WORD8)dc_val);
91
92 _mm_storel_epi64((__m128i *)dst, value);
93 _mm_storel_epi64((__m128i *) (dst + dst_wd), value);
94 _mm_storel_epi64((__m128i *) (dst + 2 * dst_wd), value);
95 _mm_storel_epi64((__m128i *) (dst + 3 * dst_wd), value);
96 _mm_storel_epi64((__m128i *) (dst + 4 * dst_wd), value);
97 _mm_storel_epi64((__m128i *) (dst + 5 * dst_wd), value);
98 _mm_storel_epi64((__m128i *) (dst + 6 * dst_wd), value);
99 _mm_storel_epi64((__m128i *) (dst + 7 * dst_wd), value);
100 }
101