• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 hme_common_utils.h
24 *
25 * \brief
26 *    Common utility functions used by ME
27 *
28 * \date
29 *    18/09/2012
30 *
31 * \author
32 *    Ittiam
33 *
34 ******************************************************************************
35 */
36 
37 #ifndef _HME_COMMON_UTILS_H_
38 #define _HME_COMMON_UTILS_H_
39 
40 #include "ihevc_platform_macros.h"
41 
42 /*****************************************************************************/
43 /* Macros                                                                    */
44 /*****************************************************************************/
45 
46 #define MEDIAN4(a, b, c, d, e) (median4_##e(a, b, c, d))
47 
48 /*****************************************************************************/
49 /* Functions                                                                 */
50 /*****************************************************************************/
51 /**
52 ********************************************************************************
53 *  @fn     S32 median4_s16(S16 i2_n1, S16 i2_n2, S16 i2_n3, S16 i2_n4);
54 *
55 *  @brief  Returns median4 of 4 16 bits signed nubers
56 *
57 *  @param[in] i2_n1 : first number
58 *
59 *  @param[in] i2_n2 : 2nd number
60 *
61 *  @param[in] i2_n3 : 3rd number
62 *
63 *  @param[in] i2_n4 : 4th number (order does not matter)
64 *
65 *  @return range of the number
66 ********************************************************************************
67 */
68 S16 median4_s16(S16 i2_n1, S16 i2_n2, S16 i2_n3, S16 i2_n4);
69 
70 /**
71 ********************************************************************************
72 *  @fn     S32 hme_get_range(U32 u4_num);
73 *
74 *  @brief  Returns the range of the number
75 *
76 *  @param[in] u4_num : number whose range is to be found
77 *
78 *  @return range of the number
79 ********************************************************************************
80 */
81 
hme_get_range(U32 u4_num)82 static INLINE S32 hme_get_range(U32 u4_num)
83 {
84     S32 r;
85 
86     GETRANGE(r, u4_num);
87     return (r);
88 }
89 
90 /**
91 ********************************************************************************
92 *  @fn     S32 hme_compute_2d_sum_unsigned(void *pv_inp,
93 *                                       S32 i4_blk_wd,
94 *                                       S32 i4_blk_ht,
95 *                                   S32 i4_stride,
96 *                                   S32 i4_datatype)
97 *
98 *  @brief  Computes and returns 2D sum of a unsigned 2d buffer, with datatype
99 *          equal to 8/16/32 bit.
100 *
101 *  @param[in] pv_inp : input pointer
102 *
103 *  @param[in] i4_blk_wd : block width
104 *
105 *  @param[in] i4_blk_ht : block ht
106 *
107 *  @param[in] i4_stride : stride
108 *
109 *  @param[in] i4_datatype : datatype 1 - 8 bit, 2 - 16 bit, 4 - 32 bit
110 *
111 *  @return sum of i4_blk_wd * i4_blk_ht number of entries starting at pv_inp
112 ********************************************************************************
113 */
114 
115 U32 hme_compute_2d_sum_unsigned(
116     void *pv_inp, S32 i4_blk_wd, S32 i4_blk_ht, S32 i4_stride, S32 i4_datatype);
117 
118 /**
119 ********************************************************************************
120 *  @fn     S32 get_rand_num(S32 low, S32 high)
121 *
122 *  @brief  returns a radom integer in the closed interval [low, high - 1]
123 *
124 *  @param[in] low : lower limit
125 *
126 *  @param[in] high : higher limit
127 *
128 *  @return S32 result: the random number
129 ********************************************************************************
130 */
131 S32 get_rand_num(S32 low, S32 high);
132 
133 #endif /* #ifndef _HME_COMMON_UTILS_H_ */
134