MCPcopy Create free account
hub / github.com/denoland/std / resliceBufferWithPadding

Function resliceBufferWithPadding

webgpu/row_padding.ts:74–91  ·  view source on GitHub ↗
(
  buffer: Uint8Array,
  width: number,
  height: number,
)

Source from the content-addressed store, hash-verified

72 */
73// deno-lint-ignore deno-style-guide/exported-function-args-maximum
74export function resliceBufferWithPadding(
75 buffer: Uint8Array,
76 width: number,
77 height: number,
78): Uint8Array {
79 const { padded, unpadded } = getRowPadding(width);
80 const outputBuffer = new Uint8Array(unpadded * height);
81
82 for (let i = 0; i < height; i++) {
83 const slice = buffer
84 .slice(i * padded, (i + 1) * padded)
85 .slice(0, unpadded);
86
87 outputBuffer.set(slice, i * unpadded);
88 }
89
90 return outputBuffer;
91}

Callers 1

Calls 3

getRowPaddingFunction · 0.85
setMethod · 0.65
sliceMethod · 0.45

Tested by

no test coverage detected