1 /******************************************************************************
2 *
3 * Copyright (C) 2018 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *****************************************************************************
18 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19 */
20
21 /**
22 ******************************************************************************
23 * @file ihevce_trace.c
24 *
25 * @brief
26 * This file contains function definitions for implementing trace
27 *
28 * @author
29 * Ittiam
30 *
31 * List of Functions
32 * ihevce_trace_deinit()
33 * ihevce_trace_init()
34 *
35 ******************************************************************************
36 */
37
38 /*****************************************************************************/
39 /* File Includes */
40 /*****************************************************************************/
41 /* System include files */
42 #include <stdio.h>
43 #include <string.h>
44 #include <stdlib.h>
45 #include <assert.h>
46 #include <stdarg.h>
47 #include <math.h>
48
49 /* User include files */
50 #include "ihevc_typedefs.h"
51 #include "ihevc_debug.h"
52 #include "ihevc_defs.h"
53 #include "ihevc_macros.h"
54 #include "ihevc_structs.h"
55 #include "ihevc_platform_macros.h"
56 #include "ihevc_cabac_tables.h"
57 #include "itt_video_api.h"
58 #include "ihevce_api.h"
59 #include "ihevce_defs.h"
60 #include "ihevce_buffer_que_interface.h"
61 #include "ihevce_hle_interface.h"
62
63 #include "ihevce_error_codes.h"
64 #include "ihevce_bitstream.h"
65 #include "ihevce_trace.h"
66
67 /*****************************************************************************/
68 /* Global Variable Definitions */
69 /*****************************************************************************/
70
71 /* Table of Prefix names, one for each bit of the debug_id mask */
72 /* bits 12 - 16 are used inly to indicate the layer id */
73 /* add null strings to those locations */
74 // clang-format off
75 const char *g_api1_prefix_name[32] =
76 {
77 SEQ_LEVEL, /* TRACE_SEQ = 0x00000001, !< sequence params dump enable */
78 PIC_LEVEL, /* TRACE_PIC = 0x00000002, !< picparams dump enable */
79 SLICE_LEVEL, /* TRACE_SLICE = 0x00000004, !< slice params dump enable */
80 MB_LEVEL, /* TRACE_MB_PARAMS = 0x00000008, !< mb level decoded dump enable */
81 MB_LEVEL, /* TRACE_MB_INF_PARAMS = 0x00000010, !< mb level inferred dumping enable */
82 ECD_DATA, /* TRACE_ECD_DATA = 0x00000020, !< ECD data dump */
83 LYR_COEFF_LEVEL, /* TRACE_LYR_COEFF_LEVEL = 0x00000040, !< Current layer coeff levels */
84 ACC_COEFF_LEVEL, /* TRACE_ACC_COEFF_LEVEL = 0x00000080, !< Accumulated coffs/level */
85 ACC_COEFFS, /* TRACE_ACC_COEFFS = 0x00000100, !< Accumulated coeffs */
86 LYR_DIFF_SIG, /* TRACE_LYR_DIFF_SIG = 0x00000200, !< layer level differential signal */
87 LYR_IP_SIG, /* TRACE_LYR_IP_SIG = 0x00000400, !< layer level Intra pred signal */
88 MB_LEVEL, /* TRACE_INTRA_UPSMPL_SIG= 0x00000800, !< Intra upsampled data */
89 MB_LEVEL, /* TRACE_RES_UPSMPL_SIG = 0x00001000, !< Residual upsampled data */
90 MB_LEVEL, /* TRACE_BS_INFO = 0x00002000, !< BS information */
91 DUMMY, /* 0x00004000 */
92 DUMMY, /* 0x00008000 */
93 DUMMY, /* 0x00010000 */
94 DUMMY, /* 0x00020000 */
95 DUMMY, /* 0x00040000 */
96 DUMMY, /* 0x00080000 */
97 RES_CHANGE_SIG, /* TRACE_RES_CGE_MV = 0x00100000, !< Res change Motion vectors */
98 RES_CHANGE_SIG, /* TRACE_RES_CGE_MODE = 0x00200000, !< Res change MB modes */
99 RES_CHANGE_SIG, /* TRACE_RES_CGE_DATA = 0x00400000, !< Res change data */
100 TARGET_MC, /* TRACE_TGT_MC_PRED = 0x00800000, !< moiton comp pred sugnal dump enable */
101 DUMMY, /* 0x01000000 */
102 DUMMY, /* 0x02000000 */
103 DUMMY, /* 0x04000000 */
104 TARGET_DEBLK, /* TRACE_TGT_LYR_DEBLK = 0x08000000, !< Input to target layer deblocking */
105 REF_BASE_DEBLK, /* TRACE_REF_BASE_DEBLK = 0x10000000, !< deblocked data dumping enable */
106 DUMMY, /* 0x20000000 */
107 DUMMY, /* 0x40000000 */
108 DUMMY /* 0x80000000 */
109 };
110 // clang-format on
111
112 /*****************************************************************************/
113 /* Function Definitions */
114 /*****************************************************************************/
115
116 /**
117 ******************************************************************************
118 *
119 * @brief Dummar trace init when trace is disabled in encoder
120 *
121 * @par Description
122 * This routine needs to be called at start of trace
123 *
124 * @param[in] pu1_file_name
125 * Name of file where trace outputs need to be stores (handle)
126 *
127 * @return success or failure error code
128 *
129 ******************************************************************************
130 */
ihevce_trace_init(UWORD8 * pu1_file_name)131 WORD32 ihevce_trace_init(UWORD8 *pu1_file_name)
132 {
133 (void)pu1_file_name;
134 return IHEVCE_SUCCESS;
135 }
136
137 /**
138 ******************************************************************************
139 *
140 * @brief Dummar trace de-init function when trace is disabled
141 *
142 * @par Description
143 * This routine needs to be called at end of trace
144 *
145 * @return success or failure error code
146 *
147 ******************************************************************************
148 */
ihevce_trace_deinit(void)149 WORD32 ihevce_trace_deinit(void)
150 {
151 return IHEVCE_SUCCESS;
152 }
153
154 /** \brief This function return the bit position set of the input */
svcd_trace_get_bit_pos(UWORD32 u4_input)155 WORD32 svcd_trace_get_bit_pos(UWORD32 u4_input)
156 {
157 /* local variables */
158 WORD32 i4_bit_pos;
159
160 i4_bit_pos = -1;
161
162 /* only a single bit of 32 bits should to be set */
163 assert(0 == (u4_input & (u4_input - 1)));
164
165 /* loop to get the bit position of the prefix */
166 while(0 != u4_input)
167 {
168 u4_input >>= 1;
169 i4_bit_pos++;
170 } /* end of while loop */
171
172 /* check on validity of the bit position */
173 assert((31 >= i4_bit_pos) && (0 <= i4_bit_pos));
174
175 return (i4_bit_pos);
176 }
177
178 /** \brief This function does the parameter dumping for trace info */
179
ihevce_trace(UWORD32 u4_prefix)180 WORD32 ihevce_trace(UWORD32 u4_prefix)
181 {
182 WORD32 i4_array_indx;
183
184 /* get the bit position of the prefix */
185 i4_array_indx = svcd_trace_get_bit_pos(u4_prefix);
186 return i4_array_indx;
187 }
188