Java Code Examples for java.nio.ByteBuffer.asShortBuffer()

The following are Jave code examples for showing how to use asShortBuffer() of the java.nio.ByteBuffer class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: EZFilter   File: AudioChannel.java   View Source Code Vote up 6 votes
public void drainDecoderBufferAndQueue(final int bufferIndex, final long presentationTimeUs) {
    if (mActualDecodedFormat == null) {
        throw new RuntimeException("Buffer received before format!");
    }

    final ByteBuffer data = bufferIndex == BUFFER_INDEX_END_OF_STREAM ? null : MediaUtil.getOutputBuffer(mDecoder, bufferIndex);

    AudioBuffer buffer = mEmptyBuffers.poll();
    if (buffer == null) {
        buffer = new AudioBuffer();
    }

    buffer.bufferIndex = bufferIndex;
    buffer.presentationTimeUs = presentationTimeUs;
    buffer.data = data == null ? null : data.asShortBuffer();

    if (mOverflowBuffer.data == null) {
        mOverflowBuffer.data = ByteBuffer
                .allocateDirect(data.capacity())
                .order(ByteOrder.nativeOrder())
                .asShortBuffer();
        mOverflowBuffer.data.clear().flip();
    }

    mFilledBuffers.add(buffer);
}
 
Example 2
Project: AndroidCollection   File: Cube.java   View Source Code Vote up 6 votes
public Cube(float width, float height, float depth) {
    ByteBuffer vByteBuffer = ByteBuffer.allocateDirect(vertices.length * 4);
    vByteBuffer.order(ByteOrder.nativeOrder());
    mVertexBuffer = vByteBuffer.asFloatBuffer();
    mVertexBuffer.put(vertices);
    mVertexBuffer.position(0);

    ByteBuffer iByteBuffer = ByteBuffer.allocateDirect(indices.length * 2);
    iByteBuffer.order(ByteOrder.nativeOrder());
    mIndexBuffer = iByteBuffer.asShortBuffer();
    mIndexBuffer.put(indices);
    mIndexBuffer.position(0);

    ByteBuffer cByteBuffer = ByteBuffer.allocateDirect(colors.length * 4);
    cByteBuffer.order(ByteOrder.nativeOrder());
    mColorBuffer = cByteBuffer.asFloatBuffer();
    mColorBuffer.put(colors);
    mColorBuffer.position(0);
    this.width = width / 2;
    this.height = height / 2;
    this.depth = depth / 2;
}
 
Example 3
Project: SpriteKit-Android   File: SpriteKitRenderer.java   View Source Code Vote up 6 votes
private void setUpBuffers() {
    indices = new short[6];
    indices = new short[]{0, 1, 2, 0, 2, 3};
    ByteBuffer dlb = ByteBuffer.allocateDirect(indices.length * 2);
    dlb.order(ByteOrder.nativeOrder());
    drawListBuffer = dlb.asShortBuffer();
    drawListBuffer.put(indices);
    drawListBuffer.position(0);


    uvs = new float[]{
            0.0f, 0.0f,
            0.0f, 1.0f,
            1.0f, 1.0f,
            1.0f, 0.0f
    };
    ByteBuffer bb = ByteBuffer.allocateDirect(uvs.length * 4);
    bb.order(ByteOrder.nativeOrder());
    uvBuffer = bb.asFloatBuffer();
    uvBuffer.put(uvs);
    uvBuffer.position(0);
}
 
Example 4
Project: Progetto-C   File: AiffData.java   View Source Code Vote up 6 votes
/**
 * Convert the audio bytes into the stream
 * 
 * @param format The audio format being decoded
 * @param audio_bytes The audio byts
 * @param two_bytes_data True if we using double byte data
 * @return The byte bufer of data
 */
private static ByteBuffer convertAudioBytes(AudioFormat format, byte[] audio_bytes, boolean two_bytes_data) {
	ByteBuffer dest = ByteBuffer.allocateDirect(audio_bytes.length);
	dest.order(ByteOrder.nativeOrder());
	ByteBuffer src = ByteBuffer.wrap(audio_bytes);
	src.order(ByteOrder.BIG_ENDIAN);
	if (two_bytes_data) {
		ShortBuffer dest_short = dest.asShortBuffer();
		ShortBuffer src_short = src.asShortBuffer();
		while (src_short.hasRemaining())
			dest_short.put(src_short.get());
	} else {
		while (src.hasRemaining()) {
			byte b = src.get();
			if (format.getEncoding() == Encoding.PCM_SIGNED) {
				b = (byte) (b + 127);
			}
			dest.put(b);
		}
	}
	dest.rewind();
	return dest;
}
 
