xref: /aosp_15_r20/external/libavc/common/ih264_list.h (revision 495ae853bb871d1e5a258cb02c2cc13cde8ddb9a)
1 /******************************************************************************
2  *
3  * Copyright (C) 2015 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 *  ih264_list.h
25 *
26 * @brief
27 *  Contains functions for buf queue
28 *
29 * @author
30 *  ittiam
31 *
32 * @remarks
33 *  none
34 *
35 *******************************************************************************
36 */
37 
38 #ifndef _IH264_LIST_H_
39 #define _IH264_LIST_H_
40 
41 /*****************************************************************************/
42 /* Structure Definitions                                                     */
43 /*****************************************************************************/
44 typedef struct
45 {
46     /** Pointer to buffer base which contains the bufs */
47     void *pv_buf_base;
48 
49     /** Mutex used to keep the functions thread-safe */
50     void *pv_mutex;
51 
52     /** Current write index */
53     volatile WORD32 i4_buf_wr_idx;
54 
55     /** Current read index */
56     volatile WORD32 i4_buf_rd_idx;
57 
58     /** Maximum index */
59     WORD32 i4_buf_max_idx;
60 
61     /** Log2(buf_max_idx) -
62      * To ensure number of entries is power of two
63      * This makes it easier to wrap around by using AND with buf_max_idx - 1
64      * */
65     WORD32 i4_log2_buf_max_idx;
66 
67     /** Flag to indicate list has to be terminated */
68     WORD32 i4_terminate;
69 
70     /** Size of each entry */
71     WORD32 i4_entry_size;
72 
73     /** If the list is to be used frequently send this as zero, else send a large value
74      * to ensure cores are not loaded unnecessarily.
75      * For eg: For picture level queues this can be a large value like 100us
76      * but for jobq this will be zero.
77      */
78     WORD32 i4_yield_interval_us;
79 
80 }list_t;
81 
82 /*****************************************************************************/
83 /* Function Declarations                                                     */
84 /*****************************************************************************/
85 WORD32 ih264_list_size(WORD32 num_entries, WORD32 entry_size);
86 
87 void* ih264_list_init(void *pv_buf, WORD32 buf_size, WORD32 num_entries,
88                       WORD32 entry_size, WORD32 yeild_interval_us);
89 
90 IH264_ERROR_T ih264_list_free(list_t *ps_list);
91 
92 IH264_ERROR_T ih264_list_reset(list_t *ps_list);
93 
94 IH264_ERROR_T ih264_list_deinit(list_t *ps_list);
95 
96 IH264_ERROR_T ih264_list_terminate(list_t *ps_list);
97 
98 IH264_ERROR_T ih264_list_queue(list_t *ps_list, void *pv_buf, WORD32 blocking);
99 
100 IH264_ERROR_T ih264_list_dequeue(list_t *ps_list, void *pv_buf,
101                                  WORD32 blocking);
102 
103 #endif /* _IH264_LIST_H_ */
104