• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 * @file
24 *  ihevce_lap_structs.h
25 *
26 * @brief
27 *  This file contains structure definitions related to look-ahead processing
28 *
29 * @author
30 *  ittiam
31 *
32 ******************************************************************************
33 */
34 
35 #ifndef _IHEVCE_LAP_STRUCTS_H_
36 #define _IHEVCE_LAP_STRUCTS_H_
37 
38 /*****************************************************************************/
39 /* Constant Macros                                                           */
40 /*****************************************************************************/
41 #define EVAL_VERSION 0
42 #define EVAL_MODE_FORCE_LOGO 0
43 #define MAX_FRAMES_EVAL_VERSION 50000
44 #define LAP_DEBUG_PRINT 0
45 #define FORCE_IDR_TEST 1
46 #define MAX_NUM_ENC_NODES 8
47 #define MAX_QUEUE_LENGTH (MAX_LAP_WINDOW_SIZE + MAX_SUB_GOP_SIZE + 2)
48 #define MAX_SUBGOP_IN_ENCODE_QUEUE 4
49 
50 #if(MAX_SUBGOP_IN_ENCODE_QUEUE) & (MAX_SUBGOP_IN_ENCODE_QUEUE - 1)
51 #error max_subgop_in_encode_queue must be a power of 2
52 #endif
53 
54 /*****************************************************************************/
55 /* Enums                                                                     */
56 /*****************************************************************************/
57 typedef enum
58 {
59     LAP_CTXT = 0,
60     LAP_NODE_MEM,
61     NUM_LAP_MEM_RECS,
62 } LAP_MEM_T;
63 
64 /*****************************************************************************/
65 /* Structures                                                                */
66 /*****************************************************************************/
67 
68 /* Picture types */
69 typedef enum PIC_TYPE_E
70 {
71     PIC_TYPE_NA = -1, /* Invalid frame type*/
72     PIC_TYPE_I, /* I frame */
73     PIC_TYPE_P, /* P frame */
74     PIC_TYPE_B, /* B frame */
75     PIC_TYPE_IDR, /* IDR frame */
76     PIC_TYPE_CRA, /* CRA frame */
77     MAX_NUM_PIC_TYPES
78 } PIC_TYPE_E;
79 
80 typedef struct ihevce_encode_node_t
81 {
82     WORD32 data;
83     void *pv_left_node;
84     void *pv_right_node;
85     WORD32 i4_hierachical_layer;
86     WORD32 i4_interlace_field;
87     ihevce_lap_enc_buf_t *ps_lap_top_buff;
88     ihevce_lap_enc_buf_t *ps_lap_bottom_buff;
89 
90 } ihevce_encode_node_t;
91 
92 /**
93 ******************************************************************************
94  *  @brief  lap context
95 ******************************************************************************
96  */
97 typedef struct
98 {
99     // cfg params
100     ihevce_static_cfg_params_t s_static_cfg_params;
101     ihevce_lap_static_params_t s_lap_static_params;
102 
103     //pic reorder info
104     ihevce_lap_enc_buf_t *aps_lap_inp_buf[MAX_QUEUE_LENGTH];
105 
106     ihevce_encode_node_t *aps_encode_node[1];
107 
108     /** Array of nodes in encode order*/
109     ihevce_lap_enc_buf_t *api4_encode_order_array[MAX_NUM_ENC_NODES];
110 
111     /** Array of lap output in lap encode array*/
112     ihevce_lap_enc_buf_t *api4_lap_out_buf[MAX_SUBGOP_IN_ENCODE_QUEUE][MAX_NUM_ENC_NODES];
113 
114     /** Array of nodes in capture order*/
115     ihevce_lap_enc_buf_t *api4_capture_order_array[MAX_NUM_ENC_NODES];
116 
117     /**Array of POCS in encode order*/
118     WORD32 ai4_encode_order_poc[MAX_NUM_ENC_NODES];
119 
120     /**Array of POCS in capture order*/
121     WORD32 ai4_capture_order_poc[MAX_NUM_ENC_NODES];
122 
123     /** Pointer to POC in encode order*/
124     WORD32 *pi4_encode_poc_ptr;
125 
126     /** Pointer to POC in capture order*/
127     WORD32 *pi4_capture_poc_ptr;
128 
129     WORD32 ai4_pic_type_to_be_removed[NUM_LAP2_LOOK_AHEAD];
130 
131     WORD32 ai4_num_buffer[MAX_SUBGOP_IN_ENCODE_QUEUE];
132 
133     void *pv_prev_inp_buf;
134 
135     WORD32 i4_buf_enq_idx;
136     WORD32 i4_buf_deq_idx;
137     WORD32 i4_lap_out_idx;
138     WORD32 i4_capture_idx;
139     WORD32 i4_idr_flag;
140     WORD32 i4_num_bufs_encode_order;
141     WORD32 i4_deq_idx;
142     WORD32 i4_enq_idx;
143     // poc info
144     WORD32 ref_poc_array[MAX_REF_PICS];
145     WORD8 ai1_pic_type[10];
146     WORD32 i4_curr_poc;
147     WORD32 i4_cra_poc;
148     WORD32 i4_assoc_IRAP_poc;
149     // counters
150     WORD32 i4_max_idr_period;
151     WORD32 i4_min_idr_period;
152     WORD32 i4_max_cra_period;
153     WORD32 i4_max_i_period;
154     WORD32 i4_idr_counter;
155     WORD32 i4_cra_counter;
156     WORD32 i4_i_counter;
157     WORD32 i4_idr_gop_num;
158     WORD32 i4_curr_ref_pics;
159     WORD32 i4_display_num;
160     WORD32 i4_num_frm_type_decided;
161     WORD32 i4_frm_gop_idx;
162     WORD32 i4_is_all_i_pic_in_seq;
163     WORD32 i4_next_start_ctr;
164     WORD32 i4_fixed_open_gop_period;
165     WORD32 i4_fixed_i_period;
166     // misc
167     WORD32 i4_enable_logo;
168     WORD32 i4_cra_i_pic_flag;
169     WORD32 i4_force_end_flag;
170     WORD32 i4_sub_gop_size;
171     WORD32 i4_sub_gop_size_idr;
172     WORD32 i4_dyn_sub_gop_size;
173     WORD32 end_flag;
174     WORD32 i4_immediate_idr_case;
175     WORD32 i4_max_buf_in_enc_order;
176     WORD32 i4_end_flag_pic_idx;
177     WORD32 i4_lap2_counter;
178     WORD32 i4_rc_lap_period;
179     WORD32 i4_gop_period;
180     WORD32 i4_no_back_to_back_i_avoidance;
181     WORD32 i4_sub_gop_pic_idx;
182     WORD32 i4_force_idr_pos;
183     WORD32 i4_num_dummy_pic;
184     WORD32 i4_sub_gop_end;
185     WORD32 i4_lap_encode_idx;
186     WORD32 i4_deq_lap_buf;
187 } lap_struct_t;
188 
189 void ihevce_populate_tree_nodes(
190     ihevce_encode_node_t *encode_parent_node_t,
191     ihevce_encode_node_t *encode_node_t,
192     WORD32 *loop_count,
193     WORD32 layer,
194     WORD32 hier_layer);
195 
196 #endif /* _IHEVCE_LAP_STRUCTS_H_ */
197