VXLIB User Guide
VXLIB_debugPrint3DVReg.cpp
Go to the documentation of this file.
1 /******************************************************************************/
2 /* Copyright (C) 2015 Texas Instruments Incorporated - https://www.ti.com/
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  ******************************************************************************/
33 
34 /*******************************************************************************
35  *
36  * INCLUDES
37  *
38  ******************************************************************************/
39 
40 #include "../VXLIB_bufParams.h"
41 #include "../VXLIB_types.h"
42 
43 /******************************************************************************/
44 
45 template <typename dataType> void VXLIB_debugPrint3DVReg_helper(dataType *matrix, const VXLIB_bufParams3D_t *params)
46 {
47  uint32_t r, c, t;
48  dataType *xPtr;
49  dataType *yPtr;
50  dataType *zPtr = matrix;
51 
52  // stride_y is stored in bytes, but easier to use in elements
53  uint32_t stride_y_elements = params->stride_y / VXLIB_sizeof(params->data_type);
54  uint32_t stride_z_elements = params->stride_z / VXLIB_sizeof(params->data_type);
55 
56  VXLIB_PRINTF("%s", "{\n");
57  for (t = 0; t < params->dim_z; t++) {
58  yPtr = zPtr;
59  for (r = 0; r < params->dim_y; r++) {
60  xPtr = yPtr;
61  for (c = 0; c < params->dim_x; c++) {
62  VXLIB_PRINTF("%3d, ", *(xPtr));
63  xPtr++;
64  }
65  VXLIB_PRINTF("%s", "\n");
66  yPtr += stride_y_elements;
67  }
68  zPtr += stride_z_elements;
69  }
70  VXLIB_PRINTF("%s", "};\n");
71  return;
72 }
73 
74 template void VXLIB_debugPrint3DVReg_helper<int8_t>(int8_t *matrix, const VXLIB_bufParams3D_t *params);
75 template void VXLIB_debugPrint3DVReg_helper<int16_t>(int16_t *matrix, const VXLIB_bufParams3D_t *params);
76 template void VXLIB_debugPrint3DVReg_helper<uint16_t>(uint16_t *matrix, const VXLIB_bufParams3D_t *params);
77 template void VXLIB_debugPrint3DVReg_helper<int32_t>(int32_t *matrix, const VXLIB_bufParams3D_t *params);
78 
79 /******************************************************************************/
80 
81 // want this function to have C-linkage in library...
82 #ifdef __cplusplus
83 extern "C" {
84 #endif /* __cplusplus */
85 
86 void VXLIB_debugPrint3DVReg(void *matrix, const VXLIB_bufParams3D_t *params)
87 {
88  switch (params->data_type) {
89  case VXLIB_INT32:
90  VXLIB_debugPrint3DVReg_helper<int32_t>((int32_t *) matrix, params);
91  break;
92  case VXLIB_INT16:
93  VXLIB_debugPrint3DVReg_helper<int16_t>((int16_t *) matrix, params);
94  break;
95  case VXLIB_UINT16:
96  VXLIB_debugPrint3DVReg_helper<uint16_t>((uint16_t *) matrix, params);
97  break;
98  case VXLIB_INT8:
99  VXLIB_debugPrint3DVReg_helper<int8_t>((int8_t *) matrix, params);
100  break;
101  default:
102  VXLIB_PRINTF("\nERROR: Unrecognized data type in %s.\n", __FUNCTION__);
103  }
104 
105  return;
106 }
107 #ifdef __cplusplus
108 }
109 #endif /* __cplusplus */
template void VXLIB_debugPrint3DVReg_helper< uint16_t >(uint16_t *matrix, const VXLIB_bufParams3D_t *params)
void VXLIB_debugPrint3DVReg(void *matrix, const VXLIB_bufParams3D_t *params)
template void VXLIB_debugPrint3DVReg_helper< int32_t >(int32_t *matrix, const VXLIB_bufParams3D_t *params)
void VXLIB_debugPrint3DVReg_helper(dataType *matrix, const VXLIB_bufParams3D_t *params)
template void VXLIB_debugPrint3DVReg_helper< int16_t >(int16_t *matrix, const VXLIB_bufParams3D_t *params)
template void VXLIB_debugPrint3DVReg_helper< int8_t >(int8_t *matrix, const VXLIB_bufParams3D_t *params)
#define VXLIB_PRINTF(fmt,...)
Definition: VXLIB_types.h:95
static int32_t VXLIB_sizeof(uint32_t type)
Inline function returns number of bytes per element given a type of VXLIB_data_type_e.
@ VXLIB_UINT16
@ VXLIB_INT32
@ VXLIB_INT16
@ VXLIB_INT8
A structure for a 3 dimensional buffer descriptor.
int32_t stride_z
Stride in Z dimension in bytes.
int32_t stride_y
Stride in Y dimension in bytes.
uint32_t dim_z
Depth of patch in Z dimension in elements.
uint32_t dim_y
Height of buffer in Y dimension in elements.
uint32_t dim_x
Width of buffer in X dimension in elements.
uint32_t data_type
Values are of type VXLIB_data_type_e.