• 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 * \file hme_common_defs.h
23 *
24 * \brief
25 *    Important definitions, enumerations, macros and structures used by ME
26 *
27 * \date
28 *    18/09/2012
29 *
30 * \author
31 *    Ittiam
32 *
33 ******************************************************************************
34 */
35 
36 #ifndef _HME_COMMON_DEFS_H_
37 #define _HME_COMMON_DEFS_H_
38 
39 /*****************************************************************************/
40 /* Constant Macros                                                           */
41 /*****************************************************************************/
42 #define MAX_32BIT_VAL (0x7FFFFFFF)
43 #define MAX_SIGNED_16BIT_VAL (0x07FFF)
44 #define INTERP_INTERMED_BUF_SIZE (72 * 72 * 2)
45 
46 /*****************************************************************************/
47 /* Function Macros                                                           */
48 /*****************************************************************************/
49 #define HME_CLIP(x, min, max) (((x) < (min)) ? (min) : (((x) > (max)) ? (max) : (x)))
50 
51 #define ARG_NOT_USED(x) ((void)(x))
52 /**
53 ******************************************************************************
54  *  @brief Average of 2 numbers of any datatype
55 ******************************************************************************
56 */
57 #define AVG2(x, y) (((x) + (y) + 1) >> 1)
58 
59 #define FLOOR16(x) ((x) & (~15))
60 #define FLOOR8(x) ((x) & (~7))
61 
62 #define SET_PIC_LIMIT(s_pic_limit, pad_x, pad_y, wd, ht, num_post_refine)                          \
63     {                                                                                              \
64         s_pic_limit.i2_min_x = (S16)(-(pad_x) + (num_post_refine));                                \
65         s_pic_limit.i2_min_y = (S16)(-(pad_y) + (num_post_refine));                                \
66         s_pic_limit.i2_max_x = (S16)((wd) + (pad_x) - (num_post_refine));                          \
67         s_pic_limit.i2_max_y = (S16)((ht) + (pad_y) - (num_post_refine));                          \
68     }
69 
70 #define SCALE_FOR_POC_DELTA(x, y, node, ref_tgt, pi2_ref_scf)                                      \
71     {                                                                                              \
72         x = node->s_mv.i2_mvx;                                                                     \
73         y = node->s_mv.i2_mvy;                                                                     \
74         x = x * pi2_ref_scf[ref_tgt * MAX_NUM_REF + node->i1_ref_idx];                             \
75         y = y * pi2_ref_scf[ref_tgt * MAX_NUM_REF + node->i1_ref_idx];                             \
76         x = (x + 128) >> 8;                                                                        \
77         y = (y + 128) >> 8;                                                                        \
78         HME_CLIP(x, -32768, 32767);                                                                \
79         HME_CLIP(y, -32768, 32767);                                                                \
80     }
81 
82 #define SWAP_HME(a, b, data_type)                                                                  \
83     {                                                                                              \
84         data_type temp = a;                                                                        \
85         a = b;                                                                                     \
86         b = temp;                                                                                  \
87     }
88 
89 /**
90 ******************************************************************************
91  *  @brief Check if MVs lie within a range
92 ******************************************************************************
93 */
94 #define CHECK_MV_WITHIN_RANGE(x, y, range)                                                         \
95     (((x) > (range)->i2_min_x) && ((x) < (range)->i2_max_x) && ((y) > (range)->i2_min_y) &&        \
96      ((y) < (range)->i2_max_y))
97 
98 /*****************************************************************************/
99 /* Structure                                                                 */
100 /*****************************************************************************/
101 
102 /**
103  ******************************************************************************
104  *  @struct mv_t
105  *  @brief  Basic Motion vector structure (x and y components)
106  ******************************************************************************
107 */
108 typedef struct
109 {
110     S16 i2_mv_x;
111     S16 i2_mv_y;
112 } hme_mv_t;
113 
114 #endif /* #ifndef _HME_COMMON_DEFS_H_ */
115