/*==========================================================================*/ /* Copyright (C) 2009-2013 Texas Instruments Incorporated. */ /* All Rights Reserved */ /*==========================================================================*/ /*----------------------------------------------------------------------------*/ /* NAME: eve_array_add_uns_char */ /* */ /* */ /* DESCRIPTION: */ /* */ /* The function "eve_array_add_uns_char_ " takes two input arrays */ /* in1_ptr and in2_ptr, and adds the values in them writing it out to */ /* the output array "optr". The input and output arrays are 2D arrays */ /* of the form [width * height]. */ /* */ /* The function has the following prototype: */ /* */ /* void eve_array_add_uns_char_ */ /* ( */ /* __vptr_uint8 in1_ptr, // input 1 data pointer */ /* __vptr_uint8 in2_ptr, // input 2 data pointer */ /* __vptr_uint8 optr, // output data pointer */ /* Uint16 width, // width of each line */ /* Uint16 height // height of each line */ /* ) */ /* */ /* ASSUMPTIONS: */ /* */ /* This function does not expect any alignment restrictions on "in1_ptr" */ /* "in2_ptr" and "optr". It expects the width to be a multiple of 8, and */ /* can be as small as 8. */ /* */ /*----------------------------------------------------------------------------*/ /* Texas Instruments Incorporated 2010-2012. */ /*============================================================================*/ #define ELEMSZ sizeof(*in_ptr) #define VECTORSZ (VCOP_SIMD_WIDTH*ELEMSZ) void vcop_vec_gradients ( __vptr_uint8 in_ptr, __vptr_uint8 out_ptr, unsigned short width, unsigned short height ) { __vector VinT1,VinT2; //Top pixel __vector VinL1,VinL2; //Left pixel __vector VinR1,VinR2; //Right pixel __vector VinB1,VinB2; //Bottom pixel __vector VgX_1,VgX_2; //Gx __vector VgY_1,VgY_2; //Gy __vector Vabs_gX_1,Vabs_gX_2; //abs of Gx __vector Vabs_gY_1,Vabs_gY_2; //abs of Gy __vector Vmag1,Vmag2; //Mag for (int I1 = 0; I1 < height; I1++) { for (int I2 = 0; I2 < width/VCOP_SIMD_WIDTH; I2++) { __agen Addr; Addr = I1*width*ELEMSZ + I2*VECTORSZ; (VinT1,VinT2) = (in_ptr) [Addr].deinterleave(); (VinL1,VinL2) = (in_ptr+width) [Addr].deinterleave(); (VinR1,VinR2) = (in_ptr+width+2) [Addr].deinterleave(); (VinB1,VinB2) = (in_ptr+2*width+1)[Addr].deinterleave(); VgX_1 = VinR1 - VinL1; VgY_1 = VinB1 - VinT1; VgX_2 = VinR2 - VinL2; VgY_2 = VinB2 - VinT2; Vabs_gX_1 = abs(VgX_1); Vabs_gY_1 = abs(VgY_1); Vabs_gX_2 = abs(VgX_2); Vabs_gY_2 = abs(VgY_2); Vmag1 = 0; //Vabs_gX_1 + Vabs_gY_1; Vmag2 = 0;//Vabs_gX_2 + Vabs_gY_2; out_ptr[Addr].interleave() = (Vmag1,Vmag2).saturate(0,255); } } }