/src/libmpeg2/common/impeg2_disp_mgr.c
Line | Count | Source (jump to first uncovered line) |
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 | | * @file |
23 | | * impeg2_disp_mgr.c |
24 | | * |
25 | | * @brief |
26 | | * Contains function definitions for display management |
27 | | * |
28 | | * @author |
29 | | * Srinivas T |
30 | | * |
31 | | * @par List of Functions: |
32 | | * - impeg2_disp_mgr_init() |
33 | | * - impeg2_disp_mgr_add() |
34 | | * - impeg2_disp_mgr_get() |
35 | | * |
36 | | * @remarks |
37 | | * None |
38 | | * |
39 | | ******************************************************************************* |
40 | | */ |
41 | | #include <stdio.h> |
42 | | #include <stdlib.h> |
43 | | #include "iv_datatypedef.h" |
44 | | #include "impeg2_defs.h" |
45 | | #include "impeg2_disp_mgr.h" |
46 | | |
47 | | /** |
48 | | ******************************************************************************* |
49 | | * |
50 | | * @brief |
51 | | * Initialization function for display buffer manager |
52 | | * |
53 | | * @par Description: |
54 | | * Initializes the display buffer management structure |
55 | | * |
56 | | * @param[in] ps_disp_mgr |
57 | | * Pointer to the display buffer management structure |
58 | | * |
59 | | * @returns none |
60 | | * |
61 | | * @remarks |
62 | | * None |
63 | | * |
64 | | ******************************************************************************* |
65 | | */ |
66 | | void impeg2_disp_mgr_init( |
67 | | disp_mgr_t *ps_disp_mgr) |
68 | 14.8k | { |
69 | 14.8k | WORD32 id; |
70 | | |
71 | | |
72 | 963k | for(id = 0; id < DISP_MGR_MAX_CNT; id++) |
73 | 948k | { |
74 | 948k | ps_disp_mgr->apv_ptr[id] = NULL; |
75 | 948k | } |
76 | | |
77 | 14.8k | ps_disp_mgr->i4_wr_idx = 0; |
78 | 14.8k | ps_disp_mgr->i4_rd_idx = 0; |
79 | 14.8k | } |
80 | | |
81 | | |
82 | | /** |
83 | | ******************************************************************************* |
84 | | * |
85 | | * @brief |
86 | | * Adds a buffer to the display manager |
87 | | * |
88 | | * @par Description: |
89 | | * Adds a buffer to the display buffer manager |
90 | | * |
91 | | * @param[in] ps_disp_mgr |
92 | | * Pointer to the diaplay buffer management structure |
93 | | * |
94 | | * @param[in] buf_id |
95 | | * ID of the display buffer |
96 | | * |
97 | | * @param[in] abs_poc |
98 | | * Absolute POC of the display buffer |
99 | | * |
100 | | * @param[in] pv_ptr |
101 | | * Pointer to the display buffer |
102 | | * |
103 | | * @returns 0 if success, -1 otherwise |
104 | | * |
105 | | * @remarks |
106 | | * None |
107 | | * |
108 | | ******************************************************************************* |
109 | | */ |
110 | | WORD32 impeg2_disp_mgr_add(disp_mgr_t *ps_disp_mgr, |
111 | | void *pv_ptr, |
112 | | WORD32 i4_buf_id) |
113 | 18.5k | { |
114 | | |
115 | | |
116 | 18.5k | WORD32 id; |
117 | 18.5k | id = ps_disp_mgr->i4_wr_idx % DISP_MGR_MAX_CNT; |
118 | | |
119 | 18.5k | ps_disp_mgr->apv_ptr[id] = pv_ptr; |
120 | 18.5k | ps_disp_mgr->ai4_buf_id[id] = i4_buf_id; |
121 | 18.5k | ps_disp_mgr->i4_wr_idx++; |
122 | | |
123 | 18.5k | return 0; |
124 | 18.5k | } |
125 | | |
126 | | |
127 | | /** |
128 | | ******************************************************************************* |
129 | | * |
130 | | * @brief |
131 | | * Gets the next buffer |
132 | | * |
133 | | * @par Description: |
134 | | * Gets the next display buffer |
135 | | * |
136 | | * @param[in] ps_disp_mgr |
137 | | * Pointer to the display buffer structure |
138 | | * |
139 | | * @param[out] pi4_buf_id |
140 | | * Pointer to hold buffer id of the display buffer being returned |
141 | | * |
142 | | * @returns Pointer to the next display buffer |
143 | | * |
144 | | * @remarks |
145 | | * None |
146 | | * |
147 | | ******************************************************************************* |
148 | | */ |
149 | | void* impeg2_disp_mgr_get(disp_mgr_t *ps_disp_mgr, WORD32 *pi4_buf_id) |
150 | 18.7k | { |
151 | 18.7k | WORD32 id; |
152 | | |
153 | 18.7k | *pi4_buf_id = -1; |
154 | | |
155 | 18.7k | if(ps_disp_mgr->i4_rd_idx < ps_disp_mgr->i4_wr_idx) |
156 | 16.1k | { |
157 | 16.1k | id = ps_disp_mgr->i4_rd_idx % DISP_MGR_MAX_CNT; |
158 | 16.1k | if(NULL == ps_disp_mgr->apv_ptr[id]) |
159 | 0 | { |
160 | 0 | return NULL; |
161 | 0 | } |
162 | | |
163 | 16.1k | *pi4_buf_id = ps_disp_mgr->ai4_buf_id[id]; |
164 | | |
165 | 16.1k | ps_disp_mgr->i4_rd_idx++; |
166 | | |
167 | 16.1k | return ps_disp_mgr->apv_ptr[id]; |
168 | 16.1k | } |
169 | 2.65k | else |
170 | 2.65k | return NULL; |
171 | | |
172 | 18.7k | } |