1 /*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 /* ---- includes ----------------------------------------------------------- */
18
19 #include "b_BasicEm/Functions.h"
20 #include "b_APIEm/FaceFinderRef.h"
21 #include "b_APIEm/Functions.h"
22
23 /* ------------------------------------------------------------------------- */
24
25 /* ========================================================================= */
26 /* */
27 /* ---- \ghd{ auxiliary functions } ---------------------------------------- */
28 /* */
29 /* ========================================================================= */
30
31 /* ------------------------------------------------------------------------- */
32
33 /* ========================================================================= */
34 /* */
35 /* ---- \ghd{ constructor / destructor } ----------------------------------- */
36 /* */
37 /* ========================================================================= */
38
39 /* ------------------------------------------------------------------------- */
40
bpi_FaceFinderRef_init(struct bbs_Context * cpA,struct bpi_FaceFinderRef * ptrA)41 void bpi_FaceFinderRef_init( struct bbs_Context* cpA,
42 struct bpi_FaceFinderRef* ptrA )
43 {
44 bbs_UInt16Arr_init( cpA, &ptrA->objBufE );
45 ptrA->faceFinderPtrE = NULL;
46 }
47
48 /* ------------------------------------------------------------------------- */
49
bpi_FaceFinderRef_exit(struct bbs_Context * cpA,struct bpi_FaceFinderRef * ptrA)50 void bpi_FaceFinderRef_exit( struct bbs_Context* cpA,
51 struct bpi_FaceFinderRef* ptrA )
52 {
53 if( ptrA->faceFinderPtrE != NULL ) bpi_faceFinderExit( cpA, ptrA->faceFinderPtrE );
54 bbs_UInt16Arr_exit( cpA, &ptrA->objBufE );
55 }
56
57 /* ------------------------------------------------------------------------- */
58
59 /* ========================================================================= */
60 /* */
61 /* ---- \ghd{ operators } -------------------------------------------------- */
62 /* */
63 /* ========================================================================= */
64
65 /* ------------------------------------------------------------------------- */
66
bpi_FaceFinderRef_copy(struct bbs_Context * cpA,struct bpi_FaceFinderRef * ptrA,const struct bpi_FaceFinderRef * srcPtrA)67 void bpi_FaceFinderRef_copy( struct bbs_Context* cpA,
68 struct bpi_FaceFinderRef* ptrA,
69 const struct bpi_FaceFinderRef* srcPtrA )
70 {
71 bbs_ERROR0( "bpi_FaceFinderRef_copy: function is not implemented" );
72 }
73
74 /* ------------------------------------------------------------------------- */
75
bpi_FaceFinderRef_equal(struct bbs_Context * cpA,const struct bpi_FaceFinderRef * ptrA,const struct bpi_FaceFinderRef * srcPtrA)76 flag bpi_FaceFinderRef_equal( struct bbs_Context* cpA,
77 const struct bpi_FaceFinderRef* ptrA,
78 const struct bpi_FaceFinderRef* srcPtrA )
79 {
80 bbs_ERROR0( "bpi_FaceFinderRef_equal: function is not implemented" );
81 return FALSE;
82 }
83
84 /* ------------------------------------------------------------------------- */
85
86 /* ========================================================================= */
87 /* */
88 /* ---- \ghd{ query functions } -------------------------------------------- */
89 /* */
90 /* ========================================================================= */
91
92 /* ------------------------------------------------------------------------- */
93
94 /* ========================================================================= */
95 /* */
96 /* ---- \ghd{ modify functions } ------------------------------------------- */
97 /* */
98 /* ========================================================================= */
99
100 /* ------------------------------------------------------------------------- */
101
102 /* ========================================================================= */
103 /* */
104 /* ---- \ghd{ I/O } -------------------------------------------------------- */
105 /* */
106 /* ========================================================================= */
107
108 /* ------------------------------------------------------------------------- */
109
bpi_FaceFinderRef_memSize(struct bbs_Context * cpA,const struct bpi_FaceFinderRef * ptrA)110 uint32 bpi_FaceFinderRef_memSize( struct bbs_Context* cpA,
111 const struct bpi_FaceFinderRef* ptrA )
112 {
113 uint32 memSizeL = 0;
114 memSizeL += bbs_SIZEOF16( uint32 ); /* mem size */
115 memSizeL += bbs_SIZEOF16( flag ); /* object presence flag */
116 if( ptrA->faceFinderPtrE != NULL ) memSizeL += bpi_faceFinderMemSize( cpA, ptrA->faceFinderPtrE );
117 memSizeL += bbs_SIZEOF16( uint16 ); /* csa */
118 return memSizeL;
119 }
120
121 /* ------------------------------------------------------------------------- */
122
bpi_FaceFinderRef_memWrite(struct bbs_Context * cpA,const struct bpi_FaceFinderRef * ptrA,uint16 * memPtrA)123 uint32 bpi_FaceFinderRef_memWrite( struct bbs_Context* cpA,
124 const struct bpi_FaceFinderRef* ptrA,
125 uint16* memPtrA )
126 {
127 uint32 memSizeL = bpi_FaceFinderRef_memSize( cpA, ptrA );
128 flag objPresentL = ptrA->faceFinderPtrE != NULL;
129 memPtrA += bbs_memWrite32( &memSizeL, memPtrA );
130 memPtrA += bbs_memWrite32( &objPresentL, memPtrA );
131 if( objPresentL ) memPtrA += bpi_faceFinderMemWrite( cpA, ptrA->faceFinderPtrE, memPtrA );
132 memPtrA += bpi_memWriteCsa16( memPtrA, memSizeL, 0xFFFF );
133 return memSizeL;
134 }
135
136 /* ------------------------------------------------------------------------- */
137
bpi_FaceFinderRef_memRead(struct bbs_Context * cpA,struct bpi_FaceFinderRef * ptrA,uint32 maxImageWidthA,uint32 maxImageHeightA,const uint16 * memPtrA,struct bbs_MemTbl * mtpA)138 uint32 bpi_FaceFinderRef_memRead( struct bbs_Context* cpA,
139 struct bpi_FaceFinderRef* ptrA,
140 uint32 maxImageWidthA,
141 uint32 maxImageHeightA,
142 const uint16* memPtrA,
143 struct bbs_MemTbl* mtpA )
144 {
145 uint32 memSizeL;
146 flag objPresentL;
147 struct bbs_MemTbl memTblL = *mtpA;
148 struct bbs_MemSeg* espL = bbs_MemTbl_segPtr( cpA, &memTblL, 0 );
149 if( bbs_Context_error( cpA ) ) return 0;
150 memPtrA += bbs_memRead32( &memSizeL, memPtrA );
151 memPtrA += bbs_memRead32( &objPresentL, memPtrA );
152
153 /* check object & allocate data buffer */
154 {
155 const uint16* memPtrL = memPtrA;
156 uint32 dataSizeL = 0;
157
158 if( objPresentL )
159 {
160 enum bpi_FaceFinderType typeL = ( enum bpi_FaceFinderType )bbs_memPeek32( memPtrL + 4 );
161 dataSizeL += bpi_faceFinderSizeOf16( cpA, typeL );
162 memPtrL += bbs_memPeek32( memPtrL );
163 }
164
165 bbs_UInt16Arr_create( cpA, &ptrA->objBufE, dataSizeL, espL );
166 }
167
168 /* load object */
169 {
170 uint16* dataPtrL = ptrA->objBufE.arrPtrE;
171
172 if( objPresentL )
173 {
174 enum bpi_FaceFinderType typeL = ( enum bpi_FaceFinderType )bbs_memPeek32( memPtrA + 4 );
175 ptrA->faceFinderPtrE = ( struct bpi_FaceFinder* )dataPtrL;
176 bpi_faceFinderInit( cpA, ptrA->faceFinderPtrE, typeL );
177 ptrA->faceFinderPtrE->vpSetParamsE( cpA, ptrA->faceFinderPtrE, maxImageWidthA, maxImageHeightA );
178 memPtrA += bpi_faceFinderMemRead( cpA, ptrA->faceFinderPtrE, memPtrA, &memTblL );
179 dataPtrL += bpi_faceFinderSizeOf16( cpA, typeL );
180 }
181 else
182 {
183 ptrA->faceFinderPtrE = NULL;
184 }
185 }
186
187 memPtrA += bpi_memReadCsa16( memPtrA );
188
189 return memSizeL;
190 }
191
192 /* ------------------------------------------------------------------------- */
193
194 /* ========================================================================= */
195 /* */
196 /* ---- \ghd{ exec functions } --------------------------------------------- */
197 /* */
198 /* ========================================================================= */
199
200 /* ------------------------------------------------------------------------- */
201
bpi_FaceFinderRef_setParams(struct bbs_Context * cpA,struct bpi_FaceFinderRef * ptrA,uint32 maxImageWidthA,uint32 maxImageHeightA)202 void bpi_FaceFinderRef_setParams( struct bbs_Context* cpA,
203 struct bpi_FaceFinderRef* ptrA,
204 uint32 maxImageWidthA,
205 uint32 maxImageHeightA )
206 {
207 bbs_DEF_fNameL( "bpi_FaceFinderRef_setParams" );
208 if( ptrA->faceFinderPtrE == NULL )
209 {
210 bbs_ERROR1( "%s:\nNo face finder object was loaded", fNameL );
211 return;
212 }
213 ptrA->faceFinderPtrE->vpSetParamsE( cpA, ptrA->faceFinderPtrE, maxImageWidthA, maxImageHeightA );
214 }
215
216 /* ------------------------------------------------------------------------- */
217
bpi_FaceFinderRef_setRange(struct bbs_Context * cpA,struct bpi_FaceFinderRef * ptrA,uint32 minEyeDistanceA,uint32 maxEyeDistanceA)218 void bpi_FaceFinderRef_setRange( struct bbs_Context* cpA,
219 struct bpi_FaceFinderRef* ptrA,
220 uint32 minEyeDistanceA,
221 uint32 maxEyeDistanceA )
222 {
223 bbs_DEF_fNameL( "bpi_FaceFinderRef_setRange" );
224 if( ptrA->faceFinderPtrE == NULL )
225 {
226 bbs_ERROR1( "%s:\nNo face finder object was loaded", fNameL );
227 return;
228 }
229 ptrA->faceFinderPtrE->vpSetRangeE( cpA, ptrA->faceFinderPtrE, minEyeDistanceA, maxEyeDistanceA );
230 }
231
232 /* ------------------------------------------------------------------------- */
233
bpi_FaceFinderRef_process(struct bbs_Context * cpA,const struct bpi_FaceFinderRef * ptrA,struct bpi_DCR * dcrPtrA)234 int32 bpi_FaceFinderRef_process( struct bbs_Context* cpA,
235 const struct bpi_FaceFinderRef* ptrA,
236 struct bpi_DCR* dcrPtrA )
237 {
238 bbs_DEF_fNameL( "bpi_FaceFinderRef_process" );
239 if( ptrA->faceFinderPtrE == NULL )
240 {
241 bbs_ERROR1( "%s:\nNo face finder object was loaded", fNameL );
242 return 0;
243 }
244 return ptrA->faceFinderPtrE->vpProcessE( cpA, ptrA->faceFinderPtrE, dcrPtrA );
245 }
246
247 /* ------------------------------------------------------------------------- */
248
bpi_FaceFinderRef_putDcr(struct bbs_Context * cpA,const struct bpi_FaceFinderRef * ptrA,struct bpi_DCR * dcrPtrA)249 int32 bpi_FaceFinderRef_putDcr( struct bbs_Context* cpA,
250 const struct bpi_FaceFinderRef* ptrA,
251 struct bpi_DCR* dcrPtrA )
252 {
253 bbs_DEF_fNameL( "bpi_FaceFinderRef_putDcr" );
254 if( ptrA->faceFinderPtrE == NULL )
255 {
256 bbs_ERROR1( "%s:\nNo face finder object was loaded", fNameL );
257 return 0;
258 }
259 return ptrA->faceFinderPtrE->vpPutDcrE( cpA, ptrA->faceFinderPtrE, dcrPtrA );
260 }
261
262 /* ------------------------------------------------------------------------- */
263
bpi_FaceFinderRef_getDcr(struct bbs_Context * cpA,const struct bpi_FaceFinderRef * ptrA,uint32 indexA,struct bpi_DCR * dcrPtrA)264 void bpi_FaceFinderRef_getDcr( struct bbs_Context* cpA,
265 const struct bpi_FaceFinderRef* ptrA,
266 uint32 indexA,
267 struct bpi_DCR* dcrPtrA )
268 {
269 bbs_DEF_fNameL( "bpi_FaceFinderRef_getDcr" );
270 if( ptrA->faceFinderPtrE == NULL )
271 {
272 bbs_ERROR1( "%s:\nNo face finder object was loaded", fNameL );
273 return;
274 }
275 ptrA->faceFinderPtrE->vpGetDcrE( cpA, ptrA->faceFinderPtrE, indexA, dcrPtrA );
276 }
277
278
279 /* ------------------------------------------------------------------------- */
280
281 /* ========================================================================= */
282
283