• 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 * \file ihevce_plugin_priv.h
23 *
24 * \brief
25 *    This file contains sample application definations and structures
26 *
27 * \date
28 *    15/04/2014
29 *
30 * \author
31 *    Ittiam
32 *
33 *
34 * List of Functions
35 *
36 *
37 ******************************************************************************
38 */
39 #ifndef _IHEVCE_PLUGIN_PRIV_H_
40 #define _IHEVCE_PLUGIN_PRIV_H_
41 
42 /*****************************************************************************/
43 /* File Includes                                                             */
44 /*****************************************************************************/
45 
46 /*****************************************************************************/
47 /* Constant Macros                                                           */
48 /*****************************************************************************/
49 
50 #define XTRA_INP_DATA_BUFS 0
51 #define MAX_NUM_INP_DATA_BUFS MAX_SUB_GOP_SIZE + NUM_LAP2_LOOK_AHEAD
52 #define MAX_NUM_INP_CTRL_SYNC_BUFS MAX_NUM_INP_DATA_BUFS
53 #define MAX_NUM_INP_CTRL_ASYNC_BUFS 5
54 
55 #define XTRA_OUT_DATA_BUFS 0
56 #define MAX_NUM_OUT_DATA_BUFS (16 + XTRA_OUT_DATA_BUFS)
57 #define MAX_NUM_OUT_CTRL_ASYNC_BUFS 16
58 
59 #define MAX_NUM_RECON_DATA_BUFS 64
60 
61 /** Queue from Master to Slave for MBR/MRES cases **/
62 #define MBR_M2S_QUEUE 200
63 
64 /*****************************************************************************/
65 /* Function Macros                                                           */
66 /*****************************************************************************/
67 #define SET_CTB_ALIGN(x, y) ((((x) & ((y)-1)) == 0) ? 0 : (y) - ((x) & ((y)-1)))
68 
69 /*****************************************************************************/
70 /* Typedefs                                                                  */
71 /*****************************************************************************/
72 
73 /*****************************************************************************/
74 /* Enums                                                                     */
75 /*****************************************************************************/
76 
77 /*****************************************************************************/
78 /* Structure                                                                 */
79 /*****************************************************************************/
80 
81 /**
82 *  @brief  Store output buffer parameters
83 */
84 typedef struct
85 {
86     UWORD8 *pu1_bs_buffer;
87     WORD32 i4_bytes_generated;
88     WORD32 i4_is_key_frame;
89     ULWORD64 u8_pts;
90     LWORD64 i8_dts;
91 } bitstream_buf_t;
92 
93 /**
94 *  @brief  Store buffer queue parameters
95 */
96 typedef struct
97 {
98     /******* Buffer q indexes *******/
99     WORD32 i4_q_rd_idx;
100     WORD32 i4_q_wr_idx;
101     WORD32 i4_quit;
102     WORD32 i4_q_size;
103 
104     /******* Semaphore Handles ******/
105     void *pv_q_deq_sem_handle;
106     void *pv_rel_free_sem_handle;
107 } queue_t;
108 
109 /**
110 *  @brief  Datatype of global pointer used for data sharing
111 *          across encoder nodes.
112 */
113 
114 typedef struct
115 {
116     queue_t s_queue_params;
117     bitstream_buf_t bs_buf_nodes[MBR_M2S_QUEUE];
118     WORD32 i4_slave_inst_done;
119 
120 } ihevce_mbr_mres_handle_t;
121 
122 typedef struct
123 {
124     WORD32 i4_idx;
125 
126     UWORD8 *pu1_buf;
127 
128     WORD32 i4_is_free;
129 
130     WORD32 i4_is_prod;
131 
132     WORD32 i4_timestamp_low;
133 
134     WORD32 i4_timestamp_high;
135 
136     WORD32 i4_bytes_gen;
137 
138     WORD32 i4_is_key_frame;
139 
140     WORD32 i4_buf_size;
141 
142     WORD32 i4_end_flag;
143 
144 } out_buf_ctxt_t;
145 
146 typedef struct
147 {
148     ULWORD64 u8_total_bits;
149 
150     UWORD32 u4_num_frms_enc;
151 
152     /* mutex controlling the out strm buf b/w appln and encoder */
153     void *pv_app_out_strm_buf_mutex_hdl;
154 
155     void *pv_app_out_strm_buf_cond_var_hdl;
156 
157 } out_strm_prms_t;
158 
159 typedef struct
160 {
161     void *pv_mem_mngr_handle; /*!< memory manager handle */
162 
163     WORD32 ai4_out_strm_end_flag[IHEVCE_MAX_NUM_RESOLUTIONS]
164                                 [IHEVCE_MAX_NUM_BITRATES]; /*!< end of strm processing */
165 
166     out_strm_prms_t as_out_strm_prms[IHEVCE_MAX_NUM_RESOLUTIONS]
167                                     [IHEVCE_MAX_NUM_BITRATES]; /*!< to store out strm related prms */
168 
169 } app_ctxt_t;
170 
171 typedef struct
172 {
173     /*!< Static paramters same memory pointer will be passed to
174          processing interface layer */
175     ihevce_static_cfg_params_t *ps_static_cfg_prms;
176 
177     /*!< Osal Handle */
178     void *pv_osal_handle;
179 
180     /*!< Call back API for freeing */
181     void (*ihevce_mem_free)(void *pv_handle, void *pv_mem);
182 
183     /*!< Call back API to be called during allocation */
184     void *(*ihevce_mem_alloc)(void *pv_handle, UWORD32 u4_size);
185 
186     /** App context memory */
187     app_ctxt_t s_app_ctxt;
188 
189     /** semaphore handle for Input data proc thread */
190     void *pv_app_inp_ctrl_sem_hdl;
191 
192     /** semaphore handle for Output data proc thread */
193     void *pv_app_out_sts_sem_hdl;
194 
195     /** Pointer to HLE interface ctxt */
196     void *pv_hle_interface_ctxt;
197 
198     /** Memtab of input buffers */
199     iv_mem_rec_t s_memtab_inp_data_buf;
200 
201     /** Memtab of input command buffers */
202     iv_mem_rec_t s_memtab_inp_sync_ctrl_buf;
203 
204     /** Array of memtabs of outptu buffers */
205     iv_mem_rec_t as_memtab_out_data_buf[IHEVCE_MAX_NUM_RESOLUTIONS][IHEVCE_MAX_NUM_BITRATES];
206 
207     /* pointer to async command input buffer */
208     UWORD8 *pu1_inp_async_ctrl_buf;
209 
210     /* pointer to async command output buffer*/
211     UWORD8 *pu1_out_ctrl_buf;
212 
213     /* HLE thread handle */
214     void *pv_hle_thread_hdl;
215 
216     /* flag to indicate that flush mode is ON */
217     WORD32 i4_flush_mode_on;
218 
219     /* field id for interlaced case */
220     WORD32 i4_field_id;
221 
222     /* frame stride of input buffers */
223     WORD32 i4_frm_stride;
224 
225     /* flag to indicate Output end status */
226     WORD32 ai4_out_end_flag[IHEVCE_MAX_NUM_RESOLUTIONS][IHEVCE_MAX_NUM_BITRATES];
227 
228     /* output buffer context */
229     out_buf_ctxt_t aaas_out_bufs[IHEVCE_MAX_NUM_RESOLUTIONS][IHEVCE_MAX_NUM_BITRATES]
230                                 [MAX_NUM_OUT_DATA_BUFS + 1];
231 
232     /* Num Output buffers */
233     WORD32 i4_num_out_bufs;
234 
235     /* Free outbuf idx */
236     WORD32 ai4_free_out_buf_idx[IHEVCE_MAX_NUM_RESOLUTIONS][IHEVCE_MAX_NUM_BITRATES];
237 
238     /* Out produced idx */
239     WORD32 i4_prod_out_buf_idx;
240 
241     /* DTS for output population */
242     LWORD64 i8_dts;
243 
244     /* Flag used for flushing in case of EVAL version */
245     WORD32 i4_internal_flush;
246 
247     ULWORD64 u8_num_frames_encoded;
248 
249     /* Count no of frames queued */
250     ULWORD64 u8_num_frames_queued;
251 
252     /** Structure which contains params to be shared across different FFMPEG instances **/
253     ihevce_mbr_mres_handle_t
254         *ps_mbr_mres_handle[IHEVCE_MAX_NUM_RESOLUTIONS][IHEVCE_MAX_NUM_BITRATES];
255 
256     /* Dynamic change in bitrate detecting mechnaism related vaiables */
257     WORD32 ai4_old_bitrate[IHEVCE_MAX_NUM_RESOLUTIONS][IHEVCE_MAX_NUM_BITRATES];
258 
259 } plugin_ctxt_t;
260 
261 /*****************************************************************************/
262 /* Extern Variable Declarations                                              */
263 /*****************************************************************************/
264 
265 /*****************************************************************************/
266 /* Extern Function Declarations                                              */
267 /*****************************************************************************/
268 
269 #endif /* _IHEVCE_PLUGIN_PRIV_H_ */
270