17f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*
27f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * Copyright (C) 2008 The Android Open Source Project
37f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *
47f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License");
57f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * you may not use this file except in compliance with the License.
67f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * You may obtain a copy of the License at
77f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *
87f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *      http://www.apache.org/licenses/LICENSE-2.0
97f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *
107f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * Unless required by applicable law or agreed to in writing, software
117f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
127f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
137f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * See the License for the specific language governing permissions and
147f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * limitations under the License.
157f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project */
167f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
177f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ---- includes ----------------------------------------------------------- */
187f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
197f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project#include "b_BasicEm/Functions.h"
207f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project#include "b_BasicEm/Math.h"
217f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project#include "b_ImageEm/Flt16Image.h"
227f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project#include "b_ImageEm/ComplexImage.h"
237f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
247f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
257f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
267f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
277f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
287f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ---- \ghd{ auxiliary functions } ---------------------------------------- */
297f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
307f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
317f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
327f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
337f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
347f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
357f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
367f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ---- \ghd{ constructor / destructor } ----------------------------------- */
377f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
387f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
397f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
407f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
417f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
427f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectvoid bim_Flt16Image_init( struct bbs_Context* cpA,
437f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						  struct bim_Flt16Image* ptrA )
447f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
457f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bbs_Int16Arr_init( cpA, &ptrA->allocArrE );
467f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bbs_Int16Arr_init( cpA, &ptrA->arrE );
477f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	ptrA->widthE = 0;
487f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	ptrA->heightE = 0;
497f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	ptrA->bbpE = 0;
507f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
517f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
527f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
537f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
547f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectvoid bim_Flt16Image_exit( struct bbs_Context* cpA,
557f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						  struct bim_Flt16Image* ptrA )
567f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
577f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bbs_Int16Arr_exit( cpA, &ptrA->arrE );
587f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bbs_Int16Arr_exit( cpA, &ptrA->allocArrE );
597f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	ptrA->widthE = 0;
607f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	ptrA->heightE = 0;
617f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	ptrA->bbpE = 0;
627f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
637f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
647f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
657f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
667f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
677f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
687f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ---- \ghd{ operators } -------------------------------------------------- */
697f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
707f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
717f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
727f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
737f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
747f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectvoid bim_Flt16Image_copy( struct bbs_Context* cpA,
757f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						  struct bim_Flt16Image* ptrA,
767f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						  const struct bim_Flt16Image* srcPtrA )
777f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
787f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project#ifdef DEBUG1
797f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	if( ptrA->arrE.allocatedSizeE < srcPtrA->arrE.allocatedSizeE )
807f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	{
817f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		bbs_ERROR0( "void bim_Flt16Image_copy(...):\n"
827f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project				   "Unsufficient allocated memory in destination image." );
837f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		return;
847f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	}
857f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project#endif
867f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	ptrA->widthE  = srcPtrA->widthE;
877f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	ptrA->heightE = srcPtrA->heightE;
887f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	ptrA->bbpE    = srcPtrA->bbpE;
897f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bbs_Int16Arr_copy( cpA, &ptrA->arrE, &srcPtrA->arrE );
907f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
917f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
927f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
937f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
947f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectflag bim_Flt16Image_equal( struct bbs_Context* cpA,
957f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						   const struct bim_Flt16Image* ptrA,
967f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						   const struct bim_Flt16Image* srcPtrA )
977f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
987f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	if( ptrA->widthE  != srcPtrA->widthE ) return FALSE;
997f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	if( ptrA->heightE != srcPtrA->heightE ) return FALSE;
1007f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	if( ptrA->bbpE    != srcPtrA->bbpE ) return FALSE;
1017f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	return bbs_Int16Arr_equal( cpA, &ptrA->arrE, &srcPtrA->arrE );
1027f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
1037f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1047f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
1057f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1067f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
1077f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
1087f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ---- \ghd{ query functions } -------------------------------------------- */
1097f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
1107f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
1117f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1127f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
1137f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1147f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
1157f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
1167f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ---- \ghd{ modify functions } ------------------------------------------- */
1177f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
1187f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
1197f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1207f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
1217f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1227f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectvoid bim_Flt16Image_create( struct bbs_Context* cpA,
1237f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						    struct bim_Flt16Image* ptrA,
1247f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						    uint32 widthA,
1257f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project							uint32 heightA,
1267f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project 					        struct bbs_MemSeg* mspA )
1277f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
1287f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	if( bbs_Context_error( cpA ) ) return;
1297f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	if( ptrA->arrE.arrPtrE != 0 )
1307f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	{
1317f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		bim_Flt16Image_size( cpA, ptrA, widthA, heightA );
1327f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	}
1337f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	else
1347f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	{
1357f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		/* OLD CODE
1367f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		bbs_Int16Arr_create( cpA, &ptrA->arrE, widthA * heightA, mspA );
1377f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		*/
1387f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		bbs_Int16Arr_createAligned( cpA, &ptrA->arrE, widthA * heightA, mspA, &ptrA->allocArrE, bbs_MEMORY_ALIGNMENT );
1397f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1407f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		ptrA->widthE  = widthA;
1417f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		ptrA->heightE = heightA;
1427f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	}
1437f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
1447f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1457f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
1467f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* incompatible with ALIGN
1477f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectvoid bim_Flt16Image_assignExternalImage( struct bbs_Context* cpA,
1487f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project										 struct bim_Flt16Image* ptrA,
1497f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project										 struct bim_Flt16Image* srcPtrA )
1507f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
1517f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	struct bbs_MemSeg sharedSegL = bbs_MemSeg_createShared( cpA, srcPtrA->arrE.arrPtrE, srcPtrA->widthE * srcPtrA->heightE );
1527f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1537f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	if( ptrA->arrE.arrPtrE != 0 )
1547f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	{
1557f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		bbs_ERROR0( "void bim_Flt16Image_assignExternalImage( ... ): image was already created once" );
1567f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		return;
1577f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	}
1587f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1597f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bim_Flt16Image_create( cpA,
1607f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						   ptrA,
1617f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project					       srcPtrA->widthE,
1627f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						   srcPtrA->heightE,
1637f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						   &sharedSegL );
1647f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1657f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	ptrA->bbpE = srcPtrA->bbpE;
1667f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
1677f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project*/
1687f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
1697f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1707f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectvoid bim_Flt16Image_size( struct bbs_Context* cpA,
1717f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						  struct bim_Flt16Image* ptrA,
1727f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						  uint32 widthA,
1737f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						  uint32 heightA )
1747f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
1757f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	if( ptrA->arrE.allocatedSizeE < widthA * heightA )
1767f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	{
1777f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		bbs_ERROR0( "void bim_Flt16Image_size( struct bim_Flt16Image*, uint32 sizeA ):\n"
1787f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project				   "Unsufficient allocated memory" );
1797f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		return;
1807f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	}
1817f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	ptrA->widthE  = widthA;
1827f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	ptrA->heightE = heightA;
1837f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bbs_Int16Arr_size( cpA, &ptrA->arrE, widthA * heightA );
1847f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
1857f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1867f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
1877f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1887f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
1897f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
1907f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ---- \ghd{ I/O } -------------------------------------------------------- */
1917f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
1927f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
1937f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1947f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
1957f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1967f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectuint32 bim_Flt16Image_memSize( struct bbs_Context* cpA,
1977f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project							   const struct bim_Flt16Image* ptrA )
1987f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
1997f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	return  bbs_SIZEOF16( uint32 )
2007f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		  + bbs_SIZEOF16( uint32 ) /* version */
2017f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		  + bbs_SIZEOF16( ptrA->widthE )
2027f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		  + bbs_SIZEOF16( ptrA->heightE )
2037f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		  + bbs_SIZEOF16( ptrA->bbpE )
2047f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		  + bbs_Int16Arr_memSize( cpA, &ptrA->arrE );
2057f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
2067f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
2077f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
2087f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
2097f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectuint32 bim_Flt16Image_memWrite( struct bbs_Context* cpA,
2107f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project							    const struct bim_Flt16Image* ptrA,
2117f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project								uint16* memPtrA )
2127f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
2137f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	uint32 memSizeL = bim_Flt16Image_memSize( cpA, ptrA );
2147f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	memPtrA += bbs_memWrite32( &memSizeL, memPtrA );
2157f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	memPtrA += bbs_memWriteUInt32( bim_FLT16_IMAGE_VERSION, memPtrA );
2167f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	memPtrA += bbs_memWrite32( &ptrA->widthE, memPtrA );
2177f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	memPtrA += bbs_memWrite32( &ptrA->heightE, memPtrA );
2187f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	memPtrA += bbs_memWrite32( &ptrA->bbpE, memPtrA );
2197f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bbs_Int16Arr_memWrite( cpA, &ptrA->arrE, memPtrA );
2207f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	return memSizeL;
2217f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
2227f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
2237f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
2247f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
2257f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectuint32 bim_Flt16Image_memRead( struct bbs_Context* cpA,
2267f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project							   struct bim_Flt16Image* ptrA,
2277f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project							   const uint16* memPtrA,
2287f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project 					           struct bbs_MemSeg* mspA )
2297f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
2307f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	uint32 memSizeL, versionL;
2317f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	if( bbs_Context_error( cpA ) ) return 0;
2327f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	memPtrA += bbs_memRead32( &memSizeL, memPtrA );
2337f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	memPtrA += bbs_memReadVersion32( cpA, &versionL, bim_FLT16_IMAGE_VERSION, memPtrA );
2347f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	memPtrA += bbs_memRead32( &ptrA->widthE, memPtrA );
2357f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	memPtrA += bbs_memRead32( &ptrA->heightE, memPtrA );
2367f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	memPtrA += bbs_memRead32( &ptrA->bbpE, memPtrA );
2377f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bbs_Int16Arr_memRead( cpA, &ptrA->arrE, memPtrA, mspA );
2387f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
2397f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	if( memSizeL != bim_Flt16Image_memSize( cpA, ptrA ) )
2407f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	{
2417f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		bbs_ERR0( bbs_ERR_CORRUPT_DATA, "uint32 bim_Flt16Image_memRead( const struct bim_Flt16Image* ptrA, const void* memPtrA ):\n"
2427f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project                   "size mismatch" );
2437f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		return 0;
2447f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	}
2457f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	return memSizeL;
2467f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
2477f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
2487f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
2497f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
2507f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
2517f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
2527f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ---- \ghd{ exec functions } --------------------------------------------- */
2537f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
2547f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
2557f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
2567f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
2577f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
2587f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectvoid bim_Flt16Image_setAllPixels( struct bbs_Context* cpA,
2597f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project								  struct bim_Flt16Image* ptrA,
2607f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project								  int16 valueA,
2617f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project								  int32 bbpA )
2627f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
2637f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	long iL;
2647f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	int16* ptrL = ptrA->arrE.arrPtrE;
2657f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	for( iL = ptrA->widthE * ptrA->heightE; iL > 0; iL-- )
2667f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	{
2677f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		*ptrL++ = valueA;
2687f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	}
2697f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	ptrA->bbpE = bbpA;
2707f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
2717f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
2727f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
2737f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
2747f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/**
2757f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			|				|				|				|
2767f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			|	(loop x1)	|	(loop x2)	|	(loop x3)	|
2777f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			o------------->-o------------>--o------------->-o
2787f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			|				|				|				|
2797f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			|				|				|				|
2807f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			|				|				|				|
2817f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			|				|				|				|
2827f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	( sectionL->x1E, sectionL->y1E )		|				|
2837f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project---------o-	R-------------------------------|----------------
2847f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|				|				|
2857f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|				|				|
2867f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|				|				|
2877f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|				|				|
2887f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project   (loop y1)|				|				|				|
2897f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|				|				|
2907f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 V	|				|				|				|
2917f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|( 0, 0 )		|				|		X
2927f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project---------o------------------I------------------------------------------------->
2937f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|				|				|
2947f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|				|				|
2957f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|				|				|
2967f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|				|				|
2977f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|				|				|
2987f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project   (loop y2)|				|				|				|
2997f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|				|				|
3007f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|				|				|
3017f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|				|				|
3027f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 V	|				|				|				|
3037f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|				|				|
3047f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project---------o------------------|---------------I				|
3057f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|		( srcPtrA->widthE, srcPtrA->heightE )
3067f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|								|
3077f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|								|
3087f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|								|
3097f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|								|
3107f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|								|
3117f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project   (loop y3)|				|								|
3127f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|								|
3137f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|								|
3147f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 V	|				|								|
3157f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		 |	|				|								|
3167f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project---------o--------------------------------------------------R
3177f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project							|				( sectionL->x2E, sectionL->y2E )
3187f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project							|
3197f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						  Y	|
3207f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project							|
3217f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project							|
3227f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project							V
3237f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
3247f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project  To understand how the algorithm work refer to the diagram above.
3257f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project  The image boundaries are indicated by letter "I" ( 0, 0 ) to ( srcPtrA->widthE, srcPtrA->heightE )
3267f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project  The rectangle boundaries are indicated by letter "R" ( sectionPtrA->x1E, sectionPtrA->y1E ) to ( sectionPtrA->x2E, sectionPtrA->y2E )
3277f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
3287f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project  In the above example the intersection of the image and the rectange is
3297f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project  ( 0, 0 ), ( srcPtrA->widthE, srcPtrA->heightE )
3307f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
3317f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project  The size of the destination image is always ( ( sectionL->x2E, sectionL->y2E ) - ( sectionL->x1E, sectionL->y1E ) )
3327f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
3337f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project  All coordinates are assumed to be relative to the original image.
3347f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
3357f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project  1. parse all pixels in "loop y1"
3367f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	1.a. parse all pixels in "loop x1"
3377f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	1.b. parse all pixels in "loop x2"
3387f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	1.c. parse all pixels in "loop x3"
3397f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project  2. parse all pixels in "loop y2"
3407f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	2.a. parse all pixels in "loop x1"
3417f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	2.b. parse all pixels in "loop x2"
3427f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	2.c. parse all pixels in "loop x3"
3437f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project  3. parse all pixels in "loop y3"
3447f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	3.a. parse all pixels in "loop x1"
3457f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	3.b. parse all pixels in "loop x2"
3467f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	3.c. parse all pixels in "loop x3"
3477f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
3487f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project*/
3497f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
3507f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/** copies a section of given image */
3517f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectvoid bim_Flt16Image_copySection( struct bbs_Context* cpA,
3527f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project								 struct bim_Flt16Image* ptrA,
3537f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project								 const struct bim_Flt16Image* srcPtrA,
3547f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project								 const struct bts_Int16Rect* sectionPtrA )
3557f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
3567f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
3577f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	int16* srcPixelPtrL;
3587f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	int16* dstPixelPtrL;
3597f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	int32 yIndexL;
3607f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	int32 xIndexL;
3617f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
3627f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	struct bts_Int16Rect srcImageSubSectionL;
3637f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	struct bts_Int16Rect sectionL;
3647f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
3657f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	/* make sure that the rectangle passed is correct, in case the x2 < x1 or y2 < y1, swap them */
3667f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	sectionL.x1E = bbs_min( sectionPtrA->x1E, sectionPtrA->x2E );
3677f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	sectionL.x2E = bbs_max( sectionPtrA->x1E, sectionPtrA->x2E );
3687f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	sectionL.y1E = bbs_min( sectionPtrA->y1E, sectionPtrA->y2E );
3697f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	sectionL.y2E = bbs_max( sectionPtrA->y1E, sectionPtrA->y2E );
3707f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
3717f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	/* find the intersection betweem the rectangle and the image, the image always starts at 0,0 */
3727f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	srcImageSubSectionL.x1E = bbs_max( 0, sectionL.x1E );
3737f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	srcImageSubSectionL.y1E = bbs_max( 0, sectionL.y1E );
3747f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	srcImageSubSectionL.x2E = bbs_min( ( int32 ) srcPtrA->widthE, sectionL.x2E );
3757f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	srcImageSubSectionL.y2E = bbs_min( ( int32 ) srcPtrA->heightE, sectionL.y2E );
3767f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
3777f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	/* If the image and the rectangle do not intersect in X direction, set the intersecting rectangle to the image coordinates */
3787f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	if( srcImageSubSectionL.x2E < srcImageSubSectionL.x1E )
3797f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	{
3807f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		srcImageSubSectionL.x1E = 0;
3817f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		srcImageSubSectionL.x2E = srcPtrA->widthE;
3827f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	}
3837f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	/* do the same as above in the Y direction */
3847f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	if( srcImageSubSectionL.y2E < srcImageSubSectionL.y1E )
3857f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	{
3867f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		srcImageSubSectionL.y1E = 0;
3877f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		srcImageSubSectionL.y2E = srcPtrA->heightE;
3887f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	}
3897f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
3907f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	/* initialize, set size, and allocate required memory for the destination image if required */
3917f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bim_Flt16Image_size( cpA, ptrA, sectionL.x2E - sectionL.x1E, sectionL.y2E - sectionL.y1E );
3927f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	ptrA->bbpE = srcPtrA->bbpE;
3937f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
3947f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	/* get the pointer to the destination image */
3957f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	dstPixelPtrL = ptrA->arrE.arrPtrE;
3967f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
3977f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	/* 1. parse all pixels in "loop y1" */
3987f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	for( yIndexL = sectionL.y1E; yIndexL < srcImageSubSectionL.y1E && yIndexL < sectionL.y2E; yIndexL++ )
3997f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	{
4007f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		/* move to the first pixel that needs to be copied. */
4017f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		srcPixelPtrL = srcPtrA->arrE.arrPtrE;
4027f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
4037f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		/* 1.a. parse all pixels in "loop x1" */
4047f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		for( xIndexL = sectionL.x1E; xIndexL < srcImageSubSectionL.x1E && xIndexL < sectionL.x2E; xIndexL++ )
4057f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		{
4067f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			*dstPixelPtrL++ = *srcPixelPtrL;
4077f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		}
4087f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		/* 1.b. parse all pixels in "loop x2" */
4097f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		for( ; xIndexL < srcImageSubSectionL.x2E && xIndexL < sectionL.x2E; xIndexL++ )
4107f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		{
4117f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			*dstPixelPtrL++ = *srcPixelPtrL++;
4127f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		}
4137f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		srcPixelPtrL--;
4147f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		/* 1.c. parse all pixels in "loop x3" */
4157f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		for( ; xIndexL < sectionL.x2E; xIndexL++ )
4167f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		{
4177f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			*dstPixelPtrL++ = *srcPixelPtrL;
4187f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		}
4197f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	}
4207f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	/* 2. parse all pixels in "loop y2" */
4217f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	for( ; yIndexL < srcImageSubSectionL.y2E && yIndexL < sectionL.y2E; yIndexL++ )
4227f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	{
4237f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		/* move to the first pixel that needs to be copied. */
4247f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		srcPixelPtrL = srcPtrA->arrE.arrPtrE + yIndexL * srcPtrA->widthE + srcImageSubSectionL.x1E;
4257f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
4267f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		/* 2.a. parse all pixels in "loop x1" */
4277f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		for( xIndexL = sectionL.x1E; xIndexL < srcImageSubSectionL.x1E && xIndexL < sectionL.x2E; xIndexL++ )
4287f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		{
4297f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			*dstPixelPtrL++ = *srcPixelPtrL;
4307f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		}
4317f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		/* 2.b. parse all pixels in "loop x2" */
4327f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		for( ; xIndexL < srcImageSubSectionL.x2E && xIndexL < sectionL.x2E; xIndexL++ )
4337f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		{
4347f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			*dstPixelPtrL++ = *srcPixelPtrL++;
4357f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		}
4367f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		srcPixelPtrL--;
4377f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		/* 2.c. parse all pixels in "loop x3" */
4387f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		for( ; xIndexL < sectionL.x2E; xIndexL++ )
4397f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		{
4407f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			*dstPixelPtrL++ = *srcPixelPtrL;
4417f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		}
4427f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	}
4437f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	/* 3. parse all pixels in "loop y3" */
4447f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	for( ; yIndexL < sectionL.y2E; yIndexL++ )
4457f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	{
4467f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		srcPixelPtrL = srcPtrA->arrE.arrPtrE + ( srcImageSubSectionL.y2E - 1 ) * srcPtrA->widthE + srcImageSubSectionL.x1E;
4477f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
4487f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		/* 3.a. parse all pixels in "loop x1" */
4497f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		for( xIndexL = sectionL.x1E; xIndexL < srcImageSubSectionL.x1E && xIndexL < sectionL.x2E; xIndexL++ )
4507f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		{
4517f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			*dstPixelPtrL++ = *srcPixelPtrL;
4527f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		}
4537f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		/* 3.b. parse all pixels in "loop x3" */
4547f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		for( ; xIndexL < srcImageSubSectionL.x2E && xIndexL < sectionL.x2E; xIndexL++ )
4557f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		{
4567f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			*dstPixelPtrL++ = *srcPixelPtrL++;
4577f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		}
4587f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		srcPixelPtrL--;
4597f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		/* 3.c. parse all pixels in "loop x3" */
4607f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		for( ; xIndexL < sectionL.x2E; xIndexL++ )
4617f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		{
4627f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			*dstPixelPtrL++ = *srcPixelPtrL;
4637f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		}
4647f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	}
4657f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
4667f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
4677f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
4687f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
4697f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
4707f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectvoid bim_Flt16Image_importReal( struct bbs_Context* cpA,
4717f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project							    struct bim_Flt16Image* dstPtrA,
4727f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						        const struct bim_ComplexImage* srcPtrA )
4737f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
4747f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	long iL;
4757f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	int16* dstL;
4767f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	const struct bbs_Complex* srcL;
4777f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bim_Flt16Image_size( cpA, dstPtrA, srcPtrA->widthE, srcPtrA->heightE );
4787f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	dstPtrA->bbpE = 0;
4797f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	dstL = dstPtrA->arrE.arrPtrE;
4807f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	srcL = srcPtrA->arrE.arrPtrE;
4817f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	for( iL = srcPtrA->widthE * srcPtrA->heightE; iL > 0; iL-- )
4827f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	{
4837f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		*dstL++ = ( *srcL++ ).realE;
4847f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	}
4857f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
4867f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
4877f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
4887f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
4897f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectvoid bim_Flt16Image_importImag( struct bbs_Context* cpA,
4907f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project							    struct bim_Flt16Image* dstPtrA,
4917f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						        const struct bim_ComplexImage* srcPtrA )
4927f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
4937f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	long iL;
4947f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	int16* dstL;
4957f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	const struct bbs_Complex* srcL;
4967f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bim_Flt16Image_size( cpA, dstPtrA, srcPtrA->widthE, srcPtrA->heightE );
4977f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	dstPtrA->bbpE = 0;
4987f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	dstL = dstPtrA->arrE.arrPtrE;
4997f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	srcL = srcPtrA->arrE.arrPtrE;
5007f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	for( iL = srcPtrA->widthE * srcPtrA->heightE; iL > 0; iL-- )
5017f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	{
5027f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		*dstL++ = ( *srcL++ ).imagE;
5037f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	}
5047f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
5057f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
5067f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
5077f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
5087f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectvoid bim_Flt16Image_importAbs( struct bbs_Context* cpA,
5097f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project							   struct bim_Flt16Image* dstPtrA,
5107f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						       const struct bim_ComplexImage* srcPtrA )
5117f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
5127f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	long iL;
5137f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	int16* dstL;
5147f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	const struct bbs_Complex* srcL;
5157f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bim_Flt16Image_size( cpA, dstPtrA, srcPtrA->widthE, srcPtrA->heightE );
5167f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	dstPtrA->bbpE = 0;
5177f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	dstL = dstPtrA->arrE.arrPtrE;
5187f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	srcL = srcPtrA->arrE.arrPtrE;
5197f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	for( iL = srcPtrA->widthE * srcPtrA->heightE; iL > 0; iL-- )
5207f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	{
5217f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		*dstL++ = bbs_sqrt32( ( int32 )srcL->realE * srcL->realE + ( int32 )srcL->imagE * srcL->imagE );
5227f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		srcL++;
5237f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	}
5247f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
5257f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
5267f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
5277f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
5287f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectvoid bim_Flt16Image_importPhase( struct bbs_Context* cpA,
5297f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project								 struct bim_Flt16Image* dstPtrA,
5307f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						         const struct bim_ComplexImage* srcPtrA )
5317f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
5327f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	long iL;
5337f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	int16* dstL;
5347f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	const struct bbs_Complex* srcL;
5357f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bim_Flt16Image_size( cpA, dstPtrA, srcPtrA->widthE, srcPtrA->heightE );
5367f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	dstPtrA->bbpE = 0;
5377f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	dstL = dstPtrA->arrE.arrPtrE;
5387f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	srcL = srcPtrA->arrE.arrPtrE;
5397f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	for( iL = srcPtrA->widthE * srcPtrA->heightE; iL > 0; iL-- )
5407f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	{
5417f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		*dstL++ = bbs_phase16( srcL->realE, srcL->imagE );
5427f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		srcL++;
5437f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	}
5447f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
5457f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
5467f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
5477f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
5487f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
5497f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
5507f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
551