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 bbf_SEQUENCE_EM_H
18#define bbf_SEQUENCE_EM_H
19
20/* ---- includes ----------------------------------------------------------- */
21
22#include "b_BasicEm/Context.h"
23#include "b_BasicEm/Basic.h"
24#include "b_BasicEm/Int32Arr.h"
25#include "b_BasicEm/UInt16Arr.h"
26#include "b_BasicEm/MemTbl.h"
27#include "b_BitFeatureEm/Feature.h"
28
29/* ---- related objects  --------------------------------------------------- */
30
31/* ---- typedefs ----------------------------------------------------------- */
32
33/* ---- constants ---------------------------------------------------------- */
34
35/** data format version number */
36#define bbf_SEQUENCE_VERSION 101
37
38/** maximum sequence size */
39#define bbf_SEQUENCE_MAX_SIZE 16
40
41/* ---- object definition -------------------------------------------------- */
42
43/** inhomogenious sequence of features */
44struct bbf_Sequence
45{
46	/* ---- public data ---------------------------------------------------- */
47
48	/** base element (must be first element) */
49	struct bbf_Feature baseE;
50
51	/* ---- private data --------------------------------------------------- */
52
53	/** feature pointer arrray */
54	struct bbf_Feature* ftrPtrArrE[ bbf_SEQUENCE_MAX_SIZE ];
55
56	/* ---- public data ---------------------------------------------------- */
57
58	/** sequence size */
59	uint32 sizeE;
60
61	/** array of thresholds (4.28) */
62	struct bbs_Int32Arr thrArrE;
63
64	/** array of weights (0.16); value 1.0 is saturated to 0xFFFF */
65	struct bbs_UInt16Arr wgtArrE;
66
67	/** data array (contains feature elements) */
68	struct bbs_UInt16Arr dataArrE;
69};
70
71/* ---- associated objects ------------------------------------------------- */
72
73/* ---- external functions ------------------------------------------------- */
74
75/* ---- \ghd{ constructor/destructor } ------------------------------------- */
76
77/** initializes bbf_Sequence  */
78void bbf_Sequence_init( struct bbs_Context* cpA,
79					   struct bbf_Sequence* ptrA );
80
81/** resets bbf_Sequence  */
82void bbf_Sequence_exit( struct bbs_Context* cpA,
83					   struct bbf_Sequence* ptrA );
84
85/* ---- \ghd{ operators } -------------------------------------------------- */
86
87/** copy operator */
88void bbf_Sequence_copy( struct bbs_Context* cpA,
89 					   struct bbf_Sequence* ptrA,
90					   const struct bbf_Sequence* srcPtrA );
91
92/** equal operator */
93flag bbf_Sequence_equal( struct bbs_Context* cpA,
94						const struct bbf_Sequence* ptrA,
95						const struct bbf_Sequence* srcPtrA );
96
97/* ---- \ghd{ query functions } -------------------------------------------- */
98
99/* ---- \ghd{ modify functions } ------------------------------------------- */
100
101/* ---- \ghd{ memory I/O } ------------------------------------------------- */
102
103/** word size (16-bit) object needs when written to memory */
104uint32 bbf_Sequence_memSize( struct bbs_Context* cpA,
105						    const struct bbf_Sequence* ptrA );
106
107/** writes object to memory; returns number of words (16-bit) written */
108uint32 bbf_Sequence_memWrite( struct bbs_Context* cpA,
109							 const struct bbf_Sequence* ptrA, uint16* memPtrA );
110
111/** reads object from memory; returns number of words (16-bit) read */
112uint32 bbf_Sequence_memRead( struct bbs_Context* cpA,
113							struct bbf_Sequence* ptrA,
114							const uint16* memPtrA,
115							struct bbs_MemTbl* mtpA );
116
117/* ---- \ghd{ exec functions } --------------------------------------------- */
118
119/** computes feature's activity (4.28) on the given patch */
120int32 bbf_Sequence_activity( const struct bbf_Feature* ptrA, const uint32* patchA );
121
122#endif /* bbf_SEQUENCE_EM_H */
123
124