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