libcvd-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libcvd-members] libcvd/cvd_src/NEON half_sample.cc


From: Gerhard Reitmayr
Subject: [libcvd-members] libcvd/cvd_src/NEON half_sample.cc
Date: Wed, 11 May 2011 14:31:57 +0000

CVSROOT:        /cvsroot/libcvd
Module name:    libcvd
Changes by:     Gerhard Reitmayr <gerhard>      11/05/11 14:31:57

Added files:
        cvd_src/NEON   : half_sample.cc 

Log message:
        NEON halfSample implementation

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/NEON/half_sample.cc?cvsroot=libcvd&rev=1.1

Patches:
Index: half_sample.cc
===================================================================
RCS file: half_sample.cc
diff -N half_sample.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ half_sample.cc      11 May 2011 14:31:56 -0000      1.1
@@ -0,0 +1,37 @@
+#include "cvd/vision.h"
+
+#include <arm_neon.h>
+
+namespace CVD
+{
+       namespace Internal{
+                               
+               void halfSampleNEON( const SubImage<byte> & in, SubImage<byte> 
& out ){
+                       for( int y = 0; y < in.size().y; y += 2){
+                               const byte * in_top = in[y];
+                               const byte * in_bottom = in[y+1];
+                               byte * out_data = out[y >> 1];
+                               for( int x = in.size().x; x > 0 ; x-=16, in_top 
+= 16, in_bottom += 16, out_data += 8){
+                                       uint8x8x2_t top  = vld2_u8((const 
uint8_t *)in_top);
+                                       uint8x8x2_t bottom = vld2_u8((const 
uint8_t *)in_bottom);
+                                       uint16x8_t sum = vaddl_u8( top.val[0], 
top.val[1]); 
+                                       sum = vaddw_u8( sum, bottom.val[0] ); 
+                                       sum = vaddw_u8( sum, bottom.val[1] ); 
+                                       uint8x8_t final_sum = vshrn_n_u16(sum, 
2);
+                                       vst1_u8(out_data, final_sum);
+                               }
+                       }
+               }
+       }
+
+       void halfSample(const BasicImage<byte>& in, BasicImage<byte>& out)
+       {   
+               if( (in.size()/2) != out.size())
+                       throw 
Exceptions::Vision::IncompatibleImageSizes("halfSample");
+
+               if ((in.size().x % 16) == 0)
+                       Internal::halfSampleNEON(in, out);
+               else
+                       halfSample<byte>(in, out);
+       }
+}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]