include common include primitives include xmmintrin SSE include smmint

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "common.h"
#include "primitives.h"
#include <xmmintrin.h> // SSE
#include <smmintrin.h> // SSE4.1
using namespace x265;
namespace {
void dequant_scaling(const int16_t* quantCoef, const int32_t *deQuantCoef, int16_t* coef, int num, int per, int shift)
{
X265_CHECK(num <= 32 * 32, "dequant num too large\n");
int valueToAdd;
shift += 4;
if (shift > per)
{
valueToAdd = 1 << (shift - per - 1);
__m128i IAdd = _mm_set1_epi32(valueToAdd);
for (int n = 0; n < num; n = n + 8)
{
__m128i quantCoef1, quantCoef2, deQuantCoef1, deQuantCoef2, quantCoef12, sign;
quantCoef12 = _mm_loadu_si128((__m128i*)(quantCoef + n));
deQuantCoef1 = _mm_loadu_si128((__m128i*)(deQuantCoef + n));
deQuantCoef2 = _mm_loadu_si128((__m128i*)(deQuantCoef + n + 4));
sign = _mm_srai_epi16(quantCoef12, 15);
quantCoef1 = _mm_unpacklo_epi16(quantCoef12, sign);
quantCoef2 = _mm_unpackhi_epi16(quantCoef12, sign);
quantCoef1 = _mm_sra_epi32(_mm_add_epi32(_mm_mullo_epi32(quantCoef1, deQuantCoef1), IAdd), _mm_cvtsi32_si128(shift - per));
quantCoef2 = _mm_sra_epi32(_mm_add_epi32(_mm_mullo_epi32(quantCoef2, deQuantCoef2), IAdd), _mm_cvtsi32_si128(shift - per));
quantCoef12 = _mm_packs_epi32(quantCoef1, quantCoef2);
_mm_storeu_si128((__m128i*)(coef + n), quantCoef12);
}
}
else
{
for (int n = 0; n < num; n = n + 8)
{
__m128i quantCoef1, quantCoef2, deQuantCoef1, deQuantCoef2, quantCoef12, sign;
quantCoef12 = _mm_loadu_si128((__m128i*)(quantCoef + n));
deQuantCoef1 = _mm_loadu_si128((__m128i*)(deQuantCoef + n));
deQuantCoef2 = _mm_loadu_si128((__m128i*)(deQuantCoef + n + 4));
sign = _mm_srai_epi16(quantCoef12, 15);
quantCoef1 = _mm_unpacklo_epi16(quantCoef12, sign);
quantCoef2 = _mm_unpackhi_epi16(quantCoef12, sign);
quantCoef1 = _mm_mullo_epi32(quantCoef1, deQuantCoef1);
quantCoef2 = _mm_mullo_epi32(quantCoef2, deQuantCoef2);
quantCoef12 = _mm_packs_epi32(quantCoef1, quantCoef2);
sign = _mm_srai_epi16(quantCoef12, 15);
quantCoef1 = _mm_unpacklo_epi16(quantCoef12, sign);
quantCoef2 = _mm_unpackhi_epi16(quantCoef12, sign);
quantCoef1 = _mm_sll_epi32(quantCoef1, _mm_cvtsi32_si128(per - shift));
quantCoef2 = _mm_sll_epi32(quantCoef2, _mm_cvtsi32_si128(per - shift));
quantCoef12 = _mm_packs_epi32(quantCoef1, quantCoef2);
_mm_storeu_si128((__m128i*)(coef + n), quantCoef12);
}
}
}
}
namespace x265 {
void setupIntrinsicDCT_sse41(EncoderPrimitives &p)
{
p.dequant_scaling = dequant_scaling;
}
}
~