How do I convert _m128i to an unsigned int with SSE?

前端 未结 2 2056
野趣味
野趣味 2021-02-10 05:41

I have made a function for posterizing images.

// =(
#define ARGB_COLOR(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))

inline UINT         


        
2条回答
  •  故里飘歌
    2021-02-10 06:25

    A combination of _mm_shuffle_epi8 and _mm_cvtsi128_si32 is what you need:

    static const __m128i shuffleMask = _mm_setr_epi8(0,  4,  8, 12, -1, -1, -1, -1,
                                                   -1, -1, -1, -1, -1, -1, -1, -1);
    UINT color = _mm_cvtsi128_si32(_mm_shuffle_epi8(iClr, shuffleMask));
    

提交回复
热议问题