Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions impl/ocean/cv/FrameConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2635,9 +2635,9 @@ void FrameConverter::convertTwoRows_1Plane3Channels_To_1Plane1ChannelAnd1Plane2C

// let's handle the last two channels

const int16x8_t sourcePlaneAverage_0_s_16x8 = vreinterpretq_s16_u16(vrshrq_n_s16(vrhaddq_u16(sourcePlaneAverage_0_Upper_u_16x8, sourcePlaneAverage_0_Lower_u_16x8), 1));
const int16x8_t sourcePlaneAverage_1_s_16x8 = vreinterpretq_s16_u16(vrshrq_n_s16(vrhaddq_u16(sourcePlaneAverage_1_Upper_u_16x8, sourcePlaneAverage_1_Lower_u_16x8), 1));
const int16x8_t sourcePlaneAverage_2_s_16x8 = vreinterpretq_s16_u16(vrshrq_n_s16(vrhaddq_u16(sourcePlaneAverage_2_Upper_u_16x8, sourcePlaneAverage_2_Lower_u_16x8), 1));
const int16x8_t sourcePlaneAverage_0_s_16x8 = vreinterpretq_s16_u16(vrshrq_n_u16(vrhaddq_u16(sourcePlaneAverage_0_Upper_u_16x8, sourcePlaneAverage_0_Lower_u_16x8), 1));
const int16x8_t sourcePlaneAverage_1_s_16x8 = vreinterpretq_s16_u16(vrshrq_n_u16(vrhaddq_u16(sourcePlaneAverage_1_Upper_u_16x8, sourcePlaneAverage_1_Lower_u_16x8), 1));
const int16x8_t sourcePlaneAverage_2_s_16x8 = vreinterpretq_s16_u16(vrshrq_n_u16(vrhaddq_u16(sourcePlaneAverage_2_Upper_u_16x8, sourcePlaneAverage_2_Lower_u_16x8), 1));

int16x8_t intermediate_1_s_16x8 = vmlaq_n_s16(vmlaq_n_s16(vmulq_n_s16(sourcePlaneAverage_0_s_16x8, factorChannel10_128), sourcePlaneAverage_1_s_16x8, factorChannel11_128), sourcePlaneAverage_2_s_16x8, factorChannel12_128); // = channel0 * factor0 + channel1 * factor1 + channel2 * factor2
int16x8_t intermediate_2_s_16x8 = vmlaq_n_s16(vmlaq_n_s16(vmulq_n_s16(sourcePlaneAverage_0_s_16x8, factorChannel20_128), sourcePlaneAverage_1_s_16x8, factorChannel21_128), sourcePlaneAverage_2_s_16x8, factorChannel22_128);
Expand Down Expand Up @@ -2868,9 +2868,9 @@ void FrameConverter::convertTwoRows_1Plane3Channels_To_1Plane1ChannelAnd2Planes1

// let's handle the last two channels

const int16x8_t sourcePlaneAverage_0_s_16x8 = vreinterpretq_s16_u16(vrshrq_n_s16(vrhaddq_u16(sourcePlaneAverage_0_Upper_u_16x8, sourcePlaneAverage_0_Lower_u_16x8), 1));
const int16x8_t sourcePlaneAverage_1_s_16x8 = vreinterpretq_s16_u16(vrshrq_n_s16(vrhaddq_u16(sourcePlaneAverage_1_Upper_u_16x8, sourcePlaneAverage_1_Lower_u_16x8), 1));
const int16x8_t sourcePlaneAverage_2_s_16x8 = vreinterpretq_s16_u16(vrshrq_n_s16(vrhaddq_u16(sourcePlaneAverage_2_Upper_u_16x8, sourcePlaneAverage_2_Lower_u_16x8), 1));
const int16x8_t sourcePlaneAverage_0_s_16x8 = vreinterpretq_s16_u16(vrshrq_n_u16(vrhaddq_u16(sourcePlaneAverage_0_Upper_u_16x8, sourcePlaneAverage_0_Lower_u_16x8), 1));
const int16x8_t sourcePlaneAverage_1_s_16x8 = vreinterpretq_s16_u16(vrshrq_n_u16(vrhaddq_u16(sourcePlaneAverage_1_Upper_u_16x8, sourcePlaneAverage_1_Lower_u_16x8), 1));
const int16x8_t sourcePlaneAverage_2_s_16x8 = vreinterpretq_s16_u16(vrshrq_n_u16(vrhaddq_u16(sourcePlaneAverage_2_Upper_u_16x8, sourcePlaneAverage_2_Lower_u_16x8), 1));

int16x8_t intermediate_1_s_16x8 = vmlaq_n_s16(vmlaq_n_s16(vmulq_n_s16(sourcePlaneAverage_0_s_16x8, factorChannel10_128), sourcePlaneAverage_1_s_16x8, factorChannel11_128), sourcePlaneAverage_2_s_16x8, factorChannel12_128); // = channel0 * factor0 + channel1 * factor1 + channel2 * factor2
int16x8_t intermediate_2_s_16x8 = vmlaq_n_s16(vmlaq_n_s16(vmulq_n_s16(sourcePlaneAverage_0_s_16x8, factorChannel20_128), sourcePlaneAverage_1_s_16x8, factorChannel21_128), sourcePlaneAverage_2_s_16x8, factorChannel22_128);
Expand Down
14 changes: 7 additions & 7 deletions impl/ocean/cv/FrameConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -3536,24 +3536,24 @@ OCEAN_FORCE_INLINE void FrameConverter::unpack5ElementsBayerMosaicPacked10Bit(co
template <bool tAllowLastOverlappingElement>
OCEAN_FORCE_INLINE void FrameConverter::unpack15ElementsBayerMosaicPacked10BitNEON(const uint8_t* const packed, uint16x8_t& unpackedAB_u_16x8, uint16x4_t& unpackedC_u_16x4)
{
constexpr uint8x8_t shuffleC_u_8x8 = NEON::create_uint8x8(6u, 2u, 6u, 3u, 6u, 4u, 6u, 5u);
const uint8x8_t shuffleC_u_8x8 = NEON::create_uint8x8(6u, 2u, 6u, 3u, 6u, 4u, 6u, 5u);

constexpr int8x16_t leftShifts_s_8x16 = NEON::create_int8x16(6, 0, 4, 0, 2, 0, 0, 0, 6, 0, 4, 0, 2, 0, 0, 0);
constexpr int16x8_t rightShifts_s_16x8 = NEON::create_int16x8(-6, -6, -6, -6, -6, -6, -6, -6);
const int8x16_t leftShifts_s_8x16 = NEON::create_int8x16(6, 0, 4, 0, 2, 0, 0, 0, 6, 0, 4, 0, 2, 0, 0, 0);
const int16x8_t rightShifts_s_16x8 = NEON::create_int16x8(-6, -6, -6, -6, -6, -6, -6, -6);

const uint8x16_t packed_u_8x16 = tAllowLastOverlappingElement ? vld1q_u8(packed) : vcombine_u8(vld1_u8(packed), vext_u8(vld1_u8(packed + 7), shuffleC_u_8x8, 1)); // shuffleC_u_8x8 is just a dummy value

// F E D C B A 9 8 7 6 5 4 3 2 1 0
// 8 9 7 9 6 9 5 9 3 4 2 4 1 4 0 4

#ifdef __aarch64__
constexpr uint8x16_t shuffle_u_8x16 = NEON::create_uint8x16(4u, 0u, 4u, 1u, 4u, 2u, 4u, 3u, 9u, 5u, 9u, 6u, 9u, 7u, 9u, 8u);
const uint8x16_t shuffle_u_8x16 = NEON::create_uint8x16(4u, 0u, 4u, 1u, 4u, 2u, 4u, 3u, 9u, 5u, 9u, 6u, 9u, 7u, 9u, 8u);
const uint8x16_t intermediateAB_u_8x16 = vqtbl1q_u8(packed_u_8x16, shuffle_u_8x16);
#else
const uint8x8_t packedA_u_8x8 = vget_low_u8(packed_u_8x16);
const uint8x8_t packedB_u_8x8 = vget_low_u8(vextq_u8(packed_u_8x16, packed_u_8x16, 5));

constexpr uint8x8_t shuffleAB_u_8x8 = NEON::create_uint8x8(4u, 0u, 4u, 1u, 4u, 2u, 4u, 3u);
const uint8x8_t shuffleAB_u_8x8 = NEON::create_uint8x8(4u, 0u, 4u, 1u, 4u, 2u, 4u, 3u);
const uint8x16_t intermediateAB_u_8x16 = vcombine_u8(vtbl1_u8(packedA_u_8x8, shuffleAB_u_8x8), vtbl1_u8(packedB_u_8x8, shuffleAB_u_8x8));
#endif // __aarch64__

Expand All @@ -3567,14 +3567,14 @@ OCEAN_FORCE_INLINE void FrameConverter::unpack15ElementsBayerMosaicPacked10BitNE
// ... 99------ 33333333 44------ 22222222 44------ 11111111 44------ 00000000 44------
const uint16x8_t intermediateAB_u_16x8 = vreinterpretq_u16_u8(vshlq_u8(intermediateAB_u_8x16, leftShifts_s_8x16));

const uint16x4_t intermediateC_u_16x4 = vreinterpret_u16_u8(vshl_u8(intermediateC_u_8x8, vget_low_u8(leftShifts_s_8x16)));
const uint16x4_t intermediateC_u_16x4 = vreinterpret_u16_u8(vshl_u8(intermediateC_u_8x8, vget_low_s8(leftShifts_s_8x16)));


// ... 99------ 33333333 44------ 22222222 44------ 11111111 44------ 00000000 44------
// ... 55555599 ------33 33333344 ------22 22222244 ------11 11111144 ------00 00000044
unpackedAB_u_16x8 = vshlq_u16(intermediateAB_u_16x8, rightShifts_s_16x8);

unpackedC_u_16x4 = vshl_u16(intermediateC_u_16x4, vget_low_u8(rightShifts_s_16x8));
unpackedC_u_16x4 = vshl_u16(intermediateC_u_16x4, vget_low_s16(rightShifts_s_16x8));
}

#endif // OCEAN_HARDWARE_NEON_VERSION
Expand Down
34 changes: 17 additions & 17 deletions impl/ocean/cv/FrameConverterY10_Packed.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ OCEAN_FORCE_INLINE void FrameConverterY10_Packed::convert16PixelY10_PackedToY8Li

// F E D C B A 9 8 7 6 5 4 3 2 1 0
// D C B A 8 7 6 5 3 2 1 0 X X X X
constexpr uint8x16_t shuffle_u_8x16 = NEON::create_uint8x16(16u, 16u, 16u, 16u, 0u, 1u, 2u, 3u, 5u, 6u, 7u, 8u, 10u, 11u, 12u, 13u);
const uint8x16_t shuffle_u_8x16 = NEON::create_uint8x16(16u, 16u, 16u, 16u, 0u, 1u, 2u, 3u, 5u, 6u, 7u, 8u, 10u, 11u, 12u, 13u);
const uint8x16_t intermediateA_u_8x16 = vqtbl1q_u8(packedA_u_8x16, shuffle_u_8x16);

const uint8x8_t intermediateB_u_8x8 = vext_u8(packedB_u_8x8, packedB_u_8x8, 3);
Expand All @@ -411,16 +411,16 @@ OCEAN_FORCE_INLINE void FrameConverterY10_Packed::convert16PixelY10_PackedToY8Li

#else

constexpr uint8x16_t mask_u_8x16 = NEON::create_uint8x16(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0xFFu, 0xFFu, 0xFFu);
const uint8x16_t mask_u_8x16 = NEON::create_uint8x16(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0xFFu, 0xFFu, 0xFFu);

const uint8x16_t packedA_u_8x16 = vld1q_u8(source);
const uint8x8_t packedB_u_8x8 = vld1_u8(source + 11);

const uint8x8_t packedAA_u_8x8 = vget_low_u8(packedA_u_8x16);
const uint8x8_t packedAB_u_8x8 = vget_high_u8(packedA_u_8x16);

constexpr uint8x8_t shuffleA_u_8x8 = NEON::create_uint8x8(8u, 0u, 1u, 2u, 3u, 5u, 6u, 7u);
constexpr uint8x8_t shuffleB_u_8x8 = NEON::create_uint8x8(0u, 2u, 3u, 4u, 5u, 7u, 8u, 8u);
const uint8x8_t shuffleA_u_8x8 = NEON::create_uint8x8(8u, 0u, 1u, 2u, 3u, 5u, 6u, 7u);
const uint8x8_t shuffleB_u_8x8 = NEON::create_uint8x8(0u, 2u, 3u, 4u, 5u, 7u, 8u, 8u);
const uint8x16_t intermediateA_u_8x16 = vextq_u8(vcombine_u8(vtbl1_u8(packedAA_u_8x8, shuffleA_u_8x8), vtbl1_u8(packedAB_u_8x8, shuffleB_u_8x8)), mask_u_8x16, 1); // we use the first zero element of mask_u_8x16

const uint8x16_t intermediateB_u_8x16 = vcombine_u8(vget_low_u8(mask_u_8x16), vand_u8(packedB_u_8x8, vget_high_u8(mask_u_8x16)));
Expand All @@ -437,8 +437,8 @@ OCEAN_FORCE_INLINE void FrameConverterY10_Packed::convert16PixelY10_PackedToY8Ap
{
static_assert(0u < tStep01 && tStep01 < tStep12 && tStep12 < 1023u, "Invalid steps");

constexpr int8x16_t leftShifts_s_8x16 = NEON::create_int8x16(6, 0, 4, 0, 2, 0, 0, 0, 6, 0, 4, 0, 2, 0, 0, 0);
constexpr int16x8_t rightShifts_s_16x8 = NEON::create_int16x8(-6, -6, -6, -6, -6, -6, -6, -6);
const int8x16_t leftShifts_s_8x16 = NEON::create_int8x16(6, 0, 4, 0, 2, 0, 0, 0, 6, 0, 4, 0, 2, 0, 0, 0);
const int16x8_t rightShifts_s_16x8 = NEON::create_int16x8(-6, -6, -6, -6, -6, -6, -6, -6);

#ifdef __aarch64__

Expand All @@ -447,17 +447,17 @@ OCEAN_FORCE_INLINE void FrameConverterY10_Packed::convert16PixelY10_PackedToY8Ap

// F E D C B A 9 8 7 6 5 4 3 2 1 0
// 8 9 7 9 6 9 5 9 3 4 2 4 1 4 0 4
constexpr uint8x16_t shuffleAB_u_8x16 = NEON::create_uint8x16(4u, 0u, 4u, 1u, 4u, 2u, 4u, 3u, 9u, 5u, 9u, 6u, 9u, 7u, 9u, 8u);
const uint8x16_t shuffleAB_u_8x16 = NEON::create_uint8x16(4u, 0u, 4u, 1u, 4u, 2u, 4u, 3u, 9u, 5u, 9u, 6u, 9u, 7u, 9u, 8u);
const uint8x16_t intermediateAB_u_8x16 = vqtbl1q_u8(packedAB_u_8x16, shuffleAB_u_8x16);

constexpr uint8x16_t shuffleCD_u_8x16 = NEON::create_uint8x16(10u, 6u, 10u, 7u, 10u, 8u, 10u, 9u, 15u, 11u, 15u, 12u, 15u, 13u, 15u, 14u);
const uint8x16_t shuffleCD_u_8x16 = NEON::create_uint8x16(10u, 6u, 10u, 7u, 10u, 8u, 10u, 9u, 15u, 11u, 15u, 12u, 15u, 13u, 15u, 14u);
const uint8x16_t intermediateCD_u_8x16 = vqtbl1q_u8(packedCD_u_8x16, shuffleCD_u_8x16);

#else

constexpr uint8x8_t shuffleAB_u_8x8 = NEON::create_uint8x8(4u, 0u, 4u, 1u, 4u, 2u, 4u, 3u);
constexpr uint8x8_t shuffleC_u_8x8 = NEON::create_uint8x8(6u, 2u, 6u, 3u, 6u, 4u, 6u, 5u);
constexpr uint8x8_t shuffleD_u_8x8 = NEON::create_uint8x8(7u, 3u, 7u, 4u, 7u, 5u, 7u, 6u);
const uint8x8_t shuffleAB_u_8x8 = NEON::create_uint8x8(4u, 0u, 4u, 1u, 4u, 2u, 4u, 3u);
const uint8x8_t shuffleC_u_8x8 = NEON::create_uint8x8(6u, 2u, 6u, 3u, 6u, 4u, 6u, 5u);
const uint8x8_t shuffleD_u_8x8 = NEON::create_uint8x8(7u, 3u, 7u, 4u, 7u, 5u, 7u, 6u);

const uint8x16_t packedAB_u_8x16 = vld1q_u8(source);
const uint8x8_t packedForD_u_8x8 = vld1_u8(source + 12);
Expand Down Expand Up @@ -490,8 +490,8 @@ OCEAN_FORCE_INLINE void FrameConverterY10_Packed::convert16PixelY10_PackedToY8Ap
// [step01, step12]: f_1(x) = m_1 * x + c_1
// [step21, 1 ]: f_2(x) = m_2 * x + c_2, with f_2(1) = 1

constexpr int16x8_t step01_s_16x8 = NEON::create_int16x8(int16_t(tStep01), int16_t(tStep01), int16_t(tStep01), int16_t(tStep01), int16_t(tStep01), int16_t(tStep01), int16_t(tStep01), int16_t(tStep01));
constexpr int16x8_t step12_s_16x8 = NEON::create_int16x8(int16_t(tStep12), int16_t(tStep12), int16_t(tStep12), int16_t(tStep12), int16_t(tStep12), int16_t(tStep12), int16_t(tStep12), int16_t(tStep12));
const int16x8_t step01_s_16x8 = NEON::create_int16x8(int16_t(tStep01), int16_t(tStep01), int16_t(tStep01), int16_t(tStep01), int16_t(tStep01), int16_t(tStep01), int16_t(tStep01), int16_t(tStep01));
const int16x8_t step12_s_16x8 = NEON::create_int16x8(int16_t(tStep12), int16_t(tStep12), int16_t(tStep12), int16_t(tStep12), int16_t(tStep12), int16_t(tStep12), int16_t(tStep12), int16_t(tStep12));

// determining masks to switch between one of the tree linear equations

Expand All @@ -506,10 +506,10 @@ OCEAN_FORCE_INLINE void FrameConverterY10_Packed::convert16PixelY10_PackedToY8Ap
const uint8x16_t isWithin1_u_8x16 = vmvnq_u8(vorrq_u8(isWithin0_u_8x16, isWithin2_u_8x16)); // unpacked > step01 && unpacked <= step02 ? 0xFFFFFFFF : 0x00000000


const int16x4_t unpackedA_s_16x4 = vreinterpret_s16_u16(vget_low_u8(unpackedAB_u_16x8));
const int16x4_t unpackedB_s_16x4 = vreinterpret_s16_u16(vget_high_u8(unpackedAB_u_16x8));
const int16x4_t unpackedC_s_16x4 = vreinterpret_s16_u16(vget_low_u8(unpackedCD_u_16x8));
const int16x4_t unpackedD_s_16x4 = vreinterpret_s16_u16(vget_high_u8(unpackedCD_u_16x8));
const int16x4_t unpackedA_s_16x4 = vreinterpret_s16_u16(vget_low_u16(unpackedAB_u_16x8));
const int16x4_t unpackedB_s_16x4 = vreinterpret_s16_u16(vget_high_u16(unpackedAB_u_16x8));
const int16x4_t unpackedC_s_16x4 = vreinterpret_s16_u16(vget_low_u16(unpackedCD_u_16x8));
const int16x4_t unpackedD_s_16x4 = vreinterpret_s16_u16(vget_high_u16(unpackedCD_u_16x8));

// result0 = (m0 * x) / 256)
const uint16x8_t resultAB0_u_16x8 = vcombine_u16(vqrshrun_n_s32(vmull_s16(m0_s_16x4, unpackedA_s_16x4), 8), vqrshrun_n_s32(vmull_s16(m0_s_16x4, unpackedB_s_16x4), 8));
Expand Down
Loading