/** Creates a new short buffer by wrapping the given short array. * <p> * Calling this method has the same effect as {@code wrap(array, 0, array.length)}. * </p> * * @param array the short array which the new buffer will be based on. * @return the created short buffer. * @since Android 1.0 */ public static ShortBuffer wrap (short[] array) { return wrap(array, 0, array.length); }
/** Creates a new short buffer by wrapping the given short array. * <p> * Calling this method has the same effect as {@code wrap(array, 0, array.length)}. * </p> * * @param array the short array which the new buffer will be based on. * @return the created short buffer. * @since Android 1.0 */ public static ShortBuffer wrap (short[] array) { return wrap(array, 0, array.length); }
/** * Creates a new short buffer by wrapping the given short array. * <p> * Calling this method has the same effect as * {@code wrap(array, 0, array.length)}. * * @param array * the short array which the new buffer will be based on. * @return the created short buffer. */ public static ShortBuffer wrap(short[] array) { return wrap(array, 0, array.length); }
/** * Create an run container with a run of ones from firstOfRun to lastOfRun. * * @param firstOfRun first index * @param lastOfRun last index (range is exclusive) */ public MappeableRunContainer(final int firstOfRun, final int lastOfRun) { this.nbrruns = 1; short[] vl = {(short) firstOfRun, (short) (lastOfRun - 1 - firstOfRun)}; this.valueslength = ShortBuffer.wrap(vl); }
BenchmarkContainer(short[] content) { this.content = ShortBuffer.wrap(content); this.length = content.length; }
private static MappeableArrayContainer arrayContainerOf(final int from, final int to, final int cardinality, final long[] words) { // precondition: cardinality is max 4096 final short[] content = new short[cardinality]; int index = 0; for (int i = from, socket = 0; i < to; ++i, socket += Long.SIZE) { long word = words[i]; while (word != 0) { content[index++] = (short) (socket + numberOfTrailingZeros(word)); word &= (word - 1); } } return new MappeableArrayContainer(ShortBuffer.wrap(content), cardinality); }
if(screenshot){ int screenshotSize = width * height; ByteBuffer bb = ByteBuffer.allocateDirect(screenshotSize * 4); bb.order(ByteOrder.nativeOrder()); gl.glReadPixels(0, 0, width, height, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, bb); int pixelsBuffer[] = new int[screenshotSize]; bb.asIntBuffer().get(pixelsBuffer); bb = null; Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); bitmap.setPixels(pixelsBuffer, screenshotSize-width, -width, 0, 0, width, height); pixelsBuffer = null; short sBuffer[] = new short[screenshotSize]; ShortBuffer sb = ShortBuffer.wrap(sBuffer); bitmap.copyPixelsToBuffer(sb); //Making created bitmap (from OpenGL points) compatible with Android bitmap for (int i = 0; i < screenshotSize; ++i) { short v = sBuffer[i]; sBuffer[i] = (short) (((v&0x1f) << 11) | (v&0x7e0) | ((v&0xf800) >> 11)); } sb.rewind(); bitmap.copyPixelsFromBuffer(sb); lastScreenshot = bitmap; screenshot = false; }
@Override public void trim() { if (this.content.limit() == this.cardinality) { return; } if (BufferUtil.isBackedBySimpleArray(content)) { this.content = ShortBuffer.wrap(Arrays.copyOf(content.array(), cardinality)); } else { final ShortBuffer co = ShortBuffer.allocate(this.cardinality); // can assume that new co is array backed short[] x = co.array(); for (int k = 0; k < this.cardinality; ++k) { x[k] = this.content.get(k); } this.content = co; } }
@Override public void trim() { if (valueslength.limit() == 2 * nbrruns) { return; } if (BufferUtil.isBackedBySimpleArray(valueslength)) { this.valueslength = ShortBuffer.wrap(Arrays.copyOf(valueslength.array(), 2 * nbrruns)); } else { final ShortBuffer co = ShortBuffer.allocate(2 * nbrruns); short[] a = co.array(); for (int k = 0; k < 2 * nbrruns; ++k) { a[k] = this.valueslength.get(k); } this.valueslength = co; } }
/** * Creates a new image by linking this images data to the data of the provider. * * @param metadata * The mata data to use. * @param data * The data to use. */ public SingleImage(ImageMetadata metadata, short[] data, String name) { this(ShortBuffer.wrap(data), metadata.width, metadata.height, metadata.offsetX, metadata.offsetY, name); }
/** * Create an run container with a run of ones from firstOfRun to lastOfRun. * * @param firstOfRun first index * @param lastOfRun last index (range is exclusive) */ public MappeableRunContainer(final int firstOfRun, final int lastOfRun) { this.nbrruns = 1; short[] vl = {(short) firstOfRun, (short) (lastOfRun - 1 - firstOfRun)}; this.valueslength = ShortBuffer.wrap(vl); }
/** * Creates a new short buffer by wrapping the given short array. * <p> * Calling this method has the same effect as * {@code wrap(array, 0, array.length)}. * * @param array * the short array which the new buffer will be based on. * @return the created short buffer. */ public static ShortBuffer wrap(short[] array) { return wrap(array, 0, array.length); }
@Override public ShortBuffer wrap(Object array) { return ShortBuffer.wrap((short[]) array); } }
/** Creates a new short buffer by wrapping the given short array. * <p> * Calling this method has the same effect as {@code wrap(array, 0, array.length)}. * </p> * * @param array the short array which the new buffer will be based on. * @return the created short buffer. * @since Android 1.0 */ public static ShortBuffer wrap (short[] array) { return wrap(array, 0, array.length); }
protected short[] loadData( final ByteBuffer bytes, final int numElements ) { final short[] data = new short[ numElements ]; ShortBuffer.wrap( data, 0, numElements ).put( bytes.asShortBuffer() ); return data; }
/** * Creates a new Pointer to the given values. * The values may not be null. * * @param values The values the pointer should point to * @return The pointer */ public static Pointer to(short values[]) { return new Pointer(ShortBuffer.wrap(values)); }
/** * Creates a new Pointer to the given values. * The values may not be null. * * @param values The values the pointer should point to * @return The pointer */ public static Pointer to(short values[]) { return new Pointer(ShortBuffer.wrap(values)); }
@Override public void save( final A access, final ByteBuffer out, final int numElements ) { final short[] data = access.getCurrentStorageArray(); out.asShortBuffer().put( ShortBuffer.wrap( data, 0, numElements ) ); } }
protected static ShortBuffer allocateShortBuffer(short[] arr) { if (USE_DIRECT_BUFFERS) { ShortBuffer buf = allocateDirectShortBuffer(arr.length); buf.put(arr); buf.position(0); return buf; } else { return ShortBuffer.wrap(arr); } }
@Override public void process(short[] input, int offset, int length) throws InterruptedException { if (canPassThrough(length)) { downstream.process(input, offset, length); } else { if (inputChannels == 1 && outputChannels == 2) { processMonoToStereo(ShortBuffer.wrap(input, offset, length)); } else { processNormalizer(ShortBuffer.wrap(input, offset, length)); } } }