Package java.nio

Examples of java.nio.ShortBuffer


          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_SHORT_ARRAY)) {
          arrayStart = this.getHeap().heap[getArrayStartAddress(fs.getAddress())];
          buf = ByteBuffer.allocate(arraySize * 2);
          ShortBuffer shortbuf = buf.asShortBuffer();
          shortbuf.put(this.getShortHeap().heap, arrayStart, arraySize);

          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_LONG_ARRAY)) {
          arrayStart = this.getHeap().heap[getArrayStartAddress(fs.getAddress())];
View Full Code Here


        if (bit_depth == 8) {
            for (int samp = 0; samp < number_samples; samp++)
                for (int chan = 0; chan < number_of_channels; chan++)
                    sample_values[chan][samp] = (double) byte_buffer.get() / max_sample_value;
        } else if (bit_depth == 16) {
            ShortBuffer short_buffer = byte_buffer.asShortBuffer();
            for (int samp = 0; samp < number_samples; samp++)
                for (int chan = 0; chan < number_of_channels; chan++)
                    sample_values[chan][samp] = (double) short_buffer.get() / max_sample_value;
        }

        // Return the samples
        return sample_values;
    }
View Full Code Here

                for (double[] sample_value1 : sample_values) {
                    double sample_value = sample_value1[samp] * max_sample_value;
                    byte_buffer.put((byte) sample_value);
                }
        } else if (bit_depth == 16) {
            ShortBuffer short_buffer = byte_buffer.asShortBuffer();
            for (int samp = 0; samp < sample_values[0].length; samp++)
                for (double[] sample_value1 : sample_values) {
                    double sample_value = sample_value1[samp] * max_sample_value;
                    short_buffer.put((short) sample_value);
                }
        }
    }
View Full Code Here

          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_SHORT_ARRAY)) {
          arrayStart = this.getHeap().heap[getArrayStartAddress(fs.getAddress())];
          buf = ByteBuffer.allocate(arraySize * 2);
          ShortBuffer shortbuf = buf.asShortBuffer();
          shortbuf.put(this.getShortHeap().heap, arrayStart, arraySize);

          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_LONG_ARRAY)) {
          arrayStart = this.getHeap().heap[getArrayStartAddress(fs.getAddress())];
View Full Code Here

          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_SHORT_ARRAY)) {
          arrayStart = this.getHeap().heap[getArrayStartAddress(fs.getAddress())];
          buf = ByteBuffer.allocate(arraySize * 2);
          ShortBuffer shortbuf = buf.asShortBuffer();
          shortbuf.put(this.getShortHeap().heap, arrayStart, arraySize);

          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_LONG_ARRAY)) {
          arrayStart = this.getHeap().heap[getArrayStartAddress(fs.getAddress())];
View Full Code Here

          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_SHORT_ARRAY)) {
          arrayStart = this.getHeap().heap[getArrayStartAddress(fs.getAddress())];
          buf = ByteBuffer.allocate(arraySize * 2);
          ShortBuffer shortbuf = buf.asShortBuffer();
          shortbuf.put(this.getShortHeap().heap, arrayStart, arraySize);

          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_LONG_ARRAY)) {
          arrayStart = this.getHeap().heap[getArrayStartAddress(fs.getAddress())];
View Full Code Here

                oldPosition * Sizeof.cl_short);
            buffer.position(oldPosition);
        }
        else if (buffer.hasArray())
        {
            ShortBuffer t = ShortBuffer.wrap(buffer.array());
            int elementOffset = buffer.position() + buffer.arrayOffset();
            result = Pointer.to(t).withByteOffset(
                elementOffset * Sizeof.cl_short);
        }
        else
View Full Code Here

  }

  /** Bulk output of a short array. */
  public void writeShorts (short[] object) throws KryoException {
    if (capacity - position >= object.length * 2 && isNativeOrder()) {
      ShortBuffer buf = niobuffer.asShortBuffer();
      buf.put(object);
      position += object.length * 2;
    } else
      super.writeShorts(object);
  }
View Full Code Here

    }

    public void doConversion(final ByteBuffer sourceData, final byte[] store, final int destX, final int destY,
            final int dataSize, final int tileSize) {
        final int offset = (destY * tileSize * dataSize + destX * tileSize) * 3;
        final ShortBuffer source = sourceData.asShortBuffer();
        try {
            int destIndex = offset;
            int sourceIndex = 0;
            for (int y = 0; y < tileSize; y++) {
                for (int x = 0; x < tileSize; x++) {
                    final short sourceShort = source.get(sourceIndex++);
                    // Mark wants us to shift off bottom 4 bits and cast.
                    final byte sourceValue = (byte) (sourceShort >> 4 & 0xFF);
                    store[destIndex++] = sourceValue;
                    store[destIndex++] = sourceValue;
                    store[destIndex++] = sourceValue;
View Full Code Here

          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_SHORT_ARRAY)) {
          arrayStart = this.getHeap().heap[getArrayStartAddress(fs.getAddress())];
          buf = ByteBuffer.allocate(arraySize * 2);
          ShortBuffer shortbuf = buf.asShortBuffer();
          shortbuf.put(this.getShortHeap().heap, arrayStart, arraySize);

          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_LONG_ARRAY)) {
          arrayStart = this.getHeap().heap[getArrayStartAddress(fs.getAddress())];
View Full Code Here

TOP

Related Classes of java.nio.ShortBuffer

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.