Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. bool ASIO :: SSEFrom32To24(float *source,void* target,long frames)
  2. {
  3. PrepareSSEHelpBuffer(frames);
  4. unsigned long long jX1 = (unsigned long long )SSEHelpBufferPointerAligned16A1;
  5. if (jX1 % 16 || jX1 == 0)
  6. return false;
  7. unsigned long long jX2 = (unsigned long long )SSEHelpBufferPointerAligned16A2;
  8. if (jX2 % 16 || jX2 == 0)
  9. return false;
  10. memcpy(SSEHelpBufferPointerAligned16A1,source,frames*sizeof(float));
  11.  
  12. static const float L = (1 << 31);
  13. static const __m128 LI = {(float)L, (float)L, (float)L, (float)L};
  14.  
  15. __m128* floats = (__m128*)SSEHelpBufferPointerAligned16A1;
  16. __m128i* ints = (__m128i*)SSEHelpBufferPointerAligned16A2;
  17.  
  18. for(int i = 0 ; i < frames/4 ; i ++)
  19. ints[i] = _mm_cvtps_epi32(_mm_mul_ps(floats[i], LI));
  20.  
  21. for(int i = 0 ; i < frames ; i++)
  22. {
  23. memcpy(target + i*3,SSEHelpBufferPointerAligned16A2,3); // only the 3 lower bytes
  24. }
  25.  
  26. return true;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement