本文整理了Java中org.bytedeco.javacpp.BytePointer.position()
方法的一些代码示例,展示了BytePointer.position()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BytePointer.position()
方法的具体详情如下:
包路径:org.bytedeco.javacpp.BytePointer
类名称:BytePointer
方法名:position
暂无
代码示例来源:origin: bytedeco/javacpp
/** Constructor to set the {@link #pointer}, {@link #sizes} and {@link #strides}. */
public ByteRawIndexer(BytePointer pointer, long[] sizes, long[] strides) {
super(sizes, strides);
this.pointer = pointer;
base = pointer.address() + pointer.position();
size = pointer.limit() - pointer.position();
}
代码示例来源:origin: bytedeco/javacpp
/** Constructor to set the {@link #pointer}, {@link #sizes} and {@link #strides}. */
public UByteRawIndexer(BytePointer pointer, long[] sizes, long[] strides) {
super(sizes, strides);
this.pointer = pointer;
base = pointer.address() + pointer.position();
size = pointer.limit() - pointer.position();
}
代码示例来源:origin: bytedeco/javacpp
/** Calls {@code ByteRawIndexer(pointer, { pointer.limit() - pointer.position() }, { 1 })}. */
public ByteRawIndexer(BytePointer pointer) {
this(pointer, new long[] { pointer.limit() - pointer.position() }, ONE_STRIDE);
}
代码示例来源:origin: bytedeco/javacpp
/** Calls {@code UByteRawIndexer(pointer, { pointer.limit() - pointer.position() }, { 1 })}. */
public UByteRawIndexer(BytePointer pointer) {
this(pointer, new long[] { pointer.limit() - pointer.position() }, ONE_STRIDE);
}
代码示例来源:origin: bytedeco/javacpp
/**
* For direct buffers, calls {@link Pointer#Pointer(Buffer)}, while for buffers
* backed with an array, allocates enough memory for the array and copies it.
*
* @param buffer the Buffer to reference or copy
* @see #put(byte[])
*/
public BytePointer(ByteBuffer buffer) {
super(buffer);
if (buffer != null && !buffer.isDirect() && buffer.hasArray()) {
byte[] array = buffer.array();
allocateArray(array.length - buffer.arrayOffset());
put(array, buffer.arrayOffset(), array.length - buffer.arrayOffset());
position(buffer.position());
limit(buffer.limit());
}
}
/**
代码示例来源:origin: bytedeco/javacpp
@Override public void release() {
pointer.position(position).put(array);
super.release();
}
};
代码示例来源:origin: bytedeco/javacpp
/** Returns {@code create(pointer, { pointer.limit() - pointer.position() }, { 1 }, true)} */
public static UByteIndexer create(BytePointer pointer) {
return create(pointer, new long[] { pointer.limit() - pointer.position() }, ONE_STRIDE);
}
代码示例来源:origin: bytedeco/javacpp
@Override public void release() {
pointer.position(position).put(array);
super.release();
}
};
代码示例来源:origin: bytedeco/javacpp
/** Returns {@code create(pointer, { pointer.limit() - pointer.position() }, { 1 }, true)} */
public static ByteIndexer create(BytePointer pointer) {
return create(pointer, new long[] { pointer.limit() - pointer.position() }, ONE_STRIDE);
}
代码示例来源:origin: bytedeco/javacpp
/**
* Creates a byte indexer to access efficiently the data of a pointer.
*
* @param pointer data to access via a buffer or to copy to an array
* @param direct {@code true} to use a direct buffer, see {@link Indexer} for details
* @return the new byte indexer backed by the raw memory interface, a buffer, or an array
*/
public static UByteIndexer create(final BytePointer pointer, long[] sizes, long[] strides, boolean direct) {
if (direct) {
return Raw.getInstance() != null ? new UByteRawIndexer(pointer, sizes, strides)
: new UByteBufferIndexer(pointer.asBuffer(), sizes, strides);
} else {
final long position = pointer.position();
byte[] array = new byte[(int)Math.min(pointer.limit() - position, Integer.MAX_VALUE)];
pointer.get(array);
return new UByteArrayIndexer(array, sizes, strides) {
@Override public void release() {
pointer.position(position).put(array);
super.release();
}
};
}
}
代码示例来源:origin: bytedeco/javacpp
/**
* Creates a byte indexer to access efficiently the data of a pointer.
*
* @param pointer data to access via a buffer or to copy to an array
* @param direct {@code true} to use a direct buffer, see {@link Indexer} for details
* @return the new byte indexer backed by the raw memory interface, a buffer, or an array
*/
public static ByteIndexer create(final BytePointer pointer, long[] sizes, long[] strides, boolean direct) {
if (direct) {
return Raw.getInstance() != null ? new ByteRawIndexer(pointer, sizes, strides)
: new ByteBufferIndexer(pointer.asBuffer(), sizes, strides);
} else {
final long position = pointer.position();
byte[] array = new byte[(int)Math.min(pointer.limit() - position, Integer.MAX_VALUE)];
pointer.get(array);
return new ByteArrayIndexer(array, sizes, strides) {
@Override public void release() {
pointer.position(position).put(array);
super.release();
}
};
}
}
代码示例来源:origin: org.janelia/H5J_Loader_Plugin
private void linewisePageCapture(final int width, int height, final int linesize, final BytePointer data, byte[] page) {
byte[] bytes = new byte[width * pixelBytes];
for (int y = 0; y
BytePointer ptr = data.position(lineInPagePos);
ptr.get(bytes);
System.arraycopy(bytes, 0, page, y * linesize, bytes.length);
}
}
代码示例来源:origin: org.janelia/H5J_Loader_Plugin
private void pagewisePageCapture(final int width, int height, final int linesize, final BytePointer data, byte[] page) {
BytePointer ptr = data.position(0);
ptr.get(page);
}
代码示例来源:origin: org.janelia/H5J_Loader_Plugin
@Override
public void accept(BytePointer data, int linesize, int width, int height) {
final String FILENAME_FORMAT = "image%05d.ppm";
// NOTE: This code must remain at Java version 1.6, for use in export
// in a separate library.
// Open file
OutputStream stream = null;
try {
stream = new FileOutputStream(String.format(FILENAME_FORMAT,frameNum));
// Write header
stream.write(("P6\n" + width + " " + height + "\n255\n").getBytes());
// Write pixel data
byte[] bytes = new byte[width * pixelBytes];
for (int y = 0; y
stream.write(bytes);
}
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
closeStream(stream);
}
}
代码示例来源:origin: hoary/JavaAV
/**
* Free the memory of sample buffers.
*/
public void clear() {
if (planePointers != null) {
for (int i = 0; i
}
planePointers = null;
}
}
代码示例来源:origin: org.bytedeco/javacv
private void writeSamples(int nb_samples) throws Exception {
if (samples_out == null || samples_out.length == 0) {
return;
}
frame.nb_samples(nb_samples);
avcodec_fill_audio_frame(frame, audio_c.channels(), audio_c.sample_fmt(), samples_out[0], (int)samples_out[0].position(), 0);
for (int i = 0; i
if (samples_out[0].position() > 0 && samples_out[0].position()
} else {
linesize = (int)Math.min(samples_out[i].limit(), Integer.MAX_VALUE);
}
frame.data(i, samples_out[i].position(0));
frame.linesize(i, linesize);
}
frame.quality(audio_c.global_quality());
record(frame);
}
代码示例来源:origin: io.antmedia/ant-media-server-common
private void writeSamples(int nb_samples) throws Exception {
if (samples_out == null || samples_out.length == 0) {
return;
}
frame.nb_samples(nb_samples);
avcodec_fill_audio_frame(frame, audio_c.channels(), audio_c.sample_fmt(), samples_out[0], (int)samples_out[0].position(), 0);
for (int i = 0; i
if (samples_out[0].position() > 0 && samples_out[0].position()
} else {
linesize = (int)Math.min(samples_out[i].limit(), Integer.MAX_VALUE);
}
frame.data(i, samples_out[i].position(0));
frame.linesize(i, linesize);
}
frame.quality(audio_c.global_quality());
record(frame);
}
代码示例来源:origin: org.bytedeco.javacpp-presets/leptonica
/** @return {@link PIX#data()} wrapped in a {@link ByteBuffer} starting at given byte index. */
public ByteBuffer createBuffer(int index) {
int h = pixGetHeight((PIX)this);
int wpl = pixGetWpl((PIX)this);
BytePointer data = new BytePointer(pixGetData((PIX)this)).position(index).capacity(h * wpl * 4);
return data.asByteBuffer();
}
代码示例来源:origin: hoary/JavaAV
public MediaPacket[] encodeAudio(AudioFrame audioFrame) throws JavaAVException {
if (audioFormat == null)
throw new JavaAVException("Could not encode audio. No audio format specified.");
List
AudioFormat srcFormat = audioFrame.getAudioFormat();
AudioFrame[] frames;
// create re-sampler if sample formats does not match
if (!srcFormat.equals(audioFormat)) {
if (audioResampler == null) {
audioResampler = new AudioResampler();
audioResampler.open(srcFormat, audioFormat, avContext.frame_size());
}
frames = audioResampler.resample(audioFrame);
}
else {
frames = new AudioFrame[]{audioFrame};
}
for (AudioFrame frame : frames) {
avcodec_get_frame_defaults(avFrame);
for (int i = 0; i avFrame.data(i, frame.getPlane(i).position(0));
avFrame.linesize(i, frame.getPlane(i).limit());
}
avFrame.nb_samples(frame.getSampleCount());
avFrame.quality(avContext.global_quality());
MediaPacket mediaPacket = encodeAudioFrame(avFrame);
packets.add(mediaPacket);
}
return packets.toArray(new MediaPacket[0]);
}
代码示例来源:origin: org.bytedeco.javacpp-presets/tensorflow
/** Returns {@link #tensor_data()} wrapped in a {@link Buffer} of appropriate type starting at given index. */
public B createBuffer(long index) {
BytePointer ptr = tensor_data();
long size = TotalBytes();
switch (dtype()) {
case DT_COMPLEX64:
case DT_FLOAT: return (B)new FloatPointer(ptr).position(index).capacity(size/4).asBuffer();
case DT_DOUBLE: return (B)new DoublePointer(ptr).position(index).capacity(size/8).asBuffer();
case DT_QINT32:
case DT_INT32: return (B)new IntPointer(ptr).position(index).capacity(size/4).asBuffer();
case DT_BOOL:
case DT_QUINT8:
case DT_UINT8:
case DT_QINT8:
case DT_INT8: return (B)ptr.position(index).capacity(size).asBuffer();
case DT_BFLOAT16:
case DT_INT16: return (B)new ShortPointer(ptr).position(index).capacity(size/2).asBuffer();
case DT_INT64: return (B)new LongPointer(ptr).position(index).capacity(size/8).asBuffer();
case DT_STRING:
default: assert false;
}
return null;
}