Advertisement
Guest User

Untitled

a guest
Nov 18th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.70 KB | None | 0 0
  1. C code :
  2. static void FUNC(put_hevc_qpel_pixels)(int16_t *dst, ptrdiff_t dststride,
  3.                                        uint8_t *_src, ptrdiff_t _srcstride,
  4.                                        int width, int height, int16_t* mcbuffer)
  5. {
  6.     int x, y;
  7.     pixel *src          = (pixel *)_src;
  8.     ptrdiff_t srcstride = _srcstride / sizeof(pixel);
  9.  
  10.     for (y = 0; y < height; y++) {
  11.         for (x = 0; x < width; x++)
  12.             dst[x] = src[x] << (14 - BIT_DEPTH);
  13.         src += srcstride;
  14.         dst += dststride;
  15.     }
  16. }
  17.  
  18. intrinsics :
  19.  
  20. void ff_hevc_put_hevc_qpel_pixels_8_sse(int16_t *dst, ptrdiff_t dststride,
  21.         uint8_t *_src, ptrdiff_t _srcstride, int width, int height,
  22.         int16_t* mcbuffer) {
  23.     int x, y;
  24.     __m128i x1, x2, x3, x0, x4;
  25.     uint8_t *src = (uint8_t*) _src;
  26.     ptrdiff_t srcstride = _srcstride;
  27.     x0= _mm_setzero_si128();
  28.     if(!(width & 15)){
  29.         for (y = 0; y < height; y++) {
  30.             for (x = 0; x < width; x += 16) {
  31.  
  32.                 x1 = _mm_loadu_si128((__m128i *) &src[x]);
  33.                 x2 = _mm_unpacklo_epi8(x1, x0);
  34.  
  35.                 x3 = _mm_unpackhi_epi8(x1, x0);
  36.  
  37.                 x2 = _mm_slli_epi16(x2, 6);
  38.                 x3 = _mm_slli_epi16(x3, 6);
  39.                 _mm_storeu_si128((__m128i *) &dst[x], x2);
  40.                 _mm_storeu_si128((__m128i *) &dst[x + 8], x3);
  41.  
  42.             }
  43.             src += srcstride;
  44.             dst += dststride;
  45.         }
  46.     }else if(!(width & 7)){
  47.         for (y = 0; y < height; y++) {
  48.             for (x = 0; x < width; x += 8) {
  49.  
  50.                 x1 = _mm_loadl_epi64((__m128i *) &src[x]);
  51.                 x2 = _mm_unpacklo_epi8(x1, x0);
  52.                 x2 = _mm_slli_epi16(x2, 6);
  53.                 _mm_storeu_si128((__m128i *) &dst[x], x2);
  54.  
  55.             }
  56.             src += srcstride;
  57.             dst += dststride;
  58.         }
  59.     }else if(!(width & 3)){
  60.         for (y = 0; y < height; y++) {
  61.             for(x=0;x<width;x+=4){
  62.                 x1 = _mm_loadu_si128((__m128i *) &src[x]);
  63.                 x2 = _mm_unpacklo_epi8(x1, x0);
  64.                 x2 = _mm_slli_epi16(x2, 6);
  65.                 _mm_storel_epi64((__m128i *) &dst[x], x2);
  66.             }
  67.             src += srcstride;
  68.             dst += dststride;
  69.         }
  70.     }else{
  71.         x4= _mm_set_epi32(0,0,0,-1); //mask to store
  72.         for (y = 0; y < height; y++) {
  73.             for(x=0;x<width;x+=2){
  74.                 x1 = _mm_loadl_epi64((__m128i *) &src[x]);
  75.                 x2 = _mm_unpacklo_epi8(x1, x0);
  76.                 x2 = _mm_slli_epi16(x2, 6);
  77.                 _mm_maskmoveu_si128(x2,x4,(char *) (dst+x));
  78.             }
  79.             src += srcstride;
  80.             dst += dststride;
  81.         }
  82.     }
  83.  
  84.  
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement