Debian Codegraph @

cvd_src/NEON/half_sample.cc

raw symbols SCIP
1 #include "cvd/vision.h"
2
3 #include <arm_neon.h>
4
5 namespace CVD
6 {
7 namespace Internal
8 {
9
10 void halfSampleNEON(const BasicImage<byte>& in, BasicImage<byte>& out)
11 {
12 for(int y = 0; y < in.size().y; y += 2)
13 {
14 const byte* in_top = in[y];
15 const byte* in_bottom = in[y + 1];
16 byte* out_data = out[y >> 1];
17 for(int x = in.size().x; x > 0; x -= 16, in_top += 16, in_bottom += 16, out_data += 8)
18 {
19 uint8x8x2_t top = vld2_u8((const uint8_t*)in_top);
20 uint8x8x2_t bottom = vld2_u8((const uint8_t*)in_bottom);
21 uint16x8_t sum = vaddl_u8(top.val[0], top.val[1]);
22 sum = vaddw_u8(sum, bottom.val[0]);
23 sum = vaddw_u8(sum, bottom.val[1]);
24 uint8x8_t final_sum = vshrn_n_u16(sum, 2);
25 vst1_u8(out_data, final_sum);
26 }
27 }
28 }
29 }
30
31 void halfSample(const BasicImage<byte>& in, BasicImage<byte>& out)
32 {
33 if((in.size() / 2) != out.size())
34 throw Exceptions::Vision::IncompatibleImageSizes("halfSample");
35
36 if((in.size().x % 16) == 0)
37 Internal::halfSampleNEON(in, out);
38 else
39 halfSample<byte>(in, out);
40 }
41 }