Initial Contribution
The Android Open Source Project [Tue, 21 Oct 2008 14:00:00 +0000 (07:00 -0700)]
189 files changed:
Android.mk [new file with mode: 0644]
Embedded/common/conf/b_BasicEm/LibConfig.h [new file with mode: 0644]
Embedded/common/data/APIEm/Modules/RFFprec_501.bmd [new file with mode: 0644]
Embedded/common/data/APIEm/Modules/RFFspeed_501.bmd [new file with mode: 0644]
Embedded/common/data/APIEm/Modules/RFFstd_501.bmd [new file with mode: 0644]
Embedded/common/src/b_APIEm/BFFaceFinder.c [new file with mode: 0644]
Embedded/common/src/b_APIEm/BFFaceFinder.h [new file with mode: 0644]
Embedded/common/src/b_APIEm/DCR.c [new file with mode: 0644]
Embedded/common/src/b_APIEm/DCR.h [new file with mode: 0644]
Embedded/common/src/b_APIEm/FaceFinder.c [new file with mode: 0644]
Embedded/common/src/b_APIEm/FaceFinder.h [new file with mode: 0644]
Embedded/common/src/b_APIEm/FaceFinderRef.c [new file with mode: 0644]
Embedded/common/src/b_APIEm/FaceFinderRef.h [new file with mode: 0644]
Embedded/common/src/b_APIEm/Functions.c [new file with mode: 0644]
Embedded/common/src/b_APIEm/Functions.h [new file with mode: 0644]
Embedded/common/src/b_APIEm/Types.h [new file with mode: 0644]
Embedded/common/src/b_BasicEm/APh.c [new file with mode: 0644]
Embedded/common/src/b_BasicEm/APh.h [new file with mode: 0644]
Embedded/common/src/b_BasicEm/APhArr.c [new file with mode: 0644]
Embedded/common/src/b_BasicEm/APhArr.h [new file with mode: 0644]
Embedded/common/src/b_BasicEm/Basic.h [new file with mode: 0644]
Embedded/common/src/b_BasicEm/Complex.c [new file with mode: 0644]
Embedded/common/src/b_BasicEm/Complex.h [new file with mode: 0644]
Embedded/common/src/b_BasicEm/ComplexArr.c [new file with mode: 0644]
Embedded/common/src/b_BasicEm/ComplexArr.h [new file with mode: 0644]
Embedded/common/src/b_BasicEm/Config.h [new file with mode: 0644]
Embedded/common/src/b_BasicEm/Context.c [new file with mode: 0644]
Embedded/common/src/b_BasicEm/Context.h [new file with mode: 0644]
Embedded/common/src/b_BasicEm/DynMemManager.c [new file with mode: 0644]
Embedded/common/src/b_BasicEm/DynMemManager.h [new file with mode: 0644]
Embedded/common/src/b_BasicEm/Functions.c [new file with mode: 0644]
Embedded/common/src/b_BasicEm/Functions.h [new file with mode: 0644]
Embedded/common/src/b_BasicEm/Int16Arr.c [new file with mode: 0644]
Embedded/common/src/b_BasicEm/Int16Arr.h [new file with mode: 0644]
Embedded/common/src/b_BasicEm/Int32Arr.c [new file with mode: 0644]
Embedded/common/src/b_BasicEm/Int32Arr.h [new file with mode: 0644]
Embedded/common/src/b_BasicEm/Int8Arr.c [new file with mode: 0644]
Embedded/common/src/b_BasicEm/Int8Arr.h [new file with mode: 0644]
Embedded/common/src/b_BasicEm/Math.c [new file with mode: 0644]
Embedded/common/src/b_BasicEm/Math.h [new file with mode: 0644]
Embedded/common/src/b_BasicEm/MathSSE2.c [new file with mode: 0644]
Embedded/common/src/b_BasicEm/MemSeg.c [new file with mode: 0644]
Embedded/common/src/b_BasicEm/MemSeg.h [new file with mode: 0644]
Embedded/common/src/b_BasicEm/MemTbl.c [new file with mode: 0644]
Embedded/common/src/b_BasicEm/MemTbl.h [new file with mode: 0644]
Embedded/common/src/b_BasicEm/Memory.c [new file with mode: 0644]
Embedded/common/src/b_BasicEm/Memory.h [new file with mode: 0644]
Embedded/common/src/b_BasicEm/Phase.c [new file with mode: 0644]
Embedded/common/src/b_BasicEm/Phase.h [new file with mode: 0644]
Embedded/common/src/b_BasicEm/String.c [new file with mode: 0644]
Embedded/common/src/b_BasicEm/String.h [new file with mode: 0644]
Embedded/common/src/b_BasicEm/UInt16Arr.c [new file with mode: 0644]
Embedded/common/src/b_BasicEm/UInt16Arr.h [new file with mode: 0644]
Embedded/common/src/b_BasicEm/UInt32Arr.c [new file with mode: 0644]
Embedded/common/src/b_BasicEm/UInt32Arr.h [new file with mode: 0644]
Embedded/common/src/b_BasicEm/UInt8Arr.c [new file with mode: 0644]
Embedded/common/src/b_BasicEm/UInt8Arr.h [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/BitParam.c [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/BitParam.h [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/Feature.c [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/Feature.h [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/Functions.c [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/Functions.h [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/I04Dns2x2Ftr.c [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/I04Dns2x2Ftr.h [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/I04Dns2x4Ftr.c [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/I04Dns2x4Ftr.h [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/I04Tld2x4Ftr.c [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/I04Tld2x4Ftr.h [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/L01Dns2x4Ftr.c [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/L01Dns2x4Ftr.h [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/L01Tld1x1Ftr.c [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/L01Tld1x1Ftr.h [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/L01Tld2x4Ftr.c [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/L01Tld2x4Ftr.h [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/L04Dns2x2Ftr.c [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/L04Dns2x2Ftr.h [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/L04Dns2x4Ftr.c [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/L04Dns2x4Ftr.h [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/L04Dns3x3Ftr.c [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/L04Dns3x3Ftr.h [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/L04Tld2x4Ftr.c [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/L04Tld2x4Ftr.h [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/L06Dns3x3Ftr.c [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/L06Dns3x3Ftr.h [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/L06Dns4x4Ftr.c [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/L06Dns4x4Ftr.h [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/L06DnsNx4x4Ftr.c [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/L06DnsNx4x4Ftr.h [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/LocalScanDetector.c [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/LocalScanDetector.h [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/LocalScanner.c [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/LocalScanner.h [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/ScanDetector.c [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/ScanDetector.h [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/Scanner.c [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/Scanner.h [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/Sequence.c [new file with mode: 0644]
Embedded/common/src/b_BitFeatureEm/Sequence.h [new file with mode: 0644]
Embedded/common/src/b_ImageEm/APhImage.c [new file with mode: 0644]
Embedded/common/src/b_ImageEm/APhImage.h [new file with mode: 0644]
Embedded/common/src/b_ImageEm/ComplexImage.c [new file with mode: 0644]
Embedded/common/src/b_ImageEm/ComplexImage.h [new file with mode: 0644]
Embedded/common/src/b_ImageEm/Flt16Image.c [new file with mode: 0644]
Embedded/common/src/b_ImageEm/Flt16Image.h [new file with mode: 0644]
Embedded/common/src/b_ImageEm/Functions.c [new file with mode: 0644]
Embedded/common/src/b_ImageEm/Functions.h [new file with mode: 0644]
Embedded/common/src/b_ImageEm/HistoEq.c [new file with mode: 0644]
Embedded/common/src/b_ImageEm/HistoEq.h [new file with mode: 0644]
Embedded/common/src/b_ImageEm/HistoEq16.c [new file with mode: 0644]
Embedded/common/src/b_ImageEm/HistoEq16.h [new file with mode: 0644]
Embedded/common/src/b_ImageEm/ToneDownBGSupp.c [new file with mode: 0644]
Embedded/common/src/b_ImageEm/ToneDownBGSupp.h [new file with mode: 0644]
Embedded/common/src/b_ImageEm/UInt16ByteImage.c [new file with mode: 0644]
Embedded/common/src/b_ImageEm/UInt16ByteImage.h [new file with mode: 0644]
Embedded/common/src/b_ImageEm/UInt16BytePyrImage.c [new file with mode: 0644]
Embedded/common/src/b_ImageEm/UInt16BytePyrImage.h [new file with mode: 0644]
Embedded/common/src/b_ImageEm/UInt32Image.c [new file with mode: 0644]
Embedded/common/src/b_ImageEm/UInt32Image.h [new file with mode: 0644]
Embedded/common/src/b_ImageEm/UInt8Image.c [new file with mode: 0644]
Embedded/common/src/b_ImageEm/UInt8Image.h [new file with mode: 0644]
Embedded/common/src/b_ImageEm/UInt8PyramidalImage.c [new file with mode: 0644]
Embedded/common/src/b_ImageEm/UInt8PyramidalImage.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Alt.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Alt.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Cluster2D.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Cluster2D.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Cluster3D.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Cluster3D.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/CompactAlt.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/CompactAlt.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/CompactMat.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/CompactMat.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Flt16Alt2D.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Flt16Alt2D.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Flt16Alt3D.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Flt16Alt3D.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Flt16Mat2D.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Flt16Mat2D.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Flt16Mat3D.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Flt16Mat3D.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Flt16Vec.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Flt16Vec.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Flt16Vec2D.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Flt16Vec2D.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Flt16Vec3D.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Flt16Vec3D.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Functions.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Functions.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/IdCluster2D.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/IdCluster2D.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Int16Mat2D.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Int16Mat2D.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Int16Rect.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Int16Rect.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Int16Vec2D.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Int16Vec2D.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Int16Vec3D.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Int16Vec3D.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Int32Mat.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Int32Mat.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/MapSequence.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/MapSequence.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Mat.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Mat.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Normalizer.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Normalizer.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/RBFMap2D.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/RBFMap2D.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/SubVecMap.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/SubVecMap.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Uint32Rect.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/Uint32Rect.h [new file with mode: 0644]
Embedded/common/src/b_TensorEm/VectorMap.c [new file with mode: 0644]
Embedded/common/src/b_TensorEm/VectorMap.h [new file with mode: 0644]
FaceDetector_jni.cpp [new file with mode: 0644]
FaceRecEm/common/src/b_FDSDK/DCR.c [new file with mode: 0644]
FaceRecEm/common/src/b_FDSDK/DCR.h [new file with mode: 0644]
FaceRecEm/common/src/b_FDSDK/DCR_Internal.h [new file with mode: 0644]
FaceRecEm/common/src/b_FDSDK/FaceFinder.c [new file with mode: 0644]
FaceRecEm/common/src/b_FDSDK/FaceFinder.h [new file with mode: 0644]
FaceRecEm/common/src/b_FDSDK/FaceFinder_Internal.h [new file with mode: 0644]
FaceRecEm/common/src/b_FDSDK/SDK.c [new file with mode: 0644]
FaceRecEm/common/src/b_FDSDK/SDK.h [new file with mode: 0644]
FaceRecEm/common/src/b_FDSDK/SDK_Internal.h [new file with mode: 0644]
FaceRecEm/common/src/b_FDSDK/Types.h [new file with mode: 0644]
FaceRecEm/common/src/b_FDSDK/fd_emb_sdk.h [new file with mode: 0644]
MODULE_LICENSE_APACHE2 [new file with mode: 0644]
NOTICE [new file with mode: 0644]

diff --git a/Android.mk b/Android.mk
new file mode 100644 (file)
index 0000000..e223867
--- /dev/null
@@ -0,0 +1,136 @@
+# Copyright (C) 2008 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.
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+       FaceDetector_jni.cpp \
+       Embedded/common/src/b_APIEm/DCR.c \
+       Embedded/common/src/b_APIEm/BFFaceFinder.c \
+       Embedded/common/src/b_APIEm/FaceFinder.c \
+       Embedded/common/src/b_APIEm/FaceFinderRef.c \
+       Embedded/common/src/b_APIEm/Functions.c \
+       Embedded/common/src/b_BasicEm/APh.c \
+       Embedded/common/src/b_BasicEm/APhArr.c \
+       Embedded/common/src/b_BasicEm/Complex.c \
+       Embedded/common/src/b_BasicEm/ComplexArr.c \
+       Embedded/common/src/b_BasicEm/Context.c \
+       Embedded/common/src/b_BasicEm/DynMemManager.c \
+       Embedded/common/src/b_BasicEm/Functions.c \
+       Embedded/common/src/b_BasicEm/Int16Arr.c \
+       Embedded/common/src/b_BasicEm/Int32Arr.c \
+       Embedded/common/src/b_BasicEm/Int8Arr.c \
+       Embedded/common/src/b_BasicEm/Math.c.arm \
+       Embedded/common/src/b_BasicEm/MemSeg.c \
+       Embedded/common/src/b_BasicEm/MemTbl.c \
+       Embedded/common/src/b_BasicEm/Memory.c \
+       Embedded/common/src/b_BasicEm/Phase.c \
+       Embedded/common/src/b_BasicEm/String.c \
+       Embedded/common/src/b_BasicEm/UInt16Arr.c \
+       Embedded/common/src/b_BasicEm/UInt32Arr.c \
+       Embedded/common/src/b_BasicEm/UInt8Arr.c \
+       Embedded/common/src/b_BitFeatureEm/BitParam.c \
+       Embedded/common/src/b_BitFeatureEm/Feature.c \
+       Embedded/common/src/b_BitFeatureEm/Functions.c \
+       Embedded/common/src/b_BitFeatureEm/I04Dns2x2Ftr.c \
+       Embedded/common/src/b_BitFeatureEm/I04Dns2x4Ftr.c \
+       Embedded/common/src/b_BitFeatureEm/I04Tld2x4Ftr.c \
+       Embedded/common/src/b_BitFeatureEm/L01Dns2x4Ftr.c \
+       Embedded/common/src/b_BitFeatureEm/L01Tld1x1Ftr.c \
+       Embedded/common/src/b_BitFeatureEm/L01Tld2x4Ftr.c \
+       Embedded/common/src/b_BitFeatureEm/L04Dns2x2Ftr.c \
+       Embedded/common/src/b_BitFeatureEm/L04Dns2x4Ftr.c \
+       Embedded/common/src/b_BitFeatureEm/L04Dns3x3Ftr.c \
+       Embedded/common/src/b_BitFeatureEm/L04Tld2x4Ftr.c \
+       Embedded/common/src/b_BitFeatureEm/L06Dns3x3Ftr.c \
+       Embedded/common/src/b_BitFeatureEm/L06Dns4x4Ftr.c \
+       Embedded/common/src/b_BitFeatureEm/L06DnsNx4x4Ftr.c \
+       Embedded/common/src/b_BitFeatureEm/LocalScanDetector.c \
+       Embedded/common/src/b_BitFeatureEm/LocalScanner.c \
+       Embedded/common/src/b_BitFeatureEm/ScanDetector.c \
+       Embedded/common/src/b_BitFeatureEm/Scanner.c \
+       Embedded/common/src/b_BitFeatureEm/Sequence.c \
+       Embedded/common/src/b_ImageEm/APhImage.c \
+       Embedded/common/src/b_ImageEm/ComplexImage.c \
+       Embedded/common/src/b_ImageEm/Flt16Image.c \
+       Embedded/common/src/b_ImageEm/Functions.c \
+       Embedded/common/src/b_ImageEm/HistoEq.c \
+       Embedded/common/src/b_ImageEm/UInt16ByteImage.c \
+       Embedded/common/src/b_ImageEm/UInt16BytePyrImage.c \
+       Embedded/common/src/b_ImageEm/UInt8Image.c \
+       Embedded/common/src/b_ImageEm/UInt32Image.c \
+       Embedded/common/src/b_ImageEm/UInt8PyramidalImage.c \
+       Embedded/common/src/b_TensorEm/Alt.c \
+       Embedded/common/src/b_TensorEm/Cluster2D.c \
+       Embedded/common/src/b_TensorEm/Cluster3D.c \
+       Embedded/common/src/b_TensorEm/CompactAlt.c \
+       Embedded/common/src/b_TensorEm/CompactMat.c \
+       Embedded/common/src/b_TensorEm/Flt16Alt2D.c \
+       Embedded/common/src/b_TensorEm/Flt16Alt3D.c \
+       Embedded/common/src/b_TensorEm/Flt16Mat2D.c \
+       Embedded/common/src/b_TensorEm/Flt16Mat3D.c \
+       Embedded/common/src/b_TensorEm/Flt16Vec.c \
+       Embedded/common/src/b_TensorEm/Flt16Vec2D.c \
+       Embedded/common/src/b_TensorEm/Flt16Vec3D.c \
+       Embedded/common/src/b_TensorEm/Functions.c \
+       Embedded/common/src/b_TensorEm/IdCluster2D.c \
+       Embedded/common/src/b_TensorEm/Int16Mat2D.c \
+       Embedded/common/src/b_TensorEm/Int16Rect.c \
+       Embedded/common/src/b_TensorEm/Int16Vec2D.c \
+       Embedded/common/src/b_TensorEm/Int16Vec3D.c \
+       Embedded/common/src/b_TensorEm/Int32Mat.c \
+       Embedded/common/src/b_TensorEm/MapSequence.c \
+       Embedded/common/src/b_TensorEm/Mat.c \
+       Embedded/common/src/b_TensorEm/Normalizer.c \
+       Embedded/common/src/b_TensorEm/RBFMap2D.c \
+       Embedded/common/src/b_TensorEm/SubVecMap.c \
+       Embedded/common/src/b_TensorEm/Uint32Rect.c \
+       Embedded/common/src/b_TensorEm/VectorMap.c \
+       FaceRecEm/common/src/b_FDSDK/DCR.c \
+       FaceRecEm/common/src/b_FDSDK/FaceFinder.c \
+       FaceRecEm/common/src/b_FDSDK/SDK.c
+##
+
+LOCAL_CFLAGS += -Depl_LINUX
+
+LOCAL_C_INCLUDES += \
+       external/neven/FaceRecEm/common/src/b_FDSDK \
+       $(JNI_H_INCLUDE) \
+       $(call include-path-for, corecg graphics) \
+       $(LOCAL_PATH)/FaceRecEm/common/src \
+       $(LOCAL_PATH)/Embedded/common/conf \
+       $(LOCAL_PATH)/Embedded/common/src \
+       $(LOCAL_PATH)/unix/src
+
+LOCAL_SHARED_LIBRARIES := \
+       libandroid_runtime \
+       libnativehelper \
+       libutils \
+       libcorecg \
+       libsgl \
+       libcutils
+
+LOCAL_MODULE:= libFFTEm
+
+ALL_PREBUILT += $(TARGET_OUT)/usr/share/bmd/RFFspeed_501.bmd
+$(TARGET_OUT)/usr/share/bmd/RFFspeed_501.bmd : $(LOCAL_PATH)/Embedded/common/data/APIEm/Modules/RFFspeed_501.bmd | $(ACP)
+       $(transform-prebuilt-to-target)
+
+ALL_PREBUILT += $(TARGET_OUT)/usr/share/bmd/RFFstd_501.bmd
+$(TARGET_OUT)/usr/share/bmd/RFFstd_501.bmd : $(LOCAL_PATH)/Embedded/common/data/APIEm/Modules/RFFstd_501.bmd | $(ACP)
+       $(transform-prebuilt-to-target)
+
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/Embedded/common/conf/b_BasicEm/LibConfig.h b/Embedded/common/conf/b_BasicEm/LibConfig.h
new file mode 100644 (file)
index 0000000..dfe8e12
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+#ifndef bbs_LIB_CONFIG_H
+#define bbs_LIB_CONFIG_H
+
+/* ----------------- library tags --------------------------- */
+
+/* ----------------- other tags ----------------------------- */
+
+#define bbs_MINIMIZE_FRQ_IMG
+
+#define bbs_USE_FRQ_IMG_SYMMETRY
+
+/*#define bbs_COMPACT_MESSAGE_HANDLING*/
+
+#define bbs_ENABLE_BIT_FEATURE
+
+#endif /* bbs_LIB_CONFIG_H */
diff --git a/Embedded/common/data/APIEm/Modules/RFFprec_501.bmd b/Embedded/common/data/APIEm/Modules/RFFprec_501.bmd
new file mode 100644 (file)
index 0000000..00f96a6
Binary files /dev/null and b/Embedded/common/data/APIEm/Modules/RFFprec_501.bmd differ
diff --git a/Embedded/common/data/APIEm/Modules/RFFspeed_501.bmd b/Embedded/common/data/APIEm/Modules/RFFspeed_501.bmd
new file mode 100644 (file)
index 0000000..e7299a5
Binary files /dev/null and b/Embedded/common/data/APIEm/Modules/RFFspeed_501.bmd differ
diff --git a/Embedded/common/data/APIEm/Modules/RFFstd_501.bmd b/Embedded/common/data/APIEm/Modules/RFFstd_501.bmd
new file mode 100644 (file)
index 0000000..2187396
Binary files /dev/null and b/Embedded/common/data/APIEm/Modules/RFFstd_501.bmd differ
diff --git a/Embedded/common/src/b_APIEm/BFFaceFinder.c b/Embedded/common/src/b_APIEm/BFFaceFinder.c
new file mode 100644 (file)
index 0000000..180d376
--- /dev/null
@@ -0,0 +1,499 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_APIEm/BFFaceFinder.h"
+#include "b_APIEm/Functions.h"
+#include "b_APIEm/DCR.h"
+#include "b_BasicEm/Functions.h"
+#include "b_BasicEm/Math.h"
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ auxiliary functions } ---------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ constructor / destructor } ----------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_BFFaceFinder_init( struct bbs_Context* cpA,
+                                                   struct bpi_BFFaceFinder* ptrA )
+{
+       bpi_FaceFinder_init( cpA, &ptrA->baseE );
+       ptrA->baseE.typeE = ( uint32 )bpi_FF_BF_FACE_FINDER;
+       ptrA->baseE.vpSetParamsE = bpi_BFFaceFinder_setParams;
+       ptrA->baseE.vpSetRangeE = bpi_BFFaceFinder_setRange;
+       ptrA->baseE.vpProcessE = bpi_BFFaceFinder_processDcr;
+       ptrA->baseE.vpPutDcrE = bpi_BFFaceFinder_putDcr;
+       ptrA->baseE.vpGetDcrE = bpi_BFFaceFinder_getDcr;
+
+       ptrA->detectedFacesE = 0;
+       ptrA->availableFacesE = 0;
+       ptrA->faceDataBufferE = NULL;
+       bbf_ScanDetector_init( cpA, &ptrA->detectorE );
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_BFFaceFinder_exit( struct bbs_Context* cpA,
+                                                   struct bpi_BFFaceFinder* ptrA )
+{
+       ptrA->detectedFacesE = 0;
+       ptrA->availableFacesE = 0;
+       ptrA->faceDataBufferE = NULL;
+       bbf_ScanDetector_exit( cpA, &ptrA->detectorE );
+
+       bpi_FaceFinder_exit( cpA, &ptrA->baseE );
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ operators } -------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_BFFaceFinder_copy( struct bbs_Context* cpA,
+                                                   struct bpi_BFFaceFinder* ptrA, 
+                                                       const struct bpi_BFFaceFinder* srcPtrA )
+{
+       bpi_FaceFinder_copy( cpA, &ptrA->baseE, &srcPtrA->baseE );
+       bbf_ScanDetector_copy( cpA, &ptrA->detectorE, &srcPtrA->detectorE );
+}
+
+/* ------------------------------------------------------------------------- */
+
+flag bpi_BFFaceFinder_equal( struct bbs_Context* cpA,
+                                                        const struct bpi_BFFaceFinder* ptrA, 
+                                                        const struct bpi_BFFaceFinder* srcPtrA )
+{
+       if( !bpi_FaceFinder_equal( cpA, &ptrA->baseE, &srcPtrA->baseE ) ) return FALSE;
+       if( !bbf_ScanDetector_equal( cpA, &ptrA->detectorE, &srcPtrA->detectorE ) ) return FALSE;
+       return TRUE;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ query functions } -------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_BFFaceFinder_getMinEyeDistance( const struct bpi_BFFaceFinder* ptrA )
+{
+       return ( ( ptrA->detectorE.refDistanceE >> 8 ) * ( ptrA->detectorE.minScaleE >> 12 ) ) >> 16;
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_BFFaceFinder_getMaxEyeDistance( const struct bpi_BFFaceFinder* ptrA )
+{
+       return ( ( ptrA->detectorE.refDistanceE >> 8 ) * ( ptrA->detectorE.maxScaleE >> 12 ) ) >> 16;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+       
+void bpi_BFFaceFinder_setMinEyeDistance( struct bbs_Context* cpA,
+                                                                                struct bpi_BFFaceFinder* ptrA, 
+                                                                                uint32 distA )
+{
+       ptrA->detectorE.minScaleE = ( ( distA << 16 ) / ( ptrA->detectorE.refDistanceE >> 8 ) ) << 12;
+       if( ptrA->detectorE.minScaleE < 0x100000 /* 1.0 */ ) ptrA->detectorE.minScaleE = 0x100000;
+}
+
+/* ------------------------------------------------------------------------- */
+       
+void bpi_BFFaceFinder_setMaxEyeDistance( struct bbs_Context* cpA,
+                                                                                struct bpi_BFFaceFinder* ptrA, 
+                                                                                uint32 distA )
+{
+       if( distA > 0x0FFFF )
+       {
+               ptrA->detectorE.maxScaleE = 0; /* unlimited */
+       }
+       else
+       {
+               ptrA->detectorE.maxScaleE = ( ( distA << 16 ) / ( ptrA->detectorE.refDistanceE >> 8 ) ) << 12;
+       }
+}
+
+/* ------------------------------------------------------------------------- */
+       
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ I/O } -------------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bpi_BFFaceFinder_memSize( struct bbs_Context* cpA,
+                                                                const struct bpi_BFFaceFinder *ptrA )
+{
+       uint32 memSizeL = 0;
+       memSizeL += bbs_SIZEOF16( uint32 );
+       memSizeL += bbs_SIZEOF16( uint32 ); /* version */
+       memSizeL += bpi_FaceFinder_memSize( cpA, &ptrA->baseE );
+       memSizeL += bbf_ScanDetector_memSize( cpA, &ptrA->detectorE );
+       memSizeL += bbs_SIZEOF16( uint16 ); /* csa */
+       return memSizeL;
+}
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bpi_BFFaceFinder_memWrite( struct bbs_Context* cpA,
+                                                                 const struct bpi_BFFaceFinder* ptrA, 
+                                                                 uint16* memPtrA )
+{
+       uint32 memSizeL = bpi_BFFaceFinder_memSize( cpA, ptrA );
+       memPtrA += bbs_memWrite32( &memSizeL, memPtrA );
+       memPtrA += bbs_memWriteUInt32( bpi_BF_FACE_FINDER_VERSION, memPtrA );
+       memPtrA += bpi_FaceFinder_memWrite( cpA, &ptrA->baseE, memPtrA );
+       memPtrA += bbf_ScanDetector_memWrite( cpA, &ptrA->detectorE, memPtrA );
+       memPtrA += bpi_memWriteCsa16( memPtrA, memSizeL, 0xFFFF );
+       return memSizeL;
+}
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bpi_BFFaceFinder_memRead( struct bbs_Context* cpA,
+                                                                struct bpi_BFFaceFinder* ptrA, 
+                                                                const uint16* memPtrA,
+                                                                struct bbs_MemTbl* mtpA )
+{
+       uint32 memSizeL, versionL;
+       if( bbs_Context_error( cpA ) ) return 0;
+       memPtrA += bbs_memRead32( &memSizeL, memPtrA );
+       memPtrA += bbs_memReadVersion32( cpA, &versionL, bpi_BF_FACE_FINDER_VERSION, memPtrA );
+       memPtrA += bpi_FaceFinder_memRead( cpA, &ptrA->baseE, memPtrA );
+       if( bbs_Context_error( cpA ) ) return 0;
+
+       memPtrA += bbf_ScanDetector_memRead( cpA, &ptrA->detectorE, memPtrA, mtpA );
+       if( bbs_Context_error( cpA ) ) return 0;
+       memPtrA += bpi_memReadCsa16( memPtrA );
+
+/*     if( memSizeL != bpi_BFFaceFinder_memSize( cpA, ptrA ) )
+       {
+               bbs_ERROR0( "uint32 bpi_BFFaceFinder_memRead( .... ):\n"
+                    "Module file is corrupt or incorrect. Please check if the face finder module is still supported." ); 
+               return 0;
+       }
+*/
+       return memSizeL;
+}
+
+/* ------------------------------------------------------------------------- */
+       
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+       
+/* ------------------------------------------------------------------------- */
+
+int32 bpi_BFFaceFinder_process( struct bbs_Context* cpA,
+                                                           const struct bpi_BFFaceFinder* ptrA, 
+                                                               void* imagePtrA,
+                                                               uint32 imageWidthA,
+                                                               uint32 imageHeightA,
+                                                               const struct bts_Int16Rect* roiPtrA,
+                                                               struct bts_Int16Vec2D* offsPtrA,
+                                                               struct bts_IdCluster2D* idClusterPtrA )
+{
+       int32 xL = 0; /* 16.16 */
+       int32 yL = 0; /* 16.16 */
+       uint32 scaleL = 0;
+       int32 actL = 0;
+       int32* outArrL;
+
+       struct bts_Flt16Alt2D altL;
+       struct bts_Flt16Vec2D centerL;
+
+       struct bpi_BFFaceFinder* ptrL = ( struct bpi_BFFaceFinder* )ptrA;
+
+       /* reset multi face imformation so they are not accidentally used */
+       ptrL->detectedFacesE = 0;
+       ptrL->availableFacesE = 0;
+       ptrL->faceDataBufferE = NULL;
+
+       bbf_ScanDetector_process( cpA, ( struct bbf_ScanDetector* )&ptrA->detectorE, imagePtrA, imageWidthA, imageHeightA, roiPtrA, &outArrL );
+
+       xL      = outArrL[ 0 ]; /* 16.16 */
+       yL      = outArrL[ 1 ]; /* 16.16 */
+       scaleL  = outArrL[ 2 ]; /* 12.20 */
+       actL    = outArrL[ 3 ]; /*  4.28 */
+
+       if( bbs_Context_error( cpA ) ) return 0;
+
+       offsPtrA->xE = xL >> 16;
+       offsPtrA->yE = yL >> 16;
+       xL -= ( ( int32 )offsPtrA->xE << 16 );
+       yL -= ( ( int32 )offsPtrA->yE << 16 );
+
+       centerL = bts_Flt16Vec2D_create32( 0, 0, 0 );
+       altL = bts_Flt16Alt2D_createScale( scaleL, 20, &centerL );
+       altL.vecE = bts_Flt16Vec2D_create32( xL, yL, 16 );
+
+       /* compute cluster */
+       {
+               uint32 eyeDistL = ( ( ptrA->detectorE.refDistanceE >> 16 ) * scaleL ) >> 20;
+               uint32 logEyeDistL = bbs_intLog2( eyeDistL );
+               int32 bbpL = 11 - logEyeDistL;
+               bbpL = bbpL < 0 ? 0 : bbpL;
+               bbpL = bbpL > 6 ? 6 : bbpL;
+               bts_IdCluster2D_copyTransform( cpA, idClusterPtrA, &ptrA->detectorE.refClusterE, altL, bbpL );
+       }
+
+
+       return ( actL + 0x10000000 ) >> 5; /*output range 0...1 in 8.24*/
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_BFFaceFinder_multiProcess( struct bbs_Context* cpA,
+                                                                         const struct bpi_BFFaceFinder* ptrA, 
+                                                                         void* imagePtrA,
+                                                                         uint32 imageWidthA,
+                                                                         uint32 imageHeightA,
+                                                                         const struct bts_Int16Rect* roiPtrA )
+{
+       struct bpi_BFFaceFinder* ptrL = ( struct bpi_BFFaceFinder* )ptrA;
+       ptrL->detectedFacesE = bbf_ScanDetector_process( cpA, ( struct bbf_ScanDetector* )&ptrA->detectorE, imagePtrA, imageWidthA, imageHeightA, roiPtrA, &ptrL->faceDataBufferE );
+       ptrL->availableFacesE = ptrA->detectedFacesE > 0 ? ptrA->detectedFacesE : 1;
+       if( bbs_Context_error( cpA ) ) return 0;
+       return ptrL->detectedFacesE;
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_BFFaceFinder_getFace( struct bbs_Context* cpA,
+                                                                const struct bpi_BFFaceFinder* ptrA, 
+                                                                uint32 indexA,
+                                                                struct bts_Int16Vec2D* offsPtrA,
+                                                                struct bts_IdCluster2D* idClusterPtrA )
+{
+       bbs_DEF_fNameL( "bpi_BFFaceFinder_getFace" )
+       int32 xL = 0; /* 16.16 */
+       int32 yL = 0; /* 16.16 */
+       uint32 scaleL = 0;
+       int32 actL = 0;
+       struct bts_Flt16Alt2D altL;
+       struct bts_Flt16Vec2D centerL;
+
+       if( bbs_Context_error( cpA ) ) return 0;
+
+       if( ptrA->availableFacesE == 0 || ptrA->faceDataBufferE == NULL ) 
+       {
+               bbs_ERROR1( "%s:\nNo faces are availabe. This function was called before the face finder could detect multiple faces in an image", fNameL );
+               return 0;
+       }
+
+       if( indexA >= ptrA->availableFacesE ) 
+       {
+               bbs_ERROR1( "%s:\nface index exceeds number of available faces", fNameL );
+               return 0;
+       }
+
+       xL      = ptrA->faceDataBufferE[ indexA * 4 + 0 ]; /* 16.16 */
+       yL      = ptrA->faceDataBufferE[ indexA * 4 + 1 ]; /* 16.16 */
+       scaleL  = ptrA->faceDataBufferE[ indexA * 4 + 2 ]; /* 12.20 */
+       actL    = ptrA->faceDataBufferE[ indexA * 4 + 3 ]; /*  4.28 */
+
+       offsPtrA->xE = xL >> 16;
+       offsPtrA->yE = yL >> 16;
+
+       xL -= ( ( int32 )offsPtrA->xE << 16 );
+       yL -= ( ( int32 )offsPtrA->yE << 16 );
+
+       centerL = bts_Flt16Vec2D_create32( 0, 0, 0 );
+       altL = bts_Flt16Alt2D_createScale( scaleL, 20, &centerL );
+       altL.vecE = bts_Flt16Vec2D_create32( xL, yL, 16 );
+
+       /* compute cluster */
+       {
+               uint32 eyeDistL = ( ( ptrA->detectorE.refDistanceE >> 16 ) * scaleL ) >> 20;
+               uint32 logEyeDistL = bbs_intLog2( eyeDistL );
+               int32 bbpL = 11 - logEyeDistL;
+               bbpL = bbpL < 0 ? 0 : bbpL;
+               bbpL = bbpL > 6 ? 6 : bbpL;
+               bts_IdCluster2D_copyTransform( cpA, idClusterPtrA, &ptrA->detectorE.refClusterE, altL, bbpL );
+       }
+
+       return ( actL + 0x10000000 ) >> 5; /*output range 0...1 in 8.24*/
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_BFFaceFinder_getFaceDCR( struct bbs_Context* cpA,
+                                                                 const struct bpi_BFFaceFinder* ptrA, 
+                                                                 uint32 indexA,
+                                                                 struct bpi_DCR* dcrPtrA )
+{
+       int32 confL = bpi_BFFaceFinder_getFace( cpA, ptrA, indexA, &dcrPtrA->offsE, &dcrPtrA->mainClusterE );
+       bts_IdCluster2D_copy( cpA, &dcrPtrA->sdkClusterE, &dcrPtrA->mainClusterE );
+       dcrPtrA->confidenceE = confL;
+       dcrPtrA->approvedE = confL > ( ( int32 )1 << 23 );
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_BFFaceFinder_setMaxImageSize( struct bbs_Context* cpA,
+                                                                          struct bpi_BFFaceFinder* ptrA, 
+                                                                          uint32 maxImageWidthA,
+                                                                          uint32 maxImageHeightA )
+{
+       ptrA->detectorE.maxImageWidthE = maxImageWidthA;
+       ptrA->detectorE.maxImageHeightE = maxImageHeightA;
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_BFFaceFinder_setParams( struct bbs_Context* cpA,
+                                                                struct bpi_FaceFinder* ptrA, 
+                                                                uint32 maxImageWidthA,
+                                                                uint32 maxImageHeightA )
+{
+       bbs_DEF_fNameL( "bpi_BFFaceFinder_setParams" );
+
+       if( bbs_Context_error( cpA ) ) return;
+
+       if( ptrA->typeE != bpi_FF_BF_FACE_FINDER ) 
+       {
+               bbs_ERROR1( "%s:\nObject type mismatch", fNameL );
+               return;
+       }
+       bpi_BFFaceFinder_setMaxImageSize( cpA, ( struct bpi_BFFaceFinder* )ptrA, maxImageWidthA, maxImageHeightA );
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_BFFaceFinder_setRange( struct bbs_Context* cpA,
+                                                               struct bpi_FaceFinder* ptrA, 
+                                                               uint32 minEyeDistanceA,
+                                                               uint32 maxEyeDistanceA )
+{
+       bbs_DEF_fNameL( "bpi_BFFaceFinder_setParams" );
+
+       if( bbs_Context_error( cpA ) ) return;
+
+       if( ptrA->typeE != bpi_FF_BF_FACE_FINDER ) 
+       {
+               bbs_ERROR1( "%s:\nObject type mismatch", fNameL );
+               return;
+       }
+       bpi_BFFaceFinder_setMinEyeDistance( cpA, ( struct bpi_BFFaceFinder* )ptrA, minEyeDistanceA );
+       bpi_BFFaceFinder_setMaxEyeDistance( cpA, ( struct bpi_BFFaceFinder* )ptrA, maxEyeDistanceA );
+}
+
+/* ------------------------------------------------------------------------- */
+
+int32 bpi_BFFaceFinder_processDcr( struct bbs_Context* cpA,
+                                                                  const struct bpi_FaceFinder* ptrA, 
+                                                          struct bpi_DCR* dcrPtrA )
+{
+       bbs_DEF_fNameL( "bpi_BFFaceFinder_processDcr" );
+
+       if( bbs_Context_error( cpA ) ) return 0;
+
+       if( ptrA->typeE != bpi_FF_BF_FACE_FINDER ) 
+       {
+               bbs_ERROR1( "%s:\nObject type mismatch", fNameL );
+               return 0;
+       }
+
+       return bpi_BFFaceFinder_process( cpA, 
+                                                                       ( const struct bpi_BFFaceFinder* )ptrA, 
+                                                                       dcrPtrA->imageDataPtrE,
+                                                                       dcrPtrA->imageWidthE,
+                                                                       dcrPtrA->imageHeightE,
+                                                                       &dcrPtrA->roiRectE,
+                                                                       &dcrPtrA->offsE,
+                                                                       &dcrPtrA->mainClusterE );
+}
+
+/* ------------------------------------------------------------------------- */
+
+int32 bpi_BFFaceFinder_putDcr( struct bbs_Context* cpA,
+                                                          const struct bpi_FaceFinder* ptrA, 
+                                                          struct bpi_DCR* dcrPtrA )
+{
+       bbs_DEF_fNameL( "bpi_BFFaceFinder_putDcr" );
+
+       if( bbs_Context_error( cpA ) ) return 0;
+
+       if( ptrA->typeE != bpi_FF_BF_FACE_FINDER ) 
+       {
+               bbs_ERROR1( "%s:\nObject type mismatch", fNameL );
+               return 0;
+       }
+
+       return bpi_BFFaceFinder_multiProcess( cpA, 
+                                                                                ( const struct bpi_BFFaceFinder* )ptrA, 
+                                                                                dcrPtrA->imageDataPtrE,
+                                                                                dcrPtrA->imageWidthE,
+                                                                                dcrPtrA->imageHeightE,
+                                                                                &dcrPtrA->roiRectE );
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_BFFaceFinder_getDcr( struct bbs_Context* cpA,
+                                                         const struct bpi_FaceFinder* ptrA, 
+                                                         uint32 indexA,
+                                                         struct bpi_DCR* dcrPtrA )
+{
+       bbs_DEF_fNameL( "bpi_BFFaceFinder_getDcr" );
+
+       if( bbs_Context_error( cpA ) ) return;
+
+       if( ptrA->typeE != bpi_FF_BF_FACE_FINDER ) 
+       {
+               bbs_ERROR1( "%s:\nObject type mismatch", fNameL );
+               return;
+       }
+
+       bpi_BFFaceFinder_getFaceDCR( cpA, ( const struct bpi_BFFaceFinder* )ptrA, indexA, dcrPtrA );
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
diff --git a/Embedded/common/src/b_APIEm/BFFaceFinder.h b/Embedded/common/src/b_APIEm/BFFaceFinder.h
new file mode 100644 (file)
index 0000000..3f1b438
--- /dev/null
@@ -0,0 +1,256 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+#ifndef bpi_BF_FACE_FINDER_EM_H
+#define bpi_BF_FACE_FINDER_EM_H
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Context.h"
+#include "b_APIEm/FaceFinder.h"
+#include "b_BitFeatureEm/ScanDetector.h"
+
+/* ---- related objects  --------------------------------------------------- */
+
+struct bpi_DCR;
+
+/* ---- typedefs ----------------------------------------------------------- */
+
+/* ---- constants ---------------------------------------------------------- */
+
+/* data format version number */
+#define bpi_BF_FACE_FINDER_VERSION 100
+
+/* ---- object definition -------------------------------------------------- */
+
+/** Face Finder using ractangle features */
+struct bpi_BFFaceFinder
+{
+       /* ---- private data --------------------------------------------------- */
+
+       /** base object */
+       struct bpi_FaceFinder baseE;
+
+       /* number of detected faces in last call of multiProcess in face data buffer */
+       uint32 detectedFacesE;
+
+       /* number of available faces in last call of multiProcess in face data buffer */
+       uint32 availableFacesE;
+
+       /* pointer to face data buffer */
+       int32* faceDataBufferE;
+
+       /* ---- public data ---------------------------------------------------- */
+
+       /* detector */
+       struct bbf_ScanDetector detectorE;
+};
+
+/* ---- associated objects ------------------------------------------------- */
+
+/* ---- external functions ------------------------------------------------- */
+
+/* ---- \ghd{ constructor/destructor } ------------------------------------- */
+
+/** initializes module */
+void bpi_BFFaceFinder_init( struct bbs_Context* cpA,
+                                                   struct bpi_BFFaceFinder* ptrA );
+
+/** destroys module */
+void bpi_BFFaceFinder_exit( struct bbs_Context* cpA,
+                                                   struct bpi_BFFaceFinder* ptrA );
+
+/* ---- \ghd{ operators } -------------------------------------------------- */
+
+/** copies module */
+void bpi_BFFaceFinder_copy( struct bbs_Context* cpA,
+                                                   struct bpi_BFFaceFinder* ptrA, 
+                                                       const struct bpi_BFFaceFinder* srcPtrA );
+
+/** determines equality of parameters */
+flag bpi_BFFaceFinder_equal( struct bbs_Context* cpA,
+                                                        const struct bpi_BFFaceFinder* ptrA, 
+                                                        const struct bpi_BFFaceFinder* srcPtrA );
+
+/* ---- \ghd{ query functions } -------------------------------------------- */
+
+/** minimum eye distance (pixel) */
+uint32 bpi_BFFaceFinder_getMinEyeDistance( const struct bpi_BFFaceFinder* ptrA );
+
+/** maximum eye distance (pixel) */
+uint32 bpi_BFFaceFinder_getMaxEyeDistance( const struct bpi_BFFaceFinder* ptrA );
+
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+
+/** minimum eye distance (pixel) */
+void bpi_BFFaceFinder_setMinEyeDistance( struct bbs_Context* cpA,
+                                                                                struct bpi_BFFaceFinder* ptrA, 
+                                                                                uint32 distA );
+
+/** maximum eye distance (pixel) */
+void bpi_BFFaceFinder_setMaxEyeDistance( struct bbs_Context* cpA,
+                                                                                struct bpi_BFFaceFinder* ptrA, 
+                                                                                uint32 distA );
+
+/* ---- \ghd{ memory I/O } ------------------------------------------------- */
+
+/** size object needs when written to memory */
+uint32 bpi_BFFaceFinder_memSize( struct bbs_Context* cpA,
+                                                                const struct bpi_BFFaceFinder* ptrA );
+
+/** writes object to memory; returns number of 16-bit words written */
+uint32 bpi_BFFaceFinder_memWrite( struct bbs_Context* cpA,
+                                                                 const struct bpi_BFFaceFinder* ptrA, 
+                                                             uint16* memPtrA );
+
+/** reads object from memory; returns number of 16-bit words read 
+ * Note: Before executing this function the maximum image dimensions must be specified 
+ * through function bpi_BFFaceFinder_setMaxImageSize. This is to ensure proper allocation 
+ * of internal memory. Otherwise this function will cause an exception.
+ */
+uint32 bpi_BFFaceFinder_memRead( struct bbs_Context* cpA,
+                                                                struct bpi_BFFaceFinder* ptrA, 
+                                                                const uint16* memPtrA,
+                                                            struct bbs_MemTbl* mtpA );
+
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+
+/** processes image for single face detection; 
+ *  returns confidence ( 8.24 ) 
+ *  fills external id cluster with node positions and ids
+ *
+ *  If roiPtrA is NULL, the whole image is considered for processsing 
+ *  otherwise *roiPtrA specifies a section of the original image to which
+ *  processing is limited. All coordinates refer to that section and must 
+ *  eventually be adjusted externally.
+ *  The roi rectangle must not include pixels outside of the original image
+ *  (checked -> error). The rectangle may be of uneven width.
+ *
+ *  offsPtrA points to an offset vector (whole pixels) that is to be added to
+ *  cluster coordinates in order to obtain image coordinates
+ *
+ */
+int32 bpi_BFFaceFinder_process( struct bbs_Context* cpA,
+                                                           const struct bpi_BFFaceFinder* ptrA, 
+                                                           void* imagePtrA,
+                                                           uint32 imageWidthA,
+                                                               uint32 imageHeightA,
+                                                               const struct bts_Int16Rect* roiPtrA,
+                                                               struct bts_Int16Vec2D* offsPtrA,
+                                                               struct bts_IdCluster2D* idClusterPtrA );
+
+/** Processes integral image for multiple face detection; 
+ *  returns number of faces detected 
+ *  return pointer to faceBuffer (intermediate data format)
+ *  call getFace() to retrieve face information from buffer.
+ *  *faceDataBufferPtrA is set to the address of an internal buffer that is valid until the next image processing
+ *
+ *  Positions are sorted by confidence (highest confidence first)
+ *
+ *  When this function returns 0 (no face detected) faceDataBuffer
+ *  still contains one valid entry retrievable by getFace() that 
+ *  represents the most likely position. The confidence is then below
+ *  or equal 0.5.
+ *
+ *  If roiPtrA is NULL, the whole image is considered for processsing 
+ *  otherwise *roiPtrA specifies a section of the original image to which
+ *  processing is limited. All coordinates refer to that section and must 
+ *  eventually be adjusted externally.
+ *  The roi rectangle must not include pixels outside of the original image
+ *  (checked -> error). The rectangle may be of uneven width.
+ */
+uint32 bpi_BFFaceFinder_multiProcess( struct bbs_Context* cpA,
+                                                                         const struct bpi_BFFaceFinder* ptrA, 
+                                                                         void* imagePtrA,
+                                                                         uint32 imageWidthA,
+                                                                         uint32 imageHeightA,
+                                                                         const struct bts_Int16Rect* roiPtrA );
+
+/** Extracts a single face from a face buffer that was previously filled with face data by function 
+ *  multiProcess(). 
+ *  returns confidence ( 8.24 ) 
+ *  Fills external id cluster with node positions and ids
+ *
+ *  offsPtrA points to an offset vector (whole pixels) that is to be added to
+ *  cluster coordinates in order to obtain image coordinates
+ */
+uint32 bpi_BFFaceFinder_getFace( struct bbs_Context* cpA,
+                                                                const struct bpi_BFFaceFinder* ptrA, 
+                                                                uint32 indexA,
+                                                                struct bts_Int16Vec2D* offsPtrA,
+                                                                struct bts_IdCluster2D* idClusterPtrA );
+
+/** Extracts a single face from a face buffer that was previously filled with face data by function 
+ *  multiProcess(). 
+ *  returns confidence ( 8.24 ) 
+ *  provides 
+ *             - id cluster with node positions and ids
+ *             - confidence
+ */
+void bpi_BFFaceFinder_getFaceDCR( struct bbs_Context* cpA,
+                                                                 const struct bpi_BFFaceFinder* ptrA, 
+                                                                 uint32 indexA,
+                                                                 struct bpi_DCR* dcrPtrA );
+
+/** this function must be executed before calling _memRead */
+void bpi_BFFaceFinder_setMaxImageSize( struct bbs_Context* cpA,
+                                                                          struct bpi_BFFaceFinder* ptrA, 
+                                                                          uint32 maxImageWidthA,
+                                                                          uint32 maxImageHeightA );
+
+/** initializes some parameters prior to reading  
+ *  Overload of vpSetParams
+ *  wraps function setMaxImageSize
+ */ 
+void bpi_BFFaceFinder_setParams( struct bbs_Context* cpA,
+                                                                struct bpi_FaceFinder* ptrA, 
+                                                                uint32 maxImageWidthA,
+                                                                uint32 maxImageHeightA );
+
+/** sets detection range
+ *  Overload of vpSetParams
+ */
+void bpi_BFFaceFinder_setRange( struct bbs_Context* cpA,
+                                                               struct bpi_FaceFinder* ptrA, 
+                                                               uint32 minEyeDistanceA,
+                                                               uint32 maxEyeDistanceA );
+
+/** Single face processing function; returns confidence (8.24)  
+ *  Overload of vpProcess
+ *  wraps function process
+ */ 
+int32 bpi_BFFaceFinder_processDcr( struct bbs_Context* cpA,
+                                                                  const struct bpi_FaceFinder* ptrA, 
+                                                          struct bpi_DCR* dcrPtrA );
+
+/** Multiple face processing function; returns number of faces detected 
+ *  Overload of vpPutDcr
+ *  wraps function multiProcess
+ */ 
+int32 bpi_BFFaceFinder_putDcr( struct bbs_Context* cpA,
+                                                          const struct bpi_FaceFinder* ptrA, 
+                                                          struct bpi_DCR* dcrPtrA );
+
+/** Retrieves indexed face from face finder after calling PutDCR 
+ *  Overload of vpGetDcr
+ *  wraps function getFaceDCR
+ */ 
+void bpi_BFFaceFinder_getDcr( struct bbs_Context* cpA,
+                                                         const struct bpi_FaceFinder* ptrA, 
+                                                         uint32 indexA,
+                                                         struct bpi_DCR* dcrPtrA );
+
+#endif /* bpi_BF_FACE_FINDER_EM_H */
diff --git a/Embedded/common/src/b_APIEm/DCR.c b/Embedded/common/src/b_APIEm/DCR.c
new file mode 100644 (file)
index 0000000..c1fc1f6
--- /dev/null
@@ -0,0 +1,238 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_APIEm/DCR.h"
+#include "b_BasicEm/Functions.h"
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ auxiliary functions } ---------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ constructor / destructor } ----------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_DCR_init( struct bbs_Context* cpA,
+                                  struct bpi_DCR* ptrA )
+{
+       ptrA->maxImageWidthE = 0;
+       ptrA->maxImageHeightE = 0;
+       ptrA->imageDataPtrE = NULL;
+       ptrA->imageWidthE = 0;
+       ptrA->imageHeightE = 0;
+       bts_Int16Vec2D_init( &ptrA->offsE );
+       bts_IdCluster2D_init( cpA, &ptrA->mainClusterE );
+       bts_IdCluster2D_init( cpA, &ptrA->sdkClusterE );
+       ptrA->confidenceE = 0;
+       ptrA->approvedE = FALSE;
+       ptrA->idE = 0;
+       ptrA->roiRectE = bts_Int16Rect_create( 0, 0, 0, 0 );
+       bbs_UInt16Arr_init( cpA, &ptrA->cueDataE );
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_DCR_exit( struct bbs_Context* cpA,
+                                  struct bpi_DCR* ptrA )
+{
+       ptrA->maxImageWidthE = 0;
+       ptrA->maxImageHeightE = 0;
+       ptrA->imageDataPtrE = NULL;
+       ptrA->imageWidthE = 0;
+       ptrA->imageHeightE = 0;
+       bts_Int16Vec2D_exit( &ptrA->offsE );
+       bts_IdCluster2D_exit( cpA, &ptrA->mainClusterE );
+       bts_IdCluster2D_exit( cpA, &ptrA->sdkClusterE );
+       ptrA->confidenceE = 0;
+       ptrA->approvedE = FALSE;
+       ptrA->idE = 0;
+       bbs_UInt16Arr_exit( cpA, &ptrA->cueDataE );
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ operators } -------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ query functions } -------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_DCR_create( struct bbs_Context* cpA,
+                                        struct bpi_DCR* ptrA,
+                                        uint32 imageWidthA,
+                                        uint32 imageHeightA,
+                                        uint32 cueSizeA,
+                                        struct bbs_MemTbl* mtpA )
+{
+       struct bbs_MemTbl memTblL = *mtpA;
+       struct bbs_MemSeg* espL =
+            bbs_MemTbl_fastestSegPtr( cpA, &memTblL,
+                                      bpi_DCR_MAX_CLUSTER_SIZE * bbs_SIZEOF16( struct bts_Int16Vec2D ) );
+       if( bbs_Context_error( cpA ) ) return;
+
+       bts_IdCluster2D_create( cpA, &ptrA->mainClusterE, bpi_DCR_MAX_CLUSTER_SIZE, espL );
+       bts_IdCluster2D_size( cpA, &ptrA->mainClusterE, 0 );
+       if( bbs_Context_error( cpA ) ) return;
+       bts_IdCluster2D_create( cpA, &ptrA->sdkClusterE, bpi_DCR_MAX_SDK_CLUSTER_SIZE, espL );
+       bts_IdCluster2D_size( cpA, &ptrA->sdkClusterE, 0 );
+       if( bbs_Context_error( cpA ) ) return;
+       if( bbs_Context_error( cpA ) ) return;
+       bbs_UInt16Arr_create( cpA, &ptrA->cueDataE, cueSizeA, espL );
+       bbs_UInt16Arr_size( cpA, &ptrA->cueDataE, 0 );
+
+       ptrA->maxImageWidthE = imageWidthA;
+       ptrA->maxImageHeightE = imageHeightA;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ I/O } -------------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_DCR_assignGrayByteImage( struct bbs_Context* cpA,
+                                                                 struct bpi_DCR* ptrA, 
+                                                                 const void* bufferPtrA, 
+                                                                 uint32 widthA, 
+                                                                 uint32 heightA )
+{
+       bbs_DEF_fNameL( "void bpi_DCR_assignGrayByteImage( struct bbs_Context* cpA, struct bpi_DCR* ptrA, const void* bufferPtrA, uint32 widthA, uint32 heightA )" )
+
+       if( widthA > ptrA->maxImageWidthE || heightA > ptrA->maxImageHeightE )
+       {
+               bbs_ERROR5( "%s:\nSize of assigned image (%ix%i) exceeds maximum size defined at DCR initialization (%ix%i).",
+                                   fNameL,
+                                       widthA, heightA,
+                                       ptrA->maxImageWidthE, ptrA->maxImageHeightE     );
+               return;
+       }
+
+       if( ( widthA & 1 ) != 0 )
+       {
+               bbs_ERROR1( "%s:\nWidth of image must be even.\n", fNameL );
+               return;
+       }
+
+       ptrA->imageDataPtrE = ( void* )bufferPtrA;
+       ptrA->imageWidthE = widthA;
+       ptrA->imageHeightE = heightA;
+
+       /* reset some data */
+       ptrA->roiRectE = bts_Int16Rect_create( 0, 0, widthA, heightA );
+       bts_IdCluster2D_size( cpA, &ptrA->mainClusterE, 0 );
+       bts_IdCluster2D_size( cpA, &ptrA->sdkClusterE, 0 );
+       bbs_UInt16Arr_size( cpA, &ptrA->cueDataE, 0 );
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_DCR_assignGrayByteImageROI( struct bbs_Context* cpA,
+                                                                        struct bpi_DCR* ptrA, 
+                                                                        const void* bufferPtrA, 
+                                                                        uint32 widthA, 
+                                                                        uint32 heightA,
+                                                                        const struct bts_Int16Rect* pRectA )
+{
+       bbs_DEF_fNameL( "void bpi_DCR_assignGrayByteImageROI( struct bpi_DCR* ptrA, const void* bufferPtrA, uint32 widthA, uint32 heightA )" )
+
+       if( widthA > ptrA->maxImageWidthE || heightA > ptrA->maxImageHeightE )
+       {
+               bbs_ERROR5( "%s:\nSize of assigned image (%ix%i) exceeds maximum size defined at DCR initialization (%ix%i).",
+                                   fNameL,
+                                       widthA, heightA,
+                                       ptrA->maxImageWidthE, ptrA->maxImageHeightE     );
+               return;
+       }
+
+       if( ( widthA & 1 ) != 0 )
+       {
+               bbs_ERROR1( "%s:\nWidth of image must be even.\n",
+                                   fNameL );
+               return;
+       }
+
+       if( pRectA->x2E < pRectA->x1E || pRectA->y2E < pRectA->y1E || 
+               pRectA->x1E < 0           || pRectA->y1E < 0 ||
+               pRectA->x2E > ( int32 )widthA || pRectA->y2E > ( int32 )heightA )
+       {
+               bbs_ERROR1( "%s:\nInvalid ROI rectangle.\n", fNameL );
+               return;
+       }
+
+       ptrA->imageDataPtrE = ( void* )bufferPtrA;
+       ptrA->imageWidthE = widthA;
+       ptrA->imageHeightE = heightA;
+
+       /* reset some data */
+       ptrA->roiRectE = *pRectA;
+       bts_IdCluster2D_size( cpA, &ptrA->mainClusterE, 0 );
+       bts_IdCluster2D_size( cpA, &ptrA->sdkClusterE, 0 );
+       bbs_UInt16Arr_size( cpA, &ptrA->cueDataE, 0 );
+}
+
+/* ------------------------------------------------------------------------- */
+
+int32 bpi_DCR_confidence( struct bbs_Context* cpA,
+                                                 const struct bpi_DCR* ptrA )
+{
+       return ptrA->confidenceE;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
diff --git a/Embedded/common/src/b_APIEm/DCR.h b/Embedded/common/src/b_APIEm/DCR.h
new file mode 100644 (file)
index 0000000..64b2378
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+#ifndef bpi_DCR_EM_H
+#define bpi_DCR_EM_H
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Context.h"
+#include "b_BasicEm/MemTbl.h"
+#include "b_ImageEm/UInt16ByteImage.h"
+#include "b_ImageEm/UInt32Image.h"
+#include "b_TensorEm/IdCluster2D.h"
+#include "b_TensorEm/RBFMap2D.h"
+#include "b_BitFeatureEm/Scanner.h"
+
+
+/* ---- related objects  --------------------------------------------------- */
+
+/* ---- typedefs ----------------------------------------------------------- */
+
+/* ---- constants ---------------------------------------------------------- */
+
+/** maximum size of dcr cluster */
+#define bpi_DCR_MAX_CLUSTER_SIZE 60
+
+/** maximum size of dcr sdk cluster */
+#define bpi_DCR_MAX_SDK_CLUSTER_SIZE 24
+
+/* ---- object definition -------------------------------------------------- */
+
+/** data carrier */
+struct bpi_DCR
+{
+       /* ---- temporary data ------------------------------------------------- */
+
+       /* ---- private data --------------------------------------------------- */
+
+       /* ---- public data ---------------------------------------------------- */
+
+       /** maximum allowed image width */
+       uint32 maxImageWidthE;
+
+       /** maximum allowed image height */
+       uint32 maxImageHeightE;
+
+       /** pointer to original image data */
+       void* imageDataPtrE;
+
+       /** width of original image */
+       uint32 imageWidthE;
+
+       /** height of original image */
+       uint32 imageHeightE;
+
+       /** offset refering to main and sdk clusters */
+       struct bts_Int16Vec2D offsE;
+
+       /** main cluster */
+       struct bts_IdCluster2D mainClusterE;
+
+       /** output cluster accessible by sdk users */
+       struct bts_IdCluster2D sdkClusterE;
+
+       /** confidence value ( 8.24 ) */
+       int32 confidenceE;
+
+       /** approval flag */
+       flag approvedE;
+
+       /** (image) id value */
+       int32 idE;
+
+       /** region of interest */
+       struct bts_Int16Rect roiRectE;
+
+       /** cue data */
+       struct bbs_UInt16Arr cueDataE;
+
+};
+
+/* ---- associated objects ------------------------------------------------- */
+
+/* ---- external functions ------------------------------------------------- */
+
+/* ---- \ghd{ constructor/destructor } ------------------------------------- */
+
+/** initializes data carrier */
+void bpi_DCR_init( struct bbs_Context* cpA,
+                                  struct bpi_DCR* ptrA );
+
+/** destroys data carrier */
+void bpi_DCR_exit( struct bbs_Context* cpA,
+                                  struct bpi_DCR* ptrA );
+
+/* ---- \ghd{ operators } -------------------------------------------------- */
+
+/* ---- \ghd{ query functions } -------------------------------------------- */
+
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+
+/** create a data carrier */
+void bpi_DCR_create( struct bbs_Context* cpA,
+                                        struct bpi_DCR* ptrA, 
+                                        uint32 imageWidthA,
+                                        uint32 imageHeightA,
+                                        uint32 cueSizeA,
+                                        struct bbs_MemTbl* mtpA );
+
+/* ---- \ghd{ memory I/O } ------------------------------------------------- */
+
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+
+/** references external byte gray image through memory block referenced by bufferPtrA to be used as input image */
+void bpi_DCR_assignGrayByteImage( struct bbs_Context* cpA,
+                                                                 struct bpi_DCR* ptrA,
+                                                                 const void* bufferPtrA,
+                                                                 uint32 widthA,
+                                                                 uint32 heightA );
+
+/** assigns external byte gray image as input image and region of interest.
+  *
+  * bufferPtrA:  pointer to memory block of imput image
+  * pRectA:             rectangle describing region of interest
+  */
+void bpi_DCR_assignGrayByteImageROI( struct bbs_Context* cpA,
+                                                                        struct bpi_DCR* ptrA,
+                                                                        const void* bufferPtrA, 
+                                                                        uint32 widthA, 
+                                                                        uint32 heightA,
+                                                                        const struct bts_Int16Rect* pRectA );
+
+/** returns confidence 8.24 fixed format */
+int32 bpi_DCR_confidence( struct bbs_Context* cpA,
+                                                 const struct bpi_DCR* ptrA );
+
+#endif /* bpi_DCR_EM_H */
diff --git a/Embedded/common/src/b_APIEm/FaceFinder.c b/Embedded/common/src/b_APIEm/FaceFinder.c
new file mode 100644 (file)
index 0000000..d12c04d
--- /dev/null
@@ -0,0 +1,264 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Functions.h"
+#include "b_APIEm/FaceFinder.h"
+#include "b_APIEm/BFFaceFinder.h"
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ auxiliary functions } ---------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ constructor / destructor } ----------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_FaceFinder_init( struct bbs_Context* cpA,
+                                             struct bpi_FaceFinder* ptrA )
+{
+       ptrA->typeE = 0;
+       ptrA->vpSetParamsE = NULL;
+       ptrA->vpSetRangeE = NULL;
+       ptrA->vpProcessE = NULL;
+       ptrA->vpPutDcrE = NULL;
+       ptrA->vpGetDcrE = NULL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_FaceFinder_exit( struct bbs_Context* cpA,
+                                                 struct bpi_FaceFinder* ptrA )
+{
+       ptrA->typeE = 0;
+       ptrA->vpSetParamsE = NULL;
+       ptrA->vpSetRangeE = NULL;
+       ptrA->vpProcessE = NULL;
+       ptrA->vpPutDcrE = NULL;
+       ptrA->vpGetDcrE = NULL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ operators } -------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_FaceFinder_copy( struct bbs_Context* cpA,
+                                                 struct bpi_FaceFinder* ptrA, 
+                                                 const struct bpi_FaceFinder* srcPtrA )
+{
+       ptrA->typeE = srcPtrA->typeE;
+       ptrA->vpSetParamsE = srcPtrA->vpSetParamsE;
+       ptrA->vpSetRangeE = srcPtrA->vpSetRangeE;
+       ptrA->vpProcessE = srcPtrA->vpProcessE;
+       ptrA->vpPutDcrE = srcPtrA->vpPutDcrE;
+       ptrA->vpGetDcrE = srcPtrA->vpGetDcrE;
+}
+
+/* ------------------------------------------------------------------------- */
+
+flag bpi_FaceFinder_equal( struct bbs_Context* cpA,
+                                                  const struct bpi_FaceFinder* ptrA, 
+                                                  const struct bpi_FaceFinder* srcPtrA )
+{
+
+       if( ptrA->typeE != srcPtrA->typeE ) return FALSE;
+       if( ptrA->vpSetParamsE != srcPtrA->vpSetParamsE ) return FALSE;
+       if( ptrA->vpSetRangeE != srcPtrA->vpSetRangeE ) return FALSE;
+       if( ptrA->vpProcessE != srcPtrA->vpProcessE ) return FALSE;
+       if( ptrA->vpPutDcrE != srcPtrA->vpPutDcrE ) return FALSE;
+       if( ptrA->vpGetDcrE != srcPtrA->vpGetDcrE ) return FALSE;
+       return TRUE;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ query functions } -------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+       
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ I/O } -------------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bpi_FaceFinder_memSize( struct bbs_Context* cpA,
+                                                          const struct bpi_FaceFinder* ptrA )
+{
+       uint32 memSizeL = 0;
+       memSizeL += bbs_SIZEOF16( ptrA->typeE );
+       return memSizeL; 
+}
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bpi_FaceFinder_memWrite( struct bbs_Context* cpA,
+                                                           const struct bpi_FaceFinder* ptrA, 
+                                                           uint16* memPtrA )
+{
+       uint32 memSizeL = bpi_FaceFinder_memSize( cpA, ptrA );
+       memPtrA += bbs_memWrite32( &ptrA->typeE, memPtrA );
+       return memSizeL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_FaceFinder_memRead( struct bbs_Context* cpA,
+                                                          struct bpi_FaceFinder* ptrA, 
+                                                          const uint16* memPtrA )
+{
+       bbs_DEF_fNameL( "uint32 bpi_FaceFinder_memRead( struct bbs_Context* cpA, struct bpi_FaceFinder* ptrA, const uint16* memPtrA )" )
+       uint32 typeL;
+
+       if( bbs_Context_error( cpA ) ) return 0;
+       memPtrA += bbs_memRead32( &typeL, memPtrA );
+
+       if( typeL != ptrA->typeE )
+       {
+               bbs_ERROR1( "%s:\nObject type mismatch! Attempt to read an incorrect object.", fNameL );
+               return 0;
+       }
+
+       return bpi_FaceFinder_memSize( cpA, ptrA );
+}
+
+/* ------------------------------------------------------------------------- */
+       
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+       
+/* ------------------------------------------------------------------------- */
+
+void bpi_faceFinderInit( struct bbs_Context* cpA,
+                                                struct bpi_FaceFinder* ptrA,
+                                                enum bpi_FaceFinderType typeA )
+{
+       switch( typeA )
+       {
+               case bpi_FF_BF_FACE_FINDER:             bpi_BFFaceFinder_init( cpA,             ( struct bpi_BFFaceFinder* )ptrA ); return; 
+                       
+               default: bbs_ERROR0( "bpi_faceFinderInit: invalid type" );
+       }
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_faceFinderExit( struct bbs_Context* cpA, 
+                                            struct bpi_FaceFinder* ptrA )
+{
+       switch( ptrA->typeE )
+       {
+               case bpi_FF_BF_FACE_FINDER:     bpi_BFFaceFinder_exit( cpA,             ( struct bpi_BFFaceFinder* )ptrA ); return;
+
+               default: bbs_ERROR0( "bpi_faceFinderExit: invalid type" );
+       }
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_faceFinderMemSize( struct bbs_Context* cpA, 
+                                                         const struct bpi_FaceFinder* ptrA )
+{
+       switch( ptrA->typeE )
+       {
+               case bpi_FF_BF_FACE_FINDER:     return bpi_BFFaceFinder_memSize( cpA,   ( struct bpi_BFFaceFinder* )ptrA );
+
+               default: bbs_ERROR0( "bpi_faceFinderExit: invalid type" );
+       }
+       return 0;
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_faceFinderMemWrite( struct bbs_Context* cpA, 
+                                                          const struct bpi_FaceFinder* ptrA, uint16* memPtrA )
+{
+       switch( ptrA->typeE )
+       {
+               case bpi_FF_BF_FACE_FINDER:             return bpi_BFFaceFinder_memWrite( cpA,  ( struct bpi_BFFaceFinder* )ptrA, memPtrA  );
+
+               default: bbs_ERROR0( "bpi_faceFinderMemWrite: invalid type" );
+       }
+       return 0;
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_faceFinderMemRead( struct bbs_Context* cpA,
+                                                         struct bpi_FaceFinder* ptrA, 
+                                                         const uint16* memPtrA,
+                                                         struct bbs_MemTbl* mtpA )
+{
+       switch( ptrA->typeE )
+       {
+               case bpi_FF_BF_FACE_FINDER:     return bpi_BFFaceFinder_memRead( cpA,   ( struct bpi_BFFaceFinder* )ptrA, memPtrA, mtpA );
+
+               default: bbs_ERROR0( "bpi_faceFinderMemRead: invalid type" );
+       }
+       return 0;
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_faceFinderSizeOf16( struct bbs_Context* cpA, enum bpi_FaceFinderType typeA )
+{
+       switch( typeA )
+       {
+               case bpi_FF_BF_FACE_FINDER:     return bbs_SIZEOF16( struct bpi_BFFaceFinder );
+
+               default: bbs_ERROR0( "bpi_faceFinderSizeOf16: invalid type" );
+       }
+       return 0;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+
diff --git a/Embedded/common/src/b_APIEm/FaceFinder.h b/Embedded/common/src/b_APIEm/FaceFinder.h
new file mode 100644 (file)
index 0000000..76c4829
--- /dev/null
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+#ifndef bpi_FACE_FINDER_EM_H
+#define bpi_FACE_FINDER_EM_H
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Context.h"
+#include "b_BasicEm/Basic.h"
+#include "b_BasicEm/MemTbl.h"
+#include "b_TensorEm/Flt16Vec.h"
+#include "b_TensorEm/IdCluster2D.h"
+#include "b_APIEm/DCR.h"
+
+/* ---- related objects  --------------------------------------------------- */
+
+/* ---- typedefs ----------------------------------------------------------- */
+
+/** Object Type */
+enum bpi_FaceFinderType
+{
+       bpi_FF_UNDEFINED = 0,
+       bpi_FF_BF_FACE_FINDER    /* bitfeature based faceFinder */
+};
+
+/* ---- constants ---------------------------------------------------------- */
+
+/* ---- object definition -------------------------------------------------- */
+
+/** base object for face finder modules (occurs as first element in all face finder objects) */
+struct bpi_FaceFinder 
+{
+       /* ---- private data --------------------------------------------------- */
+
+       /* ---- public data ---------------------------------------------------- */
+
+       /** object type */
+       uint32 typeE;
+
+       /* ---- virtual functions ---------------------------------------------- */
+
+       /** initializes some parameters prior to reading */ 
+       void ( *vpSetParamsE )( struct bbs_Context* cpA,
+                                                       struct bpi_FaceFinder* ptrA, 
+                                                       uint32 maxImageWidthA,
+                                                       uint32 maxImageHeightA );
+
+       /** sets detection range */ 
+       void ( *vpSetRangeE )( struct bbs_Context* cpA,
+                                                  struct bpi_FaceFinder* ptrA, 
+                                                  uint32 minEyeDistanceA,
+                                                  uint32 maxEyeDistanceA );
+
+       /** single face processing function; returns confidence (8.24) */ 
+       int32 ( *vpProcessE )( struct bbs_Context* cpA,
+                                                  const struct bpi_FaceFinder* ptrA, 
+                                                  struct bpi_DCR* dcrPtrA );
+
+       /** multiple face processing function; returns number of faces detected */ 
+       int32 ( *vpPutDcrE )( struct bbs_Context* cpA,
+                                                 const struct bpi_FaceFinder* ptrA, 
+                                                 struct bpi_DCR* dcrPtrA );
+
+       /** retrieves indexed face from face finder after calling PutDCR */ 
+       void ( *vpGetDcrE )( struct bbs_Context* cpA,
+                                                const struct bpi_FaceFinder* ptrA, 
+                                                uint32 indexA,
+                                                struct bpi_DCR* dcrPtrA );
+
+};
+
+/* ---- associated objects ------------------------------------------------- */
+
+/* ---- external functions ------------------------------------------------- */
+
+/* ---- \ghd{ constructor/destructor } ------------------------------------- */
+
+/** initializes bpi_FaceFinder  */
+void bpi_FaceFinder_init( struct bbs_Context* cpA,
+                                         struct bpi_FaceFinder* ptrA );
+
+/** resets bpi_FaceFinder  */
+void bpi_FaceFinder_exit( struct bbs_Context* cpA,
+                                         struct bpi_FaceFinder* ptrA );
+
+/* ---- \ghd{ operators } -------------------------------------------------- */
+
+/** copy operator */
+void bpi_FaceFinder_copy( struct bbs_Context* cpA,
+                                             struct bpi_FaceFinder* ptrA, 
+                                             const struct bpi_FaceFinder* srcPtrA );
+
+/** equal operator */
+flag bpi_FaceFinder_equal( struct bbs_Context* cpA,
+                                                  const struct bpi_FaceFinder* ptrA, 
+                                                  const struct bpi_FaceFinder* srcPtrA );
+
+/* ---- \ghd{ query functions } -------------------------------------------- */
+
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+
+/* ---- \ghd{ memory I/O } ------------------------------------------------- */
+
+/** word size (16-bit) object needs when written to memory */
+uint32 bpi_FaceFinder_memSize( struct bbs_Context* cpA,
+                                                      const struct bpi_FaceFinder* ptrA );
+
+/** writes object to memory; returns number of words (16-bit) written */
+uint32 bpi_FaceFinder_memWrite( struct bbs_Context* cpA,
+                                                           const struct bpi_FaceFinder* ptrA, uint16* memPtrA );
+
+/** reads object from memory; returns number of words (16-bit) read */
+uint32 bpi_FaceFinder_memRead( struct bbs_Context* cpA,
+                                                          struct bpi_FaceFinder* ptrA, const uint16* memPtrA );
+
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+
+/** virtual init function  */
+void bpi_faceFinderInit( struct bbs_Context* cpA,
+                                                struct bpi_FaceFinder* ptrA,
+                                                enum bpi_FaceFinderType typeA );
+
+/** virtual exit function */
+void bpi_faceFinderExit( struct bbs_Context* cpA, 
+                                                struct bpi_FaceFinder* ptrA );
+
+/** virtual mem size function */
+uint32 bpi_faceFinderMemSize( struct bbs_Context* cpA, 
+                                                     const struct bpi_FaceFinder* ptrA );
+
+/** virtual mem write function */
+uint32 bpi_faceFinderMemWrite( struct bbs_Context* cpA, 
+                                                      const struct bpi_FaceFinder* ptrA, 
+                                                          uint16* memPtrA );
+
+/** virtual mem read function */
+uint32 bpi_faceFinderMemRead( struct bbs_Context* cpA,
+                                                         struct bpi_FaceFinder* ptrA, 
+                                                         const uint16* memPtrA,
+                                                         struct bbs_MemTbl* mtpA );
+
+/** virtual sizeof operator for 16bit units */
+uint32 bpi_faceFinderSizeOf16( struct bbs_Context* cpA, 
+                                                          enum bpi_FaceFinderType typeA );
+
+#endif /* bpi_FACE_FINDER_EM_H */
+
diff --git a/Embedded/common/src/b_APIEm/FaceFinderRef.c b/Embedded/common/src/b_APIEm/FaceFinderRef.c
new file mode 100644 (file)
index 0000000..01e5ed1
--- /dev/null
@@ -0,0 +1,282 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Functions.h"
+#include "b_APIEm/FaceFinderRef.h"
+#include "b_APIEm/Functions.h"
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ auxiliary functions } ---------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ constructor / destructor } ----------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_FaceFinderRef_init( struct bbs_Context* cpA,
+                                                        struct bpi_FaceFinderRef* ptrA )
+{
+       bbs_UInt16Arr_init( cpA, &ptrA->objBufE );
+       ptrA->faceFinderPtrE = NULL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_FaceFinderRef_exit( struct bbs_Context* cpA,
+                                                        struct bpi_FaceFinderRef* ptrA )
+{
+       if( ptrA->faceFinderPtrE != NULL ) bpi_faceFinderExit( cpA, ptrA->faceFinderPtrE );
+       bbs_UInt16Arr_exit( cpA, &ptrA->objBufE );
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ operators } -------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_FaceFinderRef_copy( struct bbs_Context* cpA,
+                                                        struct bpi_FaceFinderRef* ptrA, 
+                                                        const struct bpi_FaceFinderRef* srcPtrA )
+{
+       bbs_ERROR0( "bpi_FaceFinderRef_copy: function is not implemented" );
+}
+
+/* ------------------------------------------------------------------------- */
+
+flag bpi_FaceFinderRef_equal( struct bbs_Context* cpA,
+                                                         const struct bpi_FaceFinderRef* ptrA, 
+                                                         const struct bpi_FaceFinderRef* srcPtrA )
+{
+       bbs_ERROR0( "bpi_FaceFinderRef_equal: function is not implemented" );
+       return FALSE;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ query functions } -------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+       
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ I/O } -------------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bpi_FaceFinderRef_memSize( struct bbs_Context* cpA,
+                                                                 const struct bpi_FaceFinderRef* ptrA )
+{
+       uint32 memSizeL = 0;
+       memSizeL += bbs_SIZEOF16( uint32 ); /* mem size */
+       memSizeL += bbs_SIZEOF16( flag ); /* object presence flag */
+       if( ptrA->faceFinderPtrE != NULL ) memSizeL += bpi_faceFinderMemSize( cpA, ptrA->faceFinderPtrE );
+       memSizeL += bbs_SIZEOF16( uint16 ); /* csa */
+       return memSizeL; 
+}
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bpi_FaceFinderRef_memWrite( struct bbs_Context* cpA,
+                                                                  const struct bpi_FaceFinderRef* ptrA, 
+                                                                  uint16* memPtrA )
+{
+       uint32 memSizeL = bpi_FaceFinderRef_memSize( cpA, ptrA );
+       flag objPresentL = ptrA->faceFinderPtrE != NULL;
+       memPtrA += bbs_memWrite32( &memSizeL, memPtrA );
+       memPtrA += bbs_memWrite32( &objPresentL, memPtrA );
+       if( objPresentL ) memPtrA += bpi_faceFinderMemWrite( cpA, ptrA->faceFinderPtrE, memPtrA );
+       memPtrA += bpi_memWriteCsa16( memPtrA, memSizeL, 0xFFFF );
+       return memSizeL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_FaceFinderRef_memRead( struct bbs_Context* cpA,
+                                                                 struct bpi_FaceFinderRef* ptrA, 
+                                                                 uint32 maxImageWidthA,
+                                                                 uint32 maxImageHeightA,
+                                                                 const uint16* memPtrA,
+                                                                 struct bbs_MemTbl* mtpA )
+{
+       uint32 memSizeL;
+       flag objPresentL;
+       struct bbs_MemTbl memTblL = *mtpA;
+       struct bbs_MemSeg* espL = bbs_MemTbl_segPtr( cpA, &memTblL, 0 );
+       if( bbs_Context_error( cpA ) ) return 0;
+       memPtrA += bbs_memRead32( &memSizeL, memPtrA );
+       memPtrA += bbs_memRead32( &objPresentL, memPtrA );
+
+       /* check object & allocate data buffer */
+       {
+               const uint16* memPtrL = memPtrA;
+               uint32 dataSizeL = 0;
+
+               if( objPresentL )
+               {
+                       enum bpi_FaceFinderType typeL = ( enum bpi_FaceFinderType )bbs_memPeek32( memPtrL + 4 );
+                       dataSizeL += bpi_faceFinderSizeOf16( cpA, typeL );
+                       memPtrL += bbs_memPeek32( memPtrL );
+               }
+
+               bbs_UInt16Arr_create( cpA, &ptrA->objBufE, dataSizeL, espL );
+       }
+
+       /* load object */
+       {
+               uint16* dataPtrL = ptrA->objBufE.arrPtrE;
+
+               if( objPresentL )
+               {
+                       enum bpi_FaceFinderType typeL = ( enum bpi_FaceFinderType )bbs_memPeek32( memPtrA + 4 );
+                       ptrA->faceFinderPtrE = ( struct bpi_FaceFinder* )dataPtrL;
+                       bpi_faceFinderInit( cpA, ptrA->faceFinderPtrE, typeL );
+                       ptrA->faceFinderPtrE->vpSetParamsE( cpA, ptrA->faceFinderPtrE, maxImageWidthA, maxImageHeightA );
+                       memPtrA += bpi_faceFinderMemRead( cpA, ptrA->faceFinderPtrE, memPtrA, &memTblL );
+                       dataPtrL += bpi_faceFinderSizeOf16( cpA, typeL );
+               }
+               else
+               {
+                       ptrA->faceFinderPtrE = NULL;
+               }
+       }
+
+       memPtrA += bpi_memReadCsa16( memPtrA );
+
+       return memSizeL;
+}
+
+/* ------------------------------------------------------------------------- */
+       
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+       
+/* ------------------------------------------------------------------------- */
+
+void bpi_FaceFinderRef_setParams( struct bbs_Context* cpA,
+                                                                 struct bpi_FaceFinderRef* ptrA, 
+                                                                 uint32 maxImageWidthA,
+                                                                 uint32 maxImageHeightA )
+{
+       bbs_DEF_fNameL( "bpi_FaceFinderRef_setParams" );
+       if( ptrA->faceFinderPtrE == NULL )
+       {
+               bbs_ERROR1( "%s:\nNo face finder object was loaded", fNameL );
+               return;
+       }
+       ptrA->faceFinderPtrE->vpSetParamsE( cpA, ptrA->faceFinderPtrE, maxImageWidthA, maxImageHeightA );
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_FaceFinderRef_setRange( struct bbs_Context* cpA,
+                                                                struct bpi_FaceFinderRef* ptrA, 
+                                                                uint32 minEyeDistanceA,
+                                                                uint32 maxEyeDistanceA )
+{
+       bbs_DEF_fNameL( "bpi_FaceFinderRef_setRange" );
+       if( ptrA->faceFinderPtrE == NULL )
+       {
+               bbs_ERROR1( "%s:\nNo face finder object was loaded", fNameL );
+               return;
+       }
+       ptrA->faceFinderPtrE->vpSetRangeE( cpA, ptrA->faceFinderPtrE, minEyeDistanceA, maxEyeDistanceA );
+}
+
+/* ------------------------------------------------------------------------- */
+
+int32 bpi_FaceFinderRef_process( struct bbs_Context* cpA,
+                                                            const struct bpi_FaceFinderRef* ptrA, 
+                                                                struct bpi_DCR* dcrPtrA )
+{
+       bbs_DEF_fNameL( "bpi_FaceFinderRef_process" );
+       if( ptrA->faceFinderPtrE == NULL )
+       {
+               bbs_ERROR1( "%s:\nNo face finder object was loaded", fNameL );
+               return 0;
+       }
+       return ptrA->faceFinderPtrE->vpProcessE( cpA, ptrA->faceFinderPtrE, dcrPtrA );
+}
+
+/* ------------------------------------------------------------------------- */
+
+int32 bpi_FaceFinderRef_putDcr( struct bbs_Context* cpA,
+                                                               const struct bpi_FaceFinderRef* ptrA, 
+                                                               struct bpi_DCR* dcrPtrA )
+{
+       bbs_DEF_fNameL( "bpi_FaceFinderRef_putDcr" );
+       if( ptrA->faceFinderPtrE == NULL )
+       {
+               bbs_ERROR1( "%s:\nNo face finder object was loaded", fNameL );
+               return 0;
+       }
+       return ptrA->faceFinderPtrE->vpPutDcrE( cpA, ptrA->faceFinderPtrE, dcrPtrA );
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_FaceFinderRef_getDcr( struct bbs_Context* cpA,
+                                                          const struct bpi_FaceFinderRef* ptrA, 
+                                                          uint32 indexA,
+                                                          struct bpi_DCR* dcrPtrA )
+{
+       bbs_DEF_fNameL( "bpi_FaceFinderRef_getDcr" );
+       if( ptrA->faceFinderPtrE == NULL )
+       {
+               bbs_ERROR1( "%s:\nNo face finder object was loaded", fNameL );
+               return;
+       }
+       ptrA->faceFinderPtrE->vpGetDcrE( cpA, ptrA->faceFinderPtrE, indexA, dcrPtrA );
+}
+
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+
diff --git a/Embedded/common/src/b_APIEm/FaceFinderRef.h b/Embedded/common/src/b_APIEm/FaceFinderRef.h
new file mode 100644 (file)
index 0000000..4fcfe09
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+#ifndef bpi_FACE_FINDER_REF_EM_H
+#define bpi_FACE_FINDER_REF_EM_H
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/UInt16Arr.h"
+#include "b_APIEm/FaceFinder.h"
+
+/* ---- related objects  --------------------------------------------------- */
+
+/* ---- typedefs ----------------------------------------------------------- */
+
+/* ---- constants ---------------------------------------------------------- */
+
+/* ---- object definition -------------------------------------------------- */
+
+/** type independent reference to a faceFinder module */
+struct bpi_FaceFinderRef 
+{
+       /* ---- private data --------------------------------------------------- */
+
+       /* ---- public data ---------------------------------------------------- */
+
+       /** object buffer */
+       struct bbs_UInt16Arr objBufE;
+
+       /** faceFinder pointer */
+       struct bpi_FaceFinder* faceFinderPtrE;
+
+       /* ---- functions ------------------------------------------------------ */
+
+};
+
+/* ---- associated objects ------------------------------------------------- */
+
+/* ---- external functions ------------------------------------------------- */
+
+/* ---- \ghd{ constructor/destructor } ------------------------------------- */
+
+/** initializes bpi_FaceFinderRef  */
+void bpi_FaceFinderRef_init( struct bbs_Context* cpA,
+                                                        struct bpi_FaceFinderRef* ptrA );
+
+/** resets bpi_FaceFinderRef  */
+void bpi_FaceFinderRef_exit( struct bbs_Context* cpA,
+                                                        struct bpi_FaceFinderRef* ptrA );
+
+/* ---- \ghd{ operators } -------------------------------------------------- */
+
+/** copy operator */
+void bpi_FaceFinderRef_copy( struct bbs_Context* cpA,
+                                                        struct bpi_FaceFinderRef* ptrA, 
+                                                        const struct bpi_FaceFinderRef* srcPtrA );
+
+/** equal operator */
+flag bpi_FaceFinderRef_equal( struct bbs_Context* cpA,
+                                                         const struct bpi_FaceFinderRef* ptrA, 
+                                                         const struct bpi_FaceFinderRef* srcPtrA );
+
+/* ---- \ghd{ query functions } -------------------------------------------- */
+
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+
+/* ---- \ghd{ memory I/O } ------------------------------------------------- */
+
+/** word size (16-bit) object needs when written to memory */
+uint32 bpi_FaceFinderRef_memSize( struct bbs_Context* cpA,
+                                                         const struct bpi_FaceFinderRef* ptrA );
+
+/** writes object to memory; returns number of words (16-bit) written */
+uint32 bpi_FaceFinderRef_memWrite( struct bbs_Context* cpA,
+                                                              const struct bpi_FaceFinderRef* ptrA, uint16* memPtrA );
+
+/** reads object from memory; returns number of words (16-bit) read */
+uint32 bpi_FaceFinderRef_memRead( struct bbs_Context* cpA,
+                                                             struct bpi_FaceFinderRef* ptrA, 
+                                                                 uint32 maxImageWidthA,
+                                                                 uint32 maxImageHeightA,
+                                                                 const uint16* memPtrA,
+                                                                 struct bbs_MemTbl* mtpA );
+
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+
+/** sets detection range */ 
+void bpi_FaceFinderRef_setRange( struct bbs_Context* cpA,
+                                                                struct bpi_FaceFinderRef* ptrA, 
+                                                                uint32 minEyeDistanceA,
+                                                                uint32 maxEyeDistanceA );
+
+/** single face processing function; returns confidence (8.24) */ 
+int32 bpi_FaceFinderRef_process( struct bbs_Context* cpA,
+                                                            const struct bpi_FaceFinderRef* ptrA, 
+                                                                struct bpi_DCR* dcrPtrA );
+
+/** multiple face processing function; returns number of faces detected */ 
+int32 bpi_FaceFinderRef_putDcr( struct bbs_Context* cpA,
+                                                               const struct bpi_FaceFinderRef* ptrA, 
+                                                               struct bpi_DCR* dcrPtrA );
+
+/** retrieves indexed face from face finder after calling PutDCR */ 
+void bpi_FaceFinderRef_getDcr( struct bbs_Context* cpA,
+                                                          const struct bpi_FaceFinderRef* ptrA, 
+                                                          uint32 indexA,
+                                                          struct bpi_DCR* dcrPtrA );
+
+#endif /* bpi_FACE_FINDER_REF_EM_H */
+
diff --git a/Embedded/common/src/b_APIEm/Functions.c b/Embedded/common/src/b_APIEm/Functions.c
new file mode 100644 (file)
index 0000000..fe8de17
--- /dev/null
@@ -0,0 +1,316 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_APIEm/Functions.h"
+#include "b_BasicEm/Memory.h"
+
+
+/* ---- related objects  --------------------------------------------------- */
+
+/* ---- typedefs ----------------------------------------------------------- */
+
+/* ---- constants ---------------------------------------------------------- */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ external functions } ----------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_normalizeSimilarities( struct bbs_Context* cpA,
+                                                           const int32* rawSimArrA,
+                                                           const int32* rawIdArrA,
+                                                               uint32 rawSizeA,
+                                                               const int32* refSimArrA,
+                                                               const int32* refIdArrA,
+                                                               uint32 refSizeA,
+                                                               enum bpi_SimType simTypeA,
+                                                               int32* outSimArrA )
+{
+       /* 8.24 */
+       int32 refSimL = 0;
+       uint32 iL, jL, kL; 
+       int32* outPtrL = outSimArrA;
+       const int32* rawPtrL = rawSimArrA;
+
+       switch( simTypeA )
+       {
+               case bpi_RAW_SIM: 
+               {
+                       /* nothing to do */
+               }
+               break;
+
+               case bpi_SUB_MEAN:
+               {
+                       int32 shiftL = 0;
+                       int32 roundL = 0;
+                       refSimL = 0;
+                       for( iL = 0; iL < refSizeA; iL++ )
+                       {
+                               refSimL += ( refSimArrA[ iL ] + roundL ) >> shiftL;
+                               if( refSimL > 0x40000000 )
+                               {
+                                       refSimL = ( refSimL + 1 ) >> 1;
+                                       shiftL++;
+                                       roundL = ( int32 )1 << ( shiftL - 1 );
+                               }
+                       }
+                       refSimL = ( refSimL / refSizeA ) << shiftL;
+               }
+               break;
+
+               case bpi_SUB_MAX_2:
+               {
+                       int32 maxL = 0;
+                       uint32 maxIndexL = 0;
+                       int32 idL = 0;
+
+                       /* find raw maximum */
+                       for( iL = 0; iL < rawSizeA; iL++ )
+                       {
+                               if( maxL < rawSimArrA[ iL ] )
+                               {
+                                       maxL = refSimArrA[ iL ];
+                                       maxIndexL = iL;
+                               }
+                       }
+
+                       /* consider id of maximum equal to probe id */
+                       idL = rawIdArrA[ maxIndexL ];
+
+                       /* find maximum similarity in ref array of different id */
+                       for( iL = 0; iL < refSizeA; iL++ )
+                       {
+                               if( refIdArrA[ iL ] != idL )
+                               {
+                                       refSimL = ( refSimL > refSimArrA[ iL ] ) ? refSimL : refSimArrA[ iL ];
+                               }
+                       }
+               }
+               break;
+
+               case bpi_SUB_16_MAX_2:
+               {
+                       int32 maxL = 0;
+                       uint32 maxIndexL = 0;
+                       int32 idL = 0;
+
+                       int32 maxSimArrL[ 16 ];
+                       bbs_memset32( maxSimArrL, ( uint32 )-1, bbs_SIZEOF32( maxSimArrL ) );
+
+                       /* find raw maximum */
+                       for( iL = 0; iL < rawSizeA; iL++ )
+                       {
+                               if( maxL < rawSimArrA[ iL ] )
+                               {
+                                       maxL = rawSimArrA[ iL ];
+                                       maxIndexL = iL;
+                               }
+                       }
+
+                       /* consider id of maximum equal to probe id */
+                       idL = rawIdArrA[ maxIndexL ];
+
+                       /* find 16 maximum similarities of different id in ref array */
+                       for( iL = 0; iL < refSizeA; iL++ )
+                       {
+                               if( refIdArrA[ iL ] != idL )
+                               {
+                                       int32 simL = refSimArrA[ iL ];
+                                       for( jL = 0; jL < 16; jL++ )
+                                       {
+                                               if( simL > maxSimArrL[ jL ] ) break;
+                                       }
+                                       for( kL = 15; kL > jL; kL-- )
+                                       {
+                                               maxSimArrL[ kL ] = maxSimArrL[ kL - 1 ];
+                                       }
+                                       if( jL < 16 ) maxSimArrL[ jL ] = simL;
+                               }
+                       }
+
+                       refSimL = 0;
+                       for( jL = 0; jL < 16; jL++ )
+                       {
+                               if( maxSimArrL[ jL ] == -1 ) break;
+                               refSimL += maxSimArrL[ jL ];
+                       }
+
+                       if( jL > 0 )
+                       {
+                               refSimL /= jL;
+                       }
+               }
+               break;
+
+               default:
+               {
+                       bbs_ERROR1( "void bpi_Identifier_normalizeSimilarities(): simTypeA '%i' is handled", simTypeA );
+                       return;
+               }
+       }
+
+       /* refSimL -= 1.0 */
+       refSimL -= ( (uint32)1 << 24 );
+
+       for( iL = rawSizeA; iL > 0; iL-- )
+       {
+               *outPtrL++ = ( *rawPtrL++ - refSimL + 1 ) >> 1;
+       }
+
+}
+
+/* ------------------------------------------------------------------------- */
+
+int32 bpi_normalizedSimilarity( struct bbs_Context* cpA,
+                                                           int32 rawSimA,
+                                                           int32 rawIdA,
+                                                               const int32* refSimArrA,
+                                                               const int32* refIdArrA,
+                                                               uint32 refSizeA,
+                                                               enum bpi_SimType simTypeA )
+{
+       /* 8.24 */
+       int32 refSimL = 0;
+       uint32 iL, jL, kL; 
+
+       switch( simTypeA )
+       {
+               case bpi_RAW_SIM: 
+               {
+                       /* nothing to do */
+                       return rawSimA; /* return without adjustment of value range */
+               }
+
+               case bpi_SUB_MEAN:
+               {
+                       int32 shiftL = 0;
+                       int32 roundL = 0;
+                       refSimL = 0;
+                       for( iL = 0; iL < refSizeA; iL++ )
+                       {
+                               refSimL += ( refSimArrA[ iL ] + roundL ) >> shiftL;
+                               if( refSimL > 0x40000000 )
+                               {
+                                       refSimL = ( refSimL + 1 ) >> 1;
+                                       shiftL++;
+                                       roundL = ( int32 )1 << ( shiftL - 1 );
+                               }
+                       }
+                       refSimL = ( refSimL / refSizeA ) << shiftL;
+               }
+               break;
+
+               case bpi_SUB_MAX_2:
+               {
+                       /* find maximum similarity in ref array of different rawIdA */
+                       for( iL = 0; iL < refSizeA; iL++ )
+                       {
+                               if( refIdArrA[ iL ] != rawIdA )
+                               {
+                                       refSimL = ( refSimL > refSimArrA[ iL ] ) ? refSimL : refSimArrA[ iL ];
+                               }
+                       }
+               }
+               break;
+
+               case bpi_SUB_16_MAX_2:
+               {
+                       int32 maxSimArrL[ 16 ];
+                       int32 idL = rawIdA;
+                       bbs_memset32( maxSimArrL, ( uint32 )-1, bbs_SIZEOF32( maxSimArrL ) );
+
+                       /* find 16 maximum similarities of different id in ref array */
+                       for( iL = 0; iL < refSizeA; iL++ )
+                       {
+                               if( refIdArrA[ iL ] != idL )
+                               {
+                                       int32 simL = refSimArrA[ iL ];
+                                       for( jL = 0; jL < 16; jL++ )
+                                       {
+                                               if( simL > maxSimArrL[ jL ] ) break;
+                                       }
+                                       for( kL = 15; kL > jL; kL-- )
+                                       {
+                                               maxSimArrL[ kL ] = maxSimArrL[ kL - 1 ];
+                                       }
+                                       if( jL < 16 ) maxSimArrL[ jL ] = simL;
+                               }
+                       }
+
+                       refSimL = 0;
+                       for( jL = 0; jL < 16; jL++ )
+                       {
+                               if( maxSimArrL[ jL ] == -1 ) break;
+                               refSimL += maxSimArrL[ jL ];
+                       }
+
+                       if( jL > 0 )
+                       {
+                               refSimL /= jL;
+                       }
+               }
+               break;
+
+               default:
+               {
+                       bbs_ERROR1( "void bpi_Identifier_normalizeSimilarities(): simTypeA '%i' is handled", simTypeA );
+               }
+               break;
+       }
+
+       /* refSimL -= 1.0 */
+       refSimL -= ( (uint32)1 << 24 );
+       return ( rawSimA - refSimL + 1 ) >> 1;
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_memWriteCsa16( uint16* memPtrA, uint32 memSizeA, uint16 chkSumA )
+{
+       uint16* memPtrL = memPtrA - memSizeA + 1;
+       uint32 iL;
+       uint16 sumL = 0;
+       uint16 csaL = 0;
+
+       bbs_memWrite16( &csaL, memPtrA );
+       for( iL = 0; iL < memSizeA; iL++ )
+       {
+               uint16 valL = 0;
+               memPtrL += bbs_memRead16( &valL, memPtrL );
+               sumL += valL;
+       }
+       csaL = chkSumA - sumL;
+
+       return bbs_memWrite16( &csaL, memPtrA );
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_memReadCsa16( const uint16* memPtrA )
+{
+       return bbs_SIZEOF16( uint16 );
+}
+
+/* ------------------------------------------------------------------------- */
+
diff --git a/Embedded/common/src/b_APIEm/Functions.h b/Embedded/common/src/b_APIEm/Functions.h
new file mode 100644 (file)
index 0000000..f2f81bf
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+#ifndef bpi_FUNCTIONS_EM_H
+#define bpi_FUNCTIONS_EM_H
+
+/**
+ * This files contains general purpose functions.
+ */
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Basic.h"
+#include "b_BasicEm/Context.h"
+#include "b_BasicEm/Functions.h"
+
+/* ---- related objects  --------------------------------------------------- */
+
+/* ---- typedefs ----------------------------------------------------------- */
+
+
+/** methods of similarty normalization for identification and verification */
+enum bpi_SimType
+{
+       bpi_RAW_SIM,       /* take raw similarity only */
+       bpi_SUB_MEAN,      /* subtract average  */
+       bpi_SUB_MAX_1,     /* subtract maximum (different id of each entry) */
+       bpi_SUB_MAX_2,     /* subtract maximum (different id of best entry) */
+       bpi_SUB_4_MAX_2,   /* subtract average maximum of best 4 entries (method 2) */
+       bpi_SUB_8_MAX_2,   /* subtract average maximum of best 8 entries (method 2) */
+       bpi_SUB_16_MAX_2,  /* subtract average maximum of best 16 entries (method 2) */
+       bpi_SUB_32_MAX_2   /* subtract average maximum of best 32 entries (method 2) */
+};
+
+/* ---- constants ---------------------------------------------------------- */
+
+/* ---- external functions ------------------------------------------------- */
+
+/** Normalizes similarities. 
+ *  This function is used by identifier module
+ */
+void bpi_normalizeSimilarities( struct bbs_Context* cpA,
+                                                           const int32* rawSimArrA,
+                                                           const int32* rawIdArrA,
+                                                               uint32 rawSizeA,
+                                                               const int32* refSimArrA,
+                                                               const int32* refIdArrA,
+                                                               uint32 refSizeA,
+                                                               enum bpi_SimType simTypeA,
+                                                               int32* outSimArrA );
+
+/** Returnes normalized single similarity. 
+ *  This function is used by verifier module
+ */
+int32 bpi_normalizedSimilarity( struct bbs_Context* cpA,
+                                                           int32 rawSimA,
+                                                           int32 rawIdA,
+                                                               const int32* refSimArrA,
+                                                               const int32* refIdArrA,
+                                                               uint32 refSizeA,
+                                                               enum bpi_SimType simTypeA );
+
+
+
+/** writes checksum adjustment value to meet chkSumA to memory
+ *  the function assumes that memPtrA is memSizeA - 1 units 
+ *  away from beginning of object-memory block 
+ */
+uint32 bpi_memWriteCsa16( uint16* memPtrA, uint32 memSizeA, uint16 chkSumA );
+
+/** takes checksum adjustment value from memory stream */
+uint32 bpi_memReadCsa16( const uint16* memPtrA );
+
+/** tests check sum and produxes error condition if no match */
+void bpi_testCheckSum( struct bbs_Context* cpA, uint16* memPtrA, uint16 chkSumA, const char* fNameA );
+
+
+#endif /* bpi_FUNCTIONS_EM_H */
+
diff --git a/Embedded/common/src/b_APIEm/Types.h b/Embedded/common/src/b_APIEm/Types.h
new file mode 100644 (file)
index 0000000..ea2e294
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+#ifndef bpi_TYPES_EM_H
+#define bpi_TYPES_EM_H
+
+/**
+ * This file contains gerenral purpose types.
+ */
+
+/* ---- includes ----------------------------------------------------------- */
+
+/* ---- related objects  --------------------------------------------------- */
+
+/* ---- typedefs ----------------------------------------------------------- */
+
+/** Type of module */
+enum bpi_ModuleType
+{
+       bpi_UNDEFINED,
+       bpi_OLD_FACE_FINDER_REMOVED,
+       bpi_FACE_FINDER,
+       bpi_LANDMARKER,
+       bpi_CONVERTER,
+       bpi_IDENTIFIER
+};
+
+/** List of object identifiers 
+ *  This list is is synchronized with enum list epi_ObjectId
+ *  Not all types are neccessarily in use in the embedded realm
+ *  values in round braces ( e.g. (32) ) denote the size in bits of the associated data type
+ *
+ *  Object formats:
+ *             ASCII String: 0-terminates string of characters
+ *
+ *             Image:  <(32) type><(32) width><(32) height><(8) byte1><(8) byte2>....
+ *                             type: 0: gray image - pixels are bytes starting at upper left corner
+ *                                   1: rgb color images - prixels are 3-byte rgb groups starting at upper left corner
+ *                                       2: jpeg compressed image (<(32) type><(32) width><(32) height> precede jpeg data)
+ *
+ *      Cue:    SDK compatible template (bpi_IdCueHdr + subsequent data)
+ *
+ *  The type values never change. Type numbers can be taken for granted.
+ */
+enum bpi_ObjectId
+{
+       bpi_ID_FILE,                 /** (ASCII String) file name (of image) */
+       bpi_ID_BOUNDING_BOX,         /** bounding box (coordinates of original image) */
+       bpi_ID_GRAPH,                /** ground truth graph */
+       bpi_ID_FILE_LIST,                    /** list of filenames  */
+       bpi_ID_GRAPH_LIST,                       /** list of egp_SpatialGraph (multiple ground truth graphs per image) */
+       bpi_ID_GROUP,                            /** generic group element (used in the embedded domain to identify an object set) */
+       bpi_ID_IMAGE = 256,          /** (Image) downscaled byte image */
+       bpi_ID_IMAGE_FRAME,          /** bounding box surrounding original image */
+       bpi_ID_IMAGE_ID,                         /** (32)-integer id number of person por object in image */
+       bpi_ID_SIGNATURE_NAME = 512, /** (ASCII String) name of gallery element (=signature) */
+       bpi_ID_CONFIDENCE,           /** general purpose confidence value */
+       bpi_ID_CUE,                  /** (Cue) general purpose cue   */
+       bpi_ID_PCA_MAT,              /** eigenvector matrix obtained from PCA analysis */
+       bpi_ID_PCA_AVG,              /** PCA average vector */
+       bpi_ID_PCA_EVL,              /** PCA eigen values */
+       bpi_ID_COMMENT               /** (ASCII String) comment or description of data */
+       // never modify this list alone (!) - modification must be initiated in Kernel/API
+};
+
+/* ---- constants ---------------------------------------------------------- */
+
+/* ---- external functions ------------------------------------------------- */
+
+#endif /* bpi_TYPES_EM_H */
+
diff --git a/Embedded/common/src/b_BasicEm/APh.c b/Embedded/common/src/b_BasicEm/APh.c
new file mode 100644 (file)
index 0000000..dd53ad9
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Functions.h"
+#include "b_BasicEm/APh.h"
+#include "b_BasicEm/Complex.h"
+#include "b_BasicEm/Math.h"
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ auxiliary functions } ---------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ constructor / destructor } ----------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ operators } -------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+flag bbs_APh_equal( struct bbs_APh aph1A, 
+                                       struct bbs_APh aph2A )
+{
+       return ( aph1A.absE == aph2A.absE ) && ( aph1A.phaseE == aph2A.phaseE );
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ query functions } -------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+       
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ I/O } -------------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bbs_APh_memSize( struct bbs_Context* cpA,
+                                           struct bbs_APh aPhA )
+{
+       return bbs_SIZEOF16( aPhA.absE ) + bbs_SIZEOF16( aPhA.phaseE );
+}
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bbs_APh_memWrite( struct bbs_Context* cpA,
+                                                const struct bbs_APh* ptrA, 
+                                                uint16* memPtrA )
+{
+       memPtrA += bbs_memWrite16( &ptrA->absE, memPtrA );
+       memPtrA += bbs_memWrite16( &ptrA->phaseE, memPtrA );
+       return bbs_APh_memSize( cpA, *ptrA );
+}
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bbs_APh_memRead( struct bbs_Context* cpA,
+                                           struct bbs_APh* ptrA, 
+                                               const uint16* memPtrA )
+{
+       if( bbs_Context_error( cpA ) ) return 0;
+       memPtrA += bbs_memRead16( &ptrA->absE, memPtrA );
+       memPtrA += bbs_memRead16( &ptrA->phaseE, memPtrA );
+       return bbs_APh_memSize( cpA, *ptrA );
+}
+
+/* ------------------------------------------------------------------------- */
+       
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+struct bbs_APh bbs_APh_conj( const struct bbs_APh aPhA )
+{
+       struct bbs_APh aphL;
+       aphL.absE = aPhA.absE;
+       aphL.phaseE = - aPhA.phaseE;
+       return aphL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_APh_importComplex( struct bbs_APh* dstPtrA, 
+                                                       const struct bbs_Complex* srcPtrA )
+{
+       dstPtrA->absE = bbs_sqrt32( ( int32 ) srcPtrA->realE * srcPtrA->realE + ( int32 ) srcPtrA->imagE * srcPtrA->imagE );
+       dstPtrA->phaseE = bbs_phase16( srcPtrA->realE, srcPtrA->imagE );
+}
+
+/* ========================================================================= */
+
+
diff --git a/Embedded/common/src/b_BasicEm/APh.h b/Embedded/common/src/b_BasicEm/APh.h
new file mode 100644 (file)
index 0000000..39cc7e1
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+#ifndef bbs_APH_H
+#define bbs_APH_H
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Context.h"
+#include "b_BasicEm/Basic.h"
+#include "b_BasicEm/Phase.h"
+
+/* ---- related objects  --------------------------------------------------- */
+
+struct bbs_Complex;
+
+/* ---- typedefs ----------------------------------------------------------- */
+
+/* ---- constants ---------------------------------------------------------- */
+
+/* ---- object definition -------------------------------------------------- */
+
+/** Object representing absolute and phase value of a complex number */
+struct bbs_APh 
+{
+
+       /* ---- private data --------------------------------------------------- */
+
+       /* ---- public data ---------------------------------------------------- */
+
+       /** absolute value */
+       uint16 absE;
+       
+       /** phase value */
+       phase16 phaseE;
+
+};
+
+/* ---- associated objects ------------------------------------------------- */
+
+/* ---- external functions ------------------------------------------------- */
+
+/* ---- \ghd{ constructor/destructor } ------------------------------------- */
+
+/* ---- \ghd{ operators } -------------------------------------------------- */
+
+/** equal operator */
+flag bbs_APh_equal( struct bbs_APh aph1A, 
+                                       struct bbs_APh aph2A );
+
+/* ---- \ghd{ query functions } -------------------------------------------- */
+
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+
+/* ---- \ghd{ memory I/O } ------------------------------------------------- */
+
+/** size in 16-bit words object needs when written to memory */
+uint32 bbs_APh_memSize( struct bbs_Context* cpA,
+                                           struct bbs_APh aPhA );
+
+/** writes object to memory; returns number of 16-bit words written */
+uint32 bbs_APh_memWrite( struct bbs_Context* cpA,
+                                                const struct bbs_APh* ptrA, 
+                                                uint16* memPtrA );
+
+/** reads object from memory; returns number of 16-bit words read */
+uint32 bbs_APh_memRead( struct bbs_Context* cpA,
+                                           struct bbs_APh* ptrA, 
+                                               const uint16* memPtrA );
+
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+
+/** conjugated value */
+struct bbs_APh bbs_APh_conj( const struct bbs_APh aPhA );
+
+/** imports complex value */
+void bbs_APh_importComplex( struct bbs_APh* dstPtrA, 
+                                                       const struct bbs_Complex* srcPtrA );
+
+/* ------------------------------------------------------------------------- */
+
+#endif /* bbs_APH_H */
diff --git a/Embedded/common/src/b_BasicEm/APhArr.c b/Embedded/common/src/b_BasicEm/APhArr.c
new file mode 100644 (file)
index 0000000..7bfa0e0
--- /dev/null
@@ -0,0 +1,232 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Functions.h"
+#include "b_BasicEm/APhArr.h"
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ auxiliary functions } ---------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ constructor / destructor } ----------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_APhArr_init( struct bbs_Context* cpA,
+                                         struct bbs_APhArr* ptrA )
+{
+       ptrA->arrPtrE = NULL;
+       ptrA->sizeE = 0;
+       ptrA->allocatedSizeE = 0;
+       ptrA->mspE = NULL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_APhArr_exit( struct bbs_Context* cpA,
+                                         struct bbs_APhArr* ptrA )
+{
+       bbs_MemSeg_free( cpA, ptrA->mspE, ptrA->arrPtrE );
+       ptrA->arrPtrE = NULL;
+       ptrA->mspE = NULL;
+       ptrA->sizeE = 0;
+       ptrA->allocatedSizeE = 0;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ operators } -------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_APhArr_copy( struct bbs_Context* cpA,
+                                         struct bbs_APhArr* ptrA, 
+                                         const struct bbs_APhArr* srcPtrA )
+{
+#ifdef DEBUG1
+       if( ptrA->allocatedSizeE < srcPtrA->allocatedSizeE )
+       {
+               bbs_ERROR0( "void bbs_APhArr_copy(...):\n"
+                                   "Insufficient allocated memory in destination array." );            
+               return;
+       }
+#endif
+       bbs_APhArr_size( cpA, ptrA, srcPtrA->sizeE );
+       bbs_memcpy32( ptrA->arrPtrE, srcPtrA->arrPtrE, srcPtrA->sizeE * bbs_SIZEOF32( struct bbs_APh ) ); 
+}
+
+/* ------------------------------------------------------------------------- */
+
+flag bbs_APhArr_equal( struct bbs_Context* cpA,
+                                          const struct bbs_APhArr* ptrA, 
+                                          const struct bbs_APhArr* srcPtrA )
+{
+       uint32 iL;
+       const struct bbs_APh* ptr1L = ptrA->arrPtrE;
+       const struct bbs_APh* ptr2L = srcPtrA->arrPtrE;
+       if( ptrA->sizeE != srcPtrA->sizeE ) return FALSE;
+       for( iL = ptrA->sizeE; iL > 0; iL-- )
+       {
+               if( !bbs_APh_equal( *ptr1L, *ptr2L ) ) return FALSE;
+       }
+       return TRUE;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ query functions } -------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bbs_APhArr_heapSize( struct bbs_Context* cpA,
+                                                   const struct bbs_APhArr* ptrA, 
+                                                       uint32 sizeA )
+{
+       return sizeA * bbs_SIZEOF16( struct bbs_APh ) + bbs_MEM_BLOCK_OVERHD;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+       
+void bbs_APhArr_create( struct bbs_Context* cpA,
+                                           struct bbs_APhArr* ptrA, 
+                                               uint32 sizeA, 
+                                               struct bbs_MemSeg* mspA )
+{
+       if( bbs_Context_error( cpA ) ) return;
+       if( ptrA->arrPtrE != 0 )
+       {
+               bbs_APhArr_size( cpA, ptrA, sizeA );
+       }
+       else
+       {
+               ptrA->arrPtrE = bbs_MemSeg_alloc( cpA, mspA, sizeA * bbs_SIZEOF16( struct bbs_APh ) );
+               if( bbs_Context_error( cpA ) ) return;
+               ptrA->allocatedSizeE = sizeA;
+               ptrA->sizeE = sizeA;
+               if( !mspA->sharedE ) ptrA->mspE = mspA;
+       }
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_APhArr_size( struct bbs_Context* cpA,
+                                         struct bbs_APhArr* ptrA, 
+                                         uint32 sizeA )
+{
+       if( ptrA->allocatedSizeE < sizeA )
+       {
+               bbs_ERROR1( "void bbs_APhArr_size( struct bbs_APhArr*, uint32 ):\n"
+                                   "Insufficient allocated memory (allocatedSizeE = '%i')",
+                                   ptrA->allocatedSizeE );
+               return;
+       }
+       ptrA->sizeE = sizeA;
+}
+
+/* ------------------------------------------------------------------------- */
+       
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ I/O } -------------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bbs_APhArr_memSize( struct bbs_Context* cpA,
+                                                  const struct bbs_APhArr* ptrA )
+{
+       return bbs_SIZEOF16( uint32 ) + bbs_SIZEOF16( ptrA->sizeE ) + 
+                                                               ptrA->sizeE * bbs_SIZEOF16( struct bbs_APh );
+}
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bbs_APhArr_memWrite( struct bbs_Context* cpA,
+                                                   const struct bbs_APhArr* ptrA, 
+                                                       uint16* memPtrA )
+{
+       uint32 memSizeL = bbs_APhArr_memSize( cpA, ptrA );
+       memPtrA += bbs_memWrite32( &memSizeL, memPtrA );
+       memPtrA += bbs_memWrite32( &ptrA->sizeE, memPtrA );
+       memPtrA += bbs_memWrite16Arr( cpA, ptrA->arrPtrE, ptrA->sizeE * 2, memPtrA );
+       return memSizeL;
+}
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bbs_APhArr_memRead( struct bbs_Context* cpA,
+                                                  struct bbs_APhArr* ptrA, 
+                                                  const uint16* memPtrA, 
+                                                  struct bbs_MemSeg* mspA )
+{
+       uint32 memSizeL, sizeL;
+       if( bbs_Context_error( cpA ) ) return 0;
+       memPtrA += bbs_memRead32( &memSizeL, memPtrA );
+       memPtrA += bbs_memRead32( &sizeL, memPtrA );
+       bbs_APhArr_create( cpA, ptrA, sizeL, mspA );
+       memPtrA += bbs_memRead16Arr( cpA, ptrA->arrPtrE, ptrA->sizeE * 2, memPtrA );
+
+       if( memSizeL != bbs_APhArr_memSize( cpA, ptrA ) )
+       {
+               bbs_ERR0( bbs_ERR_CORRUPT_DATA, "uint32 bbs_APhArr_memRead( const struct bbs_APhArr*, const uint16* ):\n"
+                   "size mismatch" ); 
+               return 0; 
+       }
+       return memSizeL;
+}
+
+/* ------------------------------------------------------------------------- */
+       
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+       
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+
+
diff --git a/Embedded/common/src/b_BasicEm/APhArr.h b/Embedded/common/src/b_BasicEm/APhArr.h
new file mode 100644 (file)
index 0000000..9a70d83
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+#ifndef bbs_APH_ARR_EM_H
+#define bbs_APH_ARR_EM_H
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Context.h"
+#include "b_BasicEm/MemSeg.h"
+#include "b_BasicEm/APh.h"
+
+/* ---- related objects  --------------------------------------------------- */
+
+/* ---- typedefs ----------------------------------------------------------- */
+
+/* ---- constants ---------------------------------------------------------- */
+
+/* ---- object definition -------------------------------------------------- */
+
+/** abs phase array */
+struct bbs_APhArr 
+{
+
+       /* ---- private data --------------------------------------------------- */
+
+       /** pointer to exclusive memory segment used for allocation */
+       struct bbs_MemSeg* mspE;
+
+       /* ---- public data ---------------------------------------------------- */
+
+       /** pointer to array of bytes */
+       struct bbs_APh* arrPtrE;
+
+       /** current size */
+       uint32 sizeE;
+
+       /** allocated size */
+       uint32 allocatedSizeE;
+
+};
+
+/* ---- associated objects ------------------------------------------------- */
+
+/* ---- external functions ------------------------------------------------- */
+
+/* ---- \ghd{ constructor/destructor } ------------------------------------- */
+
+/** initializes bbs_APhArr  */
+void bbs_APhArr_init( struct bbs_Context* cpA,
+                                         struct bbs_APhArr* ptrA );
+
+/** frees bbs_APhArr  */
+void bbs_APhArr_exit( struct bbs_Context* cpA,
+                                         struct bbs_APhArr* ptrA );
+
+/* ---- \ghd{ operators } -------------------------------------------------- */
+
+/** copy operator */
+void bbs_APhArr_copy( struct bbs_Context* cpA,
+                                         struct bbs_APhArr* ptrA, 
+                                         const struct bbs_APhArr* srcPtrA );
+
+/** equal operator */
+flag bbs_APhArr_equal( struct bbs_Context* cpA,
+                                          const struct bbs_APhArr* ptrA, 
+                                          const struct bbs_APhArr* srcPtrA );
+
+/* ---- \ghd{ query functions } -------------------------------------------- */
+
+/** calculates the amount of heap memory needed (16bit words) if created with given parameters */ 
+uint32 bbs_APhArr_heapSize( struct bbs_Context* cpA,
+                                                   const struct bbs_APhArr* ptrA, 
+                                                       uint32 sizeA );
+
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+
+/** creates bbs_APhArr object. 
+  * This function must be called after initialization before usage of 
+  * object. 
+  */
+void bbs_APhArr_create( struct bbs_Context* cpA,
+                                           struct bbs_APhArr* ptrA, 
+                                           uint32 sizeA, 
+                                               struct bbs_MemSeg* mspA );
+
+/** sets array size */
+void bbs_APhArr_size( struct bbs_Context* cpA,
+                                         struct bbs_APhArr* ptrA, 
+                                         uint32 sizeA );
+
+/* ---- \ghd{ memory I/O } ------------------------------------------------- */
+
+/** size object needs when written to memory */
+uint32 bbs_APhArr_memSize( struct bbs_Context* cpA,
+                                                  const struct bbs_APhArr* ptrA );
+
+/** writes object to memory; returns number of bytes written */
+uint32 bbs_APhArr_memWrite( struct bbs_Context* cpA,
+                                                   const struct bbs_APhArr* ptrA, 
+                                                       uint16* memPtrA );
+
+/** reads object from memory; returns number of bytes read */
+uint32 bbs_APhArr_memRead( struct bbs_Context* cpA,
+                                                  struct bbs_APhArr* ptrA, 
+                                                  const uint16* memPtrA, 
+                                                  struct bbs_MemSeg* mspA );
+
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+
+#endif /* bbs_APH_ARR_EM_H */
+
diff --git a/Embedded/common/src/b_BasicEm/Basic.h b/Embedded/common/src/b_BasicEm/Basic.h
new file mode 100644 (file)
index 0000000..2e75f68
--- /dev/null
@@ -0,0 +1,173 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+#ifndef bbs_BASIC_EM_H
+#define bbs_BASIC_EM_H
+
+/* ---- includes ----------------------------------------------------------- */
+
+/** This header file is not part of the repository.
+ *  If you get an error message at this point, copy 
+ *  b_BasicEm/LibConfigDefault.h into
+ *  "../conf/b_BasicEm/LibConfig.h"
+ */
+#include "../conf/b_BasicEm/LibConfig.h"
+
+#include "b_BasicEm/Config.h"
+
+/* ---- defines ------------------------------------------------------------ */
+
+#if defined( WIN32 )
+       /* disable warning for short += short: */
+       #pragma warning( disable : 4244 )
+#endif
+
+#if defined( bbs_NO_MESSAGE_HANDLING ) 
+#error bbs_NO_MESSAGE_HANDLING is obsolete, please use bbs_COMPACT_MESSAGE_HANDLING instead.
+#endif
+#if defined( bbs_ENABLE_MESSAGE_FPTRG )
+#error bbs_ENABLE_MESSAGE_FPTRG is obsolete, please use error handler in context object instead.
+#endif
+
+#if defined( bbs_NO_MESSAGE_HANDLING ) && defined( bbs_ENABLE_MESSAGE_FPTRG )
+#error LibConfig.h: bbs_NO_MESSAGE_HANDLING and bbs_ENABLE_MESSAGE_FPTRG are mutually exclusive
+#endif
+
+
+
+/* ---- typedefs ----------------------------------------------------------- */
+
+typedef signed char            int8;
+typedef signed short   int16;
+typedef unsigned char  uint8;
+typedef unsigned short uint16;
+
+#if defined HW_TMS320C6x
+       typedef signed int              int32;
+       typedef unsigned int    uint32;
+       typedef uint32                  count_t;
+#elif defined HW_TMS320C5x
+       typedef signed long             int32; 
+       typedef unsigned long   uint32;
+       typedef uint16                  count_t;
+#else
+       typedef signed int              int32;
+       typedef unsigned int    uint32;
+       typedef uint32                  count_t;
+#endif
+
+
+typedef uint32 flag; /* boolean type */
+
+/* 
+       Please modify the 64 bit types declarations below for specific platforms/compilers
+       where necessary; 
+       bbs_TYPES_64_AVAILABLE should be checked in code sections that make use of 64 bit data types.
+*/
+#ifdef bbs_TYPES_64_AVAILABLE
+
+#ifdef WIN64
+       typedef __int64                         int64;
+       typedef unsigned __int64        uint64;
+#else
+       typedef long long                       int64;
+       typedef unsigned long long      uint64;
+#endif
+
+#endif /* bbs_TYPES_64_AVAILABLE */
+
+/** floating point type */
+struct flt16
+{
+       int16 valE;
+       int16 bbpE;
+};
+
+#ifndef TRUE
+       #define TRUE 1
+       #define FALSE 0
+#endif
+
+#ifndef NULL
+       #define NULL 0L
+#endif
+
+#define bbs_MAX_STRING_LENGTH 1024
+
+/* ---- macros ------------------------------------------------------------- */
+
+/** device independent macro definitions for sizeof:
+  * bbs_SIZEOF8:  size in bytes
+  *    bbs_SIZEOF16: size in 16-bit words
+  *    bbs_SIZEOF32: size in 32-bit words
+  */                             
+#if defined( HW_TMS320C5x )
+       #define bbs_SIZEOF8( typeA )  ( sizeof( typeA ) << 1 )
+       #define bbs_SIZEOF16( typeA ) ( sizeof( typeA ) )
+       #define bbs_SIZEOF32( typeA ) ( sizeof( typeA ) >> 1 )
+#else
+       #define bbs_SIZEOF8( typeA )  ( sizeof( typeA ) )
+       #define bbs_SIZEOF16( typeA ) ( sizeof( typeA ) >> 1 )
+       #define bbs_SIZEOF32( typeA ) ( sizeof( typeA ) >> 2 )
+#endif
+
+/** messages */
+#if defined( HW_TMS320C5x ) || defined( bbs_COMPACT_MESSAGE_HANDLING ) 
+
+       #define bbs_DEF_fNameL( fNameA )
+
+       #define bbs_ERROR0( formatA )                                                                           bbs_Context_pushError( cpA, bbs_Error_create( bbs_ERR_ERROR, __LINE__, __FILE__, NULL ) )
+       #define bbs_ERROR1( formatA, arg1A )                                                            bbs_Context_pushError( cpA, bbs_Error_create( bbs_ERR_ERROR, __LINE__, __FILE__, NULL ) )
+       #define bbs_ERROR2( formatA, arg1A, arg2A )                                                     bbs_Context_pushError( cpA, bbs_Error_create( bbs_ERR_ERROR, __LINE__, __FILE__, NULL ) )
+       #define bbs_ERROR3( formatA, arg1A, arg2A, arg3A )                                      bbs_Context_pushError( cpA, bbs_Error_create( bbs_ERR_ERROR, __LINE__, __FILE__, NULL ) )
+       #define bbs_ERROR4( formatA, arg1A, arg2A, arg3A, arg4A )                       bbs_Context_pushError( cpA, bbs_Error_create( bbs_ERR_ERROR, __LINE__, __FILE__, NULL ) )
+       #define bbs_ERROR5( formatA, arg1A, arg2A, arg3A, arg4A, arg5A )        bbs_Context_pushError( cpA, bbs_Error_create( bbs_ERR_ERROR, __LINE__, __FILE__, NULL ) )
+
+       #define bbs_ERR0( errorA, formatA )                                                                     bbs_Context_pushError( cpA, bbs_Error_create( errorA, __LINE__, __FILE__, NULL ) )
+       #define bbs_ERR1( errorA, formatA, arg1A )                                                      bbs_Context_pushError( cpA, bbs_Error_create( errorA, __LINE__, __FILE__, NULL ) )
+       #define bbs_ERR2( errorA, formatA, arg1A, arg2A )                                       bbs_Context_pushError( cpA, bbs_Error_create( errorA, __LINE__, __FILE__, NULL ) )
+       #define bbs_ERR3( errorA, formatA, arg1A, arg2A, arg3A )                        bbs_Context_pushError( cpA, bbs_Error_create( errorA, __LINE__, __FILE__, NULL ) )
+       #define bbs_ERR4( errorA, formatA, arg1A, arg2A, arg3A, arg4A )         bbs_Context_pushError( cpA, bbs_Error_create( errorA, __LINE__, __FILE__, NULL ) )
+       #define bbs_ERR5( errorA, formatA, arg1A, arg2A, arg3A, arg4A, arg5A )  bbs_Context_pushError( cpA, bbs_Error_create( errorA, __LINE__, __FILE__, NULL ) )
+
+#else
+
+       #define bbs_DEF_fNameL( fNameA )                                                                        const char* fNameL = fNameA;
+
+       #define bbs_ERROR0( formatA )                                                                           bbs_Context_pushError( cpA, bbs_Error_create( bbs_ERR_ERROR, __LINE__, __FILE__, formatA ) )
+       #define bbs_ERROR1( formatA, arg1A )                                                            bbs_Context_pushError( cpA, bbs_Error_create( bbs_ERR_ERROR, __LINE__, __FILE__, formatA, arg1A ) )
+       #define bbs_ERROR2( formatA, arg1A, arg2A )                                                     bbs_Context_pushError( cpA, bbs_Error_create( bbs_ERR_ERROR, __LINE__, __FILE__, formatA, arg1A, arg2A ) )
+       #define bbs_ERROR3( formatA, arg1A, arg2A, arg3A )                                      bbs_Context_pushError( cpA, bbs_Error_create( bbs_ERR_ERROR, __LINE__, __FILE__, formatA, arg1A, arg2A, arg3A ) )
+       #define bbs_ERROR4( formatA, arg1A, arg2A, arg3A, arg4A )                       bbs_Context_pushError( cpA, bbs_Error_create( bbs_ERR_ERROR, __LINE__, __FILE__, formatA, arg1A, arg2A, arg3A, arg4A ) )
+    #define bbs_ERROR5( formatA, arg1A, arg2A, arg3A, arg4A, arg5A )   bbs_Context_pushError( cpA, bbs_Error_create( bbs_ERR_ERROR, __LINE__, __FILE__, formatA, arg1A, arg2A, arg3A, arg4A, arg5A ) ) 
+
+       #define bbs_ERR0( errorA, formatA )                                                                             bbs_Context_pushError( cpA, bbs_Error_create( errorA, __LINE__, __FILE__, formatA ) )
+       #define bbs_ERR1( errorA, formatA, arg1A )                                                              bbs_Context_pushError( cpA, bbs_Error_create( errorA, __LINE__, __FILE__, formatA, arg1A ) )
+       #define bbs_ERR2( errorA, formatA, arg1A, arg2A )                                               bbs_Context_pushError( cpA, bbs_Error_create( errorA, __LINE__, __FILE__, formatA, arg1A, arg2A ) )
+       #define bbs_ERR3( errorA, formatA, arg1A, arg2A, arg3A )                                bbs_Context_pushError( cpA, bbs_Error_create( errorA, __LINE__, __FILE__, formatA, arg1A, arg2A, arg3A ) )
+       #define bbs_ERR4( errorA, formatA, arg1A, arg2A, arg3A, arg4A )                 bbs_Context_pushError( cpA, bbs_Error_create( errorA, __LINE__, __FILE__, formatA, arg1A, arg2A, arg3A, arg4A ) )
+    #define bbs_ERR5( errorA, formatA, arg1A, arg2A, arg3A, arg4A, arg5A )     bbs_Context_pushError( cpA, bbs_Error_create( errorA, __LINE__, __FILE__, formatA, arg1A, arg2A, arg3A, arg4A, arg5A ) )        
+
+#endif
+
+/* ---- constants ---------------------------------------------------------- */
+
+/* ---- associated objects ------------------------------------------------- */
+
+/* ---- external functions ------------------------------------------------- */
+
+#endif /* bbs_BASIC_EM_H */
+
diff --git a/Embedded/common/src/b_BasicEm/Complex.c b/Embedded/common/src/b_BasicEm/Complex.c
new file mode 100644 (file)
index 0000000..07c3f43
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Complex.h"
+#include "b_BasicEm/APh.h"
+#include "b_BasicEm/Functions.h"
+#include "b_BasicEm/Math.h"
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ auxiliary functions } ---------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ constructor / destructor } ----------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ operators } -------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+flag bbs_Complex_equal( struct bbs_Complex compl1A, struct bbs_Complex compl2A )
+{
+       return ( compl1A.realE == compl2A.realE ) && ( compl1A.imagE == compl2A.imagE );
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ query functions } -------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+       
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ I/O } -------------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bbs_Complex_memSize( struct bbs_Context* cpA,
+                                                   struct bbs_Complex complA )
+{
+       return bbs_SIZEOF16( complA.realE ) + bbs_SIZEOF16( complA.imagE );
+}
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bbs_Complex_memWrite( struct bbs_Context* cpA,
+                                                        const struct bbs_Complex* ptrA, 
+                                                        uint16* memPtrA )
+{
+       memPtrA += bbs_memWrite16( &ptrA->realE, memPtrA );
+       memPtrA += bbs_memWrite16( &ptrA->imagE, memPtrA );
+       return bbs_Complex_memSize( cpA, *ptrA );
+}
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bbs_Complex_memRead( struct bbs_Context* cpA,
+                                                   struct bbs_Complex* ptrA, 
+                                                       const uint16* memPtrA )
+{
+       if( bbs_Context_error( cpA ) ) return 0;
+       memPtrA += bbs_memRead16( &ptrA->realE, memPtrA );
+       memPtrA += bbs_memRead16( &ptrA->imagE, memPtrA );
+       return bbs_Complex_memSize( cpA, *ptrA );
+}
+
+/* ------------------------------------------------------------------------- */
+       
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+struct bbs_Complex bbs_Complex_conj( struct bbs_Complex complA )
+{
+       struct bbs_Complex resultL;
+       resultL.imagE = - complA.imagE;
+       resultL.realE = complA.realE;
+       return resultL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bbs_Complex_abs2( struct bbs_Complex complA )
+{
+       return ( int32 ) complA.realE * complA.realE + 
+                  ( int32 ) complA.imagE * complA.imagE;
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint16 bbs_Complex_abs( struct bbs_Complex complA )
+{
+       return bbs_sqrt32( bbs_Complex_abs2( complA ) );
+}
+
+/* ------------------------------------------------------------------------- */
+
+phase16 bbs_Complex_phase( struct bbs_Complex complA )
+{
+       int32 realL, imagL;
+       realL = complA.realE;
+       imagL = complA.imagE;
+
+       return bbs_phase16( realL, imagL );
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_Complex_importAPh( struct bbs_Complex* dstPtrA, const struct bbs_APh* srcPtrA )
+{
+       dstPtrA->realE = ( ( bbs_cos32( srcPtrA->phaseE ) >> 8 ) * srcPtrA->absE ) >> 16;
+       dstPtrA->imagE = ( ( bbs_sin32( srcPtrA->phaseE ) >> 8 ) * srcPtrA->absE ) >> 16;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+
+
diff --git a/Embedded/common/src/b_BasicEm/Complex.h b/Embedded/common/src/b_BasicEm/Complex.h
new file mode 100644 (file)
index 0000000..fbed51e
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+#ifndef bbs_COMPLEX_H
+#define bbs_COMPLEX_H
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Context.h"
+#include "b_BasicEm/Basic.h"
+#include "b_BasicEm/Phase.h"
+
+/* ---- related objects  --------------------------------------------------- */
+
+struct bbs_APh;
+
+/* ---- typedefs ----------------------------------------------------------- */
+
+/* ---- constants ---------------------------------------------------------- */
+
+/* ---- object definition -------------------------------------------------- */
+
+/** Complex object */
+struct bbs_Complex 
+{
+
+       /* ---- private data --------------------------------------------------- */
+
+       /* ---- public data ---------------------------------------------------- */
+
+       /** real part */
+       int16 realE;
+       
+       /** imaginary part */
+       int16 imagE;
+
+};
+
+/* ---- associated objects ------------------------------------------------- */
+
+/* ---- external functions ------------------------------------------------- */
+
+/* ---- \ghd{ constructor/destructor } ------------------------------------- */
+
+/* ---- \ghd{ operators } -------------------------------------------------- */
+
+/** equal operator */
+flag bbs_Complex_equal( struct bbs_Complex compl1A, struct bbs_Complex compl2A );
+
+/* ---- \ghd{ query functions } -------------------------------------------- */
+
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+
+/* ---- \ghd{ memory I/O } ------------------------------------------------- */
+
+/** size in 16-bit words object needs when written to memory */
+uint32 bbs_Complex_memSize( struct bbs_Context* cpA,
+                                                   struct bbs_Complex complA );
+
+/** writes object to memory; returns number of words (16-bit) written */
+uint32 bbs_Complex_memWrite( struct bbs_Context* cpA,
+                                                        const struct bbs_Complex* ptrA, 
+                                                        uint16* memPtrA );
+
+/** reads object from memory; returns number of words (16-bit) read */
+uint32 bbs_Complex_memRead( struct bbs_Context* cpA,
+                                                   struct bbs_Complex* ptrA, 
+                                                       const uint16* memPtrA );
+
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+
+/** conjugated value */
+struct bbs_Complex bbs_Complex_conj( struct bbs_Complex complA );
+
+/** returns squared abs value */
+uint32 bbs_Complex_abs2( struct bbs_Complex complA );
+
+/** returns absolute value */
+uint16 bbs_Complex_abs( struct bbs_Complex complA );
+
+/** returns phase value */
+phase16 bbs_Complex_phase( struct bbs_Complex complA );
+
+/** imports abs-phase value */
+void bbs_Complex_importAPh( struct bbs_Complex* dstPtrA, const struct bbs_APh* srcPtrA );
+
+/* ------------------------------------------------------------------------- */
+
+#endif /* bbs_COMPLEX_H */
diff --git a/Embedded/common/src/b_BasicEm/ComplexArr.c b/Embedded/common/src/b_BasicEm/ComplexArr.c
new file mode 100644 (file)
index 0000000..b667f96
--- /dev/null
@@ -0,0 +1,233 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Functions.h"
+#include "b_BasicEm/ComplexArr.h"
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ auxiliary functions } ---------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ constructor / destructor } ----------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_ComplexArr_init( struct bbs_Context* cpA,
+                                                 struct bbs_ComplexArr* ptrA )
+{
+       ptrA->arrPtrE = NULL;
+       ptrA->sizeE = 0;
+       ptrA->allocatedSizeE = 0;
+       ptrA->mspE = NULL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_ComplexArr_exit( struct bbs_Context* cpA,
+                                                 struct bbs_ComplexArr* ptrA )
+{
+       bbs_MemSeg_free( cpA, ptrA->mspE, ptrA->arrPtrE );
+       ptrA->arrPtrE = NULL;
+       ptrA->mspE = NULL;
+       ptrA->sizeE = 0;
+       ptrA->allocatedSizeE = 0;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ operators } -------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_ComplexArr_copy( struct bbs_Context* cpA,
+                                                 struct bbs_ComplexArr* ptrA, 
+                                                 const struct bbs_ComplexArr* srcPtrA )
+{
+#ifdef DEBUG1
+       if( ptrA->allocatedSizeE < srcPtrA->allocatedSizeE )
+       {
+               bbs_ERROR0( "void bbs_ComplexArr_copy( ... ):\n"
+                                  "Unsufficient allocated memory in destination array." );             
+               return;
+       }
+#endif
+       bbs_ComplexArr_size( cpA, ptrA, srcPtrA->sizeE );
+       bbs_memcpy32( ptrA->arrPtrE, srcPtrA->arrPtrE, srcPtrA->sizeE * bbs_SIZEOF32( struct bbs_Complex ) ); 
+}
+
+/* ------------------------------------------------------------------------- */
+
+flag bbs_ComplexArr_equal( struct bbs_Context* cpA,
+                                                  const struct bbs_ComplexArr* ptrA, 
+                                                  const struct bbs_ComplexArr* srcPtrA )
+{
+       uint32 iL;
+       const struct bbs_Complex* ptr1L = ptrA->arrPtrE;
+       const struct bbs_Complex* ptr2L = srcPtrA->arrPtrE;
+       if( ptrA->sizeE != srcPtrA->sizeE ) return FALSE;
+       for( iL = ptrA->sizeE; iL > 0; iL-- )
+       {
+               if( !bbs_Complex_equal( *ptr1L, *ptr2L ) ) return FALSE;
+       }
+       return TRUE;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ query functions } -------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bbs_ComplexArr_heapSize( struct bbs_Context* cpA,
+                                                           const struct bbs_ComplexArr* ptrA, 
+                                                               uint32 sizeA )
+{
+       return sizeA * bbs_SIZEOF16( struct bbs_Complex ) + bbs_MEM_BLOCK_OVERHD;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+       
+void bbs_ComplexArr_create( struct bbs_Context* cpA,
+                                                   struct bbs_ComplexArr* ptrA, 
+                                                   uint32 sizeA, 
+                                                       struct bbs_MemSeg* mspA )
+{
+       if( bbs_Context_error( cpA ) ) return;
+       if( ptrA->arrPtrE != 0 )
+       {
+               bbs_ComplexArr_size( cpA, ptrA, sizeA );
+       }
+       else
+       {
+               ptrA->arrPtrE = bbs_MemSeg_alloc( cpA, mspA, sizeA * bbs_SIZEOF16( struct bbs_Complex ) );
+               if( bbs_Context_error( cpA ) ) return;
+               ptrA->allocatedSizeE = sizeA;
+               ptrA->sizeE = sizeA;
+               if( !mspA->sharedE ) ptrA->mspE = mspA;
+       }
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_ComplexArr_size( struct bbs_Context* cpA,
+                                                 struct bbs_ComplexArr* ptrA, 
+                                                 uint32 sizeA )
+{
+       if( ptrA->allocatedSizeE < sizeA )
+       {
+               bbs_ERROR1( "void bbs_ComplexArr_size( struct bbs_ComplexArr*, uint32 sizeA ):\n"
+                                  "Unsufficient allocated memory (allocatedSizeE = '%i')",
+                                  ptrA->allocatedSizeE );
+               return;
+       }
+       ptrA->sizeE = sizeA;
+}
+
+/* ------------------------------------------------------------------------- */
+       
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ I/O } -------------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bbs_ComplexArr_memSize( struct bbs_Context* cpA,
+                                                          const struct bbs_ComplexArr* ptrA )
+
+{
+       return  bbs_SIZEOF16( uint32 ) + bbs_SIZEOF16( ptrA->sizeE ) + 
+                                                       ptrA->sizeE * bbs_SIZEOF16( struct bbs_Complex );
+}
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bbs_ComplexArr_memWrite( struct bbs_Context* cpA,
+                                                           const struct bbs_ComplexArr* ptrA, 
+                                                               uint16* memPtrA )
+{
+       uint32 memSizeL = bbs_ComplexArr_memSize( cpA, ptrA );
+       memPtrA += bbs_memWrite32( &memSizeL, memPtrA );
+       memPtrA += bbs_memWrite32( &ptrA->sizeE, memPtrA );
+       memPtrA += bbs_memWrite16Arr( cpA, ptrA->arrPtrE, ptrA->sizeE * 2, memPtrA );
+       return memSizeL;
+}
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bbs_ComplexArr_memRead( struct bbs_Context* cpA,
+                                                          struct bbs_ComplexArr* ptrA, 
+                                                          const uint16* memPtrA, 
+                                                          struct bbs_MemSeg* mspA )
+{
+       uint32 memSizeL, sizeL;
+       if( bbs_Context_error( cpA ) ) return 0;
+       memPtrA += bbs_memRead32( &memSizeL, memPtrA );
+       memPtrA += bbs_memRead32( &sizeL, memPtrA );
+       bbs_ComplexArr_create( cpA, ptrA, sizeL, mspA );
+       memPtrA += bbs_memRead16Arr( cpA, ptrA->arrPtrE, ptrA->sizeE * 2, memPtrA );
+
+       if( memSizeL != bbs_ComplexArr_memSize( cpA, ptrA ) )
+       {
+               bbs_ERR0( bbs_ERR_CORRUPT_DATA, "uint32 bbs_ComplexArr_memRead( const struct bbs_ComplexArr* ptrA, const void* memPtrA ):\n"
+                   "size mismatch" ); 
+               return 0;
+       }
+       return memSizeL;
+}
+
+/* ------------------------------------------------------------------------- */
+       
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+       
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+
+
diff --git a/Embedded/common/src/b_BasicEm/ComplexArr.h b/Embedded/common/src/b_BasicEm/ComplexArr.h
new file mode 100644 (file)
index 0000000..328920a
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+#ifndef bbs_COMPLEX_ARR_EM_H
+#define bbs_COMPLEX_ARR_EM_H
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Context.h"
+#include "b_BasicEm/MemSeg.h"
+#include "b_BasicEm/Complex.h"
+
+/* ---- related objects  --------------------------------------------------- */
+
+/* ---- typedefs ----------------------------------------------------------- */
+
+/* ---- constants ---------------------------------------------------------- */
+
+/* ---- object definition -------------------------------------------------- */
+
+/** complex array */
+struct bbs_ComplexArr 
+{
+
+       /* ---- private data --------------------------------------------------- */
+
+       /** pointer to exclusive memory segment used for allocation */
+       struct bbs_MemSeg* mspE;
+
+       /* ---- public data ---------------------------------------------------- */
+
+       /** pointer to array of bytes */
+       struct bbs_Complex* arrPtrE;
+
+       /** current size */
+       uint32 sizeE;
+
+       /** allocated size */
+       uint32 allocatedSizeE;
+
+};
+
+/* ---- associated objects ------------------------------------------------- */
+
+/* ---- external functions ------------------------------------------------- */
+
+/* ---- \ghd{ constructor/destructor } ------------------------------------- */
+
+/** initializes bbs_ComplexArr  */
+void bbs_ComplexArr_init( struct bbs_Context* cpA,
+                                                 struct bbs_ComplexArr* ptrA );
+
+/** frees bbs_ComplexArr  */
+void bbs_ComplexArr_exit( struct bbs_Context* cpA,
+                                                 struct bbs_ComplexArr* ptrA );
+
+/* ---- \ghd{ operators } -------------------------------------------------- */
+
+/** copy operator */
+void bbs_ComplexArr_copy( struct bbs_Context* cpA,
+                                                 struct bbs_ComplexArr* ptrA, 
+                                                 const struct bbs_ComplexArr* srcPtrA );
+
+/** equal operator */
+flag bbs_ComplexArr_equal( struct bbs_Context* cpA,
+                                                  const struct bbs_ComplexArr* ptrA, 
+                                                  const struct bbs_ComplexArr* srcPtrA );
+
+/* ---- \ghd{ query functions } -------------------------------------------- */
+
+/** calculates the amount of heap memory needed (16bit words) if created with given parameters */ 
+uint32 bbs_ComplexArr_heapSize( struct bbs_Context* cpA,
+                                                           const struct bbs_ComplexArr* ptrA, 
+                                                               uint32 sizeA );
+
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+
+/** creates bbs_ComplexArr object */
+void bbs_ComplexArr_create( struct bbs_Context* cpA,
+                                                   struct bbs_ComplexArr* ptrA, 
+                                                   uint32 sizeA,
+                                                       struct bbs_MemSeg* mspA );
+
+/** sets array size */
+void bbs_ComplexArr_size( struct bbs_Context* cpA,
+                                                 struct bbs_ComplexArr* ptrA, 
+                                                 uint32 sizeA );
+
+/* ---- \ghd{ memory I/O } ------------------------------------------------- */
+
+/** size in 16-bit words object needs when written to memory */
+uint32 bbs_ComplexArr_memSize( struct bbs_Context* cpA,
+                                                          const struct bbs_ComplexArr* ptrA );
+
+/** writes object to memory; returns number of words (16-bit) written */
+uint32 bbs_ComplexArr_memWrite( struct bbs_Context* cpA,
+                                                           const struct bbs_ComplexArr* ptrA, 
+                                                               uint16* memPtrA );
+
+/** reads object from memory; returns number of words (16-bit) read */
+uint32 bbs_ComplexArr_memRead( struct bbs_Context* cpA,
+                                                          struct bbs_ComplexArr* ptrA, 
+                                                          const uint16* memPtrA,
+                                                          struct bbs_MemSeg* mspA );
+
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+
+#endif /* bbs_COMPLEX_ARR_EM_H */
+
diff --git a/Embedded/common/src/b_BasicEm/Config.h b/Embedded/common/src/b_BasicEm/Config.h
new file mode 100644 (file)
index 0000000..06d37c0
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+#ifndef bbs_CONFIG_EM_H
+#define bbs_CONFIG_EM_H
+
+/**
+ * This file contains hardware and OS specific definitions
+ */
+
+/* ---- release specific defines ------------------------------------------- */
+
+/* ---- hardware specific defines ------------------------------------------ */
+
+#if defined( HW_i586 ) || defined( HW_i686 )
+       #ifdef HW_SSE2
+               #define bbs_MEMORY_ALIGNMENT    16 /* SSE2: align data to 128 bits */
+       #else
+               #define bbs_MEMORY_ALIGNMENT    8  /* MMX: align data to 64 bits */
+       #endif
+#elif defined( HW_EE )
+       #define bbs_MEMORY_ALIGNMENT    16 /* align EE-MMI data to 128 bits */
+#else
+       #define bbs_MEMORY_ALIGNMENT    1
+#endif
+
+#ifdef HW_TMS470R2X
+       #pragma message("Warning: deprecated define HW_TMS470R2X, use HW_ARMv4 instead")
+       #define HW_ARMv4
+#endif
+
+#ifdef HW_ARM9E
+       #pragma message("Warning: deprecated define HW_ARM9E, use HW_ARMv5TE instead")
+       #define HW_ARMv5TE
+#endif
+
+/* ---- operating system specific defines ---------------------------------- */
+
+#if defined( WIN32 ) || defined( _WIN32_WCE )
+       /* disable warning "unreferenced formal parameter": */
+       #pragma warning( disable : 4100 )
+
+       /* disable warning for constant expression in condition: */
+       #pragma warning( disable : 4127 )
+
+       /* disable warning for short += short: */
+       #pragma warning( disable : 4244 )
+
+       /* disable warning 'unreachable code' in release build: */
+       /* this warning occurs due to a wrong code evaluation of the compiler */
+       #pragma warning( disable : 4702 )
+
+       /* disable warning for not expanded inline functions in release build: */
+       #pragma warning( disable : 4710 )
+
+       /* disable warning for automatic expanded inline functions in release build: */
+       #pragma warning( disable : 4711 )
+
+       /* disable warning "unreferenced inline function has been removed": */
+       #pragma warning( disable : 4514 )
+
+#endif
+
+/* -------------------------------------------------------------------------- */
+
+#endif /* bbs_CONFIG_EM_H */
+
diff --git a/Embedded/common/src/b_BasicEm/Context.c b/Embedded/common/src/b_BasicEm/Context.c
new file mode 100644 (file)
index 0000000..02f52c8
--- /dev/null
@@ -0,0 +1,410 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Functions.h"
+#include "b_BasicEm/Context.h"
+#include "b_BasicEm/String.h"
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ auxiliary functions } ---------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ constructor / destructor } ----------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_Context_init( struct bbs_Context* cpA )
+{
+       uint32 iL;
+       for( iL = 0; iL < bbs_CONTEXT_MAX_ERRORS; iL++ )
+       {
+               cpA->errStackE[ iL ].errorE = bbs_ERR_OK;
+               cpA->errStackE[ iL ].fileE[ 0 ] = 0;
+               cpA->errStackE[ iL ].lineE = 0;
+               cpA->errStackE[ iL ].textE[ 0 ] = 0;
+       }
+
+       cpA->errIndexE = 0;
+
+       bbs_MemTbl_init( cpA, &cpA->memTblE );
+
+       for( iL = 0; iL < bbs_CONTEXT_MAX_MEM_MANAGERS; iL++ )
+       {
+               bbs_DynMemManager_init( cpA, &cpA->dynMemManagerArrE[ iL ] );
+       }
+
+       cpA->dynMemManagerArrSizeE = 0;
+       cpA->errorHandlerE = NULL;
+       cpA->callbackHandlerE = NULL;
+       cpA->userPtrE = NULL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_Context_exit( struct bbs_Context* cpA )
+{
+       uint32 iL;
+       for( iL = 0; iL < bbs_CONTEXT_MAX_ERRORS; iL++ )
+       {
+               cpA->errStackE[ iL ].errorE = bbs_ERR_OK;
+               cpA->errStackE[ iL ].fileE[ 0 ] = 0;
+               cpA->errStackE[ iL ].lineE = 0;
+               cpA->errStackE[ iL ].textE[ 0 ] = 0;
+       }
+
+       cpA->errIndexE = 0;
+
+       bbs_MemTbl_exit( cpA, &cpA->memTblE );
+
+       for( iL = 0; iL < cpA->dynMemManagerArrSizeE; iL++ )
+       {
+               bbs_DynMemManager_freeAll( cpA, &cpA->dynMemManagerArrE[ iL ] );
+       }
+
+       for( iL = 0; iL < bbs_CONTEXT_MAX_MEM_MANAGERS; iL++ )
+       {
+               bbs_DynMemManager_exit( cpA, &cpA->dynMemManagerArrE[ iL ] );
+       }
+
+       cpA->dynMemManagerArrSizeE = 0;
+       cpA->errorHandlerE = NULL;
+       cpA->callbackHandlerE = NULL;
+       cpA->userPtrE = NULL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ operators } -------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_Context_copy( struct bbs_Context* cpA, const struct bbs_Context* srcPtrA )
+{
+       bbs_ERROR0( "void bbs_Context_copy( struct bbs_Context* cpA, const struct bbs_Context* srcPtrA ):\n"
+                       "A comtext object cannot be copied" );
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ query functions } -------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+       
+struct bbs_Error bbs_Error_create( uint32 errorA, 
+                                                                  uint32 lineA, 
+                                                                  const char* fileA, 
+                                                                  const char* textA, 
+                                                                  ... )
+{
+       struct bbs_Error errorL;
+       errorL.errorE = errorA;
+       errorL.lineE = lineA;
+
+       if( fileA != NULL )
+       {
+               uint32 lenL = bbs_strlen( fileA );
+               uint32 ofsL = ( lenL + 1 > bbs_ERROR_MAX_FILE_CHARS ) ? lenL + 1 - bbs_ERROR_MAX_FILE_CHARS : 0;
+               bbs_strcpy( errorL.fileE, fileA + ofsL );
+       }
+       else
+       {
+               errorL.fileE[ 0 ] = 0;
+       }
+
+       if( textA != NULL )
+       {
+               va_list argsL;
+               va_start( argsL, textA );
+               bbs_vsnprintf( errorL.textE, bbs_ERROR_MAX_TEXT_CHARS, textA, argsL );
+               va_end( argsL );
+       }
+       else
+       {
+               errorL.textE[ 0 ] = 0;
+       }
+
+       return errorL;
+}
+
+/* ------------------------------------------------------------------------- */
+       
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ I/O } -------------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+       
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+       
+/* ------------------------------------------------------------------------- */
+
+flag bbs_Context_pushError( struct bbs_Context* cpA, struct bbs_Error errorA )
+{
+       flag returnL = FALSE;
+       if( cpA->errIndexE < bbs_CONTEXT_MAX_ERRORS )
+       {
+               cpA->errStackE[ cpA->errIndexE++ ] = errorA;
+               returnL = TRUE;
+       }
+
+       if( cpA->errorHandlerE != NULL )
+       {
+               cpA->errorHandlerE( cpA );
+       }
+
+       return returnL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+struct bbs_Error bbs_Context_popError( struct bbs_Context* cpA )
+{
+       if( cpA->errIndexE > 0 )
+       {
+               return cpA->errStackE[ --( cpA->errIndexE ) ];
+       }
+       else
+       {
+               return cpA->errStackE[ 0 ];
+       }
+}
+
+/* ------------------------------------------------------------------------- */
+
+struct bbs_Error bbs_Context_peekError( struct bbs_Context* cpA )
+{
+       if( cpA->errIndexE > 0 )
+       {
+               return cpA->errStackE[ cpA->errIndexE - 1 ];
+       }
+       else
+       {
+               return cpA->errStackE[ 0 ];
+       }
+}
+
+/* ------------------------------------------------------------------------- */
+
+flag bbs_Context_error( struct bbs_Context* cpA )
+{
+       return cpA->errIndexE > 0;
+}
+
+/* ------------------------------------------------------------------------- */
+
+bbs_errorFPtr bbs_Context_setErrorHandler( struct bbs_Context* cpA, 
+                                                                              bbs_errorFPtr errorHandlerA )
+{
+       bbs_errorFPtr oldErrorHandlerL = cpA->errorHandlerE;
+       cpA->errorHandlerE = errorHandlerA;
+       return oldErrorHandlerL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_Context_doCallback( struct bbs_Context* cpA )
+{
+       if( cpA->callbackHandlerE != NULL )
+       {
+               uint32 errorL = ( *cpA->callbackHandlerE )( cpA );
+               if( errorL != bbs_ERR_OK ) 
+               {
+                       bbs_Context_pushError( cpA, bbs_Error_create( errorL, 0, NULL, NULL ) );
+               }
+       }
+}
+
+/* ------------------------------------------------------------------------- */
+
+bbs_callbackFPtr bbs_Context_setCallbackHandler( struct bbs_Context* cpA,
+                                                                              bbs_callbackFPtr callbackHandlerA )
+{
+       bbs_callbackFPtr oldCallbackHandlerL = cpA->callbackHandlerE;
+       cpA->callbackHandlerE = callbackHandlerA;
+       return oldCallbackHandlerL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/** adds a static memory segment to memory table of context */
+void bbs_Context_addStaticSeg( struct bbs_Context* cpA,
+                                                           uint16* memPtrA, /* pointer to memory */
+                                                               uint32 sizeA,    /* size of memory segment in 16 bit units */
+                                                               flag sharedA,    /* Indicates that this segment is to be shared among multiple objects */
+                                                               uint32 idA )     /* ID of segment, id=0: unspecified */
+{
+       struct bbs_MemSeg memSegL;
+       bbs_DEF_fNameL( "void bbs_Context_addStaticSeg(....)" )
+
+
+       /* checks */
+       if( sharedA && cpA->memTblE.ssSizeE == bbs_MAX_MEM_SEGS )
+       {
+               bbs_ERROR1( "%s:\nShared Memory Table is full! Increase bbs_MAX_MEM_SEGS", fNameL );
+               return;
+       }
+       if( sharedA && cpA->memTblE.esSizeE == bbs_MAX_MEM_SEGS )
+       {
+               bbs_ERROR1( "%s:\nExclusive Memory Table is full! Increase bbs_MAX_MEM_SEGS", fNameL );
+               return;
+       }
+
+
+       bbs_MemSeg_init( cpA, &memSegL );
+       memSegL.memPtrE = memPtrA;
+       memSegL.sizeE = sizeA;
+       memSegL.allocIndexE = 0;
+       memSegL.sharedE = sharedA;
+       memSegL.idE = idA;
+       memSegL.dynMemManagerPtrE = NULL;
+
+       if( sharedA )
+       {
+               cpA->memTblE.ssArrE[ cpA->memTblE.ssSizeE++ ] = memSegL;
+       }
+       else
+       {
+               cpA->memTblE.esArrE[ cpA->memTblE.esSizeE ] = memSegL;
+               cpA->memTblE.espArrE[ cpA->memTblE.esSizeE ] = &cpA->memTblE.esArrE[ cpA->memTblE.esSizeE ];
+               cpA->memTblE.esSizeE++;
+       }
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* adds a dynamic memory segment to memory table of context
+ * Upon destruction of the context object any residual will be freed automatically
+ */
+void bbs_Context_addDynamicSeg(        struct bbs_Context* cpA,
+                                                               bbs_mallocFPtr mallocFPtrA,     /* function pointer to external mem alloc function (s. comment of type declaration)*/
+                                                               bbs_freeFPtr freeFPtrA,     /* function pointer to external mem free function */
+                                                               flag sharedA,    /* Indicates that this segment is to be shared among multiple objects */
+                                                               uint32 idA )     /* ID of segment, id=0: unspecified */
+{
+       struct bbs_DynMemManager memManagerL;
+       struct bbs_MemSeg memSegL;
+       bbs_DEF_fNameL( "void bbs_Context_addDynamicSeg(....)" )
+
+
+       /* checks */
+       if( cpA->dynMemManagerArrSizeE == bbs_CONTEXT_MAX_MEM_MANAGERS )
+       {
+               bbs_ERROR1( "%s:\nMemory Manager Table is full! Increase bbs_CONTEXT_MAX_MEM_MANAGERS", fNameL );
+               return;
+       }
+       if( sharedA && cpA->memTblE.ssSizeE == bbs_MAX_MEM_SEGS )
+       {
+               bbs_ERROR1( "%s:\nShared Memory Table is full! Increase bbs_MAX_MEM_SEGS", fNameL );
+               return;
+       }
+       if( sharedA && cpA->memTblE.esSizeE == bbs_MAX_MEM_SEGS )
+       {
+               bbs_ERROR1( "%s:\nExclusive Memory Table is full! Increase bbs_MAX_MEM_SEGS", fNameL );
+               return;
+       }
+       
+       bbs_DynMemManager_init( cpA, &memManagerL );
+       memManagerL.mallocFPtrE = mallocFPtrA;
+       memManagerL.freeFPtrE = freeFPtrA;
+       memManagerL.memPtrE = NULL;
+       cpA->dynMemManagerArrE[ cpA->dynMemManagerArrSizeE++ ] = memManagerL;
+
+       bbs_MemSeg_init( cpA, &memSegL );
+       memSegL.memPtrE = NULL;
+       memSegL.sizeE = 0;
+       memSegL.allocIndexE = 0;
+       memSegL.sharedE = sharedA;
+       memSegL.idE = idA;
+       memSegL.dynMemManagerPtrE = &cpA->dynMemManagerArrE[ cpA->dynMemManagerArrSizeE - 1 ];
+
+       if( sharedA )
+       {
+               cpA->memTblE.ssArrE[ cpA->memTblE.ssSizeE++ ] = memSegL;
+       }
+       else
+       {
+               cpA->memTblE.esArrE[ cpA->memTblE.esSizeE ] = memSegL;
+               cpA->memTblE.espArrE[ cpA->memTblE.esSizeE ] = &cpA->memTblE.esArrE[ cpA->memTblE.esSizeE ];
+               cpA->memTblE.esSizeE++;
+       }
+}
+                         
+/* ------------------------------------------------------------------------- */
+
+uint32 bbs_Context_exclAllocSize( struct bbs_Context* cpA, uint32 segIndexA )
+{
+       return bbs_MemSeg_allocatedSize( cpA, &cpA->memTblE.esArrE[ segIndexA ] );
+}
+                                                                 
+/* ------------------------------------------------------------------------- */
+
+uint32 bbs_Context_shrdAllocSize( struct bbs_Context* cpA, uint32 segIndexA )
+{
+       return bbs_MemSeg_allocatedSize( cpA, &cpA->memTblE.ssArrE[ segIndexA ] );
+}
+                                                                 
+/* ------------------------------------------------------------------------- */
+
+void bbs_Context_quickInit( struct bbs_Context* cpA, 
+                                                   bbs_mallocFPtr mallocFPtrA, /* function pointer to external mem alloc function (s. comment of type declaration)*/
+                                                   bbs_freeFPtr freeFPtrA,
+                                                   bbs_errorFPtr errorHandlerA )
+{
+       bbs_Context_init( cpA );
+       bbs_Context_addDynamicSeg( cpA, mallocFPtrA, freeFPtrA, FALSE, 0 );
+       bbs_Context_addDynamicSeg( cpA, mallocFPtrA, freeFPtrA, TRUE, 0 );
+       bbs_Context_setErrorHandler( cpA, errorHandlerA );
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+
+
diff --git a/Embedded/common/src/b_BasicEm/Context.h b/Embedded/common/src/b_BasicEm/Context.h
new file mode 100644 (file)
index 0000000..7ea323b
--- /dev/null
@@ -0,0 +1,229 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+#ifndef bbs_CONTEXT_EM_H
+#define bbs_CONTEXT_EM_H
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Basic.h"
+#include "b_BasicEm/MemTbl.h"
+#include "b_BasicEm/DynMemManager.h"
+
+/* ---- related objects  --------------------------------------------------- */
+
+struct bbs_Context;
+
+/* ---- typedefs ----------------------------------------------------------- */
+
+/** error handler function pointer */
+typedef void ( *bbs_errorFPtr )( struct bbs_Context* cpA );
+
+/** callback handler function pointer */
+typedef uint32 ( *bbs_callbackFPtr )( struct bbs_Context* cpA );
+
+/* ---- constants ---------------------------------------------------------- */
+
+#define bbs_CONTEXT_MAX_ERRORS                 8
+#define bbs_CONTEXT_MAX_MEM_MANAGERS   8
+
+#ifdef bbs_COMPACT_MESSAGE_HANDLING
+/* characters allocated for file name string (string is stored rightbound) (minimum 1)*/
+#define bbs_ERROR_MAX_FILE_CHARS       24
+/* characters allocated for text message (minimum 1) */
+#define bbs_ERROR_MAX_TEXT_CHARS       1
+#else
+/* characters allocated for file name string (string is stored rightbound) (minimum 1)*/
+#define bbs_ERROR_MAX_FILE_CHARS       52
+/* characters allocated for text message (minimum 1) */
+#define bbs_ERROR_MAX_TEXT_CHARS       256
+#endif
+
+/* defined error codes */
+#define bbs_ERR_OK                                             0       /* no error condition */
+#define bbs_ERR_ERROR                                  1       /* generic error */
+#define bbs_ERR_OUT_OF_MEMORY                  2       /* malloc handler returns with NULL*/
+#define bbs_ERR_MEMORY_OVERFLOW                        3       /* not enough memory in a segment or no segment */
+#define bbs_ERR_WRONG_VERSION                  4       /* incompatible version in ..._memRead() */
+#define bbs_ERR_CORRUPT_DATA                   5       /* corrupt data in ..._memRead()*/
+#define bbs_ERR_CALLBACK_ERROR                 6       /* a defined error originiating from a callback function */
+
+/* ---- object definition -------------------------------------------------- */
+
+/** error object */
+struct bbs_Error
+{
+       /* error code */
+       uint32 errorE;
+
+       /* line number */
+       uint32 lineE;
+
+       /* file name */
+       char fileE[ bbs_ERROR_MAX_FILE_CHARS ];
+
+       /* error text */
+       char textE[ bbs_ERROR_MAX_TEXT_CHARS ];
+};
+
+/* ------------------------------------------------------------------------- */
+
+/** context object */
+struct bbs_Context 
+{
+
+       /* ---- private data --------------------------------------------------- */
+
+       /** error stack */
+       struct bbs_Error errStackE[ bbs_CONTEXT_MAX_ERRORS ];
+
+       /** error stack index */
+       uint32 errIndexE;
+
+       /** memory table */
+       struct bbs_MemTbl memTblE;
+
+       /** multiple purpose dynamic memory managers */
+       struct bbs_DynMemManager dynMemManagerArrE[ bbs_CONTEXT_MAX_MEM_MANAGERS ];
+
+       /** number of used memory managers */
+       uint32 dynMemManagerArrSizeE;
+
+       /** error function handler */
+       bbs_errorFPtr errorHandlerE;
+
+       /** callback function handler */
+       bbs_callbackFPtr callbackHandlerE;
+
+       /** user-defined pointer */
+       void* userPtrE;
+
+       /* ---- public data ---------------------------------------------------- */
+
+};
+
+/* ---- associated objects ------------------------------------------------- */
+
+/* ---- external functions ------------------------------------------------- */
+
+/* ---- \ghd{ constructor/destructor } ------------------------------------- */
+
+/** initializes bbs_Context  */
+void bbs_Context_init( struct bbs_Context* cpA );
+
+/** frees bbs_Context  */
+void bbs_Context_exit( struct bbs_Context* cpA );
+
+/* ---- \ghd{ operators } -------------------------------------------------- */
+
+/** copy operator */
+void bbs_Context_copy( struct bbs_Context* cpA, const struct bbs_Context* srcPtrA );
+
+/* ---- \ghd{ query functions } -------------------------------------------- */
+
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+
+/** composes an error object */
+struct bbs_Error bbs_Error_create( uint32 errorA, uint32 lineA, const char* fileA, const char* textA, ... );
+
+/* ---- \ghd{ memory I/O } ------------------------------------------------- */
+
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+
+/****** ERROR HANDLING *********/
+
+/** puts an error onto the error stack (returns false if stack was already full) */
+flag bbs_Context_pushError( struct bbs_Context* cpA, struct bbs_Error errorA );
+
+/** takes the last error from stack and returns it (when stack is empty: returns the error at stack position 0)*/
+struct bbs_Error bbs_Context_popError( struct bbs_Context* cpA );
+
+/** returns the last error of stack without removing it (when stack is empty: returns the error at stack position 0)*/
+struct bbs_Error bbs_Context_peekError( struct bbs_Context* cpA );
+
+/** returns true if the error stack is not empty */
+flag bbs_Context_error( struct bbs_Context* cpA );
+
+/** sets error handler; returns pointer to previous error handler 
+ *  Pointer to Error handler can be NULL (->no handler call)
+ *  The error handler is called by function pushError diectly after an error was posted
+ */
+bbs_errorFPtr bbs_Context_setErrorHandler( struct bbs_Context* cpA,
+                                                                              bbs_errorFPtr errorHandlerA );
+
+/*******************************/
+
+/****** CALLBACK HANDLING ******/
+
+/** call the callback handler, push error if return value is != bbs_ERR_OK */
+void bbs_Context_doCallback( struct bbs_Context* cpA );
+
+/** sets callback handler; returns pointer to previous callback handler 
+ *  Pointer to callback handler can be NULL (->no handler call)
+ *  The callback handler is called by function doCallback
+ */
+bbs_callbackFPtr bbs_Context_setCallbackHandler( struct bbs_Context* cpA,
+                                                                                    bbs_callbackFPtr callbackHandlerA );
+
+/*******************************/
+
+/******* MEMORY HANDLING *******/
+
+/** adds a static memory segment to memory table of context */
+void bbs_Context_addStaticSeg( struct bbs_Context* cpA,
+                                                           uint16* memPtrA, /* pointer to memory (32bit aligned)*/
+                                                               uint32 sizeA,    /* size of memory segment in 16 bit units */
+                                                               flag sharedA,    /* Indicates that this segment is to be shared among multiple objects */
+                                                               uint32 idA );    /* ID of segment, id=0: unspecified */
+
+/* adds a dynamic memory segment to memory table of context
+ * Upon destruction of the context object any residual will be freed automatically
+ */
+void bbs_Context_addDynamicSeg(        struct bbs_Context* cpA,
+                                                               bbs_mallocFPtr mallocFPtrA,     /* function pointer to external mem alloc function (s. comment of type declaration)*/
+                                                               bbs_freeFPtr freeFPtrA,     /* function pointer to external mem free function */
+                                                               flag sharedA,    /* Indicates that this segment is to be shared among multiple objects */
+                                                               uint32 idA );    /* ID of segment, id=0: unspecified */
+
+
+/** Returns allocated memory in selected exclusive segment in units of 16bits */
+uint32 bbs_Context_exclAllocSize( struct bbs_Context* cpA, uint32 segIndexA );
+                                                                 
+/** Returns allocated memory in selected exclusive segment in units of 16bits 
+ *  Note that in case of static memory the return value might not reflect 
+ *  the actually allocated memory amount.
+ */
+uint32 bbs_Context_shrdAllocSize( struct bbs_Context* cpA, uint32 segIndexA );
+                                                                 
+/*******************************/
+
+
+/** quick compact setup for dynamic memory management environment 
+ *  creates an initialized segment with
+ *  - one dynamic exclusive segment
+ *  - one dynamic shared segment
+ *  - error handler (can be NULL)
+ *
+ * Don't forget to call bbs_Context_exit on returned context if it goes out of scope
+ */
+void bbs_Context_quickInit( struct bbs_Context* cpA, 
+                                                   bbs_mallocFPtr mallocFPtrA, /* function pointer to external mem alloc function (s. comment of type declaration)*/
+                                                   bbs_freeFPtr freeFPtrA,
+                                                   bbs_errorFPtr errorHandlerA );
+
+                         
+#endif /* bbs_CONTEXT_EM_H */
+
diff --git a/Embedded/common/src/b_BasicEm/DynMemManager.c b/Embedded/common/src/b_BasicEm/DynMemManager.c
new file mode 100644 (file)
index 0000000..523b939
--- /dev/null
@@ -0,0 +1,301 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Functions.h"
+#include "b_BasicEm/DynMemManager.h"
+#include "b_BasicEm/Context.h"
+
+/* ------------------------------------------------------------------------- */
+
+/* minimum block size dynamically allocated in function nextBlock (affects only shared memory) */
+#define bbs_DYN_MEM_MIN_NEW_BLOCK_SIZE 0
+
+/** Offset to actual memory area on allocated memory blocks (in 16-bit words).
+  * Value needs to be large enough to hold the pointer to the next memory block
+  * and the size value (32-bit) of the memory area.
+  */
+#define bbs_MEM_OFFSET 6
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ auxiliary functions } ---------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ constructor / destructor } ----------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_DynMemManager_init( struct bbs_Context* cpA, 
+                                                        struct bbs_DynMemManager* ptrA )
+{
+       ptrA->memPtrE = NULL;
+       ptrA->mallocFPtrE = NULL;
+       ptrA->freeFPtrE = NULL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_DynMemManager_exit( struct bbs_Context* cpA, 
+                                                        struct bbs_DynMemManager* ptrA )
+{
+       ptrA->memPtrE = NULL;
+       ptrA->mallocFPtrE = NULL;
+       ptrA->freeFPtrE = NULL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ operators } -------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ query functions } -------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bbs_DynMemManager_allocatedSize( struct bbs_Context* cpA, 
+                                                                           const struct bbs_DynMemManager* ptrA )
+{
+       uint32 sizeL = 0;
+       uint16* pL = ( uint16* )ptrA->memPtrE;
+       while( pL != NULL )
+       {
+               sizeL += ( ( uint32* )pL )[ 2 ];
+               pL = *( uint16** )pL;
+       }
+       return sizeL; 
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+       
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ I/O } -------------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+       
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+       
+/* ------------------------------------------------------------------------- */
+
+uint16* bbs_DynMemManager_alloc( struct bbs_Context* cpA, 
+                                                                struct bbs_DynMemManager* ptrA, 
+                                                                const struct bbs_MemSeg* memSegPtrA,
+                                                                uint32 sizeA )
+{
+       uint16* pL = NULL;
+       bbs_DEF_fNameL( "uint16* bbs_DynMemManager_alloc( struct bbs_DynMemManager* ptrA, uint32 sizeA )" )
+
+
+       if( ptrA->mallocFPtrE == NULL )
+       {
+               bbs_ERROR1( "%s:\n Malloc handler not defined.\n", fNameL );
+               return NULL;
+       }
+
+       if( ptrA->memPtrE == NULL )
+       {
+               ptrA->memPtrE = ptrA->mallocFPtrE( cpA, memSegPtrA, ( sizeA + bbs_MEM_OFFSET ) << 1 );
+               pL = ptrA->memPtrE;
+       }
+       else
+       {
+               uint16** ppL = ( uint16** )ptrA->memPtrE;
+               while( *ppL != NULL ) ppL = ( uint16** )*ppL;
+               *ppL = ptrA->mallocFPtrE( cpA, memSegPtrA, ( sizeA + bbs_MEM_OFFSET ) << 1 );
+               pL = *ppL;
+       }
+
+       if( pL == NULL )
+       {
+               bbs_ERR1( bbs_ERR_OUT_OF_MEMORY, "%s:\n Allocation failed.\n", fNameL );
+               return NULL;
+       }
+
+       ( ( uint32* )pL )[ 0 ] = 0;
+       ( ( uint32* )pL )[ 1 ] = 0;
+       ( ( uint32* )pL )[ 2 ] = sizeA + bbs_MEM_OFFSET;
+
+       return pL + bbs_MEM_OFFSET;
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_DynMemManager_free( struct bbs_Context* cpA, 
+                                                        struct bbs_DynMemManager* ptrA, 
+                                                        uint16* memPtrA )
+{
+       bbs_DEF_fNameL( "void bbs_DynMemManager_free( .... )" )
+
+       if( ptrA->memPtrE == NULL )
+       {
+               bbs_ERROR1( "%s:\n Memory was not allocated.\n", fNameL );
+               return;
+       }
+       else if( ptrA->memPtrE + bbs_MEM_OFFSET == memPtrA )
+       {
+               uint16* memPtrL = ptrA->memPtrE;
+               ptrA->memPtrE = *( uint16** )ptrA->memPtrE;
+               ptrA->freeFPtrE( memPtrL );
+       }
+       else
+       {
+               uint16* p0L = NULL; 
+               uint16* pL = ( uint16* )ptrA->memPtrE;
+
+               while( pL != NULL )
+               {
+                       if( pL + bbs_MEM_OFFSET == memPtrA ) break;
+                       p0L = pL;
+                       pL = *( uint16** )pL;
+               }
+
+               if( pL != NULL )
+               {
+                       if( ptrA->freeFPtrE == NULL )
+                       {
+                               bbs_ERROR1( "%s:\n Free handler not defined.\n", fNameL );
+                               return;
+                       }
+
+                       if( p0L != NULL )
+                       {
+                               *( uint16** )p0L = *( uint16** )pL;
+                       }
+                       else
+                       {
+                               ptrA->memPtrE = *( uint16** )pL;
+                       }
+
+                       ptrA->freeFPtrE( pL );
+               }
+               else
+               {
+                       bbs_ERROR1( "%s:\n Attempt to free memory that was not allocated.\n", fNameL );
+                       return;
+               }
+       }
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint16* bbs_DynMemManager_nextBlock( struct bbs_Context* cpA, 
+                                                                        struct bbs_DynMemManager* ptrA, 
+                                                                        const struct bbs_MemSeg* memSegPtrA,
+                                                                        uint16* curBlockPtrA, 
+                                                                        uint32 minSizeA, 
+                                                                        uint32* actualSizePtrA )
+{
+       uint16* pL = ( uint16* )ptrA->memPtrE;
+       bbs_DEF_fNameL( "uint16* bbs_DynMemManager_nextBlock( .... )" )
+
+       if( curBlockPtrA != NULL )
+       {
+               /* find current block */
+               while( pL != NULL )
+               {
+                       if( pL + bbs_MEM_OFFSET == curBlockPtrA ) break;
+                       pL = *( uint16** )pL;
+               }
+
+               if( pL == NULL )
+               {
+                       bbs_ERROR1( "%s:\nCould not find current memory block.\n", fNameL );
+                       *actualSizePtrA = 0;
+                       return NULL;
+               }
+
+               /* go to next block */
+               pL = *( uint16** )pL;
+       }
+
+       /* find next fitting block */
+       while( pL != NULL )
+       {
+               if( ( ( uint32* )pL )[ 2 ] >= minSizeA + bbs_MEM_OFFSET ) break;
+               pL = *( uint16** )pL;
+       }
+
+       if( pL == NULL )
+       {
+               /* no proper block -> allocate new one */
+               uint32 blockSizeL = minSizeA > bbs_DYN_MEM_MIN_NEW_BLOCK_SIZE ? minSizeA : bbs_DYN_MEM_MIN_NEW_BLOCK_SIZE;
+               uint16* memPtrL = bbs_DynMemManager_alloc( cpA, ptrA, memSegPtrA, blockSizeL );
+               if( memPtrL != NULL )
+               {
+                       *actualSizePtrA = blockSizeL;
+               }
+               else
+               {
+                       *actualSizePtrA = 0;
+               }
+               return memPtrL; 
+       }
+       else
+       {
+               *actualSizePtrA = ( ( uint32* )pL )[ 2 ] - bbs_MEM_OFFSET;
+               return pL + bbs_MEM_OFFSET;
+       }
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_DynMemManager_freeAll( struct bbs_Context* cpA, struct bbs_DynMemManager* ptrA )
+{
+       uint16** ppL = ( uint16** )ptrA->memPtrE;
+       while( ppL != NULL )
+       {
+               uint16* memPtrL = ( uint16* )ppL;
+               ppL = ( uint16** )*ppL;
+               ptrA->freeFPtrE( memPtrL );
+       }
+       ptrA->memPtrE = NULL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
diff --git a/Embedded/common/src/b_BasicEm/DynMemManager.h b/Embedded/common/src/b_BasicEm/DynMemManager.h
new file mode 100644 (file)
index 0000000..13ce084
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+#ifndef bbs_DYN_MEM_MANAGER_EM_H
+#define bbs_DYN_MEM_MANAGER_EM_H
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Basic.h"
+
+/* ---- related objects  --------------------------------------------------- */
+
+struct bbs_Context;
+struct bbs_MemSeg;
+
+/* ---- typedefs ----------------------------------------------------------- */
+
+/** 'malloc' function pointer. 
+  * Allocated memory block must be 32-bit-aligned.
+  * sizeA refers to the size of a memory block in bytes   
+  */
+typedef void* ( *bbs_mallocFPtr )( struct bbs_Context* cpA, 
+                                                                  const struct bbs_MemSeg* memSegPtrA, 
+                                                                  uint32 sizeA );
+
+/** free function pointer */
+typedef void ( *bbs_freeFPtr )( void* memPtrA );
+
+/* ---- constants ---------------------------------------------------------- */
+
+/* ---- object definition -------------------------------------------------- */
+
+/** Dynamic memory manager.
+  * Handles allocation and deallocation of memory blocks via function pointers
+  * to malloc and free.
+  *
+  * Each memory block is organized as follows:
+  * - The first 8 bytes are reserved for the pointer to the next 
+  *    memory block (8 to allow support of 64-bit platforms).
+  * - Next a 32-bit value stores the allocated memory size in 16-bit units.
+  * - Finally the actual allocated memory area. 
+  * This means for each new memory block an additional 12 bytes are allocated.
+  */
+struct bbs_DynMemManager 
+{
+
+       /* ---- private data --------------------------------------------------- */
+
+       /* ---- public data ---------------------------------------------------- */
+
+       /** pointer to first memory block */ 
+       uint16* memPtrE;
+
+       /** function pointer to external mem alloc function (s. comment of type declaration)*/
+       bbs_mallocFPtr mallocFPtrE;
+
+       /** function pointer to external mem free function */
+       bbs_freeFPtr freeFPtrE;
+};
+
+/* ---- associated objects ------------------------------------------------- */
+
+/* ---- external functions ------------------------------------------------- */
+
+/* ---- \ghd{ constructor/destructor } ------------------------------------- */
+
+/** initializes bbs_DynMemManager  */
+void bbs_DynMemManager_init( struct bbs_Context* cpA, struct bbs_DynMemManager* ptrA );
+
+/** frees bbs_DynMemManager  */
+void bbs_DynMemManager_exit( struct bbs_Context* cpA, struct bbs_DynMemManager* ptrA );
+
+/* ---- \ghd{ operators } -------------------------------------------------- */
+
+/* ---- \ghd{ query functions } -------------------------------------------- */
+
+/** returns size of currently allocated memory in 16bit units */
+uint32 bbs_DynMemManager_allocatedSize( struct bbs_Context* cpA, const struct bbs_DynMemManager* ptrA );
+
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+
+/* ---- \ghd{ memory I/O } ------------------------------------------------- */
+
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+
+/** allocates sizeA words of memory */
+uint16* bbs_DynMemManager_alloc( struct bbs_Context* cpA, 
+                                                                struct bbs_DynMemManager* ptrA, 
+                                                                const struct bbs_MemSeg* memSegPtrA,
+                                                                uint32 sizeA );
+
+/** frees previously allocated memory */
+void bbs_DynMemManager_free( struct bbs_Context* cpA, 
+                                                        struct bbs_DynMemManager* ptrA, 
+                                                        uint16* memPtrA );
+
+/** returns the next memory block of at least minSizeA length; allocates new block if neccessary */
+uint16* bbs_DynMemManager_nextBlock( struct bbs_Context* cpA, 
+                                                                        struct bbs_DynMemManager* ptrA, 
+                                                                        const struct bbs_MemSeg* memSegPtrA,
+                                                                        uint16* curBlockPtrA, 
+                                                                        uint32 minSizeA, 
+                                                                        uint32* actualSizePtrA );
+
+/** frees all allocated memory */
+void bbs_DynMemManager_freeAll( struct bbs_Context* cpA, 
+                                                           struct bbs_DynMemManager* ptrA );
+
+
+#endif /* bbs_DYN_MEM_MANAGER_EM_H */
+
diff --git a/Embedded/common/src/b_BasicEm/Functions.c b/Embedded/common/src/b_BasicEm/Functions.c
new file mode 100644 (file)
index 0000000..f4a346c
--- /dev/null
@@ -0,0 +1,274 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Functions.h"
+#include "b_BasicEm/Context.h"
+
+/* ---- related objects  --------------------------------------------------- */
+
+/* ---- typedefs ----------------------------------------------------------- */
+
+/* ---- constants ---------------------------------------------------------- */
+
+/* ---- globals   ---------------------------------------------------------- */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ external functions } ----------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+uint16 bbs_swapBytes( uint16 valA )
+{
+       return ( ( valA >> 8 ) & 0x00FF ) | ( ( valA << 8 ) & 0xFF00 ); 
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bbs_memWrite32( const void* ptrA, 
+                                          uint16* memPtrA )
+{
+       uint32 valL = *( uint32* )ptrA;
+       
+       #ifdef HW_BIG_ENDIAN
+               *memPtrA++ = bbs_swapBytes( ( uint16 )( ( valL >> 0  ) & 0xFFFF ) );
+               *memPtrA++ = bbs_swapBytes( ( uint16 )( ( valL >> 16 ) & 0xFFFF ) );
+       #else
+               *memPtrA++ = ( valL >> 0  ) & 0xFFFF;
+               *memPtrA++ = ( valL >> 16 ) & 0xFFFF;
+       #endif
+       
+
+       return bbs_SIZEOF16( uint32 );
+}
+   
+/* ------------------------------------------------------------------------- */
+
+uint32 bbs_memRead32( void* ptrA, 
+                                         const uint16* memPtrA )
+{
+       uint32 valL = 0;
+       
+       #ifdef HW_BIG_ENDIAN
+               valL |= ( ( uint32 )bbs_swapBytes( *memPtrA++ ) << 0  );
+               valL |= ( ( uint32 )bbs_swapBytes( *memPtrA++ ) << 16 );
+       #else
+               valL |= ( ( uint32 )*memPtrA++ << 0  );
+               valL |= ( ( uint32 )*memPtrA++ << 16 );
+       #endif
+
+       *( uint32* )ptrA = valL;
+
+       return bbs_SIZEOF16( uint32 );
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bbs_memPeek32( const uint16* memPtrA )
+{
+       uint32 valL = 0;
+
+       #ifdef HW_BIG_ENDIAN
+               valL |= ( ( uint32 )bbs_swapBytes( *memPtrA++ ) << 0  );
+               valL |= ( ( uint32 )bbs_swapBytes( *memPtrA++ ) << 16 );
+       #else
+               valL |= ( ( uint32 )*memPtrA++ << 0  );
+               valL |= ( ( uint32 )*memPtrA++ << 16 );
+       #endif
+
+       return valL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bbs_memWrite16( const void* ptrA, 
+                                          uint16* memPtrA )
+{
+       #ifdef HW_BIG_ENDIAN
+               *memPtrA++ = bbs_swapBytes( *( uint16* )ptrA );
+       #else
+               *memPtrA++ = *( uint16* )ptrA;
+       #endif
+       return bbs_SIZEOF16( uint16 );
+}
+   
+/* ------------------------------------------------------------------------- */
+
+uint32 bbs_memRead16( void* ptrA, 
+                                         const uint16* memPtrA )
+{
+       #ifdef HW_BIG_ENDIAN
+               *( uint16* )ptrA = bbs_swapBytes( *memPtrA++ );
+       #else
+               *( uint16* )ptrA = *memPtrA++;
+       #endif
+
+       return bbs_SIZEOF16( uint16 );
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bbs_memWrite32Arr( struct bbs_Context* cpA,
+                                                 const void* ptrA, 
+                                                 uint32 sizeA, uint16* memPtrA )
+{
+       uint32 iL;
+       const uint32* srcL = ( uint32* )ptrA;
+
+       if( bbs_Context_error( cpA ) ) return 0;
+
+       for( iL = 0; iL < sizeA; iL++ )
+       {
+               memPtrA += bbs_memWrite32( srcL++, memPtrA );
+       }
+
+       return sizeA * bbs_SIZEOF16( uint32 ); 
+}
+   
+/* ------------------------------------------------------------------------- */
+
+uint32 bbs_memRead32Arr( struct bbs_Context* cpA,
+                                                void* ptrA, 
+                                                uint32 sizeA, 
+                                                const uint16* memPtrA )
+{
+       uint32 iL;
+       uint32* dstL = ( uint32* )ptrA;
+
+       if( bbs_Context_error( cpA ) ) return 0;
+
+       for( iL = 0; iL < sizeA; iL++ )
+       {
+               memPtrA += bbs_memRead32( dstL++, memPtrA );
+       }
+
+       return sizeA * bbs_SIZEOF16( uint32 ); 
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bbs_memWrite16Arr( struct bbs_Context* cpA,
+                                                 const void* ptrA, 
+                                                 uint32 sizeA, 
+                                                 uint16* memPtrA )
+{
+       uint32 iL;
+       const uint16* srcL = ( uint16* )ptrA;
+
+       if( bbs_Context_error( cpA ) ) return 0;
+
+       for( iL = 0; iL < sizeA; iL++ )
+       {
+               memPtrA += bbs_memWrite16( srcL++, memPtrA );
+       }
+
+       return sizeA * bbs_SIZEOF16( uint16 ); 
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bbs_memRead16Arr( struct bbs_Context* cpA,
+                                                void* ptrA, 
+                                                uint32 sizeA, 
+                                                const uint16* memPtrA )
+{
+       uint32 iL;
+       uint16* dstL = ( uint16* )ptrA;
+
+       if( bbs_Context_error( cpA ) ) return 0;
+
+       for( iL = 0; iL < sizeA; iL++ )
+       {
+               memPtrA += bbs_memRead16( dstL++, memPtrA );
+       }
+
+       return sizeA * bbs_SIZEOF16( uint16 ); 
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bbs_memWriteUInt32( uint32 valA, 
+                                                  uint16* memPtrA )
+{
+       #ifdef HW_BIG_ENDIAN
+               *memPtrA++ = bbs_swapBytes( ( uint16 )( ( valA >> 0  ) & 0xFFFF ) );
+               *memPtrA++ = bbs_swapBytes( ( uint16 )( ( valA >> 16 ) & 0xFFFF ) );
+       #else
+               *memPtrA++ = ( valA >> 0  ) & 0xFFFF;
+               *memPtrA++ = ( valA >> 16 ) & 0xFFFF;
+       #endif
+
+       return bbs_SIZEOF16( valA );
+}
+   
+/* ------------------------------------------------------------------------- */
+
+uint32 bbs_memWriteUInt16( uint16 valA, 
+                                                  uint16* memPtrA )
+{
+       #ifdef HW_BIG_ENDIAN
+               *memPtrA++ = bbs_swapBytes( valA );
+       #else
+               *memPtrA++ = valA;
+       #endif
+
+       return bbs_SIZEOF16( valA );
+}
+   
+/* ------------------------------------------------------------------------- */
+
+uint32 bbs_memReadVersion32( struct bbs_Context* cpA,
+                                                        uint32* versionPtrA, 
+                                                        uint32 refVersionA, 
+                                                        const uint16* memPtrA )
+{
+       if( bbs_Context_error( cpA ) ) return 0;
+
+       bbs_memRead32( versionPtrA, memPtrA );
+       if( *versionPtrA > refVersionA )
+       {
+               bbs_ERR0( bbs_ERR_WRONG_VERSION, "uint32 bbs_memReadVersion32( .... ):\n"
+                              "Data format is newer than software or corrupt\n" );
+       }
+       return bbs_SIZEOF16( uint32 );
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint16 bbs_memCheckSum16( const uint16* memPtrA, uint32 sizeA )
+{
+       uint32 iL;
+       uint16 sumL = 0;
+       for( iL = 0; iL < sizeA; iL++ )
+       {
+               #ifdef HW_BIG_ENDIAN
+                       sumL += bbs_swapBytes( memPtrA[ iL ] );
+               #else
+                       sumL += memPtrA[ iL ];
+               #endif
+       }
+
+       return sumL;
+}
+
+/* ------------------------------------------------------------------------- */
+
diff --git a/Embedded/common/src/b_BasicEm/Functions.h b/Embedded/common/src/b_BasicEm/Functions.h
new file mode 100644 (file)
index 0000000..c81d20d
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+#ifndef bbs_FUNCTIONS_EM_H
+#define bbs_FUNCTIONS_EM_H
+
+/**
+ * This files contains gerenral purpose functions.
+ */
+
+/* ---- includes ----------------------------------------------------------- */
+/*
+#include <stdarg.h>
+#include <stdlib.h>
+*/
+#include "b_BasicEm/Basic.h"
+#include "b_BasicEm/String.h"
+#include "b_BasicEm/Memory.h"
+
+/* ---- related objects  --------------------------------------------------- */
+
+struct bbs_Context;
+
+/* ---- typedefs ----------------------------------------------------------- */
+
+/* ---- constants ---------------------------------------------------------- */
+
+/* ---- external functions ------------------------------------------------- */
+
+/* Memory I/O Functions */
+
+/* Memory I/O Operations use the little endian data alignment 
+   regardless of platform */
+
+/** writes a 32 bit word to memory; returns bbs_SIZEOF16( uint32 ) */
+uint32 bbs_memWrite32( const void* ptrA, 
+                                          uint16* memPtrA );
+   
+/** reads a 32 bit word from memory; returns bbs_SIZEOF16( uint32 ) */
+uint32 bbs_memRead32( void* ptrA, 
+                                         const uint16* memPtrA );
+
+/** reads a 32 bit word from memory and returns it */
+uint32 bbs_memPeek32( const uint16* memPtrA );
+
+/** writes a 16 bit word to memory; returns bbs_SIZEOF16( uint16 ) */
+uint32 bbs_memWrite16( const void* ptrA, 
+                                          uint16* memPtrA );
+   
+/** reads a 16 bit word from memory; returns bbs_SIZEOF16( uint16 ) */
+uint32 bbs_memRead16( void* ptrA, 
+                                         const uint16* memPtrA );
+
+/** writes a 32 bit word array to memory; sizeA specifies number of words in array; returns bbs_SIZEOF16( uint32 ) * sizeA */
+uint32 bbs_memWrite32Arr( struct bbs_Context* cpA,
+                                                 const void* ptrA, 
+                                                 uint32 sizeA, uint16* memPtrA );
+   
+/** reads a 32 bit word array from memory; sizeA specifies number of words in array; returns bbs_SIZEOF16( uint32 ) * sizeA */
+uint32 bbs_memRead32Arr( struct bbs_Context* cpA,
+                                                void* ptrA, 
+                                                uint32 sizeA, const uint16* memPtrA );
+
+/** writes a 16 bit word array to memory; sizeA specifies number of words in array; returns bbs_SIZEOF16( uint16 ) * sizeA */
+uint32 bbs_memWrite16Arr( struct bbs_Context* cpA,
+                                                 const void* ptrA, 
+                                                 uint32 sizeA, uint16* memPtrA );
+   
+/** reads a 16 bit word array from memory; sizeA specifies number of words in array; returns bbs_SIZEOF16( uint16 ) * sizeA */
+uint32 bbs_memRead16Arr( struct bbs_Context* cpA,
+                                                void* ptrA, 
+                                                uint32 sizeA, const uint16* memPtrA );
+
+/* Spcial I/O Functions */
+
+/** writes a 32 bit value to memory; returns bbs_SIZEOF16( uint32 ) */
+uint32 bbs_memWriteUInt32( uint32 valA, 
+                                                  uint16* memPtrA );
+   
+/** writes a 16 bit values to memory; returns bbs_SIZEOF16( uint16 ) */
+uint32 bbs_memWriteUInt16( uint16 valA, 
+                                                  uint16* memPtrA );
+   
+/** reads a 32 bit version number word from memory.
+ *  Compares the number to refVersionA.
+ *  If refVersionA is lower an error condition is created.
+ *  returns bbs_SIZEOF16( uint32 ) 
+ */
+uint32 bbs_memReadVersion32( struct bbs_Context* cpA,
+                                                        uint32* versionPtrA, 
+                                                        uint32 refVersionA, 
+                                                        const uint16* memPtrA );
+
+/** return 16bit check sum of memory area (applies platform specific byte swapps) */
+uint16 bbs_memCheckSum16( const uint16* memPtrA, uint32 sizeA );
+                                               
+#endif /* bbs_FUNCTIONS_EM_H */
+
diff --git a/Embedded/common/src/b_BasicEm/Int16Arr.c b/Embedded/common/src/b_BasicEm/Int16Arr.c
new file mode 100644 (file)
index 0000000..1d4d0ce
--- /dev/null
@@ -0,0 +1,287 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Functions.h"
+#include "b_BasicEm/Int16Arr.h"
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ auxiliary functions } ---------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ constructor / destructor } ----------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_Int16Arr_init( struct bbs_Context* cpA,
+                                           struct bbs_Int16Arr* ptrA )
+{
+       ptrA->arrPtrE = NULL;
+       ptrA->sizeE = 0;
+       ptrA->allocatedSizeE = 0;
+       ptrA->mspE = NULL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_Int16Arr_exit( struct bbs_Context* cpA,
+                                           struct bbs_Int16Arr* ptrA )
+{
+       bbs_MemSeg_free( cpA, ptrA->mspE, ptrA->arrPtrE );
+       ptrA->arrPtrE = NULL;
+       ptrA->mspE = NULL;
+       ptrA->sizeE = 0;
+       ptrA->allocatedSizeE = 0;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ operators } -------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_Int16Arr_copy( struct bbs_Context* cpA,
+                                           struct bbs_Int16Arr* ptrA, 
+                                               const struct bbs_Int16Arr* srcPtrA )
+{
+#ifdef DEBUG1
+       if( ptrA->allocatedSizeE < srcPtrA->sizeE )
+       {
+               bbs_ERROR0( "void bbs_Int16Arr_copy(...):\n"
+                                  "Insufficient allocated memory in destination array." );             
+               return;
+       }
+#endif
+       bbs_Int16Arr_size( cpA, ptrA, srcPtrA->sizeE );
+       bbs_memcpy16( ptrA->arrPtrE, srcPtrA->arrPtrE, srcPtrA->sizeE * bbs_SIZEOF16( int16 ) ); 
+}
+
+/* ------------------------------------------------------------------------- */
+
+flag bbs_Int16Arr_equal( struct bbs_Context* cpA,
+                                                const struct bbs_Int16Arr* ptrA, 
+                                                const struct bbs_Int16Arr* srcPtrA )
+{
+       uint32 iL;
+       const int16* ptr1L = ptrA->arrPtrE;
+       const int16* ptr2L = srcPtrA->arrPtrE;
+       if( ptrA->sizeE != srcPtrA->sizeE ) return FALSE;
+       for( iL = ptrA->sizeE; iL > 0; iL-- )
+       {
+               if( *ptr1L++ != *ptr2L++ ) return FALSE;
+       }
+       return TRUE;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ query functions } -------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bbs_Int16Arr_heapSize( struct bbs_Context* cpA,
+                                                         const struct bbs_Int16Arr* ptrA, 
+                                                         uint32 sizeA )
+{
+       return sizeA * bbs_SIZEOF16( int16 ) + bbs_MEM_BLOCK_OVERHD;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+       
+void bbs_Int16Arr_create( struct bbs_Context* cpA,
+                                                 struct bbs_Int16Arr* ptrA, 
+                                                 uint32 sizeA,
+                                                 struct bbs_MemSeg* mspA )
+{
+       if( bbs_Context_error( cpA ) ) return;
+       if( ptrA->sizeE == sizeA ) return;
+       if( ptrA->arrPtrE != 0 )
+       {
+               bbs_Int16Arr_size( cpA, ptrA, sizeA );
+       }
+       else
+       {
+               ptrA->arrPtrE = bbs_MemSeg_alloc( cpA, mspA, sizeA * bbs_SIZEOF16( int16 ) );
+               if( bbs_Context_error( cpA ) ) return;
+               ptrA->allocatedSizeE = sizeA;
+               ptrA->sizeE = sizeA;
+               if( !mspA->sharedE ) ptrA->mspE = mspA;
+       }
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_Int16Arr_createAligned( struct bbs_Context* cpA,
+                                                                struct bbs_Int16Arr* ptrA,
+                                                                uint32 sizeA,
+                                                                struct bbs_MemSeg* mspA,
+                                                                struct bbs_Int16Arr* allocPtrA, 
+                                                                uint32 alignBytesA )
+{
+       /* allocate extra memory for alignment */
+       bbs_Int16Arr_create( cpA, allocPtrA, sizeA + ( ( alignBytesA - 1 ) >> 1 ), mspA );
+
+       /* set members of ptrA */
+       ptrA->mspE = 0; /* no own allocated memory */
+       ptrA->sizeE = sizeA;
+       ptrA->allocatedSizeE = ptrA->sizeE;
+       ptrA->arrPtrE = allocPtrA->arrPtrE;
+
+#if defined( WIN32 ) || defined( _WIN32_WCE )
+       /* disable warning "pointer truncation...": */
+       #pragma warning( disable : 4311 )
+#endif
+
+
+       /* align memory */
+#ifdef bbs_TYPES_64_AVAILABLE
+
+       while( ( ( ( uint64 ) ptrA->arrPtrE ) & ( alignBytesA - 1 ) ) )
+       {
+               ptrA->arrPtrE++;
+       }       
+#else
+       while( ( ( ( uint32 ) ptrA->arrPtrE ) & ( alignBytesA - 1 ) ) )
+       {
+               ptrA->arrPtrE++;
+       }       
+#endif
+
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_Int16Arr_size( struct bbs_Context* cpA,
+                                           struct bbs_Int16Arr* ptrA, 
+                                               uint32 sizeA )
+{
+       if( ptrA->allocatedSizeE < sizeA )
+       {
+               bbs_ERROR1( "void bbs_Int16Arr_size( struct bbs_Int16Arr*, uint32 sizeA ):\n"
+                                  "Unsufficient allocated memory (allocatedSizeE = '%i')",
+                                  ptrA->allocatedSizeE );
+               return;
+       }
+       ptrA->sizeE = sizeA;
+}
+
+/* ------------------------------------------------------------------------- */
+       
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ I/O } -------------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bbs_Int16Arr_memSize( struct bbs_Context* cpA,
+                                                        const struct bbs_Int16Arr* ptrA )
+{
+       return bbs_SIZEOF16( uint32 ) + bbs_SIZEOF16( ptrA->sizeE ) + 
+                                                                               ptrA->sizeE * bbs_SIZEOF16( int16 );
+}
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bbs_Int16Arr_memWrite( struct bbs_Context* cpA,
+                                                         const struct bbs_Int16Arr* ptrA, 
+                                                         uint16* memPtrA )
+{
+       uint32 memSizeL = bbs_Int16Arr_memSize( cpA, ptrA );
+       memPtrA += bbs_memWrite32( &memSizeL, memPtrA );
+       memPtrA += bbs_memWrite32( &ptrA->sizeE, memPtrA );
+       memPtrA += bbs_memWrite16Arr( cpA, ptrA->arrPtrE, ptrA->sizeE, memPtrA );
+       return memSizeL;
+}
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bbs_Int16Arr_memRead( struct bbs_Context* cpA,
+                                                        struct bbs_Int16Arr* ptrA, 
+                                                        const uint16* memPtrA,
+                                                        struct bbs_MemSeg* mspA )
+{
+       uint32 memSizeL, sizeL;
+       if( bbs_Context_error( cpA ) ) return 0;
+       memPtrA += bbs_memRead32( &memSizeL, memPtrA );
+       memPtrA += bbs_memRead32( &sizeL, memPtrA );
+       bbs_Int16Arr_create( cpA, ptrA, sizeL, mspA );
+       memPtrA += bbs_memRead16Arr( cpA, ptrA->arrPtrE, ptrA->sizeE, memPtrA );
+
+       if( memSizeL != bbs_Int16Arr_memSize( cpA, ptrA ) )
+       {
+               bbs_ERR0( bbs_ERR_CORRUPT_DATA, 
+                                 "uint32 bbs_Int16Arr_memRead( const struct bbs_Int16Arr*, const uint16* ):\n"
+                  "size mismatch" ); 
+               return 0;
+       }
+       return memSizeL;
+}
+
+/* ------------------------------------------------------------------------- */
+       
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+       
+/* ------------------------------------------------------------------------- */
+
+void bbs_Int16Arr_fill( struct bbs_Context* cpA,
+                                           struct bbs_Int16Arr* ptrA, 
+                                               int16 valA )
+{
+       uint32 iL;
+       for( iL = 0; iL < ptrA->sizeE; iL++ )
+       {
+               ptrA->arrPtrE[ iL ] = valA;
+       }
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+
+
diff --git a/Embedded/common/src/b_BasicEm/Int16Arr.h b/Embedded/common/src/b_BasicEm/Int16Arr.h
new file mode 100644 (file)
index 0000000..fbb7f39
--- /dev/null
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+#ifndef bbs_INT16ARR_EM_H
+#define bbs_INT16ARR_EM_H
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Context.h"
+#include "b_BasicEm/MemSeg.h"
+
+/* ---- related objects  --------------------------------------------------- */
+
+/* ---- typedefs ----------------------------------------------------------- */
+
+/* ---- constants ---------------------------------------------------------- */
+
+/* ---- object definition -------------------------------------------------- */
+
+/** short array */
+struct bbs_Int16Arr 
+{
+
+       /* ---- private data --------------------------------------------------- */
+
+       /** pointer to exclusive memory segment used for allocation */
+       struct bbs_MemSeg* mspE;
+
+       /* ---- public data ---------------------------------------------------- */
+
+       /** pointer to array of int16 */
+       int16* arrPtrE;
+
+       /** current size */
+       uint32 sizeE;
+
+       /** allocated size */
+       uint32 allocatedSizeE;
+
+};
+
+/* ---- associated objects ------------------------------------------------- */
+
+/* ---- external functions ------------------------------------------------- */
+
+/* ---- \ghd{ constructor/destructor } ------------------------------------- */
+
+/** initializes bbs_Int16Arr  */
+void bbs_Int16Arr_init( struct bbs_Context* cpA,
+                                           struct bbs_Int16Arr* ptrA );
+
+/** frees bbs_Int16Arr  */
+void bbs_Int16Arr_exit( struct bbs_Context* cpA,
+                                           struct bbs_Int16Arr* ptrA );
+
+/* ---- \ghd{ operators } -------------------------------------------------- */
+
+/** copy operator */
+void bbs_Int16Arr_copy( struct bbs_Context* cpA,
+                                           struct bbs_Int16Arr* ptrA, 
+                                               const struct bbs_Int16Arr* srcPtrA );
+
+/** equal operator */
+flag bbs_Int16Arr_equal( struct bbs_Context* cpA,
+                                                const struct bbs_Int16Arr* ptrA, 
+                                                const struct bbs_Int16Arr* srcPtrA );
+
+/* ---- \ghd{ query functions } -------------------------------------------- */
+
+/** calculates the amount of heap memory needed (16bit words) if created with given parameters */ 
+uint32 bbs_Int16Arr_heapSize( struct bbs_Context* cpA,
+                                                         const struct bbs_Int16Arr* ptrA, 
+                                                         uint32 sizeA );
+
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+
+/** allocates memory for bbs_Int16Arr */
+void bbs_Int16Arr_create( struct bbs_Context* cpA,
+                                                 struct bbs_Int16Arr* ptrA, 
+                                                 uint32 sizeA,
+                                                 struct bbs_MemSeg* mspA );
+
+/** allocates memory for bbs_Int16Arr, 
+       Allocation is done for allocPtrA with extra memory to allow for alignment, 
+       aligned memory pointer is copied to ptrA. 
+       alignBytes must be a power of 2.
+       bbs_Int16Arr_heapSize does not apply !
+*/
+void bbs_Int16Arr_createAligned( struct bbs_Context* cpA,
+                                                                struct bbs_Int16Arr* ptrA,
+                                                                uint32 sizeA,
+                                                                struct bbs_MemSeg* mspA,
+                                                                struct bbs_Int16Arr* allocPtrA, 
+                                                                uint32 alignBytesA );
+
+/** sets array size */
+void bbs_Int16Arr_size( struct bbs_Context* cpA,
+                                           struct bbs_Int16Arr* ptrA, 
+                                               uint32 sizeA );
+
+/* ---- \ghd{ memory I/O } ------------------------------------------------- */
+
+/** size object needs when written to memory */
+uint32 bbs_Int16Arr_memSize( struct bbs_Context* cpA,
+                                                        const struct bbs_Int16Arr* ptrA );
+
+/** writes object to memory; returns number of 16-bit words written */
+uint32 bbs_Int16Arr_memWrite( struct bbs_Context* cpA,
+                                                         const struct bbs_Int16Arr* ptrA, 
+                                                         uint16* memPtrA );
+
+/** reads object from memory; returns number of 16-bit words read */
+uint32 bbs_Int16Arr_memRead( struct bbs_Context* cpA,
+                                                        struct bbs_Int16Arr* ptrA, 
+                                                        const uint16* memPtrA,
+                                                        struct bbs_MemSeg* mspA );
+
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+
+/** fills array with a value */
+void bbs_Int16Arr_fill( struct bbs_Context* cpA,
+                                           struct bbs_Int16Arr* ptrA, 
+                                               int16 valA );
+
+#endif /* bbs_INT16ARR_EM_H */
+
diff --git a/Embedded/common/src/b_BasicEm/Int32Arr.c b/Embedded/common/src/b_BasicEm/Int32Arr.c
new file mode 100644 (file)
index 0000000..9326a7b
--- /dev/null
@@ -0,0 +1,246 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Functions.h"
+#include "b_BasicEm/Int32Arr.h"
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ auxiliary functions } ---------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ constructor / destructor } ----------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_Int32Arr_init( struct bbs_Context* cpA,
+                                           struct bbs_Int32Arr* ptrA )
+{
+       ptrA->arrPtrE = NULL;
+       ptrA->sizeE = 0;
+       ptrA->allocatedSizeE = 0;
+       ptrA->mspE = NULL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_Int32Arr_exit( struct bbs_Context* cpA,
+                                           struct bbs_Int32Arr* ptrA )
+{
+       bbs_MemSeg_free( cpA, ptrA->mspE, ptrA->arrPtrE );
+       ptrA->arrPtrE = NULL;
+       ptrA->mspE = NULL;
+       ptrA->sizeE = 0;
+       ptrA->allocatedSizeE = 0;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ operators } -------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_Int32Arr_copy( struct bbs_Context* cpA,
+                                           struct bbs_Int32Arr* ptrA, 
+                                               const struct bbs_Int32Arr* srcPtrA )
+{
+#ifdef DEBUG1
+       if( ptrA->allocatedSizeE < srcPtrA->allocatedSizeE )
+       {
+               bbs_ERROR0( "void bbs_Int32Arr_copy(...):\n"
+                                  "Unsufficient allocated memory in destination array." );             
+               return;
+       }
+#endif
+       bbs_Int32Arr_size( cpA, ptrA, srcPtrA->sizeE );
+       bbs_memcpy32( ptrA->arrPtrE, srcPtrA->arrPtrE, srcPtrA->sizeE * bbs_SIZEOF32( int32 ) ); 
+}
+
+/* ------------------------------------------------------------------------- */
+
+flag bbs_Int32Arr_equal( struct bbs_Context* cpA,
+                                                const struct bbs_Int32Arr* ptrA, 
+                                                const struct bbs_Int32Arr* srcPtrA )
+{
+       uint32 iL;
+       const int32* ptr1L = ptrA->arrPtrE;
+       const int32* ptr2L = srcPtrA->arrPtrE;
+       if( ptrA->sizeE != srcPtrA->sizeE ) return FALSE;
+       for( iL = ptrA->sizeE; iL > 0; iL-- )
+       {
+               if( *ptr1L++ != *ptr2L++ ) return FALSE;
+       }
+       return TRUE;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ query functions } -------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bbs_Int32Arr_heapSize( struct bbs_Context* cpA,
+                                                         const struct bbs_Int32Arr* ptrA, 
+                                                         uint32 sizeA )
+{
+       return sizeA * bbs_SIZEOF16( int32 ) + bbs_MEM_BLOCK_OVERHD;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+       
+void bbs_Int32Arr_create( struct bbs_Context* cpA,
+                                                 struct bbs_Int32Arr* ptrA, 
+                                                 uint32 sizeA, 
+                                                 struct bbs_MemSeg* mspA )
+{
+       if( bbs_Context_error( cpA ) ) return;
+       if( ptrA->sizeE == sizeA ) return;
+       if( ptrA->arrPtrE != 0 )
+       {
+               bbs_Int32Arr_size( cpA, ptrA, sizeA );
+       }
+       else
+       {
+               ptrA->arrPtrE = bbs_MemSeg_alloc( cpA, mspA, sizeA * bbs_SIZEOF16( int32 ) );
+               if( bbs_Context_error( cpA ) ) return;
+               ptrA->allocatedSizeE = sizeA;
+               ptrA->sizeE = sizeA;
+               if( !mspA->sharedE ) ptrA->mspE = mspA;
+       }
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bbs_Int32Arr_size( struct bbs_Context* cpA,
+                                           struct bbs_Int32Arr* ptrA, 
+                                               uint32 sizeA )
+{
+       if( ptrA->allocatedSizeE < sizeA )
+       {
+               bbs_ERROR1( "void bbs_Int32Arr_size( struct bbs_Int32Arr*, uint32 ):\n"
+                                  "Unsufficient allocated memory (allocatedSizeE = '%i')",
+                                  ptrA->allocatedSizeE );
+               return;
+       }
+       ptrA->sizeE = sizeA;
+}
+
+/* ------------------------------------------------------------------------- */
+       
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ I/O } -------------------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bbs_Int32Arr_memSize( struct bbs_Context* cpA,
+                                                        const struct bbs_Int32Arr* ptrA )
+{
+       return bbs_SIZEOF16( uint32 ) + bbs_SIZEOF16( ptrA->sizeE ) + 
+                                                                               ptrA->sizeE * bbs_SIZEOF16( int32 );
+}
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bbs_Int32Arr_memWrite( struct bbs_Context* cpA,
+                                                         const struct bbs_Int32Arr* ptrA, 
+                                                         uint16* memPtrA )
+{
+       uint32 memSizeL = bbs_Int32Arr_memSize( cpA, ptrA );
+       memPtrA += bbs_memWrite32( &memSizeL, memPtrA );
+       memPtrA += bbs_memWrite32( &ptrA->sizeE, memPtrA );
+       memPtrA += bbs_memWrite32Arr( cpA, ptrA->arrPtrE, ptrA->sizeE, memPtrA );
+       return memSizeL;
+}
+
+/* ------------------------------------------------------------------------- */
+       
+uint32 bbs_Int32Arr_memRead( struct bbs_Context* cpA,
+                                                        struct bbs_Int32Arr* ptrA, 
+                                                        const uint16* memPtrA,
+                                                        struct bbs_MemSeg* mspA )
+{
+       uint32 memSizeL, sizeL;
+       if( bbs_Context_error( cpA ) ) return 0;
+       memPtrA += bbs_memRead32( &memSizeL, memPtrA );
+       memPtrA += bbs_memRead32( &sizeL, memPtrA );
+       bbs_Int32Arr_create( cpA, ptrA, sizeL, mspA );
+       memPtrA += bbs_memRead32Arr( cpA, ptrA->arrPtrE, ptrA->sizeE, memPtrA );
+
+       if( memSizeL != bbs_Int32Arr_memSize( cpA, ptrA ) )
+       {
+               bbs_ERR0( bbs_ERR_CORRUPT_DATA, "uint32 bbs_Int32Arr_memRead( const struct bbs_Int32Arr*, const uint16* ):\n"
+                   "size mismatch" ); 
+               return 0;
+       }
+       return memSizeL;
+}
+
+/* ------------------------------------------------------------------------- */
+       
+/* ========================================================================= */
+/*                                                                           */
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+/*                                                                           */
+/* ========================================================================= */
+       
+/* ------------------------------------------------------------------------- */
+
+void bbs_Int32Arr_fill( struct bbs_Context* cpA,
+                                           struct bbs_Int32Arr* ptrA, 
+                                               int32 valA )
+{
+       uint32 iL;
+       for( iL = 0; iL < ptrA->sizeE; iL++ )
+       {
+               ptrA->arrPtrE[ iL ] = valA;
+       }
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+
+
diff --git a/Embedded/common/src/b_BasicEm/Int32Arr.h b/Embedded/common/src/b_BasicEm/Int32Arr.h
new file mode 100644 (file)
index 0000000..3ad2736
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+#ifndef bbs_INT32ARR_EM_H
+#define bbs_INT32ARR_EM_H
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Context.h"
+#include "b_BasicEm/MemSeg.h"
+
+/* ---- related objects  --------------------------------------------------- */
+
+/* ---- typedefs ----------------------------------------------------------- */
+
+/* ---- constants ---------------------------------------------------------- */
+
+/* ---- object definition -------------------------------------------------- */
+
+/** byte array */
+struct bbs_Int32Arr 
+{
+
+       /* ---- private data --------------------------------------------------- */
+
+       /** pointer to exclusive memory segment used for allocation */
+       struct bbs_MemSeg* mspE;
+
+       /* ---- public data ---------------------------------------------------- */
+
+       /** pointer to array of int32 */
+       int32* arrPtrE;
+
+       /** current size */
+       uint32 sizeE;
+
+       /** allocated size */
+       uint32 allocatedSizeE;
+
+};
+
+/* ---- associated objects ------------------------------------------------- */
+
+/* ---- external functions ------------------------------------------------- */
+
+/* ---- \ghd{ constructor/destructor } ------------------------------------- */
+
+/** initializes bbs_Int32Arr  */
+void bbs_Int32Arr_init( struct bbs_Context* cpA,
+                                           struct bbs_Int32Arr* ptrA );
+
+/** frees bbs_Int32Arr  */
+void bbs_Int32Arr_exit( struct bbs_Context* cpA,
+                                           struct bbs_Int32Arr* ptrA );
+
+/* ---- \ghd{ operators } -------------------------------------------------- */
+