DSPLIB User Guide
DSPLIB_debugPrintMatrix3D.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 #include "../DSPLIB_utility.h"
46 
47 template <typename dataType> void DSPLIB_debugPrintMatrix3D_helper(dataType *matrix, const DSPLIB_bufParams3D_t *params)
48 {
49  uint32_t x, y, z;
50  dataType *xPtr;
51  dataType *yPtr;
52  dataType *zPtr = matrix;
53 
54  // stride_y is stored in bytes, but easier to use in elements
55  uint32_t stride_y_elements = params->stride_y / DSPLIB_sizeof(params->data_type);
56  uint32_t stride_z_elements = params->stride_z / DSPLIB_sizeof(params->data_type);
57 
58  for (z = 0; z < params->dim_z; z++) {
59  DSPLIB_PRINTF("%s", "\n");
60  yPtr = zPtr;
61  for (y = 0; y < params->dim_y; y++) {
62  xPtr = yPtr;
63  DSPLIB_PRINTF("%p |", xPtr);
64  for (x = 0; x < params->dim_x; x++) {
65  DSPLIB_PRINTF("%3d ", *(xPtr));
66  xPtr++;
67  }
68  DSPLIB_PRINTF("%s", "|\n");
69  yPtr += stride_y_elements;
70  }
71  zPtr += stride_z_elements;
72  }
73 
74  return;
75 }
76 
77 template void DSPLIB_debugPrintMatrix3D_helper<int8_t>(int8_t *matrix, const DSPLIB_bufParams3D_t *params);
78 template void DSPLIB_debugPrintMatrix3D_helper<int16_t>(int16_t *matrix, const DSPLIB_bufParams3D_t *params);
79 template void DSPLIB_debugPrintMatrix3D_helper<int32_t>(int32_t *matrix, const DSPLIB_bufParams3D_t *params);
80 
81 template <typename dataType>
82 void DSPLIB_debugPrintMatrix3D_helperU(dataType *matrix, const DSPLIB_bufParams3D_t *params)
83 {
84  uint32_t x, y, z;
85  dataType *xPtr;
86  dataType *yPtr;
87  dataType *zPtr = matrix;
88 
89  // stride_y is stored in bytes, but easier to use in elements
90  uint32_t stride_y_elements = params->stride_y / DSPLIB_sizeof(params->data_type);
91  uint32_t stride_z_elements = params->stride_z / DSPLIB_sizeof(params->data_type);
92 
93  for (z = 0; z < params->dim_z; z++) {
94  DSPLIB_PRINTF("%s", "\n");
95  yPtr = zPtr;
96  for (y = 0; y < params->dim_y; y++) {
97  xPtr = yPtr;
98  DSPLIB_PRINTF("%p |", xPtr);
99  for (x = 0; x < params->dim_x; x++) {
100  DSPLIB_PRINTF("%3u ", *(xPtr));
101  xPtr++;
102  }
103  DSPLIB_PRINTF("%s", "|\n");
104  yPtr += stride_y_elements;
105  }
106  zPtr += stride_z_elements;
107  }
108 
109  return;
110 }
111 
112 template void DSPLIB_debugPrintMatrix3D_helper<uint8_t>(uint8_t *matrix, const DSPLIB_bufParams3D_t *params);
113 template void DSPLIB_debugPrintMatrix3D_helper<uint16_t>(uint16_t *matrix, const DSPLIB_bufParams3D_t *params);
114 
115 /******************************************************************************/
116 
117 /******************************************************************************/
124 /******************************************************************************/
125 
126 // want this function to have C-linkage in library...
127 #ifdef __cplusplus
128 extern "C" {
129 #endif /* __cplusplus */
130 
131 void DSPLIB_debugPrintMatrix3D(void *matrix, const DSPLIB_bufParams3D_t *params)
132 {
133  switch (params->data_type) {
134  case DSPLIB_INT32:
135  DSPLIB_debugPrintMatrix3D_helper<int32_t>((int32_t *) matrix, params);
136  break;
137  case DSPLIB_INT16:
138  DSPLIB_debugPrintMatrix3D_helper<int16_t>((int16_t *) matrix, params);
139  break;
140  case DSPLIB_UINT16:
141  DSPLIB_debugPrintMatrix3D_helperU<uint16_t>((uint16_t *) matrix, params);
142  break;
143  case DSPLIB_INT8:
144  DSPLIB_debugPrintMatrix3D_helper<int8_t>((int8_t *) matrix, params);
145  break;
146  case DSPLIB_UINT8:
147  DSPLIB_debugPrintMatrix3D_helperU<uint8_t>((uint8_t *) matrix, params);
148  break;
149  default:
150  DSPLIB_PRINTF("\nERROR: Unrecognized data type in %s.\n", __FUNCTION__);
151  }
152 
153  return;
154 }
155 #ifdef __cplusplus
156 }
157 #endif /* __cplusplus */
void DSPLIB_debugPrintMatrix3D_helperU(dataType *matrix, const DSPLIB_bufParams3D_t *params)
template void DSPLIB_debugPrintMatrix3D_helper< int32_t >(int32_t *matrix, const DSPLIB_bufParams3D_t *params)
template void DSPLIB_debugPrintMatrix3D_helper< uint16_t >(uint16_t *matrix, const DSPLIB_bufParams3D_t *params)
template void DSPLIB_debugPrintMatrix3D_helper< uint8_t >(uint8_t *matrix, const DSPLIB_bufParams3D_t *params)
template void DSPLIB_debugPrintMatrix3D_helper< int16_t >(int16_t *matrix, const DSPLIB_bufParams3D_t *params)
template void DSPLIB_debugPrintMatrix3D_helper< int8_t >(int8_t *matrix, const DSPLIB_bufParams3D_t *params)
void DSPLIB_debugPrintMatrix3D(void *matrix, const DSPLIB_bufParams3D_t *params)
void DSPLIB_debugPrintMatrix3D_helper(dataType *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_UINT8
@ 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.