OpenMAX Bellagio 0.9.3
OMXCoreRMExt.c
Go to the documentation of this file.
1
26#ifndef _GNU_SOURCE
27#define _GNU_SOURCE
28#endif
29
30#include <stdio.h>
31#include <stdlib.h>
32#include <string.h>
33#include "common.h"
34#include "OMXCoreRMExt.h"
36
37static int data_loaded = 0;
38static stLoaderComponentType** qualityList;
39static int qualityListItems = 0;
40
41OMX_ERRORTYPE getSupportedQualityLevels(OMX_STRING cComponentName, OMX_U32** ppQualityLevel, OMX_U32* pNrOfQualityLevels) {
43 int found = 0;
44 int j,i,k;
45 if (pNrOfQualityLevels == NULL) {
46 return OMX_ErrorUndefined;
47 }
48
49 if (!data_loaded) {
51 if (err != OMX_ErrorNone) {
52 return err;
53 }
54 data_loaded = 1;
55 }
56 for (i = 0; i<qualityListItems; i++) {
57 if(!strcmp(qualityList[i]->name, cComponentName)) {
58 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s found requested component %s with quality levels %i\n", __func__, cComponentName, (int)qualityList[i]->nqualitylevels);
59 *pNrOfQualityLevels = qualityList[i]->nqualitylevels;
60 if (ppQualityLevel == NULL) {
61 return OMX_ErrorNone;
62 }
63 for (k=0; k<qualityList[i]->nqualitylevels; k++) {
64 (*ppQualityLevel)[k] = k+1;
65 }
66 found = 1;
67 } else {
68 for(j=0;j<qualityList[i]->name_specific_length;j++) {
69 if(!strcmp(qualityList[i]->name_specific[j], cComponentName)) {
70 DEBUG(DEB_LEV_SIMPLE_SEQ, "Found requested component %s IN SPECIFIC COMPONENT \n", cComponentName);
71 *pNrOfQualityLevels = qualityList[i]->nqualitylevels;
72 if (ppQualityLevel == NULL) {
73 return OMX_ErrorNone;
74 }
75 for (k=0; k<qualityList[i]->nqualitylevels; k++) {
76 (*ppQualityLevel)[k] = k+1;
77 }
78 found = 1;
79 }
80 }
81 }
82 if(found) {
83 break;
84 }
85 }
86 if(!found) {
87 DEBUG(DEB_LEV_ERR, "Not found any component\n");
88 *pNrOfQualityLevels = 0;
89 }
90 return OMX_ErrorNone;
91}
92
93OMX_ERRORTYPE getMultiResourceEstimates(OMX_STRING cComponentName, OMX_U32 nQualityLevel, multiResourceDescriptor* pMultiResourceEstimates) {
95 int found = 0;
96 int j,i = 0;
97
98 if (pMultiResourceEstimates == NULL) {
99 return OMX_ErrorUndefined;
100 }
101 if (!data_loaded) {
103 if (err != OMX_ErrorNone) {
104 return err;
105 }
106 data_loaded = 1;
107 }
108 for (i = 0; i<qualityListItems; i++) {
109 if(!strcmp(qualityList[i]->name, cComponentName)) {
110 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s found requested component %s with quality level %i\n", __func__, cComponentName, (int)nQualityLevel);
111 if ((nQualityLevel>0) && (nQualityLevel<=qualityList[i]->nqualitylevels)) {
112 found = 1;
113 pMultiResourceEstimates->CPUResourceRequested = qualityList[i]->multiResourceLevel[nQualityLevel-1]->CPUResourceRequested;
114 pMultiResourceEstimates->MemoryResourceRequested = qualityList[i]->multiResourceLevel[nQualityLevel-1]->MemoryResourceRequested;
115 break;
116 }
117 } else {
118 for(j=0;j<qualityList[i]->name_specific_length;j++) {
119 if(!strcmp(qualityList[i]-> name_specific[j], cComponentName)) {
120 DEBUG(DEB_LEV_SIMPLE_SEQ, "Found requested component %s IN SPECIFIC COMPONENT \n", cComponentName);
121 if ((nQualityLevel>0) && (nQualityLevel<=qualityList[i]->nqualitylevels)) {
122 found = 1;
123 pMultiResourceEstimates->CPUResourceRequested = qualityList[i]->multiResourceLevel[nQualityLevel-1]->CPUResourceRequested;
124 pMultiResourceEstimates->MemoryResourceRequested = qualityList[i]->multiResourceLevel[nQualityLevel-1]->MemoryResourceRequested;
125 break;
126 }
127 if (found) {
128 break;
129 }
130 }
131 }
132 }
133 if(found) {
134 break;
135 }
136 }
137 if(!found) {
138 pMultiResourceEstimates->CPUResourceRequested = -1;
139 pMultiResourceEstimates->MemoryResourceRequested = -1;
140 }
141 return OMX_ErrorNone;
142}
143
147 FILE* omxregistryfp;
148 char* line = NULL;
149 char *libname;
150 int index_readline;
151 int listindex;
152 char *registry_filename;
153 int numberOfLines = 0;
154 int index;
155 int tempindex;
156 int wordlength;
157 int roleindex;
158 int numlevels;
159 int i;
160
161 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s\n", __func__);
162 qualityList = NULL;
163
164 registry_filename = componentsRegistryGetFilenameCheck(1);
165 omxregistryfp = fopen(registry_filename, "r");
166 if (omxregistryfp == NULL){
167 DEBUG(DEB_LEV_ERR, "Cannot open OpenMAX registry file %s\n", registry_filename);
168 return OMX_ErrorUndefined;
169 }
170 free(registry_filename);
171 libname = malloc(OMX_MAX_STRINGNAME_SIZE * 2);
172 line = malloc(MAX_LINE_LENGTH+1);
173 fseek(omxregistryfp, 0, 0);
174
175 while(1) {
176 index_readline = 0;
177 while(index_readline < MAX_LINE_LENGTH) {
178 *(line+index_readline) = fgetc(omxregistryfp);
179 if ((*(line+index_readline) == '\n') || (*(line+index_readline) == '\0')) {
180 break;
181 }
182 index_readline++;
183 }
184 *(line+index_readline) = '\0';
185 if ((index_readline >= MAX_LINE_LENGTH) || (index_readline == 0)) {
186 break;
187 }
188 if ((*line == ' ') && (*(line+1) == '=')) {
189 numberOfLines++;
190 } else {
191 continue;
192 }
193 }
194 fseek(omxregistryfp, 0, 0);
195 qualityList = malloc(numberOfLines * sizeof (stLoaderComponentType*));
196 qualityListItems = numberOfLines;
197 listindex = 0;
198
199 while(1) {
200 index_readline = 0;
201 while(index_readline < MAX_LINE_LENGTH) {
202 *(line+index_readline) = fgetc(omxregistryfp);
203 if ((*(line+index_readline) == '\n') || (*(line+index_readline) == '\0')) {
204 break;
205 }
206 index_readline++;
207 }
208 *(line+index_readline) = '\0';
209 if ((index_readline >= MAX_LINE_LENGTH) || (index_readline == 0)) {
210 break;
211 }
212
213 if ((*line == ' ') && (*(line+1) == '=')) {
214 qualityList[listindex] = NULL;
215 qualityList[listindex] = calloc(1,sizeof(stLoaderComponentType));
216 index = 5;
217 wordlength = 0;
218 while((*(line + index) != ' ') && (*(line + index) != '\0')) {
219 wordlength++;
220 index++;
221 }
222 qualityList[listindex]->name = malloc(wordlength + 1);
223 strncpy(qualityList[listindex]->name, (line + 5), wordlength);
224 *(qualityList[listindex]->name + wordlength) = '\0';
225 // count rules
226 if (*(line + index) == '\n') {
227 listindex++;
228 continue;
229 }
230 index = index + 5;
231 tempindex = index;
232 qualityList[listindex]->name_specific_length = 0;
233 while((*(line + tempindex) != ' ') && (*(line + tempindex) != '\0')) {
234 while(*(line + tempindex) !=':') {
235 tempindex++;
236 }
237 tempindex++;
238 qualityList[listindex]->name_specific_length++;
239 }
240 qualityList[listindex]->name_specific = calloc(qualityList[listindex]->name_specific_length, sizeof(char *));
241 roleindex = 0;
242 while((*(line + index) != ' ') && (*(line + index) != '\n')) {
243 wordlength = 0;
244 tempindex = index;
245 while(*(line + index) !=':') {
246 wordlength++;
247 index++;
248 }
249 tempindex = index - tempindex;
250 qualityList[listindex]->name_specific[roleindex] = malloc(tempindex + 1);
251 strncpy(qualityList[listindex]->name_specific[roleindex], (line+index-tempindex), tempindex);
252 *(qualityList[listindex]->name_specific[roleindex]+tempindex) = '\0';
253 roleindex++;
254 index++;
255 }
256 if (*(line + index) == '\0') {
257 listindex++;
258 continue;
259 }
260 // finally reached the quality levels
261 index = index + 5;
262 numlevels = 0;
263 while(1) {
264 if (*(line + index) != ' ') {
265 numlevels = (numlevels * 10) + (*(line + index) -'0');
266 index++;
267 } else {
268 qualityList[listindex]->nqualitylevels = numlevels;
269 qualityList[listindex]->multiResourceLevel = malloc(sizeof(multiResourceDescriptor *) * qualityList[listindex]->nqualitylevels);
270 for (i = 0; i<qualityList[listindex]->nqualitylevels; i++) {
271 qualityList[listindex]->multiResourceLevel[i] = malloc(sizeof(multiResourceDescriptor));
272 }
273 break;
274 }
275 }
276 index++;
277 for (i = 0; i<qualityList[listindex]->nqualitylevels; i++) {
278 qualityList[listindex]->multiResourceLevel[i]->CPUResourceRequested = 0;
279 qualityList[listindex]->multiResourceLevel[i]->MemoryResourceRequested = 0;
280 while(*(line + index) != ',') {
281 qualityList[listindex]->multiResourceLevel[i]->CPUResourceRequested = (qualityList[listindex]->multiResourceLevel[i]->CPUResourceRequested * 10) + (*(line + index) - '0');
282 index++;
283 }
284 index++;
285 while((*(line + index) != ' ') && (*(line + index) != '\n')) {
286 qualityList[listindex]->multiResourceLevel[i]->MemoryResourceRequested = (qualityList[listindex]->multiResourceLevel[i]->MemoryResourceRequested * 10) + (*(line + index) - '0');
287 index++;
288 }
289 index++;
290 }
291 listindex++;
292 }
293 }
294
295 if(line) {
296 free(line);
297 line = NULL;
298 }
299 free(libname);
300 libname = NULL;
301 fclose(omxregistryfp);
302 DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s\n", __func__);
303 return OMX_ErrorNone;
304}
#define OMX_MAX_STRINGNAME_SIZE
Definition OMX_Core.h:281
OMX_ERRORTYPE
Definition OMX_Core.h:127
@ OMX_ErrorNone
Definition OMX_Core.h:128
@ OMX_ErrorUndefined
Definition OMX_Core.h:134
unsigned long OMX_U32
Definition OMX_Types.h:145
char * OMX_STRING
Definition OMX_Types.h:206
OMX_ERRORTYPE getSupportedQualityLevels(OMX_STRING cComponentName, OMX_U32 **ppQualityLevel, OMX_U32 *pNrOfQualityLevels)
Returns the supported quality levels for a scalable OMXIL component.
OMX_ERRORTYPE getMultiResourceEstimates(OMX_STRING cComponentName, OMX_U32 nQualityLevel, multiResourceDescriptor *pMultiResourceEstimates)
Returns the multiresource estimates for a given OMXIL component name and quality level.
OMX_ERRORTYPE readRegistryFile()
char * componentsRegistryGetFilenameCheck(int check_exists)
Definition common.c:51
#define MAX_LINE_LENGTH
Definition common.h:30
#define DEB_LEV_FUNCTION_NAME
#define DEB_LEV_ERR
#define DEB_LEV_SIMPLE_SEQ
#define DEBUG(n, fmt, args...)
OMX_ERRORTYPE err
the private data structure handled by the ST static loader that described an OpenMAX component
multiResourceDescriptor ** multiResourceLevel

Generated for OpenMAX Bellagio rel. 0.9.3 by  doxygen 1.5.1
SourceForge.net Logo