Example 5
Project: TeamProject   File: WaveData.java   View Source Code Vote up 6 votes
private static ByteBuffer convertAudioBytes(byte[] audio_bytes, boolean two_bytes_data, ByteOrder order) {
    ByteBuffer dest = ByteBuffer.allocateDirect(audio_bytes.length);
    dest.order(ByteOrder.nativeOrder());
    ByteBuffer src = ByteBuffer.wrap(audio_bytes);
    src.order(order);
    if (two_bytes_data) {
        ShortBuffer dest_short = dest.asShortBuffer();
        ShortBuffer src_short = src.asShortBuffer();
        while (src_short.hasRemaining())
            dest_short.put(src_short.get());
    } else {
        while (src.hasRemaining())
            dest.put(src.get());
    }
    dest.rewind();
    return dest;
}
 
Example 6
Project: aos-MediaLib   File: Mark.java   View Source Code Vote up 6 votes
private void Init( float x, float y, float z) {

		ByteBuffer vbb = ByteBuffer.allocateDirect(VERTS * 3 * 4);
		vbb.order(ByteOrder.nativeOrder());
		mFVertexBuffer = vbb.asFloatBuffer();

		ByteBuffer ibb = ByteBuffer.allocateDirect(VERTS * 2);
		ibb.order(ByteOrder.nativeOrder());
		mIndexBuffer = ibb.asShortBuffer();

		mZ = z; // planar object

		int n = 0;
		for (int i=0; i<VERTS; i++) {
			mFVertexBuffer.put( COORDS[n++] + x);
			mFVertexBuffer.put( COORDS[n++] + y);
			mFVertexBuffer.put( COORDS[n++] + z);
		}

		for(int i = 0; i < VERTS; i++) {
			mIndexBuffer.put((short) i);
		}

		mFVertexBuffer.position(0);
		mIndexBuffer.position(0);
	}
 
Example 7
Project: aos-MediaLib   File: FadeOutBand.java   View Source Code Vote up 5 votes
private void Init( float w, float h, float x, float y, float z ) {

		mWidth = w;
		mHeight = h;

		ByteBuffer vbb = ByteBuffer.allocateDirect(VERTS * 3 * 4);
		vbb.order(ByteOrder.nativeOrder());
		mFVertexBuffer = vbb.asFloatBuffer();

		ByteBuffer ibb = ByteBuffer.allocateDirect(VERTS * 2);
		ibb.order(ByteOrder.nativeOrder());
		mIndexBuffer = ibb.asShortBuffer();

		int n = 0;
		for (int i=0; i<VERTS; i++) {
			mFVertexBuffer.put( COORDS[n++]*mWidth  + x);
			mFVertexBuffer.put( COORDS[n++]*mHeight + y);
			mFVertexBuffer.put( COORDS[n++]         + z);
		}

		for(int i = 0; i < VERTS; i++) {
			mIndexBuffer.put((short) i);
		}


        ByteBuffer cbb = ByteBuffer.allocateDirect(COLORS.length*4);
        cbb.order(ByteOrder.nativeOrder());
        mColorBuffer = cbb.asIntBuffer();
        mColorBuffer.put(COLORS);
        
		mFVertexBuffer.position(0);
		mIndexBuffer.position(0);
        mColorBuffer.position(0);
	}
 
