本文整理汇总了Java中org.bytedeco.javacpp.IntPointer类的典型用法代码示例。如果您正苦于以下问题:Java IntPointer类的具体用法?Java IntPointer怎么用?Java IntPointer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IntPointer类属于org.bytedeco.javacpp包,在下文中一共展示了IntPointer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Encoder
import org.bytedeco.javacpp.IntPointer; //导入依赖的package包/类
public Encoder(int sampleRate, int channels, int frameSize, int framesPerPacket,
int bitrate, int maxBufferSize) throws NativeAudioException {
mBuffer = new byte[maxBufferSize];
mAudioBuffer = new short[framesPerPacket * frameSize];
mFramesPerPacket = framesPerPacket;
mFrameSize = frameSize;
mBufferedFrames = 0;
mEncodedLength = 0;
mTerminated = false;
IntPointer error = new IntPointer(1);
error.put(0);
mState = opus_encoder_create(sampleRate, channels, OPUS_APPLICATION_VOIP, error);
if (error.get() < 0)
throw new NativeAudioException("Opus encoder initialization failed with error: " + getErrorMessage(error.get()));
opus_encoder_ctl(mState, OPUS_SET_VBR_REQUEST, 0);
opus_encoder_ctl(mState, OPUS_SET_BITRATE_REQUEST, bitrate);
}
示例2: perform
import org.bytedeco.javacpp.IntPointer; //导入依赖的package包/类
@Override
public void perform() {
if (!connected) {
return; // Don't waste any time converting images if there's no dashboard connected
}
if (inputSocket.getValue().get().empty()) {
throw new IllegalArgumentException("Input image must not be empty");
}
synchronized (imageLock) {
imencode(".jpeg", inputSocket.getValue().get(), imagePointer,
new IntPointer(CV_IMWRITE_JPEG_QUALITY, qualitySocket.getValue().get().intValue()));
imageLock.notifyAll();
}
}
示例3: perform
import org.bytedeco.javacpp.IntPointer; //导入依赖的package包/类
@Override
public void perform() {
if (!activeSocket.getValue().orElse(false)) {
return;
}
// don't save new image until period expires
if (stopwatch.elapsed(TimeUnit.MILLISECONDS)
< periodSocket.getValue().get().doubleValue() * 1000L) {
return;
}
stopwatch.reset();
stopwatch.start();
imencode("." + fileTypesSocket.getValue().get(), inputSocket.getValue().get(), imagePointer,
new IntPointer(CV_IMWRITE_JPEG_QUALITY, qualitySocket.getValue().get().intValue()));
byte[] buffer = new byte[128 * 1024];
int bufferSize = imagePointer.limit();
if (bufferSize > buffer.length) {
buffer = new byte[imagePointer.limit()];
}
imagePointer.get(buffer, 0, bufferSize);
fileManager.saveImage(buffer, LocalDateTime.now().format(formatter)
+ "." + fileTypesSocket.getValue().get());
}
示例4: isamax
import org.bytedeco.javacpp.IntPointer; //导入依赖的package包/类
@Override
protected int isamax(int N, INDArray X, int incX) {
if (Nd4j.dataType() != DataBuffer.Type.FLOAT)
logger.warn("FLOAT iamax called");
Nd4j.getExecutioner().push();
CudaContext ctx = allocator.getFlowController().prepareAction(null, X);
int ret2;
CublasPointer xCPointer = new CublasPointer(X, ctx);
cublasHandle_t handle = ctx.getHandle();
synchronized (handle) {
cublasSetStream_v2(new cublasContext(handle), new CUstream_st(ctx.getOldStream()));
IntPointer resultPointer = new IntPointer(new int[] {0});
cublasIsamax_v2(new cublasContext(handle), N, (FloatPointer) xCPointer.getDevicePointer(), incX,
resultPointer);
ret2 = resultPointer.get();
}
allocator.registerAction(ctx, null, X);
return ret2 - 1;
}
示例5: idamax
import org.bytedeco.javacpp.IntPointer; //导入依赖的package包/类
@Override
protected int idamax(int N, INDArray X, int incX) {
if (Nd4j.dataType() != DataBuffer.Type.DOUBLE)
logger.warn("DOUBLE imax called");
Nd4j.getExecutioner().push();
CudaContext ctx = allocator.getFlowController().prepareAction(null, X);
int ret2;
CublasPointer xCPointer = new CublasPointer(X, ctx);
cublasHandle_t handle = ctx.getHandle();
synchronized (handle) {
cublasSetStream_v2(new cublasContext(handle), new CUstream_st(ctx.getOldStream()));
IntPointer resultPointer = new IntPointer(new int[] {0});
cublasIdamax_v2(new cublasContext(handle), N, (DoublePointer) xCPointer.getDevicePointer(), incX,
resultPointer);
ret2 = resultPointer.get();
}
allocator.registerAction(ctx, null, X);
return ret2 - 1;
}
示例6: sortCooIndices
import org.bytedeco.javacpp.IntPointer; //导入依赖的package包/类
@Override
public INDArray sortCooIndices(INDArray x) {
if(x.getFormat() != SparseFormat.COO){
throw new UnsupportedOperationException("Not a COO ndarray");
}
BaseSparseNDArrayCOO array = (BaseSparseNDArrayCOO) x;
DataBuffer val = array.getValues();
DataBuffer idx = array.getIndices();
long length = val.length();
int rank = array.underlyingRank();
switch(val.dataType()){
case FLOAT:
NativeOpsHolder.getInstance().getDeviceNativeOps().sortCooIndicesFloat(null, (IntPointer) idx.addressPointer(), (FloatPointer) val.addressPointer(), length, rank);
break;
case DOUBLE:
NativeOpsHolder.getInstance().getDeviceNativeOps().sortCooIndicesDouble(null, (IntPointer) idx.addressPointer(), (DoublePointer) val.addressPointer(), length, rank);
break;
default:
throw new UnsupportedOperationException("Unknown datatype " + x.data().dataType());
}
return array;
}
示例7: sortSparseCooIndicesSort2
import org.bytedeco.javacpp.IntPointer; //导入依赖的package包/类
@Test
public void sortSparseCooIndicesSort2() throws Exception {
// FIXME: we don't want this test running on cuda for now
if (Nd4j.getExecutioner().getClass().getCanonicalName().toLowerCase().contains("cuda"))
return;
int indices[] = new int[] {0, 0, 0, 2, 2, 2, 1, 1, 1};
// we don't care about
double values[] = new double[] {2, 1, 3};
int expIndices[] = new int[] {0, 0, 0, 1, 1, 1, 2, 2, 2};
double expValues[] = new double[] {2, 3, 1};
DataBuffer idx = Nd4j.getDataBufferFactory().createInt(indices);
DataBuffer val = Nd4j.createBuffer(values);
NativeOpsHolder.getInstance().getDeviceNativeOps().sortCooIndicesFloat(null, (IntPointer) idx.addressPointer(),
(FloatPointer) val.addressPointer(), 3, 3);
assertArrayEquals(expIndices, idx.asInt());
assertArrayEquals(expValues, val.asDouble(), 1e-5);
}
示例8: getSupportedSampleFormats
import org.bytedeco.javacpp.IntPointer; //导入依赖的package包/类
/**
* Get all supported sample formats by this {@code Codec}. If this {@code Codec}
* is not an audio codec, then {@code null} is returned.
*
* @return all supported sample formats by this {@code Codec}.
*/
public SampleFormat[] getSupportedSampleFormats() {
IntPointer sampleFormatsPointer = avCodec.sample_fmts();
if (getType() != MediaType.AUDIO || sampleFormatsPointer == null)
return null;
List<SampleFormat> sampleFormats = new ArrayList<SampleFormat>();
int format;
int index = 0;
while ((format = sampleFormatsPointer.get(index++)) != -1)
sampleFormats.add(SampleFormat.byId(format));
return sampleFormats.toArray(new SampleFormat[0]);
}
示例9: getSupportedSampleRates
import org.bytedeco.javacpp.IntPointer; //导入依赖的package包/类
/**
* Get all supported sample rates by this {@code Codec}. If this {@code Codec}
* is not an audio codec, then {@code null} is returned. The sample rates are
* ordered in ascending order.
*
* @return all supported sample rates by this {@code Codec}.
*/
public Integer[] getSupportedSampleRates() {
IntPointer sampleRatesPointer = avCodec.supported_samplerates();
if (getType() != MediaType.AUDIO || sampleRatesPointer == null)
return null;
List<Integer> sampleRates = new ArrayList<Integer>();
int sampleRate;
int index = 0;
while ((sampleRate = sampleRatesPointer.get(index++)) != 0)
sampleRates.add(sampleRate);
// ascending order
Collections.sort(sampleRates);
return sampleRates.toArray(new Integer[0]);
}
示例10: getSupportedPixelFormats
import org.bytedeco.javacpp.IntPointer; //导入依赖的package包/类
/**
* Get all supported pixel formats by this {@code Codec}. If this {@code Codec}
* is not a video codec, then {@code null} is returned. The pixel formats are
* ordered in ascending order.
*
* @return all supported pixel formats by this {@code Codec}.
*/
public PixelFormat[] getSupportedPixelFormats() {
IntPointer formatsPointer = avCodec.pix_fmts();
if (getType() != MediaType.VIDEO || formatsPointer == null)
return null;
List<PixelFormat> pixelFormats = new ArrayList<PixelFormat>();
int format;
int index = 0;
while ((format = formatsPointer.get(index++)) != -1)
pixelFormats.add(PixelFormat.byId(format));
// ascending order
Collections.sort(pixelFormats);
return pixelFormats.toArray(new PixelFormat[0]);
}
示例11: Decoder
import org.bytedeco.javacpp.IntPointer; //导入依赖的package包/类
public Decoder(int sampleRate, int channels) throws NativeAudioException {
IntPointer error = new IntPointer(1);
error.put(0);
mState = opus_decoder_create(sampleRate, channels, error);
if (error.get() < 0)
throw new NativeAudioException("Opus decoder initialization failed with error: " + getErrorMessage(error.get()));
}
示例12: compress
import org.bytedeco.javacpp.IntPointer; //导入依赖的package包/类
@Override
public DataBuffer compress(DataBuffer buffer) {
INDArray temp = Nd4j.createArrayFromShapeBuffer(buffer, Nd4j.getShapeInfoProvider().createShapeInformation(new int[]{1, (int) buffer.length()}));
double max = temp.amaxNumber().doubleValue();
int cntAbs = temp.scan(Conditions.absGreaterThanOrEqual(max - (max * threshold))).intValue();
long originalLength = buffer.length() * Nd4j.sizeOfDataType(buffer.dataType());
int compressedLength = cntAbs + 3;
// first 3 elements contain header
IntPointer pointer = new IntPointer(compressedLength);
pointer.put(0, cntAbs);
pointer.put(1, (int) buffer.length());
pointer.put(2, Float.floatToIntBits(threshold)); // please note, this value will be ovewritten anyway
CompressionDescriptor descriptor = new CompressionDescriptor();
descriptor.setCompressedLength(compressedLength * 4); // sizeOf(INT)
descriptor.setOriginalLength(originalLength);
descriptor.setOriginalElementSize(Nd4j.sizeOfDataType(buffer.dataType()));
descriptor.setNumberOfElements(buffer.length());
descriptor.setCompressionAlgorithm(getDescriptor());
descriptor.setCompressionType(getCompressionType());
CompressedDataBuffer cbuff = new CompressedDataBuffer(pointer, descriptor);
Nd4j.getNDArrayFactory().convertDataEx(getBufferTypeEx(buffer), buffer.addressPointer(), DataBuffer.TypeEx.FTHRESHOLD, pointer, buffer.length());
Nd4j.getAffinityManager().tagLocation(buffer, AffinityManager.Location.HOST);
return cbuff;
}
示例13: sort
import org.bytedeco.javacpp.IntPointer; //导入依赖的package包/类
@Override
public INDArray sort(INDArray x, boolean descending) {
if (x.isScalar())
return x;
if (x.data().dataType() == DataBuffer.Type.FLOAT) {
NativeOpsHolder.getInstance().getDeviceNativeOps().sortFloat(null, (FloatPointer) x.data().addressPointer(), (IntPointer) x.shapeInfoDataBuffer().addressPointer(), descending);
} else if (x.data().dataType() == DataBuffer.Type.DOUBLE) {
NativeOpsHolder.getInstance().getDeviceNativeOps().sortDouble(null, (DoublePointer) x.data().addressPointer(), (IntPointer) x.shapeInfoDataBuffer().addressPointer(), descending);
} else {
throw new UnsupportedOperationException("Unknown dataype " + x.data().dataType());
}
return x;
}
示例14: compress
import org.bytedeco.javacpp.IntPointer; //导入依赖的package包/类
@Override
public DataBuffer compress(DataBuffer buffer) {
INDArray temp = Nd4j.createArrayFromShapeBuffer(buffer, Nd4j.getShapeInfoProvider().createShapeInformation(new int[]{1, (int) buffer.length()}).getFirst());
double max = temp.amaxNumber().doubleValue();
int cntAbs = temp.scan(Conditions.absGreaterThanOrEqual(max - (max * threshold))).intValue();
long originalLength = buffer.length() * Nd4j.sizeOfDataType(buffer.dataType());
int compressedLength = cntAbs + 4;
// first 3 elements contain header
IntPointer pointer = new IntPointer(compressedLength);
pointer.put(0, cntAbs);
pointer.put(1, (int) buffer.length());
pointer.put(2, Float.floatToIntBits(threshold)); // please note, this value will be ovewritten anyway
pointer.put(3, 0);
CompressionDescriptor descriptor = new CompressionDescriptor();
descriptor.setCompressedLength(compressedLength * 4); // sizeOf(INT)
descriptor.setOriginalLength(originalLength);
descriptor.setOriginalElementSize(Nd4j.sizeOfDataType(buffer.dataType()));
descriptor.setNumberOfElements(buffer.length());
descriptor.setCompressionAlgorithm(getDescriptor());
descriptor.setCompressionType(getCompressionType());
CompressedDataBuffer cbuff = new CompressedDataBuffer(pointer, descriptor);
Nd4j.getNDArrayFactory().convertDataEx(getBufferTypeEx(buffer), buffer.addressPointer(), DataBuffer.TypeEx.FTHRESHOLD, pointer, buffer.length());
Nd4j.getAffinityManager().tagLocation(buffer, AffinityManager.Location.HOST);
return cbuff;
}
示例15: compress
import org.bytedeco.javacpp.IntPointer; //导入依赖的package包/类
@Override
public DataBuffer compress(DataBuffer buffer) {
INDArray temp = Nd4j.createArrayFromShapeBuffer(buffer, Nd4j.getShapeInfoProvider().createShapeInformation(new int[]{1, (int) buffer.length()}).getFirst());
MatchCondition condition = new MatchCondition(temp, Conditions.absGreaterThanOrEqual(threshold));
int cntAbs = Nd4j.getExecutioner().exec(condition, Integer.MAX_VALUE).getInt(0);
//log.info("density ratio: {}", String.format("%.2f", cntAbs * 100.0f / buffer.length()));
if (cntAbs < 2)
return null;
long originalLength = buffer.length() * Nd4j.sizeOfDataType(buffer.dataType());
int compressedLength = cntAbs + 4;
// first 3 elements contain header
IntPointer pointer = new IntPointer(compressedLength);
pointer.put(0, cntAbs);
pointer.put(1, (int) buffer.length());
pointer.put(2, Float.floatToIntBits(threshold));
pointer.put(3, 0);
CompressionDescriptor descriptor = new CompressionDescriptor();
descriptor.setCompressedLength(compressedLength * 4); // sizeOf(INT)
descriptor.setOriginalLength(originalLength);
descriptor.setOriginalElementSize(Nd4j.sizeOfDataType(buffer.dataType()));
descriptor.setNumberOfElements(buffer.length());
descriptor.setCompressionAlgorithm(getDescriptor());
descriptor.setCompressionType(getCompressionType());
CompressedDataBuffer cbuff = new CompressedDataBuffer(pointer, descriptor);
Nd4j.getNDArrayFactory().convertDataEx(getBufferTypeEx(buffer), buffer.addressPointer(), DataBuffer.TypeEx.THRESHOLD, pointer, buffer.length());
Nd4j.getAffinityManager().tagLocation(buffer, AffinityManager.Location.HOST);
return cbuff;
}