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_process.h 25 * 26 * @brief 27 * Contains functions for codec thread 28 * 29 * @author 30 * ittiam 31 * 32 * @remarks 33 * None 34 * 35 ******************************************************************************* 36 */ 37 38 #ifndef _ISVCE_PROCESS_H_ 39 #define _ISVCE_PROCESS_H_ 40 41 /*****************************************************************************/ 42 /* Function Declarations */ 43 /*****************************************************************************/ 44 45 /** 46 ****************************************************************************** 47 * 48 * @brief This function generates sps, pps set on request 49 * 50 * @par Description 51 * When the encoder is set in header generation mode, the following function 52 * is called. This generates sps and pps headers and returns the control back 53 * to caller. 54 * 55 * @param[in] ps_codec 56 * pointer to codec context 57 * 58 * @return success or failure error code 59 * 60 ****************************************************************************** 61 */ 62 IH264E_ERROR_T isvce_generate_sps_pps(isvce_codec_t *ps_codec, isvce_inp_buf_t *ps_inp_buf); 63 64 /** 65 ******************************************************************************* 66 * 67 * @brief initialize entropy context. 68 * 69 * @par Description: 70 * Before invoking the call to perform to entropy coding the entropy context 71 * associated with the job needs to be initialized. This involves the start 72 * mb address, end mb address, slice index and the pointer to location at 73 * which the mb residue info and mb header info are packed. 74 * 75 * @param[in] ps_proc 76 * Pointer to the current process context 77 * 78 * @returns error status 79 * 80 * @remarks none 81 * 82 ******************************************************************************* 83 */ 84 IH264E_ERROR_T isvce_init_entropy_ctxt(isvce_process_ctxt_t *ps_proc); 85 86 /** 87 ******************************************************************************* 88 * 89 * @brief entry point for entropy coding 90 * 91 * @par Description 92 * This function calls lower level functions to perform entropy coding for a 93 * group (n rows) of mb's. After encoding 1 row of mb's, the function takes 94 * back the control, updates the ctxt and calls lower level functions again. 95 * This process is repeated till all the rows or group of mb's (which ever is 96 * minimum) are coded 97 * 98 * @param[in] ps_proc 99 * process context 100 * 101 * @returns error status 102 * 103 * @remarks 104 * NOTE : It is assumed that this routine is invoked at the start of a slice, 105 * so the slice header is generated by default. 106 * 107 ******************************************************************************* 108 */ 109 IH264E_ERROR_T isvce_entropy(isvce_process_ctxt_t *ps_proc); 110 111 /** 112 ******************************************************************************* 113 * 114 * @brief Packs header information of a mb in to a buffer 115 * 116 * @par Description: 117 * After the deciding the mode info of a macroblock, the syntax elements 118 * associated with the mb are packed and stored. The entropy thread unpacks 119 * this buffer and generates the end bit stream. 120 * 121 * @param[in] ps_proc 122 * Pointer to the current process context 123 * 124 * @returns error status 125 * 126 * @remarks none 127 * 128 ******************************************************************************* 129 */ 130 IH264E_ERROR_T isvce_pack_header_data(isvce_process_ctxt_t *ps_proc); 131 132 /** 133 ******************************************************************************* 134 * 135 * @brief update process context after encoding an mb. This involves preserving 136 * the current mb information for later use, initialize the proc ctxt elements to 137 * encode next mb. 138 * 139 * @par Description: 140 * This function performs house keeping tasks after encoding an mb. 141 * After encoding an mb, various elements of the process context needs to be 142 * updated to encode the next mb. For instance, the source, recon and reference 143 * pointers, mb indices have to be adjusted to the next mb. The slice index of 144 * the current mb needs to be updated. If mb qp modulation is enabled, then if 145 * the qp changes the quant param structure needs to be updated. Also to 146 *encoding the next mb, the current mb info is used as part of mode prediction or 147 *mv prediction. Hence the current mb info has to preserved at top/top left/left 148 * locations. 149 * 150 * @param[in] ps_proc 151 * Pointer to the current process context 152 * 153 * @returns none 154 * 155 * @remarks none 156 * 157 ******************************************************************************* 158 */ 159 WORD32 isvce_update_proc_ctxt(isvce_process_ctxt_t *ps_proc); 160 161 /** 162 ******************************************************************************* 163 * 164 * @brief initialize process context. 165 * 166 * @par Description: 167 * Before dispatching the current job to process thread, the process context 168 * associated with the job is initialized. Usually every job aims to encode one 169 * row of mb's. Basing on the row indices provided by the job, the process 170 * context's buffer ptrs, slice indices and other elements that are necessary 171 * during core-coding are initialized. 172 * 173 * @param[in] ps_proc 174 * Pointer to the current process context 175 * 176 * @returns error status 177 * 178 * @remarks none 179 * 180 ******************************************************************************* 181 */ 182 IH264E_ERROR_T isvce_init_proc_ctxt(isvce_process_ctxt_t *ps_proc); 183 184 /** 185 ******************************************************************************* 186 * 187 * @brief This function performs luma & chroma padding 188 * 189 * @par Description: 190 * 191 * @param[in] ps_proc 192 * Process context corresponding to the job 193 * 194 * @param[in] pu1_curr_pic_luma 195 * Pointer to luma buffer 196 * 197 * @param[in] pu1_curr_pic_chroma 198 * Pointer to chroma buffer 199 * 200 * @param[in] i4_mb_x 201 * mb index x 202 * 203 * @param[in] i4_mb_y 204 * mb index y 205 * 206 * @param[in] i4_pad_ht 207 * number of rows to be padded 208 * 209 * @returns error status 210 * 211 * @remarks none 212 * 213 ******************************************************************************* 214 */ 215 IH264E_ERROR_T isvce_pad_recon_buffer(isvce_process_ctxt_t *ps_proc, UWORD8 *pu1_curr_pic_luma, 216 WORD32 i4_luma_stride, UWORD8 *pu1_curr_pic_chroma, 217 WORD32 i4_chroma_stride, WORD32 i4_mb_x, WORD32 i4_mb_y, 218 WORD32 i4_pad_ht); 219 220 /** 221 ******************************************************************************* 222 * 223 * @brief This function performs luma half pel planes generation 224 * 225 * @par Description: 226 * 227 * @param[in] ps_proc 228 * Process context corresponding to the job 229 * 230 * @returns error status 231 * 232 * @remarks none 233 * 234 ******************************************************************************* 235 */ 236 IH264E_ERROR_T isvce_halfpel_generation(isvce_process_ctxt_t *ps_proc, UWORD8 *pu1_curr_pic_luma, 237 WORD32 i4_mb_x, WORD32 i4_mb_y); 238 239 /** 240 ******************************************************************************* 241 * 242 * @brief This function performs luma & chroma core coding for a set of mb's. 243 * 244 * @par Description: 245 * The mb to be coded is taken and is evaluated over a predefined set of modes 246 * (intra (i16, i4, i8)/inter (mv, skip)) for best cost. The mode with least 247 *cost is selected and using intra/inter prediction filters, prediction is 248 *carried out. The deviation between src and pred signal constitutes error 249 *signal. This error signal is transformed (hierarchical transform if necessary) 250 *and quantized. The quantized residue is packed in to entropy buffer for entropy 251 *coding. This is repeated for all the mb's enlisted under the job. 252 * 253 * @param[in] ps_proc 254 * Process context corresponding to the job 255 * 256 * @returns error status 257 * 258 * @remarks none 259 * 260 ******************************************************************************* 261 */ 262 WORD32 isvce_process(isvce_process_ctxt_t *ps_proc); 263 264 /** 265 ******************************************************************************* 266 * 267 * @brief 268 * entry point of a spawned encoder thread 269 * 270 * @par Description: 271 * The encoder thread dequeues a proc/entropy job from the encoder queue and 272 * calls necessary routines. 273 * 274 * @param[in] pv_proc 275 * Process context corresponding to the thread 276 * 277 * @returns error status 278 * 279 * @remarks 280 * 281 ******************************************************************************* 282 */ 283 WORD32 isvce_process_thread(void *pv_proc); 284 285 #endif 286