Home | History | Annotate | Download | only in b_APIEm
      1 /*
      2  * Copyright (C) 2008 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef bpi_FUNCTIONS_EM_H
     18 #define bpi_FUNCTIONS_EM_H
     19 
     20 /**
     21  * This files contains general purpose functions.
     22  */
     23 
     24 /* ---- includes ----------------------------------------------------------- */
     25 
     26 #include "b_BasicEm/Basic.h"
     27 #include "b_BasicEm/Context.h"
     28 #include "b_BasicEm/Functions.h"
     29 
     30 /* ---- related objects  --------------------------------------------------- */
     31 
     32 /* ---- typedefs ----------------------------------------------------------- */
     33 
     34 
     35 /** methods of similarty normalization for identification and verification */
     36 enum bpi_SimType
     37 {
     38 	bpi_RAW_SIM,       /* take raw similarity only */
     39 	bpi_SUB_MEAN,      /* subtract average  */
     40 	bpi_SUB_MAX_1,     /* subtract maximum (different id of each entry) */
     41 	bpi_SUB_MAX_2,     /* subtract maximum (different id of best entry) */
     42 	bpi_SUB_4_MAX_2,   /* subtract average maximum of best 4 entries (method 2) */
     43 	bpi_SUB_8_MAX_2,   /* subtract average maximum of best 8 entries (method 2) */
     44 	bpi_SUB_16_MAX_2,  /* subtract average maximum of best 16 entries (method 2) */
     45 	bpi_SUB_32_MAX_2   /* subtract average maximum of best 32 entries (method 2) */
     46 };
     47 
     48 /* ---- constants ---------------------------------------------------------- */
     49 
     50 /* ---- external functions ------------------------------------------------- */
     51 
     52 /** Normalizes similarities.
     53  *  This function is used by identifier module
     54  */
     55 void bpi_normalizeSimilarities( struct bbs_Context* cpA,
     56 							    const int32* rawSimArrA,
     57 							    const int32* rawIdArrA,
     58 								uint32 rawSizeA,
     59 								const int32* refSimArrA,
     60 								const int32* refIdArrA,
     61 								uint32 refSizeA,
     62 								enum bpi_SimType simTypeA,
     63 								int32* outSimArrA );
     64 
     65 /** Returnes normalized single similarity.
     66  *  This function is used by verifier module
     67  */
     68 int32 bpi_normalizedSimilarity( struct bbs_Context* cpA,
     69 							    int32 rawSimA,
     70 							    int32 rawIdA,
     71 								const int32* refSimArrA,
     72 								const int32* refIdArrA,
     73 								uint32 refSizeA,
     74 								enum bpi_SimType simTypeA );
     75 
     76 
     77 
     78 /** writes checksum adjustment value to meet chkSumA to memory
     79  *  the function assumes that memPtrA is memSizeA - 1 units
     80  *  away from beginning of object-memory block
     81  */
     82 uint32 bpi_memWriteCsa16( uint16* memPtrA, uint32 memSizeA, uint16 chkSumA );
     83 
     84 /** takes checksum adjustment value from memory stream */
     85 uint32 bpi_memReadCsa16( const uint16* memPtrA );
     86 
     87 /** tests check sum and produxes error condition if no match */
     88 void bpi_testCheckSum( struct bbs_Context* cpA, uint16* memPtrA, uint16 chkSumA, const char* fNameA );
     89 
     90 
     91 #endif /* bpi_FUNCTIONS_EM_H */
     92 
     93