当前位置: 首页>>代码示例>>Java>>正文


Java IntPointer.put方法代码示例

本文整理汇总了Java中org.bytedeco.javacpp.IntPointer.put方法的典型用法代码示例。如果您正苦于以下问题:Java IntPointer.put方法的具体用法?Java IntPointer.put怎么用?Java IntPointer.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bytedeco.javacpp.IntPointer的用法示例。


在下文中一共展示了IntPointer.put方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
 
开发者ID:Jack-Q,项目名称:messenger,代码行数:19,代码来源:OpusCodec.java

示例2: 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()));
}
 
开发者ID:Jack-Q,项目名称:messenger,代码行数:8,代码来源:OpusCodec.java

示例3: 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;
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:33,代码来源:CudaFlexibleThreshold.java

示例4: 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;
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:34,代码来源:CpuFlexibleThreshold.java

示例5: 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;
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:41,代码来源:CpuThreshold.java


注:本文中的org.bytedeco.javacpp.IntPointer.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。