aboutsummaryrefslogtreecommitdiff
path: root/common/ih264_list.h
blob: 4b97d593e9a7f8dcfcedf353ec43d6ad505bc8b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/******************************************************************************
 *
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *****************************************************************************
 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
*/

/**
*******************************************************************************
* @file
*  ih264_list.h
*
* @brief
*  Contains functions for buf queue
*
* @author
*  ittiam
*
* @remarks
*  none
*
*******************************************************************************
*/

#ifndef _IH264_LIST_H_
#define _IH264_LIST_H_

/*****************************************************************************/
/* Structure Definitions                                                     */
/*****************************************************************************/
typedef struct
{
    /** Pointer to buffer base which contains the bufs */
    void *pv_buf_base;

    /** Mutex used to keep the functions thread-safe */
    void *pv_mutex;

    /** Current write index */
    volatile WORD32 i4_buf_wr_idx;

    /** Current read index */
    volatile WORD32 i4_buf_rd_idx;

    /** Maximum index */
    WORD32 i4_buf_max_idx;

    /** Log2(buf_max_idx) -
     * To ensure number of entries is power of two
     * This makes it easier to wrap around by using AND with buf_max_idx - 1
     * */
    WORD32 i4_log2_buf_max_idx;

    /** Flag to indicate list has to be terminated */
    WORD32 i4_terminate;

    /** Size of each entry */
    WORD32 i4_entry_size;

    /** If the list is to be used frequently send this as zero, else send a large value
     * to ensure cores are not loaded unnecessarily.
     * For eg: For picture level queues this can be a large value like 100us
     * but for jobq this will be zero.
     */
    WORD32 i4_yield_interval_us;

}list_t;

/*****************************************************************************/
/* Function Declarations                                                     */
/*****************************************************************************/
WORD32 ih264_list_size(WORD32 num_entries, WORD32 entry_size);

void* ih264_list_init(void *pv_buf, WORD32 buf_size, WORD32 num_entries,
                      WORD32 entry_size, WORD32 yeild_interval_us);

IH264_ERROR_T ih264_list_free(list_t *ps_list);

IH264_ERROR_T ih264_list_reset(list_t *ps_list);

IH264_ERROR_T ih264_list_deinit(list_t *ps_list);

IH264_ERROR_T ih264_list_terminate(list_t *ps_list);

IH264_ERROR_T ih264_list_queue(list_t *ps_list, void *pv_buf, WORD32 blocking);

IH264_ERROR_T ih264_list_dequeue(list_t *ps_list, void *pv_buf,
                                 WORD32 blocking);

#endif /* _IH264_LIST_H_ */