aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/glu/mipmap/HalveImage.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/glu/mipmap/HalveImage.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/glu/mipmap/HalveImage.java276
1 files changed, 138 insertions, 138 deletions
diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/HalveImage.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/HalveImage.java
index 7549044ba..184c5fda8 100644
--- a/src/jogl/classes/jogamp/opengl/glu/mipmap/HalveImage.java
+++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/HalveImage.java
@@ -6,15 +6,15 @@
* this file except in compliance with the License. You may obtain a copy
* of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
* Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
+ *
* http://oss.sgi.com/projects/FreeB
- *
+ *
* Note that, as provided in the License, the Software is distributed on an
* "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
* DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
* CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
* PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
+ *
* NOTE: The Original Code (as defined below) has been licensed to Sun
* Microsystems, Inc. ("Sun") under the SGI Free Software License B
* (Version 1.1), shown above ("SGI License"). Pursuant to Section
@@ -30,7 +30,7 @@
* Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
* Copyright in any portions created by third parties is as indicated
* elsewhere herein. All Rights Reserved.
- *
+ *
* Additional Notice Provisions: The application programming interfaces
* established by SGI in conjunction with the Original Code are The
* OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
@@ -52,11 +52,11 @@ import java.nio.*;
* @author Administrator
*/
public class HalveImage {
-
+
private static final int BOX2 = 2;
private static final int BOX4 = 4;
private static final int BOX8 = 8;
-
+
public static void halveImage( int components, int width, int height,
ShortBuffer datain, ShortBuffer dataout ) {
int i, j, k;
@@ -64,11 +64,11 @@ public class HalveImage {
int delta;
int t = 0;
short temp = 0;
-
+
newwidth = width / 2;
newheight = height /2;
delta = width * components;
-
+
// Piece of cake
for( i = 0; i < newheight; i++ ) {
for( j = 0; j < newwidth; j++ ) {
@@ -91,7 +91,7 @@ public class HalveImage {
t += delta;
}
}
-
+
public static void halveImage_ubyte( int components, int width, int height,
ByteBuffer datain, ByteBuffer dataout,
int element_size, int ysize, int group_size ) {
@@ -99,19 +99,19 @@ public class HalveImage {
int newwidth, newheight;
int s;
int t;
-
+
// Handle case where there is only 1 column/row
if( width == 1 || height == 1 ) {
assert( !( width == 1 && height == 1 ) ); // can't be 1x1
halve1Dimage_ubyte( components, width, height, datain, dataout, element_size, ysize, group_size );
return;
}
-
+
newwidth = width / 2;
newheight = height / 2;
s = 0;
t = 0;
-
+
int temp = 0;
// piece of cake
for( i = 0; i < newheight; i++ ) {
@@ -133,9 +133,9 @@ public class HalveImage {
t += ysize;
}
}
-
+
public static void halve1Dimage_ubyte( int components, int width, int height,
- ByteBuffer datain, ByteBuffer dataout,
+ ByteBuffer datain, ByteBuffer dataout,
int element_size, int ysize, int group_size ) {
int halfWidth = width / 2;
int halfHeight = height / 2;
@@ -143,14 +143,14 @@ public class HalveImage {
int dest = 0;
int jj;
int temp = 0;
-
+
assert( width == 1 || height == 1 ); // Must be 1D
assert( width != height ); // can't be square
-
+
if( height == 1 ) { // 1 row
assert( width != 1 ); // widthxheight can't be 1x1
halfHeight = 1;
-
+
for( jj = 0; jj < halfWidth; jj++ ) {
int kk;
for( kk = 0; kk < components; kk++ ) {
@@ -161,7 +161,7 @@ public class HalveImage {
temp /= 2;
dataout.put( (byte)temp );
/*
- dataout.setByte( (byte)(((0x000000FF & datain.setIndexInBytes(src).getByte()) +
+ dataout.setByte( (byte)(((0x000000FF & datain.setIndexInBytes(src).getByte()) +
(0x000000FF & datain.setIndexInBytes( src + group_size ).getByte())) / 2 ) );
*/
src += element_size;
@@ -188,7 +188,7 @@ public class HalveImage {
temp /= 2;
dataout.put( (byte)temp );
/*
- dataout.setByte( (byte)(((0x000000FF & datain.setIndexInBytes(src).getByte()) +
+ dataout.setByte( (byte)(((0x000000FF & datain.setIndexInBytes(src).getByte()) +
(0x000000FF & datain.setIndexInBytes(src + ysize).getByte()) ) / 2 ) );
*/
src += element_size;
@@ -202,7 +202,7 @@ public class HalveImage {
assert( src == ysize * height );
assert( dest == components * element_size * halfWidth * halfHeight );
}
-
+
public static void halveImage_byte( int components, int width, int height,
ByteBuffer datain, ByteBuffer dataout, int element_size,
int ysize, int group_size ) {
@@ -211,7 +211,7 @@ public class HalveImage {
int s = 0;
int t = 0;
byte temp = (byte)0;
-
+
// handle case where there is only 1 column
if( width == 1 || height == 1 ) {
assert( !( width == 1 && height == 1 ) );
@@ -219,10 +219,10 @@ public class HalveImage {
ysize, group_size );
return;
}
-
+
newwidth = width / 2;
newheight = height / 2;
-
+
for( i = 0; i < newheight; i++ ) {
for( j = 0; j < newwidth; j++ ) {
for( k = 0; k < components; k++ ) {
@@ -244,7 +244,7 @@ public class HalveImage {
t += ysize;
}
}
-
+
public static void halve1Dimage_byte( int components, int width, int height,
ByteBuffer datain, ByteBuffer dataout,
int element_size, int ysize, int group_size ) {
@@ -254,14 +254,14 @@ public class HalveImage {
int dest = 0;
int jj;
byte temp = (byte)0;
-
+
assert( width == 1 || height == 1 ); // must be 1D
assert( width != height ); // can't be square
-
+
if( height == 1 ) { // 1 row
assert( width != 1 ); // widthxheight can't be 1
halfHeight = 1;
-
+
for( jj = 0; jj < halfWidth; jj++ ) {
int kk;
for( kk = 0; kk < components; kk++ ) {
@@ -284,7 +284,7 @@ public class HalveImage {
halfWidth = 1;
// one vertical column with possible pad bytes per row
// average two at a time
-
+
for( jj = 0; jj < halfHeight; jj++ ) {
int kk;
for( kk = 0; kk < components; kk++ ) {
@@ -303,7 +303,7 @@ public class HalveImage {
}
assert( dest == components * element_size * halfWidth * halfHeight );
}
-
+
public static void halveImage_ushort( int components, int width, int height,
ByteBuffer datain, ShortBuffer dataout, int element_size,
int ysize, int group_size, boolean myswap_bytes ) {
@@ -319,10 +319,10 @@ public class HalveImage {
ysize, group_size, myswap_bytes );
return;
}
-
+
newwidth = width / 2;
newheight = height / 2;
-
+
// Piece of cake
if( !myswap_bytes ) {
for( i = 0; i < newheight; i++ ) {
@@ -364,7 +364,7 @@ public class HalveImage {
}
}
}
-
+
public static void halve1Dimage_ushort( int components, int width, int height,
ByteBuffer datain, ShortBuffer dataout, int element_size,
int ysize, int group_size, boolean myswap_bytes ) {
@@ -373,14 +373,14 @@ public class HalveImage {
int src = 0;
int dest = 0;
int jj;
-
+
assert( width == 1 || height == 1 ); // must be 1D
assert( width != height ); // can't be square
-
+
if( height == 1 ) { // 1 row
assert( width != 1 ); // widthxheight can't be 1
halfHeight = 1;
-
+
for( jj = 0; jj < halfWidth; jj++ ) {
int kk;
for( kk = 0; kk < halfHeight; kk++ ) {
@@ -410,7 +410,7 @@ public class HalveImage {
halfWidth = 1;
// one vertical column with possible pad bytes per row
// average two at a time
-
+
for( jj = 0; jj < halfHeight; jj++ ) {
int kk;
for( kk = 0; kk < components; kk++ ) {
@@ -437,7 +437,7 @@ public class HalveImage {
}
assert( dest == components * element_size * halfWidth * halfHeight );
}
-
+
public static void halveImage_short( int components, int width, int height,
ByteBuffer datain, ShortBuffer dataout, int element_size,
int ysize, int group_size, boolean myswap_bytes ) {
@@ -453,10 +453,10 @@ public class HalveImage {
ysize, group_size, myswap_bytes );
return;
}
-
+
newwidth = width / 2;
newheight = height / 2;
-
+
// Piece of cake
if( !myswap_bytes ) {
for( i = 0; i < newheight; i++ ) {
@@ -504,7 +504,7 @@ public class HalveImage {
}
}
}
-
+
public static void halve1Dimage_short( int components, int width, int height,
ByteBuffer datain, ShortBuffer dataout, int element_size, int ysize,
int group_size, boolean myswap_bytes ) {
@@ -513,14 +513,14 @@ public class HalveImage {
int src = 0;
int dest = 0;
int jj;
-
+
assert( width == 1 || height == 1 ); // must be 1D
assert( width != height ); // can't be square
-
+
if( height == 1 ) { // 1 row
assert( width != 1 ); // can't be 1x1
halfHeight = 1;
-
+
for( jj = 0; jj < halfWidth; jj++ ) {
int kk;
for( kk = 0; kk < components; kk++ ) {
@@ -550,7 +550,7 @@ public class HalveImage {
halfWidth = 1;
// one vertical column with possible pad bytes per row
// average two at a time
-
+
for( jj = 0; jj < halfHeight; jj++ ) {
int kk;
for( kk = 0; kk < components; kk++ ) {
@@ -577,7 +577,7 @@ public class HalveImage {
}
assert( dest == ( components * element_size * halfWidth * halfHeight ) );
}
-
+
public static void halveImage_uint( int components, int width, int height,
ByteBuffer datain, IntBuffer dataout, int element_size,
int ysize, int group_size, boolean myswap_bytes ) {
@@ -586,7 +586,7 @@ public class HalveImage {
int s = 0;
int t = 0;
double temp = 0;
-
+
// handle case where there is only 1 column/row
if( width == 1 || height == 1 ) {
assert( !( width == 1 && height == 1 ) ); // can't be 1x1
@@ -594,10 +594,10 @@ public class HalveImage {
ysize, group_size, myswap_bytes );
return;
}
-
+
newwidth = width / 2;
newheight = height / 2;
-
+
// Piece of cake
if( !myswap_bytes ) {
for( i = 0; i < newheight; i++ ) {
@@ -643,7 +643,7 @@ public class HalveImage {
}
}
}
-
+
public static void halve1Dimage_uint( int components, int width, int height,
ByteBuffer datain, IntBuffer dataout, int element_size, int ysize,
int group_size, boolean myswap_bytes ) {
@@ -652,14 +652,14 @@ public class HalveImage {
int src = 0;
int dest = 0;
int jj;
-
+
assert( width == 1 || height == 1 ); // must be 1D
assert( width != height ); // can't be square
-
+
if( height == 1 ) { // 1 row
assert( width != 1 ); // widthxheight can't be 1
halfHeight = 1;
-
+
for( jj = 0; jj < halfWidth; jj++ ) {
int kk;
for( kk = 0; kk < halfHeight; kk++ ) {
@@ -689,7 +689,7 @@ public class HalveImage {
halfWidth = 1;
// one vertical column with possible pad bytes per row
// average two at a time
-
+
for( jj = 0; jj < halfHeight; jj++ ) {
int kk;
for( kk = 0; kk < components; kk++ ) {
@@ -716,7 +716,7 @@ public class HalveImage {
}
assert( dest == components * element_size * halfWidth * halfHeight );
}
-
+
public static void halveImage_int( int components, int width, int height,
ByteBuffer datain, IntBuffer dataout, int element_size,
int ysize, int group_size, boolean myswap_bytes ) {
@@ -725,7 +725,7 @@ public class HalveImage {
int s = 0;
int t = 0;
int temp = 0;
-
+
// handle case where there is only 1 column/row
if( width == 1 || height == 1 ) {
assert( !( width == 1 && height == 1 ) ); // can't be 1x1
@@ -733,10 +733,10 @@ public class HalveImage {
ysize, group_size, myswap_bytes );
return;
}
-
+
newwidth = width / 2;
newheight = height / 2;
-
+
// Piece of cake
if( !myswap_bytes ) {
for( i = 0; i < newheight; i++ ) {
@@ -785,7 +785,7 @@ public class HalveImage {
}
}
}
-
+
public static void halve1Dimage_int( int components, int width, int height,
ByteBuffer datain, IntBuffer dataout, int element_size, int ysize,
int group_size, boolean myswap_bytes ) {
@@ -794,14 +794,14 @@ public class HalveImage {
int src = 0;
int dest = 0;
int jj;
-
+
assert( width == 1 || height == 1 ); // must be 1D
assert( width != height ); // can't be square
-
+
if( height == 1 ) { // 1 row
assert( width != 1 ); // can't be 1x1
halfHeight = 1;
-
+
for( jj = 0; jj < halfWidth; jj++ ) {
int kk;
for( kk = 0; kk < components; kk++ ) {
@@ -831,7 +831,7 @@ public class HalveImage {
halfWidth = 1;
// one vertical column with possible pad bytes per row
// average two at a time
-
+
for( jj = 0; jj < halfHeight; jj++ ) {
int kk;
for( kk = 0; kk < components; kk++ ) {
@@ -858,7 +858,7 @@ public class HalveImage {
}
assert( dest == ( components * element_size * halfWidth * halfHeight ) );
}
-
+
public static void halveImage_float( int components, int width, int height,
ByteBuffer datain, FloatBuffer dataout, int element_size,
int ysize, int group_size, boolean myswap_bytes ) {
@@ -874,10 +874,10 @@ public class HalveImage {
ysize, group_size, myswap_bytes );
return;
}
-
+
newwidth = width / 2;
newheight = height / 2;
-
+
// Piece of cake
if( !myswap_bytes ) {
for( i = 0; i < newheight; i++ ) {
@@ -920,7 +920,7 @@ public class HalveImage {
}
}
}
-
+
public static void halve1Dimage_float( int components, int width, int height,
ByteBuffer datain, FloatBuffer dataout, int element_size, int ysize,
int group_size, boolean myswap_bytes ) {
@@ -929,14 +929,14 @@ public class HalveImage {
int src = 0;
int dest = 0;
int jj;
-
+
assert( width == 1 || height == 1 ); // must be 1D
assert( width != height ); // can't be square
-
+
if( height == 1 ) { // 1 row
assert( width != 1 ); // can't be 1x1
halfHeight = 1;
-
+
for( jj = 0; jj < halfWidth; jj++ ) {
int kk;
for( kk = 0; kk < components; kk++ ) {
@@ -966,7 +966,7 @@ public class HalveImage {
halfWidth = 1;
// one vertical column with possible pad bytes per row
// average two at a time
-
+
for( jj = 0; jj < halfHeight; jj++ ) {
int kk;
for( kk = 0; kk < components; kk++ ) {
@@ -993,9 +993,9 @@ public class HalveImage {
}
assert( dest == ( components * element_size * halfWidth * halfHeight ) );
}
-
- public static void halveImagePackedPixel( int components, Extract extract, int width,
- int height, ByteBuffer datain, ByteBuffer dataout,
+
+ public static void halveImagePackedPixel( int components, Extract extract, int width,
+ int height, ByteBuffer datain, ByteBuffer dataout,
int pixelSizeInBytes, int rowSizeInBytes, boolean isSwap ) {
if( width == 1 || height == 1 ) {
assert( !( width == 1 && height == 1 ) );
@@ -1004,19 +1004,19 @@ public class HalveImage {
return;
}
int ii, jj;
-
+
int halfWidth = width / 2;
int halfHeight = height / 2;
int src = 0;
int padBytes = rowSizeInBytes - ( width * pixelSizeInBytes );
int outIndex = 0;
-
+
for( ii = 0; ii < halfHeight; ii++ ) {
for( jj = 0; jj < halfWidth; jj++ ) {
float totals[] = new float[4];
float extractTotals[][] = new float[BOX4][4];
int cc;
-
+
datain.position( src );
extract.extract( isSwap, datain, extractTotals[0] );
datain.position( src + pixelSizeInBytes );
@@ -1045,7 +1045,7 @@ public class HalveImage {
assert( src == rowSizeInBytes * height );
assert( outIndex == halfWidth * halfHeight );
}
-
+
public static void halve1DimagePackedPixel( int components, Extract extract, int width,
int height, ByteBuffer datain, ByteBuffer dataout,
int pixelSizeInBytes, int rowSizeInBytes, boolean isSwap ) {
@@ -1053,23 +1053,23 @@ public class HalveImage {
int halfHeight = height / 2;
int src = 0;
int jj;
-
+
assert( width == 1 || height == 1 );
assert( width != height );
-
+
if( height == 1 ) {
int outIndex = 0;
-
+
assert( width != 1 );
halfHeight = 1;
-
+
// one horizontal row with possible pad bytes
-
+
for( jj = 0; jj < halfWidth; jj++ ) {
float[] totals = new float[4];
float[][] extractTotals = new float[BOX2][4];
int cc;
-
+
datain.position( src );
extract.extract( isSwap, datain, extractTotals[0] );
datain.position( src + pixelSizeInBytes );
@@ -1090,17 +1090,17 @@ public class HalveImage {
}
int padBytes = rowSizeInBytes - ( width * pixelSizeInBytes );
src += padBytes;
-
+
assert( src == rowSizeInBytes );
assert( outIndex == halfWidth * halfHeight );
} else if( width == 1 ) {
int outIndex = 0;
-
+
assert( height != 1 );
halfWidth = 1;
// one vertical volumn with possible pad bytes per row
// average two at a time
-
+
for( jj = 0; jj < halfHeight; jj++ ) {
float[] totals = new float[4];
float[][] extractTotals = new float[BOX2][4];
@@ -1128,7 +1128,7 @@ public class HalveImage {
assert( outIndex == halfWidth * halfHeight );
}
}
-
+
public static void halveImagePackedPixelSlice( int components, Extract extract,
int width, int height, int depth, ByteBuffer dataIn,
ByteBuffer dataOut, int pixelSizeInBytes, int rowSizeInBytes,
@@ -1140,26 +1140,26 @@ public class HalveImage {
int src = 0;
int padBytes = rowSizeInBytes - ( width * pixelSizeInBytes );
int outIndex = 0;
-
+
assert( (width == 1 || height == 1) && depth >= 2 );
-
+
if( width == height ) {
assert( width == 1 && height == 1 );
assert( depth >= 2 );
-
+
for( ii = 0; ii < halfDepth; ii++ ) {
float totals[] = new float[4];
float extractTotals[][] = new float[BOX2][4];
int cc;
-
+
dataIn.position( src );
extract.extract( isSwap, dataIn, extractTotals[0] );
dataIn.position( src + imageSizeInBytes );
extract.extract( isSwap, dataIn, extractTotals[1] );
-
+
for( cc = 0; cc < components; cc++ ) {
int kk;
-
+
// average only 2 pixels since a column
totals[cc]= 0.0f;
for( kk = 0; kk < BOX2; kk++ ) {
@@ -1167,7 +1167,7 @@ public class HalveImage {
}
totals[cc] /= BOX2;
} // for cc
-
+
extract.shove( totals, outIndex, dataOut );
outIndex++;
// skip over to next group of 2
@@ -1175,13 +1175,13 @@ public class HalveImage {
} // for ii
} else if( height == 1 ) {
assert( width != 1 );
-
+
for( ii = 0; ii < halfDepth; ii++ ) {
for( jj = 0; jj < halfWidth; jj++ ) {
float totals[] = new float[4];
float extractTotals[][] = new float[BOX4][4];
int cc;
-
+
dataIn.position( src );
extract.extract( isSwap, dataIn, extractTotals[0] );
dataIn.position( src + pixelSizeInBytes );
@@ -1190,10 +1190,10 @@ public class HalveImage {
extract.extract( isSwap, dataIn, extractTotals[2] );
dataIn.position( src + pixelSizeInBytes + imageSizeInBytes );
extract.extract( isSwap, dataIn, extractTotals[3] );
-
+
for( cc = 0; cc < components; cc++ ) {
int kk;
-
+
// grab 4 pixels to average
totals[cc] = 0.0f;
for( kk = 0; kk < BOX4; kk++ ) {
@@ -1209,13 +1209,13 @@ public class HalveImage {
}
} else if( width == 1 ) {
assert( height != 1 );
-
+
for( ii = 0; ii < halfDepth; ii++ ) {
for( jj = 0; jj < halfWidth; jj++ ) {
float totals[] = new float[4];
float extractTotals[][] = new float[BOX4][4];
int cc;
-
+
dataIn.position( src );
extract.extract( isSwap, dataIn, extractTotals[0] );
dataIn.position( src + rowSizeInBytes );
@@ -1224,10 +1224,10 @@ public class HalveImage {
extract.extract( isSwap, dataIn, extractTotals[2] );
dataIn.position( src + rowSizeInBytes + imageSizeInBytes );
extract.extract( isSwap, dataIn, extractTotals[3] );
-
+
for( cc = 0; cc < components; cc++ ) {
int kk;
-
+
// grab 4 pixels to average
totals[cc] = 0.0f;
for( kk = 0; kk < BOX4; kk++ ) {
@@ -1243,7 +1243,7 @@ public class HalveImage {
}
}
}
-
+
public static void halveImageSlice( int components, ExtractPrimitive extract, int width,
int height, int depth, ByteBuffer dataIn, ByteBuffer dataOut,
int elementSizeInBytes, int groupSizeInBytes, int rowSizeInBytes,
@@ -1255,25 +1255,25 @@ public class HalveImage {
int src = 0;
int padBytes = rowSizeInBytes - ( width * groupSizeInBytes );
int outIndex = 0;
-
+
assert( (width == 1 || height == 1) && depth >= 2 );
-
+
if( width == height ) {
assert( width == 1 && height == 1 );
assert( depth >= 2 );
-
+
for( ii = 0; ii < halfDepth; ii++ ) {
int cc;
for( cc = 0; cc < components; cc++ ) {
double[] totals = new double[4];
double[][] extractTotals = new double[BOX2][4];
int kk;
-
+
dataIn.position( src );
extractTotals[0][cc] = extract.extract( isSwap, dataIn );
dataIn.position( src + imageSizeInBytes );
extractTotals[1][cc] = extract.extract( isSwap, dataIn );
-
+
// average 2 pixels since only a column
totals[cc] = 0.0f;
// totals[red] = extractTotals[0][red] + extractTotals[1][red];
@@ -1282,7 +1282,7 @@ public class HalveImage {
totals[cc] += extractTotals[kk][cc];
}
totals[cc] /= (double)BOX2;
-
+
extract.shove( totals[cc], outIndex, dataOut );
outIndex++;
src += elementSizeInBytes;
@@ -1290,12 +1290,12 @@ public class HalveImage {
// skip over next group of 2
src += rowSizeInBytes;
} // for ii
-
+
assert( src == rowSizeInBytes * height * depth );
assert( outIndex == halfDepth * components );
} else if( height == 1 ) {
assert( width != 1 );
-
+
for( ii = 0; ii < halfDepth; ii++ ) {
for( jj = 0; jj < halfWidth; jj++ ) {
int cc;
@@ -1303,7 +1303,7 @@ public class HalveImage {
int kk;
double totals[] = new double[4];
double extractTotals[][] = new double[BOX4][4];
-
+
dataIn.position( src );
extractTotals[0][cc] = extract.extract( isSwap, dataIn );
dataIn.position( src + groupSizeInBytes );
@@ -1312,7 +1312,7 @@ public class HalveImage {
extractTotals[2][cc] = extract.extract( isSwap, dataIn );
dataIn.position( src + imageSizeInBytes + groupSizeInBytes );
extractTotals[3][cc] = extract.extract( isSwap, dataIn );
-
+
// grab 4 pixels to average
totals[cc] = 0.0f;
// totals[red] = extractTotals[0][red] + extractTotals[1][red] +
@@ -1322,7 +1322,7 @@ public class HalveImage {
totals[cc] += extractTotals[kk][cc];
}
totals[cc] /= (double)BOX4;
-
+
extract.shove( totals[cc], outIndex, dataOut );
outIndex++;
src += elementSizeInBytes;
@@ -1337,7 +1337,7 @@ public class HalveImage {
assert( outIndex == halfWidth * halfDepth * components );
} else if( width == 1 ) {
assert( height != 1 );
-
+
for( ii = 0; ii < halfDepth; ii++ ) {
for( jj = 0; jj < halfHeight; jj++ ) {
int cc;
@@ -1345,7 +1345,7 @@ public class HalveImage {
int kk;
double totals[] = new double[4];
double extractTotals[][] = new double[BOX4][4];
-
+
dataIn.position( src );
extractTotals[0][cc] = extract.extract( isSwap, dataIn );
dataIn.position( src + rowSizeInBytes );
@@ -1354,8 +1354,8 @@ public class HalveImage {
extractTotals[2][cc] = extract.extract( isSwap, dataIn );
dataIn.position( src + imageSizeInBytes + groupSizeInBytes );
extractTotals[3][cc] = extract.extract( isSwap, dataIn );
-
-
+
+
// grab 4 pixels to average
totals[cc] = 0.0f;
// totals[red] = extractTotals[0][red] + extractTotals[1][red] +
@@ -1365,7 +1365,7 @@ public class HalveImage {
totals[cc] += extractTotals[kk][cc];
}
totals[cc] /= (double)BOX4;
-
+
extract.shove( totals[cc], outIndex, dataOut );
outIndex++;
src += elementSizeInBytes;
@@ -1380,32 +1380,32 @@ public class HalveImage {
assert( outIndex == halfWidth * halfDepth * components );
}
}
-
+
public static void halveImage3D( int components, ExtractPrimitive extract,
int width, int height, int depth, ByteBuffer dataIn, ByteBuffer dataOut,
int elementSizeInBytes, int groupSizeInBytes, int rowSizeInBytes,
int imageSizeInBytes, boolean isSwap ) {
assert( depth > 1 );
-
+
// horizontal/vertical/onecolumn slice viewed from top
if( width == 1 || height == 1 ) {
assert( 1 <= depth );
-
+
halveImageSlice( components, extract, width, height, depth, dataIn, dataOut,
elementSizeInBytes, groupSizeInBytes, rowSizeInBytes, imageSizeInBytes,
isSwap );
return;
}
-
+
int ii, jj, dd;
-
+
int halfWidth = width / 2;
int halfHeight = height / 2;
int halfDepth = depth / 2;
int src = 0;
int padBytes = rowSizeInBytes - ( width * groupSizeInBytes );
int outIndex = 0;
-
+
for( dd = 0; dd < halfDepth; dd++ ) {
for( ii = 0; ii < halfHeight; ii++ ) {
for( jj = 0; jj < halfWidth; jj++ ) {
@@ -1414,7 +1414,7 @@ public class HalveImage {
int kk;
double totals[] = new double[4];
double extractTotals[][] = new double[BOX8][4];
-
+
dataIn.position( src );
extractTotals[0][cc] = extract.extract( isSwap, dataIn );
dataIn.position( src + groupSizeInBytes );
@@ -1431,17 +1431,17 @@ public class HalveImage {
extractTotals[6][cc] = extract.extract( isSwap, dataIn );
dataIn.position( src + rowSizeInBytes + imageSizeInBytes + groupSizeInBytes );
extractTotals[7][cc] = extract.extract( isSwap, dataIn );
-
+
totals[cc] = 0.0f;
-
+
for( kk = 0; kk < BOX8; kk++ ) {
totals[cc] += extractTotals[kk][cc];
}
totals[cc] /= (double)BOX8;
-
+
extract.shove( totals[cc], outIndex, dataOut );
outIndex++;
-
+
src += elementSizeInBytes;
} // for cc
// skip over to next square of 4
@@ -1456,40 +1456,40 @@ public class HalveImage {
assert( src == rowSizeInBytes * height * depth );
assert( outIndex == halfWidth * halfHeight * halfDepth * components );
}
-
+
public static void halveImagePackedPixel3D( int components, Extract extract,
- int width, int height, int depth, ByteBuffer dataIn,
+ int width, int height, int depth, ByteBuffer dataIn,
ByteBuffer dataOut, int pixelSizeInBytes, int rowSizeInBytes,
int imageSizeInBytes, boolean isSwap ) {
if( depth == 1 ) {
assert( 1 <= width && 1 <= height );
-
+
halveImagePackedPixel( components, extract, width, height, dataIn, dataOut,
pixelSizeInBytes, rowSizeInBytes, isSwap );
return;
} else if( width == 1 || height == 1 ) { // a horizontal or vertical slice viewed from top
assert( 1 <= depth );
-
+
halveImagePackedPixelSlice( components, extract, width, height, depth, dataIn,
dataOut, pixelSizeInBytes, rowSizeInBytes, imageSizeInBytes, isSwap );
return;
}
int ii, jj, dd;
-
+
int halfWidth = width / 2;
int halfHeight = height / 2;
int halfDepth = depth / 2;
int src = 0;
int padBytes = rowSizeInBytes - ( width * pixelSizeInBytes );
int outIndex = 0;
-
+
for( dd = 0; dd < halfDepth; dd++ ) {
for( ii = 0; ii < halfHeight; ii++ ) {
for( jj = 0; jj < halfWidth; jj++ ) {
float totals[] = new float[4]; // 4 is max components
float extractTotals[][] = new float[BOX8][4];
int cc;
-
+
dataIn.position( src );
extract.extract( isSwap, dataIn, extractTotals[0] );
dataIn.position( src + pixelSizeInBytes );
@@ -1506,7 +1506,7 @@ public class HalveImage {
extract.extract( isSwap, dataIn, extractTotals[6] );
dataIn.position( src + rowSizeInBytes + pixelSizeInBytes + imageSizeInBytes );
extract.extract( isSwap, dataIn, extractTotals[7] );
-
+
for( cc = 0; cc < components; cc++ ) {
int kk;
// grab 8 pixels to average