Example 8
Project: monarch   File: ByteSourceJUnitTest.java   View Source Code Vote up 5 votes
@Test
public void testGetShortInt() {
  ByteBuffer bb = ByteBuffer.allocate(10);
  ShortBuffer sb = bb.asShortBuffer();
  sb.put((short) 0x1110);
  sb.put((short) 0x2220);
  sb.put((short) 0x3330);
  sb.put((short) 0x4440);
  sb.put((short) 0x5550);
  byte[] bytes = bb.array();
  ByteSource bs = createByteSource(bytes);
  bs.position(3);
  short s = bs.getShort(0);
  assertEquals(0x1110, s);
  assertEquals(3, bs.position());
  s = bs.getShort(2);
  assertEquals(0x2220, s);
  assertEquals(3, bs.position());
  s = bs.getShort(8);
  assertEquals(0x5550, s);
  assertEquals(3, bs.position());
  try {
    bs.getShort(9);
    fail("expected IndexOutOfBoundsException");
  } catch (IndexOutOfBoundsException expected) {
  }
}
 
Example 9
Project: jdk8u-jdk   File: TrueTypeFont.java   View Source Code Vote up 5 votes
private void setStrikethroughMetrics(ByteBuffer os_2Table, int upem) {
    if (os_2Table == null || os_2Table.capacity() < 30 || upem < 0) {
        stSize = .05f;
        stPos = -.4f;
        return;
    }
    ShortBuffer sb = os_2Table.asShortBuffer();
    stSize = sb.get(13) / (float)upem;
    stPos = -sb.get(14) / (float)upem;
}
 
Example 10
Project: Agora-Video-Source-Android   File: TextureRenderer.java   View Source Code Vote up 5 votes
public TextureRenderer(boolean isOesTexture) {
    mOesTexture = isOesTexture;

    ByteBuffer bb = ByteBuffer.allocateDirect(squareVertices.length * 4);
    bb.order(ByteOrder.nativeOrder());
    vertexBuffer = bb.asFloatBuffer();
    vertexBuffer.put(squareVertices);
    vertexBuffer.position(0);

    ByteBuffer dlb = ByteBuffer.allocateDirect(drawOrder.length * 2);
    dlb.order(ByteOrder.nativeOrder());
    drawListBuffer = dlb.asShortBuffer();
    drawListBuffer.put(drawOrder);
    drawListBuffer.position(0);

    ByteBuffer bb2 = ByteBuffer.allocateDirect(textureVertices.length * 4);
    bb2.order(ByteOrder.nativeOrder());
    textureVerticesBuffer = bb2.asFloatBuffer();
    textureVerticesBuffer.put(textureVertices);
    textureVerticesBuffer.position(0);

    int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, mVertexShader);
    int fragmentShader;
    if (mOesTexture) {
        fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER, mFragmentShaderOes);
    } else {
        fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER, mFragmentShaderRgba);
    }

    mProgram = GLES20.glCreateProgram();             // create empty OpenGL ES Program
    GLES20.glAttachShader(mProgram, vertexShader);   // add the vertex shader to program
    GLES20.glAttachShader(mProgram, fragmentShader); // add the fragment shader to program
    GLES20.glLinkProgram(mProgram);

    muMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix");
    muSTMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uSTMatrix");

    Matrix.setIdentityM(mMVPMatrix, 0);
    Matrix.setIdentityM(mSTMatrix, 0);
}
 
Example 11
Project: openjdk-jdk10   File: TrueTypeFont.java   View Source Code Vote up 5 votes
private void setStrikethroughMetrics(ByteBuffer os_2Table, int upem) {
    if (os_2Table == null || os_2Table.capacity() < 30 || upem < 0) {
        stSize = .05f;
        stPos = -.4f;
        return;
    }
    ShortBuffer sb = os_2Table.asShortBuffer();
    stSize = sb.get(13) / (float)upem;
    stPos = -sb.get(14) / (float)upem;
}
 
Example 12
Project: MegviiFacepp-Android-SDK   File: CameraMatrix.java   View Source Code Vote up 5 votes
private ShortBuffer ShortBufferUtil(short[] arr) {
	ByteBuffer dlb = ByteBuffer.allocateDirect(arr.length * 2);
	dlb.order(ByteOrder.nativeOrder());
	ShortBuffer buffer = dlb.asShortBuffer();
	buffer.put(arr);
	buffer.position(0);

	return buffer;
}
 
