__m128i test_mm_sra_epi32(__m128i A, __m128i B) { // DAG-LABEL: test_mm_sra_epi32 // DAG: call <4 x i32> @llvm.x86.sse2.psra.d // // ASM-LABEL: test_mm_sra_epi32 // ASM: psrad return _mm_sra_epi32(A, B); }
test (__m128i s1, __m128i count) { return _mm_sra_epi32 (s1, count); }
int rotate_cpx_vector(int16_t *x, int16_t *alpha, int16_t *y, uint32_t N, uint16_t output_shift) { // Multiply elementwise two complex vectors of N elements // x - input 1 in the format |Re0 Im0 |,......,|Re(N-1) Im(N-1)| // We assume x1 with a dynamic of 15 bit maximum // // alpha - input 2 in the format |Re0 Im0| // We assume x2 with a dynamic of 15 bit maximum // // y - output in the format |Re0 Im0|,......,|Re(N-1) Im(N-1)| // // N - the size f the vectors (this function does N cpx mpy. WARNING: N>=4; // // log2_amp - increase the output amplitude by a factor 2^log2_amp (default is 0) // WARNING: log2_amp>0 can cause overflow!! uint32_t i; // loop counter simd_q15_t *y_128,alpha_128; int32_t *xd=(int32_t *)x; #if defined(__x86_64__) || defined(__i386__) __m128i shift = _mm_cvtsi32_si128(output_shift); register simd_q15_t m0,m1,m2,m3; ((int16_t *)&alpha_128)[0] = alpha[0]; ((int16_t *)&alpha_128)[1] = -alpha[1]; ((int16_t *)&alpha_128)[2] = alpha[1]; ((int16_t *)&alpha_128)[3] = alpha[0]; ((int16_t *)&alpha_128)[4] = alpha[0]; ((int16_t *)&alpha_128)[5] = -alpha[1]; ((int16_t *)&alpha_128)[6] = alpha[1]; ((int16_t *)&alpha_128)[7] = alpha[0]; #elif defined(__arm__) int32x4_t shift; int32x4_t ab_re0,ab_re1,ab_im0,ab_im1,re32,im32; int16_t reflip[8] __attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1}; int32x4x2_t xtmp; ((int16_t *)&alpha_128)[0] = alpha[0]; ((int16_t *)&alpha_128)[1] = alpha[1]; ((int16_t *)&alpha_128)[2] = alpha[0]; ((int16_t *)&alpha_128)[3] = alpha[1]; ((int16_t *)&alpha_128)[4] = alpha[0]; ((int16_t *)&alpha_128)[5] = alpha[1]; ((int16_t *)&alpha_128)[6] = alpha[0]; ((int16_t *)&alpha_128)[7] = alpha[1]; int16x8_t bflip = vrev32q_s16(alpha_128); int16x8_t bconj = vmulq_s16(alpha_128,*(int16x8_t *)reflip); shift = vdupq_n_s32(-output_shift); #endif y_128 = (simd_q15_t *) y; for(i=0; i<N>>2; i++) { #if defined(__x86_64__) || defined(__i386__) m0 = _mm_setr_epi32(xd[0],xd[0],xd[1],xd[1]); m1 = _mm_setr_epi32(xd[2],xd[2],xd[3],xd[3]); m2 = _mm_madd_epi16(m0,alpha_128); //complex multiply. result is 32bit [Re Im Re Im] m3 = _mm_madd_epi16(m1,alpha_128); //complex multiply. result is 32bit [Re Im Re Im] m2 = _mm_sra_epi32(m2,shift); // shift right by shift in order to compensate for the input amplitude m3 = _mm_sra_epi32(m3,shift); // shift right by shift in order to compensate for the input amplitude y_128[0] = _mm_packs_epi32(m2,m3); // pack in 16bit integers with saturation [re im re im re im re im] #elif defined(__arm__) ab_re0 = vmull_s16(((int16x4_t*)xd)[0],((int16x4_t*)&bconj)[0]); ab_re1 = vmull_s16(((int16x4_t*)xd)[1],((int16x4_t*)&bconj)[1]); ab_im0 = vmull_s16(((int16x4_t*)xd)[0],((int16x4_t*)&bflip)[0]); ab_im1 = vmull_s16(((int16x4_t*)xd)[1],((int16x4_t*)&bflip)[1]); re32 = vshlq_s32(vcombine_s32(vpadd_s32(((int32x2_t*)&ab_re0)[0],((int32x2_t*)&ab_re0)[1]), vpadd_s32(((int32x2_t*)&ab_re1)[0],((int32x2_t*)&ab_re1)[1])), shift); im32 = vshlq_s32(vcombine_s32(vpadd_s32(((int32x2_t*)&ab_im0)[0],((int32x2_t*)&ab_im0)[1]), vpadd_s32(((int32x2_t*)&ab_im1)[0],((int32x2_t*)&ab_im1)[1])), shift); xtmp = vzipq_s32(re32,im32); y_128[0] = vcombine_s16(vmovn_s32(xtmp.val[0]),vmovn_s32(xtmp.val[1])); #endif xd+=4; y_128+=1; } _mm_empty(); _m_empty(); return(0); }
sse2_tests (void) { /* psraw */ c128.v = _mm_srai_epi16 (m128_16, SHIFT); dump128_16 (buf, "_mm_srai_epi16", c128); c128.v = _mm_sra_epi16 (m128_16, s128); dump128_16 (buf, "_mm_sra_epi16", c128); /* psrad */ c128.v = _mm_srai_epi32 (m128_32, SHIFT); dump128_32 (buf, "_mm_srai_epi32", c128); c128.v = _mm_sra_epi32 (m128_32, s128); dump128_32 (buf, "_mm_sra_epi32", c128); /* psrlw */ c128.v = _mm_srli_epi16 (m128_16, SHIFT); dump128_16 (buf, "_mm_srli_epi16", c128); c128.v = _mm_srl_epi16 (m128_16, s128); dump128_16 (buf, "_mm_srl_epi16", c128); /* psrld */ c128.v = _mm_srli_epi32 (m128_32, SHIFT); dump128_32 (buf, "_mm_srli_epi32", c128); c128.v = _mm_srl_epi32 (m128_32, s128); dump128_32 (buf, "_mm_srl_epi32", c128); /* psrlq */ c128.v = _mm_srli_epi64 (m128_64, SHIFT); dump128_64 (buf, "_mm_srli_epi64", c128); c128.v = _mm_srl_epi64 (m128_64, s128); dump128_64 (buf, "_mm_srl_epi64", c128); /* psrldq */ c128.v = _mm_srli_si128 (m128_128, SHIFT); dump128_128 (buf, "_mm_srli_si128 (byte shift) ", c128); /* psllw */ c128.v = _mm_slli_epi16 (m128_16, SHIFT); dump128_16 (buf, "_mm_slli_epi16", c128); c128.v = _mm_sll_epi16 (m128_16, s128); dump128_16 (buf, "_mm_sll_epi16", c128); /* pslld */ c128.v = _mm_slli_epi32 (m128_32, SHIFT); dump128_32 (buf, "_mm_slli_epi32", c128); c128.v = _mm_sll_epi32 (m128_32, s128); dump128_32 (buf, "_mm_sll_epi32", c128); /* psllq */ c128.v = _mm_slli_epi64 (m128_64, SHIFT); dump128_64 (buf, "_mm_slli_epi64", c128); c128.v = _mm_sll_epi64 (m128_64, s128); dump128_64 (buf, "_mm_sll_epi64", c128); /* pslldq */ c128.v = _mm_slli_si128 (m128_128, SHIFT); dump128_128 (buf, "_mm_sll_si128 (byte shift)", c128); /* Shuffle constant 0x1b == 0b_00_01_10_11, e.g. swap words: ABCD => DCBA. */ /* pshufd */ c128.v = _mm_shuffle_epi32 (m128_128, 0x1b); dump128_32 (buf, "_mm_shuffle_epi32", c128); /* pshuflw */ c128.v = _mm_shufflelo_epi16 (m128_128, 0x1b); dump128_16 (buf, "_mm_shuffelo_epi16", c128); /* pshufhw */ c128.v = _mm_shufflehi_epi16 (m128_128, 0x1b); dump128_16 (buf, "_mm_shuffehi_epi16", c128); }
int mult_cpx_vector_h(short *x1, short *x2, short *y, unsigned int N, unsigned short output_shift, short sign) { // Multiply elementwise the complex vector x1 with the complex conjugate of the complex vecotr x2 of N elements and adds it to the vector y. // x1 - input 1 in the format |Re0 Im0 Re0 Im0|,......,|Re(N-1) Im(N-1) Re(N-1) Im(N-1)| // We assume x1 with a dinamic of 15 bit maximum // // x2 - input 2 in the format |Re0 Im0 Re0 Im0|,......,|Re(N-1) Im(N-1) Re(N-1) Im(N-1)| // We assume x2 with a dinamic of 14 bit maximum // // y - output in the format |Re0 Im0 Re0 Im0|,......,|Re(N-1) Im(N-1) Re(N-1) Im(N-1)| // // N - the size f the vectors (this function does N cpx mpy. WARNING: N>=4; // // log2_amp - increase the output amplitude by a factor 2^log2_amp (default is 0) // WARNING: log2_amp>0 can cause overflow!! // sign - +1..add, -1..substract unsigned int i; // loop counter register __m128i m0,m1,m2; short *temps; int *tempd; __m128i *x1_128; __m128i *x2_128; __m128i *y_128; __m128i mask; __m128i temp; shift = _mm_cvtsi32_si128(output_shift); x1_128 = (__m128i *)&x1[0]; x2_128 = (__m128i *)&x2[0]; y_128 = (__m128i *)&y[0]; if (sign == -1) mask = (__m128i) _mm_set_epi16 (-1,1,-1,-1,-1,1,-1,-1); else mask = (__m128i) _mm_set_epi16 (1,-1,1,1,1,-1,1,1); // we compute 2*4 cpx multiply for each loop for(i=0;i<(N>>3);i++) { // printf("i=%d\n",i); // unroll 1 // temps = (short *)x1_128; // printf("x1 : %d,%d,%d,%d,%d,%d,%d,%d\n",temps[0],temps[1],temps[2],temps[3],temps[4],temps[5],temps[6],temps[7]); m1 = x1_128[0]; m2 = x2_128[0]; // temps = (short *)&x2_128[0]; // printf("x2 : %x,%x,%x,%x,%x,%x,%x,%x\n",temps[0],temps[1],temps[2],temps[3],temps[4],temps[5],temps[6],temps[7]); // bring x2 in conjugate form // the first two instructions might be replaced with a single one in SSE3 m2 = _mm_shufflelo_epi16(m2,_MM_SHUFFLE(0,1,3,2)); m2 = _mm_shufflehi_epi16(m2,_MM_SHUFFLE(0,1,3,2)); m2 = _mm_mullo_epi16(m2, mask); // temp = m2; // temps = (short *)&temp; // printf("x2 conj : %x,%x,%x,%x,%x,%x,%x,%x\n",temps[0],temps[1],temps[2],temps[3],temps[4],temps[5],temps[6],temps[7]); m0 = _mm_madd_epi16(m1,m2); //pmaddwd_r2r(mm1,mm0); // 1- compute x1[0]*x2[0] // temp = m0; // tempd = &temp; // printf("m0 : %d,%d,%d,%d\n",tempd[0],tempd[1],tempd[2],tempd[3]); m0 = _mm_sra_epi32(m0,shift); // 1- shift right by shift in order to compensate for the input amplitude // temp = m0; // tempd = (int *)&temp; // printf("m0 : %d,%d,%d,%d\n",tempd[0],tempd[1],tempd[2],tempd[3]); m0 = _mm_packs_epi32(m0,m0); // 1- pack in a 128 bit register [re im re im] m0 = _mm_unpacklo_epi32(m0,m0); // 1- pack in a 128 bit register [re im re im] y_128[0] = _mm_add_epi16(m0,y_128[0]); // temps = (short *)&y_128[0]; // printf("y0 : %d,%d,%d,%d,%d,%d,%d,%d\n",temps[0],temps[1],temps[2],temps[3],temps[4],temps[5],temps[6],temps[7]); // unroll 2 m1 = x1_128[1]; m2 = x2_128[1]; m2 = _mm_shufflelo_epi16(m2,_MM_SHUFFLE(0,1,3,2)); m2 = _mm_shufflehi_epi16(m2,_MM_SHUFFLE(0,1,3,2)); m2 = _mm_mullo_epi16(m2, mask); m0 = _mm_madd_epi16(m1,m2); //pmaddwd_r2r(mm1,mm0); // 1- compute x1[0]*x2[0] m0 = _mm_sra_epi32(m0,shift); // 1- shift right by shift in order to compensate for the input amplitude m0 = _mm_packs_epi32(m0,m0); // 1- pack in a 128 bit register [re im re im] m0 = _mm_unpacklo_epi32(m0,m0); // 1- pack in a 128 bit register [re im re im] y_128[1] = _mm_add_epi16(m0,y_128[1]); // unroll 3 m1 = x1_128[2]; m2 = x2_128[2]; m2 = _mm_shufflelo_epi16(m2,_MM_SHUFFLE(0,1,3,2)); m2 = _mm_shufflehi_epi16(m2,_MM_SHUFFLE(0,1,3,2)); m2 = _mm_mullo_epi16(m2, mask); m0 = _mm_madd_epi16(m1,m2); //pmaddwd_r2r(mm1,mm0); // 1- compute x1[0]*x2[0] m0 = _mm_sra_epi32(m0,shift); // 1- shift right by shift in order to compensate for the input amplitude m0 = _mm_packs_epi32(m0,m0); // 1- pack in a 128 bit register [re im re im] m0 = _mm_unpacklo_epi32(m0,m0); // 1- pack in a 128 bit register [re im re im] y_128[2] = _mm_add_epi16(m0,y_128[2]); // unroll 4 m1 = x1_128[3]; m2 = x2_128[3]; m2 = _mm_shufflelo_epi16(m2,_MM_SHUFFLE(0,1,3,2)); m2 = _mm_shufflehi_epi16(m2,_MM_SHUFFLE(0,1,3,2)); m2 = _mm_mullo_epi16(m2, mask); m0 = _mm_madd_epi16(m1,m2); //pmaddwd_r2r(mm1,mm0); // 1- compute x1[0]*x2[0] m0 = _mm_sra_epi32(m0,shift); // 1- shift right by shift in order to compensate for the input amplitude m0 = _mm_packs_epi32(m0,m0); // 1- pack in a 128 bit register [re im re im] m0 = _mm_unpacklo_epi32(m0,m0); // 1- pack in a 128 bit register [re im re im] y_128[3] = _mm_add_epi16(m0,y_128[3]); x1_128+=4; x2_128+=4; y_128 +=4; // printf("x1_128 = %p, x2_128 =%p, y_128=%p\n",x1_128,x2_128,y_128); } _mm_empty(); _m_empty(); return(0); }
void av1_highbd_jnt_convolve_2d_sse4_1( const uint16_t *src, int src_stride, uint16_t *dst0, int dst_stride0, int w, int h, const InterpFilterParams *filter_params_x, const InterpFilterParams *filter_params_y, const int subpel_x_q4, const int subpel_y_q4, ConvolveParams *conv_params, int bd) { DECLARE_ALIGNED(16, int16_t, im_block[(MAX_SB_SIZE + MAX_FILTER_TAP - 1) * MAX_SB_SIZE]); CONV_BUF_TYPE *dst = conv_params->dst; int dst_stride = conv_params->dst_stride; int im_h = h + filter_params_y->taps - 1; int im_stride = MAX_SB_SIZE; int i, j; const int do_average = conv_params->do_average; const int use_jnt_comp_avg = conv_params->use_jnt_comp_avg; const int fo_vert = filter_params_y->taps / 2 - 1; const int fo_horiz = filter_params_x->taps / 2 - 1; const uint16_t *const src_ptr = src - fo_vert * src_stride - fo_horiz; const int w0 = conv_params->fwd_offset; const int w1 = conv_params->bck_offset; const __m128i wt0 = _mm_set1_epi32(w0); const __m128i wt1 = _mm_set1_epi32(w1); const int offset_0 = bd + 2 * FILTER_BITS - conv_params->round_0 - conv_params->round_1; const int offset = (1 << offset_0) + (1 << (offset_0 - 1)); const __m128i offset_const = _mm_set1_epi32(offset); const int rounding_shift = 2 * FILTER_BITS - conv_params->round_0 - conv_params->round_1; const __m128i rounding_const = _mm_set1_epi32((1 << rounding_shift) >> 1); const __m128i clip_pixel_to_bd = _mm_set1_epi16(bd == 10 ? 1023 : (bd == 12 ? 4095 : 255)); // Check that, even with 12-bit input, the intermediate values will fit // into an unsigned 16-bit intermediate array. assert(bd + FILTER_BITS + 2 - conv_params->round_0 <= 16); /* Horizontal filter */ { const int16_t *x_filter = av1_get_interp_filter_subpel_kernel( filter_params_x, subpel_x_q4 & SUBPEL_MASK); const __m128i coeffs_x = _mm_loadu_si128((__m128i *)x_filter); // coeffs 0 1 0 1 2 3 2 3 const __m128i tmp_0 = _mm_unpacklo_epi32(coeffs_x, coeffs_x); // coeffs 4 5 4 5 6 7 6 7 const __m128i tmp_1 = _mm_unpackhi_epi32(coeffs_x, coeffs_x); // coeffs 0 1 0 1 0 1 0 1 const __m128i coeff_01 = _mm_unpacklo_epi64(tmp_0, tmp_0); // coeffs 2 3 2 3 2 3 2 3 const __m128i coeff_23 = _mm_unpackhi_epi64(tmp_0, tmp_0); // coeffs 4 5 4 5 4 5 4 5 const __m128i coeff_45 = _mm_unpacklo_epi64(tmp_1, tmp_1); // coeffs 6 7 6 7 6 7 6 7 const __m128i coeff_67 = _mm_unpackhi_epi64(tmp_1, tmp_1); const __m128i round_const = _mm_set1_epi32( ((1 << conv_params->round_0) >> 1) + (1 << (bd + FILTER_BITS - 1))); const __m128i round_shift = _mm_cvtsi32_si128(conv_params->round_0); for (i = 0; i < im_h; ++i) { for (j = 0; j < w; j += 8) { const __m128i data = _mm_loadu_si128((__m128i *)&src_ptr[i * src_stride + j]); const __m128i data2 = _mm_loadu_si128((__m128i *)&src_ptr[i * src_stride + j + 8]); // Filter even-index pixels const __m128i res_0 = _mm_madd_epi16(data, coeff_01); const __m128i res_2 = _mm_madd_epi16(_mm_alignr_epi8(data2, data, 4), coeff_23); const __m128i res_4 = _mm_madd_epi16(_mm_alignr_epi8(data2, data, 8), coeff_45); const __m128i res_6 = _mm_madd_epi16(_mm_alignr_epi8(data2, data, 12), coeff_67); __m128i res_even = _mm_add_epi32(_mm_add_epi32(res_0, res_4), _mm_add_epi32(res_2, res_6)); res_even = _mm_sra_epi32(_mm_add_epi32(res_even, round_const), round_shift); // Filter odd-index pixels const __m128i res_1 = _mm_madd_epi16(_mm_alignr_epi8(data2, data, 2), coeff_01); const __m128i res_3 = _mm_madd_epi16(_mm_alignr_epi8(data2, data, 6), coeff_23); const __m128i res_5 = _mm_madd_epi16(_mm_alignr_epi8(data2, data, 10), coeff_45); const __m128i res_7 = _mm_madd_epi16(_mm_alignr_epi8(data2, data, 14), coeff_67); __m128i res_odd = _mm_add_epi32(_mm_add_epi32(res_1, res_5), _mm_add_epi32(res_3, res_7)); res_odd = _mm_sra_epi32(_mm_add_epi32(res_odd, round_const), round_shift); // Pack in the column order 0, 2, 4, 6, 1, 3, 5, 7 __m128i res = _mm_packs_epi32(res_even, res_odd); _mm_storeu_si128((__m128i *)&im_block[i * im_stride + j], res); } } } /* Vertical filter */ { const int16_t *y_filter = av1_get_interp_filter_subpel_kernel( filter_params_y, subpel_y_q4 & SUBPEL_MASK); const __m128i coeffs_y = _mm_loadu_si128((__m128i *)y_filter); // coeffs 0 1 0 1 2 3 2 3 const __m128i tmp_0 = _mm_unpacklo_epi32(coeffs_y, coeffs_y); // coeffs 4 5 4 5 6 7 6 7 const __m128i tmp_1 = _mm_unpackhi_epi32(coeffs_y, coeffs_y); // coeffs 0 1 0 1 0 1 0 1 const __m128i coeff_01 = _mm_unpacklo_epi64(tmp_0, tmp_0); // coeffs 2 3 2 3 2 3 2 3 const __m128i coeff_23 = _mm_unpackhi_epi64(tmp_0, tmp_0); // coeffs 4 5 4 5 4 5 4 5 const __m128i coeff_45 = _mm_unpacklo_epi64(tmp_1, tmp_1); // coeffs 6 7 6 7 6 7 6 7 const __m128i coeff_67 = _mm_unpackhi_epi64(tmp_1, tmp_1); const __m128i round_const = _mm_set1_epi32( ((1 << conv_params->round_1) >> 1) - (1 << (bd + 2 * FILTER_BITS - conv_params->round_0 - 1))); const __m128i round_shift = _mm_cvtsi32_si128(conv_params->round_1); for (i = 0; i < h; ++i) { for (j = 0; j < w; j += 8) { // Filter even-index pixels const int16_t *data = &im_block[i * im_stride + j]; const __m128i src_0 = _mm_unpacklo_epi16(*(__m128i *)(data + 0 * im_stride), *(__m128i *)(data + 1 * im_stride)); const __m128i src_2 = _mm_unpacklo_epi16(*(__m128i *)(data + 2 * im_stride), *(__m128i *)(data + 3 * im_stride)); const __m128i src_4 = _mm_unpacklo_epi16(*(__m128i *)(data + 4 * im_stride), *(__m128i *)(data + 5 * im_stride)); const __m128i src_6 = _mm_unpacklo_epi16(*(__m128i *)(data + 6 * im_stride), *(__m128i *)(data + 7 * im_stride)); const __m128i res_0 = _mm_madd_epi16(src_0, coeff_01); const __m128i res_2 = _mm_madd_epi16(src_2, coeff_23); const __m128i res_4 = _mm_madd_epi16(src_4, coeff_45); const __m128i res_6 = _mm_madd_epi16(src_6, coeff_67); const __m128i res_even = _mm_add_epi32(_mm_add_epi32(res_0, res_2), _mm_add_epi32(res_4, res_6)); // Filter odd-index pixels const __m128i src_1 = _mm_unpackhi_epi16(*(__m128i *)(data + 0 * im_stride), *(__m128i *)(data + 1 * im_stride)); const __m128i src_3 = _mm_unpackhi_epi16(*(__m128i *)(data + 2 * im_stride), *(__m128i *)(data + 3 * im_stride)); const __m128i src_5 = _mm_unpackhi_epi16(*(__m128i *)(data + 4 * im_stride), *(__m128i *)(data + 5 * im_stride)); const __m128i src_7 = _mm_unpackhi_epi16(*(__m128i *)(data + 6 * im_stride), *(__m128i *)(data + 7 * im_stride)); const __m128i res_1 = _mm_madd_epi16(src_1, coeff_01); const __m128i res_3 = _mm_madd_epi16(src_3, coeff_23); const __m128i res_5 = _mm_madd_epi16(src_5, coeff_45); const __m128i res_7 = _mm_madd_epi16(src_7, coeff_67); const __m128i res_odd = _mm_add_epi32(_mm_add_epi32(res_1, res_3), _mm_add_epi32(res_5, res_7)); // Rearrange pixels back into the order 0 ... 7 const __m128i res_lo = _mm_unpacklo_epi32(res_even, res_odd); const __m128i res_hi = _mm_unpackhi_epi32(res_even, res_odd); const __m128i res_lo_round = _mm_sra_epi32(_mm_add_epi32(res_lo, round_const), round_shift); const __m128i res_unsigned_lo = _mm_add_epi32(res_lo_round, offset_const); if (w < 8) { if (do_average) { const __m128i data_0 = _mm_loadl_epi64((__m128i *)(&dst[i * dst_stride + j])); const __m128i data_ref_0 = _mm_cvtepu16_epi32(data_0); const __m128i comp_avg_res = highbd_comp_avg_sse4_1( &data_ref_0, &res_unsigned_lo, &wt0, &wt1, use_jnt_comp_avg); const __m128i round_result = highbd_convolve_rounding_sse2( &comp_avg_res, &offset_const, &rounding_const, rounding_shift); const __m128i res_16b = _mm_packus_epi32(round_result, round_result); const __m128i res_clip = _mm_min_epi16(res_16b, clip_pixel_to_bd); _mm_storel_epi64((__m128i *)(&dst0[i * dst_stride0 + j]), res_clip); } else { const __m128i res_16b = _mm_packus_epi32(res_unsigned_lo, res_unsigned_lo); _mm_storel_epi64((__m128i *)(&dst[i * dst_stride + j]), res_16b); } } else { const __m128i res_hi_round = _mm_sra_epi32(_mm_add_epi32(res_hi, round_const), round_shift); const __m128i res_unsigned_hi = _mm_add_epi32(res_hi_round, offset_const); if (do_average) { const __m128i data_lo = _mm_loadl_epi64((__m128i *)(&dst[i * dst_stride + j])); const __m128i data_hi = _mm_loadl_epi64((__m128i *)(&dst[i * dst_stride + j + 4])); const __m128i data_ref_0_lo = _mm_cvtepu16_epi32(data_lo); const __m128i data_ref_0_hi = _mm_cvtepu16_epi32(data_hi); const __m128i comp_avg_res_lo = highbd_comp_avg_sse4_1( &data_ref_0_lo, &res_unsigned_lo, &wt0, &wt1, use_jnt_comp_avg); const __m128i comp_avg_res_hi = highbd_comp_avg_sse4_1( &data_ref_0_hi, &res_unsigned_hi, &wt0, &wt1, use_jnt_comp_avg); const __m128i round_result_lo = highbd_convolve_rounding_sse2(&comp_avg_res_lo, &offset_const, &rounding_const, rounding_shift); const __m128i round_result_hi = highbd_convolve_rounding_sse2(&comp_avg_res_hi, &offset_const, &rounding_const, rounding_shift); const __m128i res_16b = _mm_packus_epi32(round_result_lo, round_result_hi); const __m128i res_clip = _mm_min_epi16(res_16b, clip_pixel_to_bd); _mm_store_si128((__m128i *)(&dst0[i * dst_stride0 + j]), res_clip); } else { const __m128i res_16b = _mm_packus_epi32(res_unsigned_lo, res_unsigned_hi); _mm_store_si128((__m128i *)(&dst[i * dst_stride + j]), res_16b); } } } } } }