6#ifdef QT_COMPILER_SUPPORTS_SSSE3
12template<
int a,
int r,
int g,
int b>
13void convert_to_ARGB32_ssse3(
const QVideoFrame &frame, uchar *output)
15 FETCH_INFO_PACKED(frame)
16 MERGE_LOOPS(width, height, stride, 4)
17 quint32 *argb =
reinterpret_cast<quint32*>(output);
19#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
20 __m128i shuffleMask = _mm_set_epi8(12 + a, 12 + r, 12 + g, 12 + b,
21 8 + a, 8 + r, 8 + g, 8 + b,
22 4 + a, 4 + r, 4 + g, 4 + b,
23 0 + a, 0 + r, 0 + g, 0 + b);
25 __m128i shuffleMask = _mm_set_epi8(15 - a, 15 - r, 15 - g, 15 - b,
26 11 - a, 11 - r, 11 - g, 11 - b,
27 7 - a, 7 - r, 7 - g, 7 - b,
28 3 - a, 3 - r, 3 - g, 3 - b);
31 using Pixel =
const ArgbPixel<a, r, g, b>;
33 for (
int y = 0; y < height; ++y) {
34 const auto *pixel =
reinterpret_cast<
const Pixel *>(src);
37 QT_MEDIA_ALIGN(16, argb, x, width) {
38 *argb = pixel->convert();
43 for (; x < width - 7; x += 8) {
44 __m128i pixelData = _mm_loadu_si128(
reinterpret_cast<
const __m128i*>(pixel));
45 __m128i pixelData2 = _mm_loadu_si128(
reinterpret_cast<
const __m128i*>(pixel + 4));
47 pixelData = _mm_shuffle_epi8(pixelData, shuffleMask);
48 pixelData2 = _mm_shuffle_epi8(pixelData2, shuffleMask);
49 _mm_store_si128(
reinterpret_cast<__m128i*>(argb), pixelData);
50 _mm_store_si128(
reinterpret_cast<__m128i*>(argb + 4), pixelData2);
55 for (; x < width; ++x) {
56 *argb = pixel->convert();
67void QT_FASTCALL qt_convert_ARGB8888_to_ARGB32_ssse3(
const QVideoFrame &frame, uchar *output)
69 convert_to_ARGB32_ssse3<0, 1, 2, 3>(frame, output);
72void QT_FASTCALL qt_convert_ABGR8888_to_ARGB32_ssse3(
const QVideoFrame &frame, uchar *output)
74 convert_to_ARGB32_ssse3<0, 3, 2, 1>(frame, output);
77void QT_FASTCALL qt_convert_RGBA8888_to_ARGB32_ssse3(
const QVideoFrame &frame, uchar *output)
79 convert_to_ARGB32_ssse3<3, 0, 1, 2>(frame, output);
82void QT_FASTCALL qt_convert_BGRA8888_to_ARGB32_ssse3(
const QVideoFrame &frame, uchar *output)
84 convert_to_ARGB32_ssse3<3, 2, 1, 0>(frame, output);