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