aboutsummaryrefslogtreecommitdiff
path: root/encoder/hme_common_defs.h
blob: eb44d1e217bd56430791a927b0240f21fb7db929 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/******************************************************************************
 *
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *****************************************************************************
 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
*/
/*!
******************************************************************************
* \file hme_common_defs.h
*
* \brief
*    Important definitions, enumerations, macros and structures used by ME
*
* \date
*    18/09/2012
*
* \author
*    Ittiam
*
******************************************************************************
*/

#ifndef _HME_COMMON_DEFS_H_
#define _HME_COMMON_DEFS_H_

/*****************************************************************************/
/* Constant Macros                                                           */
/*****************************************************************************/
#define MAX_32BIT_VAL (0x7FFFFFFF)
#define MAX_SIGNED_16BIT_VAL (0x07FFF)
#define INTERP_INTERMED_BUF_SIZE (72 * 72 * 2)

/*****************************************************************************/
/* Function Macros                                                           */
/*****************************************************************************/
#define HME_CLIP(x, min, max) (((x) < (min)) ? (min) : (((x) > (max)) ? (max) : (x)))

#define ARG_NOT_USED(x) ((void)(x))
/**
******************************************************************************
 *  @brief Average of 2 numbers of any datatype
******************************************************************************
*/
#define AVG2(x, y) (((x) + (y) + 1) >> 1)

#define FLOOR16(x) ((x) & (~15))
#define FLOOR8(x) ((x) & (~7))

#define SET_PIC_LIMIT(s_pic_limit, pad_x, pad_y, wd, ht, num_post_refine)                          \
    {                                                                                              \
        s_pic_limit.i2_min_x = (S16)(-(pad_x) + (num_post_refine));                                \
        s_pic_limit.i2_min_y = (S16)(-(pad_y) + (num_post_refine));                                \
        s_pic_limit.i2_max_x = (S16)((wd) + (pad_x) - (num_post_refine));                          \
        s_pic_limit.i2_max_y = (S16)((ht) + (pad_y) - (num_post_refine));                          \
    }

#define SCALE_FOR_POC_DELTA(x, y, node, ref_tgt, pi2_ref_scf)                                      \
    {                                                                                              \
        x = node->s_mv.i2_mvx;                                                                     \
        y = node->s_mv.i2_mvy;                                                                     \
        x = x * pi2_ref_scf[ref_tgt * MAX_NUM_REF + node->i1_ref_idx];                             \
        y = y * pi2_ref_scf[ref_tgt * MAX_NUM_REF + node->i1_ref_idx];                             \
        x = (x + 128) >> 8;                                                                        \
        y = (y + 128) >> 8;                                                                        \
        HME_CLIP(x, -32768, 32767);                                                                \
        HME_CLIP(y, -32768, 32767);                                                                \
    }

#define SWAP_HME(a, b, data_type)                                                                  \
    {                                                                                              \
        data_type temp = a;                                                                        \
        a = b;                                                                                     \
        b = temp;                                                                                  \
    }

/**
******************************************************************************
 *  @brief Check if MVs lie within a range
******************************************************************************
*/
#define CHECK_MV_WITHIN_RANGE(x, y, range)                                                         \
    (((x) > (range)->i2_min_x) && ((x) < (range)->i2_max_x) && ((y) > (range)->i2_min_y) &&        \
     ((y) < (range)->i2_max_y))

/*****************************************************************************/
/* Structure                                                                 */
/*****************************************************************************/

/**
 ******************************************************************************
 *  @struct mv_t
 *  @brief  Basic Motion vector structure (x and y components)
 ******************************************************************************
*/
typedef struct
{
    S16 i2_mv_x;
    S16 i2_mv_y;
} hme_mv_t;

#endif /* #ifndef _HME_COMMON_DEFS_H_ */