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 ******************************************************************************
23 *
24 * @file ihevce_cabac_rdo.h
25 *
26 * @brief
27 *  This file contains function prototypes for rdopt cabac entropy modules
28 *
29 * @author
30 *  ittiam
31 *
32 ******************************************************************************
33 */
34 
35 #ifndef _IHEVCE_CABAC_RDO_H_
36 #define _IHEVCE_CABAC_RDO_H_
37 
38 /*****************************************************************************/
39 /* Constant Macros                                                           */
40 /*****************************************************************************/
41 
42 /*****************************************************************************/
43 /* Function Macros                                                           */
44 /*****************************************************************************/
45 
46 /*****************************************************************************/
47 /* Enums                                                                     */
48 /*****************************************************************************/
49 typedef enum
50 {
51     UPDATE_ENT_SYNC_RDO_STATE = 0,
52     STORE_ENT_SYNC_RDO_STATE = 1,
53 } CABAC_RDO_COPY_STATE_T;
54 
55 /*****************************************************************************/
56 /* Structures                                                                */
57 /*****************************************************************************/
58 
59 /*****************************************************************************/
60 /* Extern Function Declarations                                              */
61 /*****************************************************************************/
62 
63 void ihevce_entropy_rdo_frame_init(
64     rdopt_entropy_ctxt_t *ps_rdopt_entropy_ctxt,
65     slice_header_t *ps_slice_hdr,
66     pps_t *ps_pps,
67     sps_t *ps_sps,
68     vps_t *ps_vps,
69     UWORD8 *pu1_cu_skip_top_row,
70     rc_quant_t *ps_rc_quant_ctxt);
71 
72 void ihevce_entropy_rdo_ctb_init(
73     rdopt_entropy_ctxt_t *ps_rdopt_entropy_ctxt, WORD32 ctb_x, WORD32 ctb_y);
74 
75 WORD32 ihevce_entropy_rdo_encode_cu(
76     rdopt_entropy_ctxt_t *ps_rdopt_entropy_ctxt,
77     enc_loop_cu_final_prms_t *ps_cu_prms,
78     WORD32 cu_pos_x,
79     WORD32 cu_pos_y,
80     WORD32 cu_size,
81     WORD32 top_avail,
82     WORD32 left_avail,
83     void *pv_ecd_coeff,
84     WORD32 *pi4_cu_rdopt_tex_bits);
85 
86 void ihevce_entropy_update_best_cu_states(
87     rdopt_entropy_ctxt_t *ps_rdopt_entropy_ctxt,
88     WORD32 cu_pos_x,
89     WORD32 cu_pos_y,
90     WORD32 cu_size,
91     WORD32 cu_skip_flag,
92     WORD32 rdopt_best_cu_idx);
93 
94 WORD32 ihevce_entropy_rdo_encode_tu(
95     rdopt_entropy_ctxt_t *ps_rdopt_entropy_ctxt,
96     void *pv_ecd_coeff,
97     WORD32 transform_size,
98     WORD32 is_luma,
99     WORD32 perform_sbh);
100 
101 WORD32 ihevce_cabac_rdo_encode_sao(
102     rdopt_entropy_ctxt_t *ps_rdopt_entropy_ctxt, ctb_enc_loop_out_t *ps_ctb_enc_loop_out);
103 
104 WORD32 ihevce_update_best_sao_cabac_state(
105     rdopt_entropy_ctxt_t *ps_rdopt_entropy_ctxt, WORD32 i4_best_buf_idx);
106 
107 WORD32 ihevce_entropy_rdo_encode_tu_rdoq(
108     rdopt_entropy_ctxt_t *ps_rdopt_entropy_ctxt,
109     void *pv_ecd_coeff,
110     WORD32 transform_size,
111     WORD32 is_luma,
112     rdoq_sbh_ctxt_t *ps_rdoq_ctxt,
113     LWORD64 *pi8_coded_tu_dist,
114     LWORD64 *pi8_not_coded_tu_dist,
115     WORD32 perform_sbh);
116 
117 void ihevce_entropy_rdo_copy_states(
118     rdopt_entropy_ctxt_t *ps_rdopt_entropy_ctxt, UWORD8 *pu1_entropy_sync_states, WORD32 copy_mode);
119 
120 #endif /* _IHEVCE_CABAC_RDO_H_ */
121