Example 13
Project: jdk8u-jdk   File: TrueTypeFont.java   View Source Code Vote up 5 votes
@Override
public void getStyleMetrics(float pointSize, float[] metrics, int offset) {

    if (ulSize == 0f && ulPos == 0f) {

        ByteBuffer head_Table = getTableBuffer(headTag);
        int upem = -1;
        if (head_Table != null && head_Table.capacity() >= 18) {
            ShortBuffer sb = head_Table.asShortBuffer();
            upem = sb.get(9) & 0xffff;
            if (upem < 16 || upem > 16384) {
                upem = 2048;
            }
        }

        ByteBuffer os2_Table = getTableBuffer(os_2Tag);
        setStrikethroughMetrics(os2_Table, upem);

        ByteBuffer post_Table = getTableBuffer(postTag);
        setUnderlineMetrics(post_Table, upem);
    }

    metrics[offset] = stPos * pointSize;
    metrics[offset+1] = stSize * pointSize;

    metrics[offset+2] = ulPos * pointSize;
    metrics[offset+3] = ulSize * pointSize;
}
 
Example 14
Project: BitmapFontLoader   File: Bitmap3DGeometryTest.java   View Source Code Vote up 5 votes
@Before
public void setUp() throws Exception {
    float[] normals = {
        0.0f, 0.0f, 1.0f,
        0.0f, 0.0f, 1.0f,
        0.0f, 0.0f, 1.0f,
        0.0f, 0.0f, 1.0f
    };
    float[] vertices = {
        0.0f, 0.0f, 0.0f, // top left
        0.0f, -1.0f, 0.0f, // bottom left
        1.0f, -1.0f, 0.0f, // bottom right
        1.0f, 0.0f, 0.0f // top right
    };
    short[] indices = {
        0, 1, 2, 0, 2, 3
    };

    ByteBuffer nbb = ByteBuffer.allocateDirect(normals.length * 4);
    nbb.order(ByteOrder.nativeOrder());
    normalBuffer = nbb.asFloatBuffer();
    normalBuffer.put(normals);
    normalBuffer.position(0);

    ByteBuffer bb = ByteBuffer.allocateDirect(vertices.length * 4);
    bb.order(ByteOrder.nativeOrder());
    vertexBuffer = bb.asFloatBuffer();
    vertexBuffer.put(vertices);
    vertexBuffer.position(0);

    ByteBuffer dlb = ByteBuffer.allocateDirect(indices.length * 2);
    dlb.order(ByteOrder.nativeOrder());
    indexBuffer = dlb.asShortBuffer();
    indexBuffer.put(indices);
    indexBuffer.position(0);
}
 
Example 15
Project: twister2   File: TestBinaryFileFormatter.java   View Source Code Vote up 4 votes
public static void main(String[] args) {
  Config.Builder builder = new Config.Builder();
  builder.put("input.file.path", "/home/pulasthi/git/twister2/twister2/"
      + "data/src/test/resources/2000.bin");
  Config txtFileConf = builder.build();
  Path path = new Path("/home/pulasthi/git/twister2/twister2/data/src/test/resources/2000.bin");
  InputFormat binaryInputFormatter = new BinaryInputFormatter(path, 2000 * Short.BYTES);
  binaryInputFormatter.configure(txtFileConf);
  int minSplits = 8;
  double expectedSum = 1.97973979E8;
  double newSum = 0.0;
  int count = 0;
  Buffer buffer = null;

  try {
    InputSplit[] inputSplits = binaryInputFormatter.createInputSplits(minSplits);
    InputSplitAssigner inputSplitAssigner = binaryInputFormatter.
        getInputSplitAssigner(inputSplits);
    InputSplit currentSplit;
    byte[] line = new byte[4000];
    ByteBuffer byteBuffer = ByteBuffer.allocate(4000);
    byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
    while ((currentSplit = inputSplitAssigner.getNextInputSplit(null, 0)) != null) {
      binaryInputFormatter.open(currentSplit);
      while (binaryInputFormatter.nextRecord(line) != null) {
        byteBuffer.clear();
        byteBuffer.put(line);
        byteBuffer.flip();
        buffer = byteBuffer.asShortBuffer();
        short[] shortArray = new short[2000];
        ((ShortBuffer) buffer).get(shortArray);
        for (short i : shortArray) {
          newSum += i;
          count++;
        }
      }
    }

    System.out.println(newSum);
    System.out.println(count);
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
Example 16
Project: AdronEngine   File: HitBox.java   View Source Code Vote up 4 votes
/**
 * same as draw in a Sprite but doesn't render a texture
 * @param gl
 */
@Override
public void draw(GL10 gl) {
    textureCoordinates = Alignment.getVertices(this, Alignment.LEFT_TOP);
    ByteBuffer byteBuf = ByteBuffer.allocateDirect(textureCoordinates.length * 4);
    byteBuf.order(ByteOrder.nativeOrder());

    mTextureBuffer = byteBuf.asFloatBuffer();
    mTextureBuffer.put(textureCoordinates);
    mTextureBuffer.position(0);

    float vertices[] = Alignment.getVertices(this, Alignment.LEFT_TOP);

    ByteBuffer vbb = ByteBuffer.allocateDirect(vertices.length * 4);
    vbb.order(ByteOrder.nativeOrder());

    vertexBuffer = vbb.asFloatBuffer();
    vertexBuffer.put(vertices);
    vertexBuffer.position(0);

    ByteBuffer ibb = ByteBuffer.allocateDirect(indices.length * 2);
    ibb.order(ByteOrder.nativeOrder());

    indexBuffer = ibb.asShortBuffer();
    indexBuffer.put(indices);
    indexBuffer.position(0);

    gl.glEnable(GL_BLEND);
    gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    gl.glColor4f(red / 100, green / 100, blue / 100, alpha / 100);

    gl.glFrontFace(GL10.GL_CCW);
    gl.glEnable(GL10.GL_CULL_FACE);
    gl.glCullFace(GL10.GL_BACK);

    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);


    gl.glEnable(GL10.GL_TEXTURE_2D);
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTextureBuffer);
    gl.glBindTexture(GL10.GL_TEXTURE_2D, 0);


    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
    gl.glDrawElements(GL10.GL_TRIANGLE_STRIP, indices.length, GL10.GL_UNSIGNED_SHORT, indexBuffer);
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glDisable(GL10.GL_CULL_FACE);
}
 
