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


TypeScript ts.Uint32ArrayBuilder.resize方法代码示例

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


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

示例1: encodeChannels

export function encodeChannels(
    output: Uint32ArrayBuilder, blockSize: ArrayLike<number>, rawData: Uint32Array,
    volumeSize: ArrayLike<number>, baseInputOffset: number, inputStrides: ArrayLike<number>,
    encodeBlock: EncodeBlockFunction) {
  let channelOffsetOutputBase = output.length;
  const numChannels = volumeSize[3];
  output.resize(channelOffsetOutputBase + numChannels);
  for (let channel = 0; channel < numChannels; ++channel) {
    output.data[channelOffsetOutputBase + channel] = output.length;
    encodeChannel(output, blockSize, rawData, volumeSize, baseInputOffset + inputStrides[3] * channel, inputStrides, encodeBlock);
  }
}
开发者ID:j6k4m8,项目名称:neuroglancer,代码行数:12,代码来源:encode_common.ts

示例2: writeBlock

export function writeBlock(
    output: Uint32ArrayBuilder, baseOffset: number, cache: ValueTableCache,
    numBlockElements: number, numUniqueValues: number, valuesBuffer2: Uint32Array,
    encodingBuffer: Uint32Array, indexBuffer2: Uint32Array,
    uint32sPerElement: number): [number, number] {
  let encodedBits: number;
  if (numUniqueValues === 1) {
    encodedBits = 0;
  } else {
    encodedBits = 1;
    while ((1 << encodedBits) < numUniqueValues) {
      encodedBits *= 2;
    }
  }

  let encodedSize32bits = Math.ceil(encodedBits * numBlockElements / 32);

  let encodedValueBaseOffset = output.length;
  let elementsToWrite = encodedSize32bits;

  let writeTable = false;
  let key = Array.prototype.join.call(
      valuesBuffer2.subarray(0, numUniqueValues * uint32sPerElement), ',');
  let tableOffset = cache.get(key);

  if (tableOffset === undefined) {
    writeTable = true;
    elementsToWrite += numUniqueValues * uint32sPerElement;
    tableOffset = encodedValueBaseOffset + encodedSize32bits - baseOffset;
    cache.set(key, tableOffset);
  }

  output.resize(encodedValueBaseOffset + elementsToWrite);
  let outputData = output.data;

  writeEncodedRepresentation(
      outputData, encodedValueBaseOffset, encodingBuffer, indexBuffer2, encodedBits,
      encodedSize32bits);

  // Write table
  if (writeTable) {
    let curOutputOff = encodedValueBaseOffset + encodedSize32bits;
    for (let i = 0, length = numUniqueValues * uint32sPerElement; i < length; ++i) {
      outputData[curOutputOff++] = valuesBuffer2[i];
    }
  }
  return [encodedBits, tableOffset];
}
开发者ID:j6k4m8,项目名称:neuroglancer,代码行数:48,代码来源:encode_common.ts

示例3: encodeChannel

export function encodeChannel(
    output: Uint32ArrayBuilder, blockSize: ArrayLike<number>, rawData: Uint32Array,
    volumeSize: ArrayLike<number>, baseInputOffset: number, inputStrides: ArrayLike<number>,
    encodeBlock: EncodeBlockFunction) {
  // Maps a sorted list of table entries in the form <low>,<high>,<low>,<high>,... to the table
  // offset relative to baseOffset.
  let cache = newCache();
  let gridSize = new Array<number>(3);
  let blockIndexSize = BLOCK_HEADER_SIZE;
  for (let i = 0; i < 3; ++i) {
    let curGridSize = gridSize[i] = Math.ceil(volumeSize[i] / blockSize[i]);
    blockIndexSize *= curGridSize;
  }
  const gx = gridSize[0], gy = gridSize[1], gz = gridSize[2];
  const xSize = volumeSize[0], ySize = volumeSize[1], zSize = volumeSize[2];
  const xBlockSize = blockSize[0], yBlockSize = blockSize[1], zBlockSize = blockSize[2];
  const baseOffset = output.length;
  let headerOffset = baseOffset;
  const actualSize = [0, 0, 0];
  output.resize(baseOffset + blockIndexSize);
  let sx = inputStrides[0], sy = inputStrides[1], sz = inputStrides[2];
  for (let bz = 0; bz < gz; ++bz) {
    actualSize[2] = Math.min(zBlockSize, zSize - bz * zBlockSize);
    for (let by = 0; by < gy; ++by) {
      actualSize[1] = Math.min(yBlockSize, ySize - by * yBlockSize);
      for (let bx = 0; bx < gx; ++bx) {
        actualSize[0] = Math.min(xBlockSize, xSize - bx * xBlockSize);
        let inputOffset = bz * zBlockSize * sz + by * yBlockSize * sy + bx * xBlockSize * sx;
        let encodedValueBaseOffset = output.length - baseOffset;
        let [encodedBits, tableOffset] = encodeBlock(
            rawData, baseInputOffset + inputOffset, inputStrides, blockSize, actualSize, baseOffset,
            cache, output);
        let outputData = output.data;
        outputData[headerOffset++] = tableOffset | (encodedBits << 24);
        outputData[headerOffset++] = encodedValueBaseOffset;
      }
    }
  }
}
开发者ID:funkey,项目名称:neuroglancer,代码行数:39,代码来源:encode_common.ts


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