當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript uint32array_builder.Uint32ArrayBuilder類代碼示例

本文整理匯總了TypeScript中neuroglancer/util/uint32array_builder.Uint32ArrayBuilder的典型用法代碼示例。如果您正苦於以下問題:TypeScript Uint32ArrayBuilder類的具體用法?TypeScript Uint32ArrayBuilder怎麽用?TypeScript Uint32ArrayBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Uint32ArrayBuilder類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: suite

suite('compressed_segmentation', () => {
  const blockSize = [8, 8, 8];
  const output = new Uint32ArrayBuilder(1000000);
  for (let volumeSize of [   //
           [16, 16, 16, 1],  //
                             // [64, 64, 64, 1],  //
  ]) {
    const numPossibleValues = 15;
    const input = makeRandomUint64Array(prod4(volumeSize), numPossibleValues);
    benchmark(`encode_uint64 ${vec3Key(volumeSize)}`, () => {
      output.clear();
      encodeChannelsUint64(output, blockSize, input, volumeSize);
    });
  }
});
開發者ID:google,項目名稱:neuroglancer,代碼行數:15,代碼來源:encode.benchmark.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:google,項目名稱: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:google,項目名稱:neuroglancer,代碼行數:39,代碼來源:encode_common.ts

示例4: benchmark

 benchmark(`encode_uint64 ${vec3Key(volumeSize)}`, () => {
   output.clear();
   encodeChannelsUint64(output, blockSize, input, volumeSize);
 });
開發者ID:google,項目名稱:neuroglancer,代碼行數:4,代碼來源:encode.benchmark.ts


注:本文中的neuroglancer/util/uint32array_builder.Uint32ArrayBuilder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。