Example 17
Project: openjdk-jdk10   File: NativeInt16Array.java   View Source Code Vote up 4 votes
@Override
public Int16ArrayData createArrayData(final ByteBuffer nb, final int start, final int end) {
    return new Int16ArrayData(nb.asShortBuffer(), start, end);
}
 
Example 18
Project: Building-Android-UIs-with-Custom-Views   File: Object3D.java   View Source Code Vote up 4 votes
public void prepare() {
    if (coordinateList.size() > 0 && coordinates == null) {
        coordinates = new float[coordinateList.size()];
        for (int i = 0; i < coordinateList.size(); i++) {
            coordinates[i] = coordinateList.get(i);
        }
    }

    if (indexList.size() > 0 && indexes == null) {
        indexes = new short[indexList.size()];
        for (int i = 0; i < indexList.size(); i++) {
            indexes[i] = indexList.get(i);
        }
    }

    colors = new float[(coordinates.length/3) * 4];
    for (int i = 0; i < colors.length/4; i++) {
        float intensity = (float) (Math.random() * 0.5 + 0.4);
        colors[i * 4    ] = intensity;
        colors[i * 4 + 1] = intensity;
        colors[i * 4 + 2] = intensity;
        colors[i * 4 + 3] = 1.f;
    }

    ByteBuffer vbb = ByteBuffer.allocateDirect(coordinates.length * (Float.SIZE / 8));
    vbb.order(ByteOrder.nativeOrder());

    vertexBuffer = vbb.asFloatBuffer();
    vertexBuffer.put(coordinates);
    vertexBuffer.position(0);

    ByteBuffer ibb = ByteBuffer.allocateDirect(indexes.length * (Short.SIZE / 8));
    ibb.order(ByteOrder.nativeOrder());

    indexBuffer = ibb.asShortBuffer();
    indexBuffer.put(indexes);
    indexBuffer.position(0);

    ByteBuffer cbb = ByteBuffer.allocateDirect(colors.length * (Float.SIZE / 8));
    cbb.order(ByteOrder.nativeOrder());

    colorBuffer = cbb.asFloatBuffer();
    colorBuffer.put(colors);
    colorBuffer.position(0);

    Log.i(TAG, "Loaded obj with " + coordinates.length + " vertices & " + (indexes.length/3) + " faces");
}
 
