LCOV - code coverage report
Current view: top level - media/libvpx/libvpx/vp9/encoder/x86 - vp9_dct_ssse3.c (source / functions) Hit Total Coverage
Test: output.info Lines: 0 278 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2014 The WebM project authors. All Rights Reserved.
       3             :  *
       4             :  *  Use of this source code is governed by a BSD-style license
       5             :  *  that can be found in the LICENSE file in the root of the source
       6             :  *  tree. An additional intellectual property rights grant can be found
       7             :  *  in the file PATENTS.  All contributing project authors may
       8             :  *  be found in the AUTHORS file in the root of the source tree.
       9             :  */
      10             : 
      11             : #include <assert.h>
      12             : #include <tmmintrin.h>  // SSSE3
      13             : 
      14             : #include "./vp9_rtcd.h"
      15             : #include "./vpx_config.h"
      16             : #include "vpx_dsp/vpx_dsp_common.h"
      17             : #include "vpx_dsp/x86/fdct.h"
      18             : #include "vpx_dsp/x86/inv_txfm_sse2.h"
      19             : #include "vpx_dsp/x86/txfm_common_sse2.h"
      20             : 
      21           0 : void vp9_fdct8x8_quant_ssse3(
      22             :     const int16_t *input, int stride, tran_low_t *coeff_ptr, intptr_t n_coeffs,
      23             :     int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr,
      24             :     const int16_t *quant_ptr, const int16_t *quant_shift_ptr,
      25             :     tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr,
      26             :     uint16_t *eob_ptr, const int16_t *scan_ptr, const int16_t *iscan_ptr) {
      27             :   __m128i zero;
      28             :   int pass;
      29             :   // Constants
      30             :   //    When we use them, in one case, they are all the same. In all others
      31             :   //    it's a pair of them that we need to repeat four times. This is done
      32             :   //    by constructing the 32 bit constant corresponding to that pair.
      33           0 :   const __m128i k__dual_p16_p16 = dual_set_epi16(23170, 23170);
      34           0 :   const __m128i k__cospi_p16_p16 = _mm_set1_epi16((int16_t)cospi_16_64);
      35           0 :   const __m128i k__cospi_p16_m16 = pair_set_epi16(cospi_16_64, -cospi_16_64);
      36           0 :   const __m128i k__cospi_p24_p08 = pair_set_epi16(cospi_24_64, cospi_8_64);
      37           0 :   const __m128i k__cospi_m08_p24 = pair_set_epi16(-cospi_8_64, cospi_24_64);
      38           0 :   const __m128i k__cospi_p28_p04 = pair_set_epi16(cospi_28_64, cospi_4_64);
      39           0 :   const __m128i k__cospi_m04_p28 = pair_set_epi16(-cospi_4_64, cospi_28_64);
      40           0 :   const __m128i k__cospi_p12_p20 = pair_set_epi16(cospi_12_64, cospi_20_64);
      41           0 :   const __m128i k__cospi_m20_p12 = pair_set_epi16(-cospi_20_64, cospi_12_64);
      42           0 :   const __m128i k__DCT_CONST_ROUNDING = _mm_set1_epi32(DCT_CONST_ROUNDING);
      43             :   // Load input
      44           0 :   __m128i in0 = _mm_load_si128((const __m128i *)(input + 0 * stride));
      45           0 :   __m128i in1 = _mm_load_si128((const __m128i *)(input + 1 * stride));
      46           0 :   __m128i in2 = _mm_load_si128((const __m128i *)(input + 2 * stride));
      47           0 :   __m128i in3 = _mm_load_si128((const __m128i *)(input + 3 * stride));
      48           0 :   __m128i in4 = _mm_load_si128((const __m128i *)(input + 4 * stride));
      49           0 :   __m128i in5 = _mm_load_si128((const __m128i *)(input + 5 * stride));
      50           0 :   __m128i in6 = _mm_load_si128((const __m128i *)(input + 6 * stride));
      51           0 :   __m128i in7 = _mm_load_si128((const __m128i *)(input + 7 * stride));
      52             :   __m128i *in[8];
      53           0 :   int index = 0;
      54             : 
      55             :   (void)scan_ptr;
      56             :   (void)zbin_ptr;
      57             :   (void)quant_shift_ptr;
      58             :   (void)coeff_ptr;
      59             : 
      60             :   // Pre-condition input (shift by two)
      61           0 :   in0 = _mm_slli_epi16(in0, 2);
      62           0 :   in1 = _mm_slli_epi16(in1, 2);
      63           0 :   in2 = _mm_slli_epi16(in2, 2);
      64           0 :   in3 = _mm_slli_epi16(in3, 2);
      65           0 :   in4 = _mm_slli_epi16(in4, 2);
      66           0 :   in5 = _mm_slli_epi16(in5, 2);
      67           0 :   in6 = _mm_slli_epi16(in6, 2);
      68           0 :   in7 = _mm_slli_epi16(in7, 2);
      69             : 
      70           0 :   in[0] = &in0;
      71           0 :   in[1] = &in1;
      72           0 :   in[2] = &in2;
      73           0 :   in[3] = &in3;
      74           0 :   in[4] = &in4;
      75           0 :   in[5] = &in5;
      76           0 :   in[6] = &in6;
      77           0 :   in[7] = &in7;
      78             : 
      79             :   // We do two passes, first the columns, then the rows. The results of the
      80             :   // first pass are transposed so that the same column code can be reused. The
      81             :   // results of the second pass are also transposed so that the rows (processed
      82             :   // as columns) are put back in row positions.
      83           0 :   for (pass = 0; pass < 2; pass++) {
      84             :     // To store results of each pass before the transpose.
      85             :     __m128i res0, res1, res2, res3, res4, res5, res6, res7;
      86             :     // Add/subtract
      87           0 :     const __m128i q0 = _mm_add_epi16(in0, in7);
      88           0 :     const __m128i q1 = _mm_add_epi16(in1, in6);
      89           0 :     const __m128i q2 = _mm_add_epi16(in2, in5);
      90           0 :     const __m128i q3 = _mm_add_epi16(in3, in4);
      91           0 :     const __m128i q4 = _mm_sub_epi16(in3, in4);
      92           0 :     const __m128i q5 = _mm_sub_epi16(in2, in5);
      93           0 :     const __m128i q6 = _mm_sub_epi16(in1, in6);
      94           0 :     const __m128i q7 = _mm_sub_epi16(in0, in7);
      95             :     // Work on first four results
      96             :     {
      97             :       // Add/subtract
      98           0 :       const __m128i r0 = _mm_add_epi16(q0, q3);
      99           0 :       const __m128i r1 = _mm_add_epi16(q1, q2);
     100           0 :       const __m128i r2 = _mm_sub_epi16(q1, q2);
     101           0 :       const __m128i r3 = _mm_sub_epi16(q0, q3);
     102             :       // Interleave to do the multiply by constants which gets us into 32bits
     103           0 :       const __m128i t0 = _mm_unpacklo_epi16(r0, r1);
     104           0 :       const __m128i t1 = _mm_unpackhi_epi16(r0, r1);
     105           0 :       const __m128i t2 = _mm_unpacklo_epi16(r2, r3);
     106           0 :       const __m128i t3 = _mm_unpackhi_epi16(r2, r3);
     107             : 
     108           0 :       const __m128i u0 = _mm_madd_epi16(t0, k__cospi_p16_p16);
     109           0 :       const __m128i u1 = _mm_madd_epi16(t1, k__cospi_p16_p16);
     110           0 :       const __m128i u2 = _mm_madd_epi16(t0, k__cospi_p16_m16);
     111           0 :       const __m128i u3 = _mm_madd_epi16(t1, k__cospi_p16_m16);
     112             : 
     113           0 :       const __m128i u4 = _mm_madd_epi16(t2, k__cospi_p24_p08);
     114           0 :       const __m128i u5 = _mm_madd_epi16(t3, k__cospi_p24_p08);
     115           0 :       const __m128i u6 = _mm_madd_epi16(t2, k__cospi_m08_p24);
     116           0 :       const __m128i u7 = _mm_madd_epi16(t3, k__cospi_m08_p24);
     117             :       // dct_const_round_shift
     118             : 
     119           0 :       const __m128i v0 = _mm_add_epi32(u0, k__DCT_CONST_ROUNDING);
     120           0 :       const __m128i v1 = _mm_add_epi32(u1, k__DCT_CONST_ROUNDING);
     121           0 :       const __m128i v2 = _mm_add_epi32(u2, k__DCT_CONST_ROUNDING);
     122           0 :       const __m128i v3 = _mm_add_epi32(u3, k__DCT_CONST_ROUNDING);
     123             : 
     124           0 :       const __m128i v4 = _mm_add_epi32(u4, k__DCT_CONST_ROUNDING);
     125           0 :       const __m128i v5 = _mm_add_epi32(u5, k__DCT_CONST_ROUNDING);
     126           0 :       const __m128i v6 = _mm_add_epi32(u6, k__DCT_CONST_ROUNDING);
     127           0 :       const __m128i v7 = _mm_add_epi32(u7, k__DCT_CONST_ROUNDING);
     128             : 
     129           0 :       const __m128i w0 = _mm_srai_epi32(v0, DCT_CONST_BITS);
     130           0 :       const __m128i w1 = _mm_srai_epi32(v1, DCT_CONST_BITS);
     131           0 :       const __m128i w2 = _mm_srai_epi32(v2, DCT_CONST_BITS);
     132           0 :       const __m128i w3 = _mm_srai_epi32(v3, DCT_CONST_BITS);
     133             : 
     134           0 :       const __m128i w4 = _mm_srai_epi32(v4, DCT_CONST_BITS);
     135           0 :       const __m128i w5 = _mm_srai_epi32(v5, DCT_CONST_BITS);
     136           0 :       const __m128i w6 = _mm_srai_epi32(v6, DCT_CONST_BITS);
     137           0 :       const __m128i w7 = _mm_srai_epi32(v7, DCT_CONST_BITS);
     138             :       // Combine
     139             : 
     140           0 :       res0 = _mm_packs_epi32(w0, w1);
     141           0 :       res4 = _mm_packs_epi32(w2, w3);
     142           0 :       res2 = _mm_packs_epi32(w4, w5);
     143           0 :       res6 = _mm_packs_epi32(w6, w7);
     144             :     }
     145             :     // Work on next four results
     146             :     {
     147             :       // Interleave to do the multiply by constants which gets us into 32bits
     148           0 :       const __m128i d0 = _mm_sub_epi16(q6, q5);
     149           0 :       const __m128i d1 = _mm_add_epi16(q6, q5);
     150           0 :       const __m128i r0 = _mm_mulhrs_epi16(d0, k__dual_p16_p16);
     151           0 :       const __m128i r1 = _mm_mulhrs_epi16(d1, k__dual_p16_p16);
     152             : 
     153             :       // Add/subtract
     154           0 :       const __m128i x0 = _mm_add_epi16(q4, r0);
     155           0 :       const __m128i x1 = _mm_sub_epi16(q4, r0);
     156           0 :       const __m128i x2 = _mm_sub_epi16(q7, r1);
     157           0 :       const __m128i x3 = _mm_add_epi16(q7, r1);
     158             :       // Interleave to do the multiply by constants which gets us into 32bits
     159           0 :       const __m128i t0 = _mm_unpacklo_epi16(x0, x3);
     160           0 :       const __m128i t1 = _mm_unpackhi_epi16(x0, x3);
     161           0 :       const __m128i t2 = _mm_unpacklo_epi16(x1, x2);
     162           0 :       const __m128i t3 = _mm_unpackhi_epi16(x1, x2);
     163           0 :       const __m128i u0 = _mm_madd_epi16(t0, k__cospi_p28_p04);
     164           0 :       const __m128i u1 = _mm_madd_epi16(t1, k__cospi_p28_p04);
     165           0 :       const __m128i u2 = _mm_madd_epi16(t0, k__cospi_m04_p28);
     166           0 :       const __m128i u3 = _mm_madd_epi16(t1, k__cospi_m04_p28);
     167           0 :       const __m128i u4 = _mm_madd_epi16(t2, k__cospi_p12_p20);
     168           0 :       const __m128i u5 = _mm_madd_epi16(t3, k__cospi_p12_p20);
     169           0 :       const __m128i u6 = _mm_madd_epi16(t2, k__cospi_m20_p12);
     170           0 :       const __m128i u7 = _mm_madd_epi16(t3, k__cospi_m20_p12);
     171             :       // dct_const_round_shift
     172           0 :       const __m128i v0 = _mm_add_epi32(u0, k__DCT_CONST_ROUNDING);
     173           0 :       const __m128i v1 = _mm_add_epi32(u1, k__DCT_CONST_ROUNDING);
     174           0 :       const __m128i v2 = _mm_add_epi32(u2, k__DCT_CONST_ROUNDING);
     175           0 :       const __m128i v3 = _mm_add_epi32(u3, k__DCT_CONST_ROUNDING);
     176           0 :       const __m128i v4 = _mm_add_epi32(u4, k__DCT_CONST_ROUNDING);
     177           0 :       const __m128i v5 = _mm_add_epi32(u5, k__DCT_CONST_ROUNDING);
     178           0 :       const __m128i v6 = _mm_add_epi32(u6, k__DCT_CONST_ROUNDING);
     179           0 :       const __m128i v7 = _mm_add_epi32(u7, k__DCT_CONST_ROUNDING);
     180           0 :       const __m128i w0 = _mm_srai_epi32(v0, DCT_CONST_BITS);
     181           0 :       const __m128i w1 = _mm_srai_epi32(v1, DCT_CONST_BITS);
     182           0 :       const __m128i w2 = _mm_srai_epi32(v2, DCT_CONST_BITS);
     183           0 :       const __m128i w3 = _mm_srai_epi32(v3, DCT_CONST_BITS);
     184           0 :       const __m128i w4 = _mm_srai_epi32(v4, DCT_CONST_BITS);
     185           0 :       const __m128i w5 = _mm_srai_epi32(v5, DCT_CONST_BITS);
     186           0 :       const __m128i w6 = _mm_srai_epi32(v6, DCT_CONST_BITS);
     187           0 :       const __m128i w7 = _mm_srai_epi32(v7, DCT_CONST_BITS);
     188             :       // Combine
     189           0 :       res1 = _mm_packs_epi32(w0, w1);
     190           0 :       res7 = _mm_packs_epi32(w2, w3);
     191           0 :       res5 = _mm_packs_epi32(w4, w5);
     192           0 :       res3 = _mm_packs_epi32(w6, w7);
     193             :     }
     194             :     // Transpose the 8x8.
     195             :     {
     196             :       // 00 01 02 03 04 05 06 07
     197             :       // 10 11 12 13 14 15 16 17
     198             :       // 20 21 22 23 24 25 26 27
     199             :       // 30 31 32 33 34 35 36 37
     200             :       // 40 41 42 43 44 45 46 47
     201             :       // 50 51 52 53 54 55 56 57
     202             :       // 60 61 62 63 64 65 66 67
     203             :       // 70 71 72 73 74 75 76 77
     204           0 :       const __m128i tr0_0 = _mm_unpacklo_epi16(res0, res1);
     205           0 :       const __m128i tr0_1 = _mm_unpacklo_epi16(res2, res3);
     206           0 :       const __m128i tr0_2 = _mm_unpackhi_epi16(res0, res1);
     207           0 :       const __m128i tr0_3 = _mm_unpackhi_epi16(res2, res3);
     208           0 :       const __m128i tr0_4 = _mm_unpacklo_epi16(res4, res5);
     209           0 :       const __m128i tr0_5 = _mm_unpacklo_epi16(res6, res7);
     210           0 :       const __m128i tr0_6 = _mm_unpackhi_epi16(res4, res5);
     211           0 :       const __m128i tr0_7 = _mm_unpackhi_epi16(res6, res7);
     212             :       // 00 10 01 11 02 12 03 13
     213             :       // 20 30 21 31 22 32 23 33
     214             :       // 04 14 05 15 06 16 07 17
     215             :       // 24 34 25 35 26 36 27 37
     216             :       // 40 50 41 51 42 52 43 53
     217             :       // 60 70 61 71 62 72 63 73
     218             :       // 54 54 55 55 56 56 57 57
     219             :       // 64 74 65 75 66 76 67 77
     220           0 :       const __m128i tr1_0 = _mm_unpacklo_epi32(tr0_0, tr0_1);
     221           0 :       const __m128i tr1_1 = _mm_unpacklo_epi32(tr0_2, tr0_3);
     222           0 :       const __m128i tr1_2 = _mm_unpackhi_epi32(tr0_0, tr0_1);
     223           0 :       const __m128i tr1_3 = _mm_unpackhi_epi32(tr0_2, tr0_3);
     224           0 :       const __m128i tr1_4 = _mm_unpacklo_epi32(tr0_4, tr0_5);
     225           0 :       const __m128i tr1_5 = _mm_unpacklo_epi32(tr0_6, tr0_7);
     226           0 :       const __m128i tr1_6 = _mm_unpackhi_epi32(tr0_4, tr0_5);
     227           0 :       const __m128i tr1_7 = _mm_unpackhi_epi32(tr0_6, tr0_7);
     228             :       // 00 10 20 30 01 11 21 31
     229             :       // 40 50 60 70 41 51 61 71
     230             :       // 02 12 22 32 03 13 23 33
     231             :       // 42 52 62 72 43 53 63 73
     232             :       // 04 14 24 34 05 15 21 36
     233             :       // 44 54 64 74 45 55 61 76
     234             :       // 06 16 26 36 07 17 27 37
     235             :       // 46 56 66 76 47 57 67 77
     236           0 :       in0 = _mm_unpacklo_epi64(tr1_0, tr1_4);
     237           0 :       in1 = _mm_unpackhi_epi64(tr1_0, tr1_4);
     238           0 :       in2 = _mm_unpacklo_epi64(tr1_2, tr1_6);
     239           0 :       in3 = _mm_unpackhi_epi64(tr1_2, tr1_6);
     240           0 :       in4 = _mm_unpacklo_epi64(tr1_1, tr1_5);
     241           0 :       in5 = _mm_unpackhi_epi64(tr1_1, tr1_5);
     242           0 :       in6 = _mm_unpacklo_epi64(tr1_3, tr1_7);
     243           0 :       in7 = _mm_unpackhi_epi64(tr1_3, tr1_7);
     244             :       // 00 10 20 30 40 50 60 70
     245             :       // 01 11 21 31 41 51 61 71
     246             :       // 02 12 22 32 42 52 62 72
     247             :       // 03 13 23 33 43 53 63 73
     248             :       // 04 14 24 34 44 54 64 74
     249             :       // 05 15 25 35 45 55 65 75
     250             :       // 06 16 26 36 46 56 66 76
     251             :       // 07 17 27 37 47 57 67 77
     252             :     }
     253             :   }
     254             :   // Post-condition output and store it
     255             :   {
     256             :     // Post-condition (division by two)
     257             :     //    division of two 16 bits signed numbers using shifts
     258             :     //    n / 2 = (n - (n >> 15)) >> 1
     259           0 :     const __m128i sign_in0 = _mm_srai_epi16(in0, 15);
     260           0 :     const __m128i sign_in1 = _mm_srai_epi16(in1, 15);
     261           0 :     const __m128i sign_in2 = _mm_srai_epi16(in2, 15);
     262           0 :     const __m128i sign_in3 = _mm_srai_epi16(in3, 15);
     263           0 :     const __m128i sign_in4 = _mm_srai_epi16(in4, 15);
     264           0 :     const __m128i sign_in5 = _mm_srai_epi16(in5, 15);
     265           0 :     const __m128i sign_in6 = _mm_srai_epi16(in6, 15);
     266           0 :     const __m128i sign_in7 = _mm_srai_epi16(in7, 15);
     267           0 :     in0 = _mm_sub_epi16(in0, sign_in0);
     268           0 :     in1 = _mm_sub_epi16(in1, sign_in1);
     269           0 :     in2 = _mm_sub_epi16(in2, sign_in2);
     270           0 :     in3 = _mm_sub_epi16(in3, sign_in3);
     271           0 :     in4 = _mm_sub_epi16(in4, sign_in4);
     272           0 :     in5 = _mm_sub_epi16(in5, sign_in5);
     273           0 :     in6 = _mm_sub_epi16(in6, sign_in6);
     274           0 :     in7 = _mm_sub_epi16(in7, sign_in7);
     275           0 :     in0 = _mm_srai_epi16(in0, 1);
     276           0 :     in1 = _mm_srai_epi16(in1, 1);
     277           0 :     in2 = _mm_srai_epi16(in2, 1);
     278           0 :     in3 = _mm_srai_epi16(in3, 1);
     279           0 :     in4 = _mm_srai_epi16(in4, 1);
     280           0 :     in5 = _mm_srai_epi16(in5, 1);
     281           0 :     in6 = _mm_srai_epi16(in6, 1);
     282           0 :     in7 = _mm_srai_epi16(in7, 1);
     283             :   }
     284             : 
     285           0 :   iscan_ptr += n_coeffs;
     286           0 :   qcoeff_ptr += n_coeffs;
     287           0 :   dqcoeff_ptr += n_coeffs;
     288           0 :   n_coeffs = -n_coeffs;
     289           0 :   zero = _mm_setzero_si128();
     290             : 
     291           0 :   if (!skip_block) {
     292             :     __m128i eob;
     293             :     __m128i round, quant, dequant, thr;
     294             :     int16_t nzflag;
     295             :     {
     296             :       __m128i coeff0, coeff1;
     297             : 
     298             :       // Setup global values
     299             :       {
     300           0 :         round = _mm_load_si128((const __m128i *)round_ptr);
     301           0 :         quant = _mm_load_si128((const __m128i *)quant_ptr);
     302           0 :         dequant = _mm_load_si128((const __m128i *)dequant_ptr);
     303             :       }
     304             : 
     305             :       {
     306             :         __m128i coeff0_sign, coeff1_sign;
     307             :         __m128i qcoeff0, qcoeff1;
     308             :         __m128i qtmp0, qtmp1;
     309             :         // Do DC and first 15 AC
     310           0 :         coeff0 = *in[0];
     311           0 :         coeff1 = *in[1];
     312             : 
     313             :         // Poor man's sign extract
     314           0 :         coeff0_sign = _mm_srai_epi16(coeff0, 15);
     315           0 :         coeff1_sign = _mm_srai_epi16(coeff1, 15);
     316           0 :         qcoeff0 = _mm_xor_si128(coeff0, coeff0_sign);
     317           0 :         qcoeff1 = _mm_xor_si128(coeff1, coeff1_sign);
     318           0 :         qcoeff0 = _mm_sub_epi16(qcoeff0, coeff0_sign);
     319           0 :         qcoeff1 = _mm_sub_epi16(qcoeff1, coeff1_sign);
     320             : 
     321           0 :         qcoeff0 = _mm_adds_epi16(qcoeff0, round);
     322           0 :         round = _mm_unpackhi_epi64(round, round);
     323           0 :         qcoeff1 = _mm_adds_epi16(qcoeff1, round);
     324           0 :         qtmp0 = _mm_mulhi_epi16(qcoeff0, quant);
     325           0 :         quant = _mm_unpackhi_epi64(quant, quant);
     326           0 :         qtmp1 = _mm_mulhi_epi16(qcoeff1, quant);
     327             : 
     328             :         // Reinsert signs
     329           0 :         qcoeff0 = _mm_xor_si128(qtmp0, coeff0_sign);
     330           0 :         qcoeff1 = _mm_xor_si128(qtmp1, coeff1_sign);
     331           0 :         qcoeff0 = _mm_sub_epi16(qcoeff0, coeff0_sign);
     332           0 :         qcoeff1 = _mm_sub_epi16(qcoeff1, coeff1_sign);
     333             : 
     334           0 :         store_tran_low(qcoeff0, qcoeff_ptr + n_coeffs);
     335           0 :         store_tran_low(qcoeff1, qcoeff_ptr + n_coeffs + 8);
     336             : 
     337           0 :         coeff0 = _mm_mullo_epi16(qcoeff0, dequant);
     338           0 :         dequant = _mm_unpackhi_epi64(dequant, dequant);
     339           0 :         coeff1 = _mm_mullo_epi16(qcoeff1, dequant);
     340             : 
     341           0 :         store_tran_low(coeff0, dqcoeff_ptr + n_coeffs);
     342           0 :         store_tran_low(coeff1, dqcoeff_ptr + n_coeffs + 8);
     343             :       }
     344             : 
     345             :       {
     346             :         // Scan for eob
     347             :         __m128i zero_coeff0, zero_coeff1;
     348             :         __m128i nzero_coeff0, nzero_coeff1;
     349             :         __m128i iscan0, iscan1;
     350             :         __m128i eob1;
     351           0 :         zero_coeff0 = _mm_cmpeq_epi16(coeff0, zero);
     352           0 :         zero_coeff1 = _mm_cmpeq_epi16(coeff1, zero);
     353           0 :         nzero_coeff0 = _mm_cmpeq_epi16(zero_coeff0, zero);
     354           0 :         nzero_coeff1 = _mm_cmpeq_epi16(zero_coeff1, zero);
     355           0 :         iscan0 = _mm_load_si128((const __m128i *)(iscan_ptr + n_coeffs));
     356           0 :         iscan1 = _mm_load_si128((const __m128i *)(iscan_ptr + n_coeffs) + 1);
     357             :         // Add one to convert from indices to counts
     358           0 :         iscan0 = _mm_sub_epi16(iscan0, nzero_coeff0);
     359           0 :         iscan1 = _mm_sub_epi16(iscan1, nzero_coeff1);
     360           0 :         eob = _mm_and_si128(iscan0, nzero_coeff0);
     361           0 :         eob1 = _mm_and_si128(iscan1, nzero_coeff1);
     362           0 :         eob = _mm_max_epi16(eob, eob1);
     363             :       }
     364           0 :       n_coeffs += 8 * 2;
     365             :     }
     366             : 
     367             :     // AC only loop
     368           0 :     index = 2;
     369           0 :     thr = _mm_srai_epi16(dequant, 1);
     370           0 :     while (n_coeffs < 0) {
     371             :       __m128i coeff0, coeff1;
     372             :       {
     373             :         __m128i coeff0_sign, coeff1_sign;
     374             :         __m128i qcoeff0, qcoeff1;
     375             :         __m128i qtmp0, qtmp1;
     376             : 
     377           0 :         assert(index < (int)(sizeof(in) / sizeof(in[0])) - 1);
     378           0 :         coeff0 = *in[index];
     379           0 :         coeff1 = *in[index + 1];
     380             : 
     381             :         // Poor man's sign extract
     382           0 :         coeff0_sign = _mm_srai_epi16(coeff0, 15);
     383           0 :         coeff1_sign = _mm_srai_epi16(coeff1, 15);
     384           0 :         qcoeff0 = _mm_xor_si128(coeff0, coeff0_sign);
     385           0 :         qcoeff1 = _mm_xor_si128(coeff1, coeff1_sign);
     386           0 :         qcoeff0 = _mm_sub_epi16(qcoeff0, coeff0_sign);
     387           0 :         qcoeff1 = _mm_sub_epi16(qcoeff1, coeff1_sign);
     388             : 
     389           0 :         nzflag = _mm_movemask_epi8(_mm_cmpgt_epi16(qcoeff0, thr)) |
     390           0 :                  _mm_movemask_epi8(_mm_cmpgt_epi16(qcoeff1, thr));
     391             : 
     392           0 :         if (nzflag) {
     393           0 :           qcoeff0 = _mm_adds_epi16(qcoeff0, round);
     394           0 :           qcoeff1 = _mm_adds_epi16(qcoeff1, round);
     395           0 :           qtmp0 = _mm_mulhi_epi16(qcoeff0, quant);
     396           0 :           qtmp1 = _mm_mulhi_epi16(qcoeff1, quant);
     397             : 
     398             :           // Reinsert signs
     399           0 :           qcoeff0 = _mm_xor_si128(qtmp0, coeff0_sign);
     400           0 :           qcoeff1 = _mm_xor_si128(qtmp1, coeff1_sign);
     401           0 :           qcoeff0 = _mm_sub_epi16(qcoeff0, coeff0_sign);
     402           0 :           qcoeff1 = _mm_sub_epi16(qcoeff1, coeff1_sign);
     403             : 
     404           0 :           store_tran_low(qcoeff0, qcoeff_ptr + n_coeffs);
     405           0 :           store_tran_low(qcoeff1, qcoeff_ptr + n_coeffs + 8);
     406             : 
     407           0 :           coeff0 = _mm_mullo_epi16(qcoeff0, dequant);
     408           0 :           coeff1 = _mm_mullo_epi16(qcoeff1, dequant);
     409             : 
     410           0 :           store_tran_low(coeff0, dqcoeff_ptr + n_coeffs);
     411           0 :           store_tran_low(coeff1, dqcoeff_ptr + n_coeffs + 8);
     412             :         } else {
     413             :           // Maybe a more efficient way to store 0?
     414           0 :           store_zero_tran_low(qcoeff_ptr + n_coeffs);
     415           0 :           store_zero_tran_low(qcoeff_ptr + n_coeffs + 8);
     416             : 
     417           0 :           store_zero_tran_low(dqcoeff_ptr + n_coeffs);
     418           0 :           store_zero_tran_low(dqcoeff_ptr + n_coeffs + 8);
     419             :         }
     420             :       }
     421             : 
     422           0 :       if (nzflag) {
     423             :         // Scan for eob
     424             :         __m128i zero_coeff0, zero_coeff1;
     425             :         __m128i nzero_coeff0, nzero_coeff1;
     426             :         __m128i iscan0, iscan1;
     427             :         __m128i eob0, eob1;
     428           0 :         zero_coeff0 = _mm_cmpeq_epi16(coeff0, zero);
     429           0 :         zero_coeff1 = _mm_cmpeq_epi16(coeff1, zero);
     430           0 :         nzero_coeff0 = _mm_cmpeq_epi16(zero_coeff0, zero);
     431           0 :         nzero_coeff1 = _mm_cmpeq_epi16(zero_coeff1, zero);
     432           0 :         iscan0 = _mm_load_si128((const __m128i *)(iscan_ptr + n_coeffs));
     433           0 :         iscan1 = _mm_load_si128((const __m128i *)(iscan_ptr + n_coeffs) + 1);
     434             :         // Add one to convert from indices to counts
     435           0 :         iscan0 = _mm_sub_epi16(iscan0, nzero_coeff0);
     436           0 :         iscan1 = _mm_sub_epi16(iscan1, nzero_coeff1);
     437           0 :         eob0 = _mm_and_si128(iscan0, nzero_coeff0);
     438           0 :         eob1 = _mm_and_si128(iscan1, nzero_coeff1);
     439           0 :         eob0 = _mm_max_epi16(eob0, eob1);
     440           0 :         eob = _mm_max_epi16(eob, eob0);
     441             :       }
     442           0 :       n_coeffs += 8 * 2;
     443           0 :       index += 2;
     444             :     }
     445             : 
     446             :     // Accumulate EOB
     447             :     {
     448             :       __m128i eob_shuffled;
     449           0 :       eob_shuffled = _mm_shuffle_epi32(eob, 0xe);
     450           0 :       eob = _mm_max_epi16(eob, eob_shuffled);
     451           0 :       eob_shuffled = _mm_shufflelo_epi16(eob, 0xe);
     452           0 :       eob = _mm_max_epi16(eob, eob_shuffled);
     453           0 :       eob_shuffled = _mm_shufflelo_epi16(eob, 0x1);
     454           0 :       eob = _mm_max_epi16(eob, eob_shuffled);
     455           0 :       *eob_ptr = _mm_extract_epi16(eob, 1);
     456             :     }
     457             :   } else {
     458             :     do {
     459           0 :       store_zero_tran_low(dqcoeff_ptr + n_coeffs);
     460           0 :       store_zero_tran_low(dqcoeff_ptr + n_coeffs + 8);
     461           0 :       store_zero_tran_low(qcoeff_ptr + n_coeffs);
     462           0 :       store_zero_tran_low(qcoeff_ptr + n_coeffs + 8);
     463           0 :       n_coeffs += 8 * 2;
     464           0 :     } while (n_coeffs < 0);
     465           0 :     *eob_ptr = 0;
     466             :   }
     467           0 : }

Generated by: LCOV version 1.13