1 /******************************************************************************
2 *
3 * Copyright (C) 2022 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
23 * isvce_ilp_mv_utils.h
24 *
25 * @brief
26 * Defs to perform experiments in ilp mv
27 *
28 *
29 * @remarks
30 * None
31 *
32 *******************************************************************************
33 */
34 #ifndef _ISVCE_ILP_MV_UTILS_H_
35 #define _ISVCE_ILP_MV_UTILS_H_
36
37 #include <stdbool.h>
38
39 #include "ih264_typedefs.h"
40 #include "isvc_defs.h"
41 #include "isvc_macros.h"
42 #include "isvce_pred_structs.h"
43 #include "isvce_structs.h"
44
45 #define MAX_CAND_IF_NUM_ILP_MV_LT_2 8
46 #define MAX_CAND_IF_NUM_ILP_MV_GTEQ_2 6
47
48 /* nbr_mb.x, nbr_mb.y, pu_pos.x, pu_pos.y */
49 #define NBR_PU_AND_MB_POS 4
50
51 static const WORD8 gai1_nbr_ilp_mv_map[MAX_ILP_MV_IN_NBR_RGN][NBR_PU_AND_MB_POS] = {
52 {-1, 0, 3, 0},
53 {0, -1, 0, 3},
54 {1, 0, 0, 0},
55 {0, 1, 0, 0},
56 };
57
58 /**
59 *******************************************************************************
60 *
61 * @brief
62 * This function checks if the max difference between ILP MVs is less than four
63 * or not if number of ILP MVs is greater than or equal to two
64 *
65 * @param[in] ps_me
66 * Pointer to ilp_me_cands
67 *
68 * @returns One if number of ILP MVs is greater than equal to two and max
69 * difference between them is less than 4 otherwise returns zero
70 *
71 * @remarks none
72 *
73 *******************************************************************************
74 */
isvce_check_max_mv_diff_lt_4(ilp_me_cands_t * ps_ilp_me_cands,WORD32 i4_reflist)75 static FORCEINLINE bool isvce_check_max_mv_diff_lt_4(ilp_me_cands_t *ps_ilp_me_cands,
76 WORD32 i4_reflist)
77 {
78 UWORD32 i, j;
79 UWORD32 u4_mv_diff_x, u4_mv_diff_y;
80
81 for(i = 1; i < ps_ilp_me_cands->u4_num_ilp_mvs; i++)
82 {
83 for(j = 0; j < i; j++)
84 {
85 if(((ps_ilp_me_cands->ae_pred_mode[i] == ((PRED_MODE_T) i4_reflist)) ||
86 ((ps_ilp_me_cands->ae_pred_mode[i] == BI))) &&
87 ((ps_ilp_me_cands->ae_pred_mode[j] == ((PRED_MODE_T) i4_reflist)) ||
88 ((ps_ilp_me_cands->ae_pred_mode[j] == BI))))
89 {
90 u4_mv_diff_x = ABS(ps_ilp_me_cands->as_mv[i][i4_reflist].s_mv.i2_mvx -
91 ps_ilp_me_cands->as_mv[j][i4_reflist].s_mv.i2_mvx);
92
93 u4_mv_diff_y = ABS(ps_ilp_me_cands->as_mv[i][i4_reflist].s_mv.i2_mvy -
94 ps_ilp_me_cands->as_mv[j][i4_reflist].s_mv.i2_mvy);
95
96 if(u4_mv_diff_x >= 4 || u4_mv_diff_y >= 4)
97 {
98 return false;
99 }
100 }
101 else
102 {
103 return false;
104 }
105 }
106 }
107
108 return true;
109 }
110
111 #endif
112