Example 19
Project: MegviiFacepp-Android-SDK   File: PointsMatrix.java   View Source Code Vote up 4 votes
public PointsMatrix(boolean isFaceCompare) {
	// FloatBuffer fb_0 = floatBufferUtil(squareCoords);
	// FloatBuffer fb_1 = floatBufferUtil(squareCoords_1);
	// vertexBuffers.add(fb_0);
	// vertexBuffers.add(fb_1);
	// initialize byte buffer for the draw list
	this.isFaceCompare = isFaceCompare;

	ByteBuffer dlb = ByteBuffer.allocateDirect(
			// (# of coordinate values * 2 bytes per short)
			drawOrder.length * 2);
	dlb.order(ByteOrder.nativeOrder());
	drawListBuffer = dlb.asShortBuffer();
	drawListBuffer.put(drawOrder);
	drawListBuffer.position(0);
	ByteBuffer line_dlb = ByteBuffer.allocateDirect(
			// (# of coordinate values * 2 bytes per short)
			drawLineOrder.length * 2);
	line_dlb.order(ByteOrder.nativeOrder());
	drawLineListBuffer = line_dlb.asShortBuffer();
	drawLineListBuffer.put(drawLineOrder);
	drawLineListBuffer.position(0);
	for (int i = 0; i < cubeOrders.length; ++i) {
		final short cubeOrder[] = cubeOrders[i];
		ByteBuffer cubedlb = ByteBuffer.allocateDirect(
				// (# of coordinate values * 2 bytes per short)
				cubeOrder.length * 2);
		cubedlb.order(ByteOrder.nativeOrder());
		cubeListBuffer[i] = cubedlb.asShortBuffer();
		cubeListBuffer[i].put(cubeOrder);
		cubeListBuffer[i].position(0);
	}

	ByteBuffer faceRectLDB = ByteBuffer.allocateDirect(drawFaceRectOrder.length * 2);
	faceRectLDB.order(ByteOrder.nativeOrder());
	faceRectListBuffer = faceRectLDB.asShortBuffer();
	faceRectListBuffer.put(drawFaceRectOrder);
	faceRectListBuffer.position(0);

	// prepare shaders and OpenGL program
	int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexShaderCode);
	int fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentShaderCode);

	mProgram = GLES20.glCreateProgram(); // create empty OpenGL Program
	GLES20.glAttachShader(mProgram, vertexShader); // add the vertex shader
	// to program
	GLES20.glAttachShader(mProgram, fragmentShader); // add the fragment
	// shader to program
	GLES20.glLinkProgram(mProgram); // create OpenGL program executables
}
 
Example 20
Project: jdk8u-jdk   File: TrueTypeFont.java   View Source Code Vote up 4 votes
protected String lookupName(short findLocaleID, int findNameID) {
    String foundName = null;
    byte[] name = new byte[1024];

    ByteBuffer buffer = getTableBuffer(nameTag);
    if (buffer != null) {
        ShortBuffer sbuffer = buffer.asShortBuffer();
        sbuffer.get(); // format - not needed.
        short numRecords = sbuffer.get();

        /* The name table uses unsigned shorts. Many of these
         * are known small values that fit in a short.
         * The values that are sizes or offsets into the table could be
         * greater than 32767, so read and store those as ints
         */
        int stringPtr = ((int) sbuffer.get()) & 0xffff;

        for (int i=0; i<numRecords; i++) {
            short platformID = sbuffer.get();
            if (platformID != MS_PLATFORM_ID) {
                sbuffer.position(sbuffer.position()+5);
                continue; // skip over this record.
            }
            short encodingID = sbuffer.get();
            short langID     = sbuffer.get();
            short nameID     = sbuffer.get();
            int   nameLen    = ((int) sbuffer.get()) & 0xffff;
            int   namePtr    = (((int) sbuffer.get()) & 0xffff) + stringPtr;
            if (nameID == findNameID &&
                ((foundName == null && langID == ENGLISH_LOCALE_ID)
                 || langID == findLocaleID)) {
                buffer.position(namePtr);
                buffer.get(name, 0, nameLen);
                foundName = makeString(name, nameLen, encodingID);
                if (langID == findLocaleID) {
                    return foundName;
                }
            }
        }
    }
    return foundName;
}