• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 bim_UINT16_IMAGE_EM_H
18 #define bim_UINT16_IMAGE_EM_H
19 
20 /* ---- includes ----------------------------------------------------------- */
21 
22 #include "b_BasicEm/Context.h"
23 #include "b_BasicEm/UInt16Arr.h"
24 #include "b_TensorEm/Int16Rect.h"
25 #include "b_TensorEm/Flt16Alt2D.h"
26 #include "b_ImageEm/UInt8Image.h"
27 
28 /* ---- related objects  --------------------------------------------------- */
29 
30 /* ---- typedefs ----------------------------------------------------------- */
31 
32 /* ---- constants ---------------------------------------------------------- */
33 
34 /* data format version number */
35 #define bim_UINT16_IMAGE_VERSION 100
36 
37 /* ---- object definition -------------------------------------------------- */
38 
39 /** Packed byte image
40  *  2 pixels are stored on a 16 bit space.
41  *  Using conventional pixel order, the first pixel is represented by the low-byte.
42  *  A Pixel at position (x,y) can be accessed as follows:
43  *  ( ( arrE.arrE + y * withE + ( x >> 1 ) ) >> ( 8 * ( x & 1 ) ) ) & 0x0FF;
44  *
45  *  On little endian platforms bim_UInt16ByteImage and bim_UInt8Image
46  *  have the same memory representation of the image data.
47  */
48 struct bim_UInt16ByteImage
49 {
50 
51 	/* ---- private data --------------------------------------------------- */
52 
53 	/* ---- public data ---------------------------------------------------- */
54 
55 	/** width of image */
56 	uint32 widthE;
57 
58 	/** height of image */
59 	uint32 heightE;
60 
61 	/** array of 16bit words */
62 	struct bbs_UInt16Arr arrE;
63 };
64 
65 /* ---- associated objects ------------------------------------------------- */
66 
67 /* ---- external functions ------------------------------------------------- */
68 
69 /* ---- \ghd{ constructor/destructor } ------------------------------------- */
70 
71 /** initializes bim_UInt16ByteImage  */
72 void bim_UInt16ByteImage_init( struct bbs_Context* cpA,
73 							   struct bim_UInt16ByteImage* ptrA );
74 
75 /** allocates memory for bim_UInt16ByteImage */
76 void bim_UInt16ByteImage_create( struct bbs_Context* cpA,
77 								 struct bim_UInt16ByteImage* ptrA,
78 						    uint32 widthA,
79 							uint32 heightA,
80  					        struct bbs_MemSeg* mspA );
81 
82 /** destructor of bim_UInt16ByteImage  */
83 void bim_UInt16ByteImage_exit( struct bbs_Context* cpA,
84 							   struct bim_UInt16ByteImage* ptrA );
85 
86 /* ---- \ghd{ operators } -------------------------------------------------- */
87 
88 /** copy operator */
89 void bim_UInt16ByteImage_copy( struct bbs_Context* cpA,
90 							   struct bim_UInt16ByteImage* ptrA,
91 							   const struct bim_UInt16ByteImage* srcPtrA );
92 
93 /** equal operator */
94 flag bim_UInt16ByteImage_equal( struct bbs_Context* cpA,
95 							    const struct bim_UInt16ByteImage* ptrA,
96 								const struct bim_UInt16ByteImage* srcPtrA );
97 
98 /* ---- \ghd{ query functions } -------------------------------------------- */
99 
100 /** checksum of image (for debugging purposes) */
101 uint32 bim_UInt16ByteImage_checkSum( struct bbs_Context* cpA,
102 									 const struct bim_UInt16ByteImage* ptrA );
103 
104 /* ---- \ghd{ modify functions } ------------------------------------------- */
105 
106 /** assigns external image to array (no allocation, deallocation or copying of data) */
107 void bim_UInt16ByteImage_assignExternalImage( struct bbs_Context* cpA,
108 											  struct bim_UInt16ByteImage* ptrA,
109 											  struct bim_UInt16ByteImage* srcPtrA );
110 
111 /** sets image size */
112 void bim_UInt16ByteImage_size( struct bbs_Context* cpA,
113 							   struct bim_UInt16ByteImage* ptrA,
114 							   uint32 widthA, uint32 heightA );
115 
116 /* ---- \ghd{ memory I/O } ------------------------------------------------- */
117 
118 /** size object needs when written to memory */
119 uint32 bim_UInt16ByteImage_memSize( struct bbs_Context* cpA,
120 								    const struct bim_UInt16ByteImage* ptrA );
121 
122 /** writes object to memory; returns number of bytes written */
123 uint32 bim_UInt16ByteImage_memWrite( struct bbs_Context* cpA,
124 									 const struct bim_UInt16ByteImage* ptrA,
125 									 uint16* memPtrA );
126 
127 /** reads object from memory; returns number of bytes read */
128 uint32 bim_UInt16ByteImage_memRead( struct bbs_Context* cpA,
129 								    struct bim_UInt16ByteImage* ptrA,
130 							   const uint16* memPtrA,
131  					           struct bbs_MemSeg* mspA );
132 
133 /* ---- \ghd{ exec functions } --------------------------------------------- */
134 
135 /** sets all pixels to one value; higher 8 bits of valueA are ignored */
136 void bim_UInt16ByteImage_setAllPixels( struct bbs_Context* cpA,
137 									   struct bim_UInt16ByteImage* ptrA,
138 									   uint16 valueA );
139 
140 /** applies affine linear warping to pixels positions of imageA before copying the into *ptrA */
141 void bim_UInt16ByteImage_warp( struct bbs_Context* cpA,
142 							   struct bim_UInt16ByteImage* ptrA,
143 							   const struct bim_UInt16ByteImage* srcPtrA,
144 						       const struct bts_Flt16Alt2D* altPtrA,
145 			                   int32 resultWidthA,
146 			                   int32 resultHeightA );
147 
148 
149 #ifndef HW_TMS320C5x /* 16bit architecture excluded */
150 
151 /** applies affine linear warping to pixels positions of ptrA before copying the into *ptrA.
152  *  This function accepts an bim_UInt16ByteImage as input, but uses a faster algorithm
153  *  utilizing 8-bit data access for warping.
154  *  Only available for platforms that allow 8 bit data access.
155  */
156 void bim_UInt16ByteImage_warp8( struct bbs_Context* cpA,
157 							    struct bim_UInt16ByteImage* ptrA,
158 							    const struct bim_UInt16ByteImage* srcPtrA,
159 							    const struct bts_Flt16Alt2D* altPtrA,
160 							    int32 resultWidthA,
161 							    int32 resultHeightA );
162 #endif /* HW_TMS320C5x */
163 
164 #endif /* bim_UINT16_IMAGE_EM_H */
165 
166