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
isvce_cabac_enc_base_mode_flag(isvce_cabac_ctxt_t * ps_cabac_ctxt,UWORD8 u1_base_mode_flag)49 static FORCEINLINE void isvce_cabac_enc_base_mode_flag(isvce_cabac_ctxt_t *ps_cabac_ctxt,
50 UWORD8 u1_base_mode_flag)
51 {
52 UWORD8 u1_ctx_inc;
53 UWORD8 u1_a, u1_b;
54
55 const UWORD32 u4_ctxidx_offset = BASE_MODE_FLAG;
56
57 u1_a = !ps_cabac_ctxt->ps_left_ctxt_mb_info->u1_base_mode_flag;
58 u1_b = !ps_cabac_ctxt->ps_top_ctxt_mb_info->u1_base_mode_flag;
59
60 u1_ctx_inc = u1_a + u1_b;
61
62 isvce_cabac_encode_bin(ps_cabac_ctxt, u1_base_mode_flag,
63 ps_cabac_ctxt->au1_cabac_ctxt_table + u4_ctxidx_offset + u1_ctx_inc);
64 }
65
isvce_cabac_enc_residual_prediction_flag(isvce_cabac_ctxt_t * ps_cabac_ctxt,UWORD8 u1_base_mode_flag,UWORD8 u1_residual_prediction_flag)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 {
70 const UWORD32 u4_ctxidx_offset = RESIDUAL_PREDICTION_FLAG;
71 UWORD8 u1_ctx_inc = !u1_base_mode_flag;
72
73 isvce_cabac_encode_bin(ps_cabac_ctxt, u1_residual_prediction_flag,
74 ps_cabac_ctxt->au1_cabac_ctxt_table + u4_ctxidx_offset + u1_ctx_inc);
75 }
76
isvce_cabac_enc_motion_prediction_flag(isvce_cabac_ctxt_t * ps_cabac_ctxt,UWORD8 u1_motion_prediction_flag,UWORD8 u1_is_l0_mvp)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 {
81 const UWORD32 u4_ctxidx_offset =
82 u1_is_l0_mvp ? MOTION_PREDICTION_FLAG_L0 : MOTION_PREDICTION_FLAG_L1;
83
84 isvce_cabac_encode_bin(ps_cabac_ctxt, u1_motion_prediction_flag,
85 ps_cabac_ctxt->au1_cabac_ctxt_table + u4_ctxidx_offset);
86 }
87
88 #endif
89