/src/libavc/encoder/svc/isvce_cabac_utils.h
Line  | Count  | Source  | 
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  |  | *******************************************************************************  | 
23  |  | * @file  | 
24  |  | *  isvce_cabac_utils.h  | 
25  |  | *  | 
26  |  | * @brief  | 
27  |  | *  Contains function declarations for function declared in  | 
28  |  | *  isvce_svc_cabac_utils.c  | 
29  |  | *  | 
30  |  | * @author  | 
31  |  | *  ittiam  | 
32  |  | *  | 
33  |  | * @remarks  | 
34  |  | *  None  | 
35  |  | *  | 
36  |  | *******************************************************************************  | 
37  |  | */  | 
38  |  |  | 
39  |  | #ifndef _ISVCE_CABAC_UTILS_H_  | 
40  |  | #define _ISVCE_CABAC_UTILS_H_  | 
41  |  |  | 
42  |  | #include "ih264_typedefs.h"  | 
43  |  | #include "isvc_macros.h"  | 
44  |  | #include "isvc_defs.h"  | 
45  |  | #include "isvc_cabac_tables.h"  | 
46  |  | #include "isvce_cabac_structs.h"  | 
47  |  | #include "isvce_cabac.h"  | 
48  |  |  | 
49  |  | static FORCEINLINE void isvce_cabac_enc_base_mode_flag(isvce_cabac_ctxt_t *ps_cabac_ctxt,  | 
50  |  |                                                        UWORD8 u1_base_mode_flag)  | 
51  | 3.58M  | { | 
52  | 3.58M  |     UWORD8 u1_ctx_inc;  | 
53  | 3.58M  |     UWORD8 u1_a, u1_b;  | 
54  |  |  | 
55  | 3.58M  |     const UWORD32 u4_ctxidx_offset = BASE_MODE_FLAG;  | 
56  |  |  | 
57  | 3.58M  |     u1_a = !ps_cabac_ctxt->ps_left_ctxt_mb_info->u1_base_mode_flag;  | 
58  | 3.58M  |     u1_b = !ps_cabac_ctxt->ps_top_ctxt_mb_info->u1_base_mode_flag;  | 
59  |  |  | 
60  | 3.58M  |     u1_ctx_inc = u1_a + u1_b;  | 
61  |  |  | 
62  | 3.58M  |     isvce_cabac_encode_bin(ps_cabac_ctxt, u1_base_mode_flag,  | 
63  | 3.58M  |                            ps_cabac_ctxt->au1_cabac_ctxt_table + u4_ctxidx_offset + u1_ctx_inc);  | 
64  | 3.58M  | }  | 
65  |  |  | 
66  |  | static FORCEINLINE void isvce_cabac_enc_residual_prediction_flag(isvce_cabac_ctxt_t *ps_cabac_ctxt,  | 
67  |  |                                                                  UWORD8 u1_base_mode_flag,  | 
68  |  |                                                                  UWORD8 u1_residual_prediction_flag)  | 
69  | 125k  | { | 
70  | 125k  |     const UWORD32 u4_ctxidx_offset = RESIDUAL_PREDICTION_FLAG;  | 
71  | 125k  |     UWORD8 u1_ctx_inc = !u1_base_mode_flag;  | 
72  |  |  | 
73  | 125k  |     isvce_cabac_encode_bin(ps_cabac_ctxt, u1_residual_prediction_flag,  | 
74  | 125k  |                            ps_cabac_ctxt->au1_cabac_ctxt_table + u4_ctxidx_offset + u1_ctx_inc);  | 
75  | 125k  | }  | 
76  |  |  | 
77  |  | static FORCEINLINE void isvce_cabac_enc_motion_prediction_flag(isvce_cabac_ctxt_t *ps_cabac_ctxt,  | 
78  |  |                                                                UWORD8 u1_motion_prediction_flag,  | 
79  |  |                                                                UWORD8 u1_is_l0_mvp)  | 
80  | 108k  | { | 
81  | 108k  |     const UWORD32 u4_ctxidx_offset =  | 
82  | 108k  |         u1_is_l0_mvp ? MOTION_PREDICTION_FLAG_L0 : MOTION_PREDICTION_FLAG_L1;  | 
83  |  |  | 
84  | 108k  |     isvce_cabac_encode_bin(ps_cabac_ctxt, u1_motion_prediction_flag,  | 
85  | 108k  |                            ps_cabac_ctxt->au1_cabac_ctxt_table + u4_ctxidx_offset);  | 
86  | 108k  | }  | 
87  |  |  | 
88  |  | #endif  |