27 unsigned char snoop[32];
28 bool dst_align =
Aligned(
reinterpret_cast<void*
>(snoop));
35 for (
int i = 0; i < 32; ++i) {
36 printf(
"DEBUG8 %d %u \n", i, snoop[i]);
40 unsigned int snoop[8];
41 bool dst_align =
Aligned(
reinterpret_cast<void*
>(snoop));
46 for (
int i = 0; i < 8; ++i) {
47 printf(
"DEBUG32 %d %u \n", i, snoop[i]);
53 bool dst_align =
Aligned(
reinterpret_cast<void*
>(snoop));
58 for (
int i = 0; i < 16; ++i) {
59 printf(
"DEBUG16 %d %u \n", i, snoop[i]);
68 yuv_m256[0] =
Load<true>(
reinterpret_cast<__m256i*
>(y));
69 yuv_m256[1] =
Load<true>(
reinterpret_cast<__m256i*
>(y) + 1);
70 yuv_m256[2] =
Load<true>(
reinterpret_cast<__m256i*
>(y) + 2);
71 yuv_m256[3] =
Load<true>(
reinterpret_cast<__m256i*
>(y) + 3);
73 yuv_m256[0] =
Load<false>(
reinterpret_cast<__m256i*
>(y));
74 yuv_m256[1] =
Load<false>(
reinterpret_cast<__m256i*
>(y) + 1);
75 yuv_m256[2] =
Load<false>(
reinterpret_cast<__m256i*
>(y) + 2);
76 yuv_m256[3] =
Load<false>(
reinterpret_cast<__m256i*
>(y) + 3);
79 *y0 = _mm256_or_si256(
80 _mm256_permute4x64_epi64(_mm256_shuffle_epi8(yuv_m256[0],
Y_SHUFFLE0), 0xD8),
81 _mm256_permute4x64_epi64(_mm256_shuffle_epi8(yuv_m256[1],
Y_SHUFFLE1), 0xD8));
82 *y1 = _mm256_or_si256(
83 _mm256_permute4x64_epi64(_mm256_shuffle_epi8(yuv_m256[2],
Y_SHUFFLE0), 0xD8),
84 _mm256_permute4x64_epi64(_mm256_shuffle_epi8(yuv_m256[3],
Y_SHUFFLE1), 0xD8));
86 *u0 = _mm256_permutevar8x32_epi32(
92 _mm256_shuffle_epi8(yuv_m256[3],
U_SHUFFLE3))),
94 *v0 = _mm256_permutevar8x32_epi32(
100 _mm256_shuffle_epi8(yuv_m256[3],
V_SHUFFLE3))),
110 Store<align>(
reinterpret_cast<__m256i*
>(rgb) + 0,
InterleaveBgr<0>(r0, g0, b0));
111 Store<align>(
reinterpret_cast<__m256i*
>(rgb) + 1,
InterleaveBgr<1>(r0, g0, b0));
112 Store<align>(
reinterpret_cast<__m256i*
>(rgb) + 2,
InterleaveBgr<2>(r0, g0, b0));
117 __m256i y0, y1, u0, v0;
119 yuv_separate_avx2<align>(yuv, &y0, &y1, &u0, &v0);
120 __m256i u0_u0 = _mm256_permute4x64_epi64(u0, 0xD8);
121 __m256i v0_v0 = _mm256_permute4x64_epi64(v0, 0xD8);
122 yuv2rgb_avx2<align>(y0, _mm256_unpacklo_epi8(u0_u0, u0_u0), _mm256_unpacklo_epi8(v0_v0, v0_v0), rgb);
124 y1, _mm256_unpackhi_epi8(u0_u0, u0_u0), _mm256_unpackhi_epi8(v0_v0, v0_v0), rgb + 3 *
sizeof(__m256i));
127void yuyv2rgb_avx(
unsigned char* YUV,
unsigned char* RGB,
int NumPixels) {
128 assert(NumPixels == (1920 * 1080));
130 uint8_t* yuv_offset = YUV;
131 uint8_t* rgb_offset = RGB;
133 for (
int i = 0; i < NumPixels; i = i + static_cast<int>(2 *
sizeof(__m256i)),
134 yuv_offset += 4 *
static_cast<int>(
sizeof(__m256i)),
135 rgb_offset += 6 *
static_cast<int>(
sizeof(__m256i))) {
136 yuv2rgb_avx2<true>(yuv_offset, rgb_offset);
139 for (
int i = 0; i < NumPixels; i = i + static_cast<int>(2 *
sizeof(__m256i)),
140 yuv_offset += 4 *
static_cast<int>(
sizeof(__m256i)),
141 rgb_offset += 6 *
static_cast<int>(
sizeof(__m256i))) {
142 yuv2rgb_avx2<false>(yuv_offset, rgb_offset);
void print_m256(__m256i a)
SIMD_INLINE __m256i YuvToRed(__m256i y, __m256i v)
SIMD_INLINE __m256i InterleaveBgr< 2 >(__m256i blue, __m256i green, __m256i red)
void print_m256_i16(const __m256i a)
void yuv2rgb_avx2(__m256i y0, __m256i u0, __m256i v0, uint8_t *rgb)
SIMD_INLINE void Store< true >(__m256i *p, __m256i a)
SIMD_INLINE __m256i YuvToBlue(__m256i y, __m256i u)
SIMD_INLINE __m256i Load< false >(const __m256i *p)
void print_m256_i32(const __m256i a)
SIMD_INLINE __m256i InterleaveBgr< 1 >(__m256i blue, __m256i green, __m256i red)
SIMD_INLINE void yuv_separate_avx2(uint8_t *y, __m256i *y0, __m256i *y1, __m256i *u0, __m256i *v0)
SIMD_INLINE __m256i YuvToGreen(__m256i y, __m256i u, __m256i v)
SIMD_INLINE __m256i InterleaveBgr< 0 >(__m256i blue, __m256i green, __m256i red)
SIMD_INLINE void Store< false >(__m256i *p, __m256i a)
void yuyv2rgb_avx(unsigned char *YUV, unsigned char *RGB, int NumPixels)
SIMD_INLINE __m256i Load< true >(const __m256i *p)
SIMD_INLINE bool Aligned(const void *ptr, size_t align=sizeof(__m256))