Skip to content

Commit

Permalink
RawImageDataU16::scaleValues_SSE2(): port to Array2DRef
Browse files Browse the repository at this point in the history
  • Loading branch information
LebedevRI committed Oct 19, 2022
1 parent 96a39e3 commit 990cec7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/librawspeed/common/RawImageDataU16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ void RawImageDataU16::scaleValues_SSE2(int start_y, int end_y) {
}
rand_mask = _mm_set1_epi32(0x00ff00ff); // 8 random bits

Array2DRef<uint16_t> out(getU16DataAsUncroppedArray2DRef());

for (int y = start_y; y < end_y; y++) {
__m128i sserandom;
if (mDitherScale) {
Expand All @@ -268,7 +270,6 @@ void RawImageDataU16::scaleValues_SSE2(int start_y, int end_y) {
} else {
sserandom = _mm_setzero_si128();
}
auto* pixel = reinterpret_cast<__m128i*>(&data[(mOffset.y + y) * pitch]);
__m128i ssescale;
__m128i ssesub;
if (((y + mOffset.y) & 1) == 0) {
Expand All @@ -283,8 +284,8 @@ void RawImageDataU16::scaleValues_SSE2(int start_y, int end_y) {
x += 8) {
__m128i pix_high;
__m128i temp;
_mm_prefetch(reinterpret_cast<char*>(pixel + 1), _MM_HINT_T0);
__m128i pix_low = _mm_load_si128(pixel);
__m128i pix_low =
_mm_load_si128(reinterpret_cast<__m128i*>(&out(mOffset.y + y, x)));
// Subtract black
pix_low = _mm_subs_epu16(pix_low, ssesub);
// Multiply the two unsigned shorts and combine it to 32 bit result
Expand Down Expand Up @@ -321,8 +322,8 @@ void RawImageDataU16::scaleValues_SSE2(int start_y, int end_y) {
pix_low = _mm_packs_epi32(pix_low, pix_high);
// Shift sign off
pix_low = _mm_xor_si128(pix_low, ssesign);
_mm_store_si128(pixel, pix_low);
pixel++;
_mm_store_si128(reinterpret_cast<__m128i*>(&out(mOffset.y + y, x)),
pix_low);
}
}
alignedFree(sub_mul);
Expand Down

0 comments on commit 990cec7

Please sign in to comment.