Package java.nio

Examples of java.nio.IntBuffer


            loadPffmTable(szPfmTable);
            FileInputStream fis = new FileInputStream(szIntTempFile);
            ByteBuffer bb = ByteBuffer.allocate(nIntByteSize * 3);
            ByteOrder bo = ByteOrder.BIG_ENDIAN;
            fis.read(bb.array());
            IntBuffer ib = bb.asIntBuffer();
            boolean swap = (ib.get(2) < 0 || ib.get(2) > MAX_NUM_CLASS_PRUNERS);
            if (swap) {
                bo = ByteOrder.LITTLE_ENDIAN;
                bb.order(bo);
                ib = bb.asIntBuffer();
            }
            int unicharset_size = ib.get(0);
            int NumClasses = ib.get(1);
            int NumClassPruners = ib.get(2);
            int version_id = 0;
            if (NumClasses < 0) {
                // handle version id
                version_id = -NumClasses;
                fis.read(bb.array(), 0, 4);
                NumClasses = ib.get(0);
            }   
            //this.ClassPruner.ensureCapacity(NumClassPruners);
            bb = ByteBuffer.allocate(nShortByteSize * unicharset_size);
            bb.order(bo);
            fis.read(bb.array());
            ShortBuffer sb = bb.asShortBuffer();
            for (int i=0; i<unicharset_size; i++) {
                this.IndexFor[i] = sb.get(i);
            }
            bb = ByteBuffer.allocate(nIntByteSize * NumClasses);
            bb.order(bo);
            fis.read(bb.array());
            ib = bb.asIntBuffer();
            for (int i=0; i<NumClasses; i++) {
                this.ClassIdFor[i] = ib.get(i);
            }
            ArrayList<byte[][][][]> ClassPruners = new ArrayList<byte[][][][]>();
            for (int i=0; i<NumClassPruners; i++) {
                byte[][][][] Pruner =
                        new byte[NUM_CP_BUCKETS][NUM_CP_BUCKETS][NUM_CP_BUCKETS][];
                bb = ByteBuffer.allocate(nIntByteSize * NUM_CP_BUCKETS *
                        NUM_CP_BUCKETS * NUM_CP_BUCKETS * WERDS_PER_CP_VECTOR);
                bb.order(bo);
                fis.read(bb.array());
                ib = bb.asIntBuffer();
                int p = 0;
                for (int j=0; j<NUM_CP_BUCKETS; j++) {
                    for (int k=0; k<NUM_CP_BUCKETS; k++) {
                        for (int l=0; l<NUM_CP_BUCKETS; l++) {
                            Pruner[j][k][l] =
                                new byte[CLASSES_PER_CP];
                            int nClass = 0;
                            for (int m=0; m<WERDS_PER_CP_VECTOR; m++) {
                                int nWord = ib.get(p++);
                                for (int n=0; n<CLASSES_PER_CP_WERD; n++) {
                                    Pruner[j][k][l][nClass++] = (byte) (nWord & 3);
                                    nWord >>>= 2;
                                }
                            }
View Full Code Here


            // Java doesn't have unsigned byte
            this.B = unsignedByteToShort(bb.get(1));
            this.C = bb.get(2) << 9;
            this.Angle = unsignedByteToShort(bb.get(3));
            int[] nInts = new int[WERDS_PER_CONFIG_VEC];
            IntBuffer ib = bb.asIntBuffer();
            for (int i=0; i<WERDS_PER_CONFIG_VEC; i++) {
                nInts[i] = ib.get(i+1);
            }
            setConfigBits(nInts);
        } catch (IOException ex) {
            Logger.getLogger(LearntFeature.class.getName()).log(Level.SEVERE, null, ex);
        }
View Full Code Here

            final int nIntByteSize = Integer.SIZE / Byte.SIZE;
            ByteBuffer bb = ByteBuffer.allocate(nIntByteSize * NUM_PP_PARAMS *
                    NUM_PP_BUCKETS * WERDS_PER_PP_VECTOR);
            bb.order(bo);
            fis.read(bb.array());
            IntBuffer ib = bb.asIntBuffer();
            int p = 0;
            for (int i=0; i<NUM_PP_PARAMS; i++) {
                for (int j=0; j<NUM_PP_BUCKETS; j++) {
                    for (int k=0; k<WERDS_PER_PP_VECTOR; k++) {
                        int nWord = ib.get(p++);
                        for (int l=0; l<Integer.SIZE && nWord != 0; l++) {
                            if ((nWord&1) == 1) {
                                this.ProtoPruner[i][j].set(k*Integer.SIZE+l);
                            }
                            nWord >>>= 1;
View Full Code Here

        if(_bigEndian != isBufBigEndian) {
            buf.order(_bigEndian ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN);
        }
        NIOUtils.readFully(channel, buf, _pageSize);
        buf.flip();
        IntBuffer ibuf = buf.asIntBuffer();
        int[] dst = new int[dstlen];
        ibuf.get(dst);
        return dst;
    }
View Full Code Here

  /**
   * Cleans up the test
   */
  private void cleanup() {
    // Destroy texture
    IntBuffer buffer = BufferUtils.createIntBuffer(1);
    buffer.put(0, texID);
    glDeleteTextures(buffer);

    texRenderer.destroy();
    Display.destroy();
  }
View Full Code Here

  private void glInit() {
    // Sync frame (only works on windows)
    Display.setVSyncEnabled(true);

    // Create shared texture
    IntBuffer buffer = BufferUtils.createIntBuffer(1);
    glGenTextures(buffer);
    texID = buffer.get(0);

    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    glEnable(GL_TEXTURE_2D);

    glBindTexture(GL_TEXTURE_2D, texID);
View Full Code Here

    direct_buffer.position(buffer.position());
    return direct_buffer;
  }

  private static IntBuffer doNoCopyWrap(IntBuffer buffer) {
    IntBuffer direct_buffer = lookupBuffer(buffer);
    direct_buffer.limit(buffer.limit());
    direct_buffer.position(buffer.position());
    return direct_buffer;
  }
View Full Code Here

    CachedBuffers buffers = getCachedBuffers(buffer.remaining()*4);
    return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.int_buffer_little : buffers.int_buffer_big;
  }

  private static IntBuffer doWrap(IntBuffer buffer) {
    IntBuffer direct_buffer = lookupBuffer(buffer);
    direct_buffer.clear();
    int saved_position = buffer.position();
    direct_buffer.put(buffer);
    buffer.position(saved_position);
    direct_buffer.flip();
    return direct_buffer;
  }
View Full Code Here

  private static PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format, RenderTexture renderTexture) throws LWJGLException {
    if ( renderTexture == null ) {
      // Though null is a perfectly valid argument, Matrox Parhelia drivers expect
      // a 0 terminated list, or else they crash. Supplying NULL or 0, should
      // cause the drivers to use default settings
      IntBuffer defaultAttribs = BufferUtils.createIntBuffer(1);
      return Display.getImplementation().createPbuffer(width, height, pixel_format, null, defaultAttribs);
    } else
      return Display.getImplementation().createPbuffer(width, height, pixel_format,
          renderTexture.pixelFormatCaps,
          renderTexture.pBufferAttribs);
View Full Code Here

   * Initializes ALC11, including any extensions
   * @return true if initialization was successfull
   */
  static boolean initialize() {
    try {
      IntBuffer ib = BufferUtils.createIntBuffer(2);
      ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MAJOR_VERSION, ib);
      ib.position(1);
      ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MINOR_VERSION, ib);

      int major = ib.get(0);
      int minor = ib.get(1);

      // checking for version 1.x+
      if(major >= 1) {

        // checking for version 1.1+
View Full Code Here

TOP

Related Classes of java.nio.IntBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.