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


Java ShortBuffer.remaining方法代码示例

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


在下文中一共展示了ShortBuffer.remaining方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drainOverflow

import java.nio.ShortBuffer; //导入方法依赖的package包/类
private long drainOverflow(final ShortBuffer outBuff) {
    final ShortBuffer overflowBuff = mOverflowBuffer.data;
    final int overflowLimit = overflowBuff.limit();
    final int overflowSize = overflowBuff.remaining();

    final long beginPresentationTimeUs = mOverflowBuffer.presentationTimeUs +
            sampleCountToDurationUs(overflowBuff.position(), mInputSampleRate, mOutputChannelCount);

    outBuff.clear();
    // Limit overflowBuff to outBuff's capacity
    overflowBuff.limit(outBuff.capacity());
    // Load overflowBuff onto outBuff
    outBuff.put(overflowBuff);

    if (overflowSize >= outBuff.capacity()) {
        // Overflow fully consumed - Reset
        overflowBuff.clear().limit(0);
    } else {
        // Only partially consumed - Keep position & restore previous limit
        overflowBuff.limit(overflowLimit);
    }

    return beginPresentationTimeUs;
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:25,代码来源:AudioChannel.java

示例2: drainOverflow

import java.nio.ShortBuffer; //导入方法依赖的package包/类
private long drainOverflow(final ShortBuffer outBuff) {
    final ShortBuffer overflowBuff = mOverflowBuffer.data;
    final int overflowLimit = overflowBuff.limit();
    final int overflowSize = overflowBuff.remaining();

    final long beginPresentationTimeUs = mOverflowBuffer.presentationTimeUs + sampleCountToDurationUs(overflowBuff.position(), mInputSampleRate,
            mOutputChannelCount);

    outBuff.clear();
    // Limit overflowBuff to outBuff's capacity
    overflowBuff.limit(outBuff.capacity());
    // Load overflowBuff onto outBuff
    outBuff.put(overflowBuff);

    if (overflowSize >= outBuff.capacity()) {
        // Overflow fully consumed - Reset
        overflowBuff.clear().limit(0);
    } else {
        // Only partially consumed - Keep position & restore previous limit
        overflowBuff.limit(overflowLimit);
    }

    return beginPresentationTimeUs;
}
 
开发者ID:uestccokey,项目名称:EZFilter,代码行数:25,代码来源:AudioChannel.java

示例3: ensureLargeEnough

import java.nio.ShortBuffer; //导入方法依赖的package包/类
public static ShortBuffer ensureLargeEnough(ShortBuffer buffer, int required) {
    if (buffer != null) {
        buffer.limit(buffer.capacity());
    }
    if (buffer == null || (buffer.remaining() < required)) {
        int position = (buffer != null ? buffer.position() : 0);
        ShortBuffer newVerts = createShortBuffer(position + required);
        if (buffer != null) {
            buffer.flip();
            newVerts.put(buffer);
            newVerts.position(position);
        }
        buffer = newVerts;
    }
    return buffer;
}
 
开发者ID:asiermarzo,项目名称:Ultraino,代码行数:17,代码来源:BufferUtils.java

示例4: remix

import java.nio.ShortBuffer; //导入方法依赖的package包/类
@Override
public void remix(final ShortBuffer inSBuff, final ShortBuffer outSBuff) {
    // Down-mix stereo to mono
    // Viktor Toth's algorithm -
    // See: http://www.vttoth.com/CMS/index.php/technical-notes/68
    //      http://stackoverflow.com/a/25102339
    final int inRemaining = inSBuff.remaining() / 2;
    final int outSpace = outSBuff.remaining();

    final int samplesToBeProcessed = Math.min(inRemaining, outSpace);
    for (int i = 0; i < samplesToBeProcessed; ++i) {
        // Convert to unsigned
        final int a = inSBuff.get() + SIGNED_SHORT_LIMIT;
        final int b = inSBuff.get() + SIGNED_SHORT_LIMIT;
        int m;
        // Pick the equation
        if ((a < SIGNED_SHORT_LIMIT) || (b < SIGNED_SHORT_LIMIT)) {
            // Viktor's first equation when both sources are "quiet"
            // (i.e. less than middle of the dynamic range)
            m = a * b / SIGNED_SHORT_LIMIT;
        } else {
            // Viktor's second equation when one or both sources are loud
            m = 2 * (a + b) - (a * b) / SIGNED_SHORT_LIMIT - UNSIGNED_SHORT_MAX;
        }
        // Convert output back to signed short
        if (m == UNSIGNED_SHORT_MAX + 1) m = UNSIGNED_SHORT_MAX;
        outSBuff.put((short) (m - SIGNED_SHORT_LIMIT));
    }
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:30,代码来源:AudioRemixer.java

示例5: remixAndMaybeFillOverflow

import java.nio.ShortBuffer; //导入方法依赖的package包/类
private long remixAndMaybeFillOverflow(final AudioBuffer input,
                                       final ShortBuffer outBuff) {
    final ShortBuffer inBuff = input.data;
    final ShortBuffer overflowBuff = mOverflowBuffer.data;

    outBuff.clear();

    // Reset position to 0, and set limit to capacity (Since MediaCodec doesn't do that for us)
    inBuff.clear();

    if (inBuff.remaining() > outBuff.remaining()) {
        // Overflow
        // Limit inBuff to outBuff's capacity
        inBuff.limit(outBuff.capacity());
        mRemixer.remix(inBuff, outBuff);

        // Reset limit to its own capacity & Keep position
        inBuff.limit(inBuff.capacity());

        // Remix the rest onto overflowBuffer
        // NOTE: We should only reach this point when overflow buffer is empty
        final long consumedDurationUs =
                sampleCountToDurationUs(inBuff.position(), mInputSampleRate, mInputChannelCount);
        mRemixer.remix(inBuff, overflowBuff);

        // Seal off overflowBuff & mark limit
        overflowBuff.flip();
        mOverflowBuffer.presentationTimeUs = input.presentationTimeUs + consumedDurationUs;
    } else {
        // No overflow
        mRemixer.remix(inBuff, outBuff);
    }

    return input.presentationTimeUs;
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:36,代码来源:AudioChannel.java

示例6: glBufferStorage

import java.nio.ShortBuffer; //导入方法依赖的package包/类
public static void glBufferStorage(int target, ShortBuffer data, int flags) {
    org.lwjgl.opengl.ARBBufferStorage.glBufferStorage(target, data, flags);
    if (Properties.PROFILE.enabled) {
        Context ctx = CURRENT_CONTEXT.get();
        BufferObject bo = ctx.bufferObjectBindings.get(target);
        if (bo != null) {
            bo.size = data != null ? data.remaining() << 1 : 0L;
        }
    }
}
 
开发者ID:LWJGLX,项目名称:debug,代码行数:11,代码来源:ARBBufferStorage.java

示例7: glBufferDataARB

import java.nio.ShortBuffer; //导入方法依赖的package包/类
public static void glBufferDataARB(int target, ShortBuffer data, int usage) {
    org.lwjgl.opengl.ARBVertexBufferObject.glBufferDataARB(target, data, usage);
    if (Properties.PROFILE.enabled) {
        Context ctx = CURRENT_CONTEXT.get();
        BufferObject bo = ctx.bufferObjectBindings.get(target);
        if (bo != null) {
            bo.size = data != null ? data.remaining() << 1 : 0L;
        }
    }
}
 
开发者ID:LWJGLX,项目名称:debug,代码行数:11,代码来源:ARBVertexBufferObject.java

示例8: glBufferStorage

import java.nio.ShortBuffer; //导入方法依赖的package包/类
public static void glBufferStorage(int target, ShortBuffer data, int flags) {
    org.lwjgl.opengl.GL44.glBufferStorage(target, data, flags);
    if (Properties.PROFILE.enabled) {
        Context ctx = CURRENT_CONTEXT.get();
        BufferObject bo = ctx.bufferObjectBindings.get(target);
        if (bo != null) {
            bo.size = data != null ? data.remaining() << 1 : 0L;
        }
    }
}
 
开发者ID:LWJGLX,项目名称:debug,代码行数:11,代码来源:GL44.java

示例9: glBufferData

import java.nio.ShortBuffer; //导入方法依赖的package包/类
public static void glBufferData(int target, ShortBuffer data, int usage) {
    org.lwjgl.opengl.GL15.glBufferData(target, data, usage);
    if (Properties.PROFILE.enabled) {
        Context ctx = CURRENT_CONTEXT.get();
        BufferObject bo = ctx.bufferObjectBindings.get(target);
        if (bo != null) {
            bo.size = data != null ? data.remaining() << 1 : 0L;
        }
    }
}
 
开发者ID:LWJGLX,项目名称:debug,代码行数:11,代码来源:GL15.java

示例10: remixAndMaybeFillOverflow

import java.nio.ShortBuffer; //导入方法依赖的package包/类
private long remixAndMaybeFillOverflow(final AudioBuffer input, final ShortBuffer outBuff) {
    final ShortBuffer inBuff = input.data;
    final ShortBuffer overflowBuff = mOverflowBuffer.data;

    outBuff.clear();

    // Reset position to 0, and set limit to capacity (Since MediaCodec doesn't do that for us)
    inBuff.clear();

    if (inBuff.remaining() > outBuff.remaining()) {
        // Overflow
        // Limit inBuff to outBuff's capacity
        inBuff.limit(outBuff.capacity());
        mRemixer.remix(inBuff, outBuff);

        // Reset limit to its own capacity & Keep position
        inBuff.limit(inBuff.capacity());

        // Remix the rest onto overflowBuffer
        // NOTE: We should only reach this point when overflow buffer is empty
        final long consumedDurationUs = sampleCountToDurationUs(inBuff.position(), mInputSampleRate, mInputChannelCount);
        mRemixer.remix(inBuff, overflowBuff);

        // Seal off overflowBuff & mark limit
        overflowBuff.flip();
        mOverflowBuffer.presentationTimeUs = input.presentationTimeUs + consumedDurationUs;
    } else {
        // No overflow
        mRemixer.remix(inBuff, outBuff);
    }

    return input.presentationTimeUs;
}
 
开发者ID:uestccokey,项目名称:EZFilter,代码行数:34,代码来源:AudioChannel.java

示例11: queueInput

import java.nio.ShortBuffer; //导入方法依赖的package包/类
/**
 * Queues remaining data from {@code buffer}, and advances its position by the number of bytes
 * consumed.
 *
 * @param buffer A {@link ShortBuffer} containing input data between its position and limit.
 */
public void queueInput(ShortBuffer buffer) {
  int samplesToWrite = buffer.remaining() / numChannels;
  int bytesToWrite = samplesToWrite * numChannels * 2;
  enlargeInputBufferIfNeeded(samplesToWrite);
  buffer.get(inputBuffer, numInputSamples * numChannels, bytesToWrite / 2);
  numInputSamples += samplesToWrite;
  processStreamInput();
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:15,代码来源:Sonic.java


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