How to use getBlockBufferOffset method in wpt

Best JavaScript code snippet using wpt

jpg.js

Source:jpg.js Github

copy

Full Screen

...85 }86 }87 return code[0].children;88 }89 function getBlockBufferOffset(component, row, col) {90 return 64 * ((component.blocksPerLine + 1) * row + col);91 }92 function decodeScan(data, offset, frame, components, resetInterval,93 spectralStart, spectralEnd, successivePrev, successive) {94 var precision = frame.precision;95 var samplesPerLine = frame.samplesPerLine;96 var scanLines = frame.scanLines;97 var mcusPerLine = frame.mcusPerLine;98 var progressive = frame.progressive;99 var maxH = frame.maxH, maxV = frame.maxV;100 var startOffset = offset, bitsData = 0, bitsCount = 0;101 function readBit() {102 if (bitsCount > 0) {103 bitsCount--;104 return (bitsData >> bitsCount) & 1;105 }106 bitsData = data[offset++];107 if (bitsData === 0xFF) {108 var nextByte = data[offset++];109 if (nextByte) {110 throw 'unexpected marker: ' +111 ((bitsData << 8) | nextByte).toString(16);112 }113 // unstuff 0114 }115 bitsCount = 7;116 return bitsData >>> 7;117 }118 function decodeHuffman(tree) {119 var node = tree;120 while (true) {121 node = node[readBit()];122 if (typeof node === 'number') {123 return node;124 }125 if (typeof node !== 'object') {126 throw 'invalid huffman sequence';127 }128 }129 }130 function receive(length) {131 var n = 0;132 while (length > 0) {133 n = (n << 1) | readBit();134 length--;135 }136 return n;137 }138 function receiveAndExtend(length) {139 if (length === 1) {140 return readBit() === 1 ? 1 : -1;141 }142 var n = receive(length);143 if (n >= 1 << (length - 1)) {144 return n;145 }146 return n + (-1 << length) + 1;147 }148 function decodeBaseline(component, offset) {149 var t = decodeHuffman(component.huffmanTableDC);150 var diff = t === 0 ? 0 : receiveAndExtend(t);151 component.blockData[offset] = (component.pred += diff);152 var k = 1;153 while (k < 64) {154 var rs = decodeHuffman(component.huffmanTableAC);155 var s = rs & 15, r = rs >> 4;156 if (s === 0) {157 if (r < 15) {158 break;159 }160 k += 16;161 continue;162 }163 k += r;164 var z = dctZigZag[k];165 component.blockData[offset + z] = receiveAndExtend(s);166 k++;167 }168 }169 function decodeDCFirst(component, offset) {170 var t = decodeHuffman(component.huffmanTableDC);171 var diff = t === 0 ? 0 : (receiveAndExtend(t) << successive);172 component.blockData[offset] = (component.pred += diff);173 }174 function decodeDCSuccessive(component, offset) {175 component.blockData[offset] |= readBit() << successive;176 }177 var eobrun = 0;178 function decodeACFirst(component, offset) {179 if (eobrun > 0) {180 eobrun--;181 return;182 }183 var k = spectralStart, e = spectralEnd;184 while (k <= e) {185 var rs = decodeHuffman(component.huffmanTableAC);186 var s = rs & 15, r = rs >> 4;187 if (s === 0) {188 if (r < 15) {189 eobrun = receive(r) + (1 << r) - 1;190 break;191 }192 k += 16;193 continue;194 }195 k += r;196 var z = dctZigZag[k];197 component.blockData[offset + z] =198 receiveAndExtend(s) * (1 << successive);199 k++;200 }201 }202 var successiveACState = 0, successiveACNextValue;203 function decodeACSuccessive(component, offset) {204 var k = spectralStart;205 var e = spectralEnd;206 var r = 0;207 var s;208 var rs;209 while (k <= e) {210 var z = dctZigZag[k];211 switch (successiveACState) {212 case 0: // initial state213 rs = decodeHuffman(component.huffmanTableAC);214 s = rs & 15;215 r = rs >> 4;216 if (s === 0) {217 if (r < 15) {218 eobrun = receive(r) + (1 << r);219 successiveACState = 4;220 } else {221 r = 16;222 successiveACState = 1;223 }224 } else {225 if (s !== 1) {226 throw 'invalid ACn encoding';227 }228 successiveACNextValue = receiveAndExtend(s);229 successiveACState = r ? 2 : 3;230 }231 continue;232 case 1: // skipping r zero items233 case 2:234 if (component.blockData[offset + z]) {235 component.blockData[offset + z] += (readBit() << successive);236 } else {237 r--;238 if (r === 0) {239 successiveACState = successiveACState === 2 ? 3 : 0;240 }241 }242 break;243 case 3: // set value for a zero item244 if (component.blockData[offset + z]) {245 component.blockData[offset + z] += (readBit() << successive);246 } else {247 component.blockData[offset + z] =248 successiveACNextValue << successive;249 successiveACState = 0;250 }251 break;252 case 4: // eob253 if (component.blockData[offset + z]) {254 component.blockData[offset + z] += (readBit() << successive);255 }256 break;257 }258 k++;259 }260 if (successiveACState === 4) {261 eobrun--;262 if (eobrun === 0) {263 successiveACState = 0;264 }265 }266 }267 function decodeMcu(component, decode, mcu, row, col) {268 var mcuRow = (mcu / mcusPerLine) | 0;269 var mcuCol = mcu % mcusPerLine;270 var blockRow = mcuRow * component.v + row;271 var blockCol = mcuCol * component.h + col;272 var offset = getBlockBufferOffset(component, blockRow, blockCol);273 decode(component, offset);274 }275 function decodeBlock(component, decode, mcu) {276 var blockRow = (mcu / component.blocksPerLine) | 0;277 var blockCol = mcu % component.blocksPerLine;278 var offset = getBlockBufferOffset(component, blockRow, blockCol);279 decode(component, offset);280 }281 var componentsLength = components.length;282 var component, i, j, k, n;283 var decodeFn;284 if (progressive) {285 if (spectralStart === 0) {286 decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;287 } else {288 decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;289 }290 } else {291 decodeFn = decodeBaseline;292 }293 var mcu = 0, marker;294 var mcuExpected;295 if (componentsLength === 1) {296 mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;297 } else {298 mcuExpected = mcusPerLine * frame.mcusPerColumn;299 }300 if (!resetInterval) {301 resetInterval = mcuExpected;302 }303 var h, v;304 while (mcu < mcuExpected) {305 // reset interval stuff306 for (i = 0; i < componentsLength; i++) {307 components[i].pred = 0;308 }309 eobrun = 0;310 if (componentsLength === 1) {311 component = components[0];312 for (n = 0; n < resetInterval; n++) {313 decodeBlock(component, decodeFn, mcu);314 mcu++;315 }316 } else {317 for (n = 0; n < resetInterval; n++) {318 for (i = 0; i < componentsLength; i++) {319 component = components[i];320 h = component.h;321 v = component.v;322 for (j = 0; j < v; j++) {323 for (k = 0; k < h; k++) {324 decodeMcu(component, decodeFn, mcu, j, k);325 }326 }327 }328 mcu++;329 }330 }331 // find marker332 bitsCount = 0;333 marker = (data[offset] << 8) | data[offset + 1];334 if (marker <= 0xFF00) {335 throw 'marker was not found';336 }337 if (marker >= 0xFFD0 && marker <= 0xFFD7) { // RSTx338 offset += 2;339 } else {340 break;341 }342 }343 return offset - startOffset;344 }345 // A port of poppler's IDCT method which in turn is taken from:346 // Christoph Loeffler, Adriaan Ligtenberg, George S. Moschytz,347 // 'Practical Fast 1-D DCT Algorithms with 11 Multiplications',348 // IEEE Intl. Conf. on Acoustics, Speech & Signal Processing, 1989,349 // 988-991.350 function quantizeAndInverse(component, blockBufferOffset, p) {351 var qt = component.quantizationTable, blockData = component.blockData;352 var v0, v1, v2, v3, v4, v5, v6, v7;353 var p0, p1, p2, p3, p4, p5, p6, p7;354 var t;355 // inverse DCT on rows356 for (var row = 0; row < 64; row += 8) {357 // gather block data358 p0 = blockData[blockBufferOffset + row];359 p1 = blockData[blockBufferOffset + row + 1];360 p2 = blockData[blockBufferOffset + row + 2];361 p3 = blockData[blockBufferOffset + row + 3];362 p4 = blockData[blockBufferOffset + row + 4];363 p5 = blockData[blockBufferOffset + row + 5];364 p6 = blockData[blockBufferOffset + row + 6];365 p7 = blockData[blockBufferOffset + row + 7];366 // dequant p0367 p0 *= qt[row];368 // check for all-zero AC coefficients369 if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {370 t = (dctSqrt2 * p0 + 512) >> 10;371 p[row] = t;372 p[row + 1] = t;373 p[row + 2] = t;374 p[row + 3] = t;375 p[row + 4] = t;376 p[row + 5] = t;377 p[row + 6] = t;378 p[row + 7] = t;379 continue;380 }381 // dequant p1 ... p7382 p1 *= qt[row + 1];383 p2 *= qt[row + 2];384 p3 *= qt[row + 3];385 p4 *= qt[row + 4];386 p5 *= qt[row + 5];387 p6 *= qt[row + 6];388 p7 *= qt[row + 7];389 // stage 4390 v0 = (dctSqrt2 * p0 + 128) >> 8;391 v1 = (dctSqrt2 * p4 + 128) >> 8;392 v2 = p2;393 v3 = p6;394 v4 = (dctSqrt1d2 * (p1 - p7) + 128) >> 8;395 v7 = (dctSqrt1d2 * (p1 + p7) + 128) >> 8;396 v5 = p3 << 4;397 v6 = p5 << 4;398 // stage 3399 v0 = (v0 + v1 + 1) >> 1;400 v1 = v0 - v1;401 t = (v2 * dctSin6 + v3 * dctCos6 + 128) >> 8;402 v2 = (v2 * dctCos6 - v3 * dctSin6 + 128) >> 8;403 v3 = t;404 v4 = (v4 + v6 + 1) >> 1;405 v6 = v4 - v6;406 v7 = (v7 + v5 + 1) >> 1;407 v5 = v7 - v5;408 // stage 2409 v0 = (v0 + v3 + 1) >> 1;410 v3 = v0 - v3;411 v1 = (v1 + v2 + 1) >> 1;412 v2 = v1 - v2;413 t = (v4 * dctSin3 + v7 * dctCos3 + 2048) >> 12;414 v4 = (v4 * dctCos3 - v7 * dctSin3 + 2048) >> 12;415 v7 = t;416 t = (v5 * dctSin1 + v6 * dctCos1 + 2048) >> 12;417 v5 = (v5 * dctCos1 - v6 * dctSin1 + 2048) >> 12;418 v6 = t;419 // stage 1420 p[row] = v0 + v7;421 p[row + 7] = v0 - v7;422 p[row + 1] = v1 + v6;423 p[row + 6] = v1 - v6;424 p[row + 2] = v2 + v5;425 p[row + 5] = v2 - v5;426 p[row + 3] = v3 + v4;427 p[row + 4] = v3 - v4;428 }429 // inverse DCT on columns430 for (var col = 0; col < 8; ++col) {431 p0 = p[col];432 p1 = p[col + 8];433 p2 = p[col + 16];434 p3 = p[col + 24];435 p4 = p[col + 32];436 p5 = p[col + 40];437 p6 = p[col + 48];438 p7 = p[col + 56];439 // check for all-zero AC coefficients440 if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {441 t = (dctSqrt2 * p0 + 8192) >> 14;442 // convert to 8 bit443 t = (t < -2040) ? 0 : (t >= 2024) ? 255 : (t + 2056) >> 4;444 blockData[blockBufferOffset + col] = t;445 blockData[blockBufferOffset + col + 8] = t;446 blockData[blockBufferOffset + col + 16] = t;447 blockData[blockBufferOffset + col + 24] = t;448 blockData[blockBufferOffset + col + 32] = t;449 blockData[blockBufferOffset + col + 40] = t;450 blockData[blockBufferOffset + col + 48] = t;451 blockData[blockBufferOffset + col + 56] = t;452 continue;453 }454 // stage 4455 v0 = (dctSqrt2 * p0 + 2048) >> 12;456 v1 = (dctSqrt2 * p4 + 2048) >> 12;457 v2 = p2;458 v3 = p6;459 v4 = (dctSqrt1d2 * (p1 - p7) + 2048) >> 12;460 v7 = (dctSqrt1d2 * (p1 + p7) + 2048) >> 12;461 v5 = p3;462 v6 = p5;463 // stage 3464 // Shift v0 by 128.5 << 5 here, so we don't need to shift p0...p7 when465 // converting to UInt8 range later.466 v0 = ((v0 + v1 + 1) >> 1) + 4112;467 v1 = v0 - v1;468 t = (v2 * dctSin6 + v3 * dctCos6 + 2048) >> 12;469 v2 = (v2 * dctCos6 - v3 * dctSin6 + 2048) >> 12;470 v3 = t;471 v4 = (v4 + v6 + 1) >> 1;472 v6 = v4 - v6;473 v7 = (v7 + v5 + 1) >> 1;474 v5 = v7 - v5;475 // stage 2476 v0 = (v0 + v3 + 1) >> 1;477 v3 = v0 - v3;478 v1 = (v1 + v2 + 1) >> 1;479 v2 = v1 - v2;480 t = (v4 * dctSin3 + v7 * dctCos3 + 2048) >> 12;481 v4 = (v4 * dctCos3 - v7 * dctSin3 + 2048) >> 12;482 v7 = t;483 t = (v5 * dctSin1 + v6 * dctCos1 + 2048) >> 12;484 v5 = (v5 * dctCos1 - v6 * dctSin1 + 2048) >> 12;485 v6 = t;486 // stage 1487 p0 = v0 + v7;488 p7 = v0 - v7;489 p1 = v1 + v6;490 p6 = v1 - v6;491 p2 = v2 + v5;492 p5 = v2 - v5;493 p3 = v3 + v4;494 p4 = v3 - v4;495 // convert to 8-bit integers496 p0 = (p0 < 16) ? 0 : (p0 >= 4080) ? 255 : p0 >> 4;497 p1 = (p1 < 16) ? 0 : (p1 >= 4080) ? 255 : p1 >> 4;498 p2 = (p2 < 16) ? 0 : (p2 >= 4080) ? 255 : p2 >> 4;499 p3 = (p3 < 16) ? 0 : (p3 >= 4080) ? 255 : p3 >> 4;500 p4 = (p4 < 16) ? 0 : (p4 >= 4080) ? 255 : p4 >> 4;501 p5 = (p5 < 16) ? 0 : (p5 >= 4080) ? 255 : p5 >> 4;502 p6 = (p6 < 16) ? 0 : (p6 >= 4080) ? 255 : p6 >> 4;503 p7 = (p7 < 16) ? 0 : (p7 >= 4080) ? 255 : p7 >> 4;504 // store block data505 blockData[blockBufferOffset + col] = p0;506 blockData[blockBufferOffset + col + 8] = p1;507 blockData[blockBufferOffset + col + 16] = p2;508 blockData[blockBufferOffset + col + 24] = p3;509 blockData[blockBufferOffset + col + 32] = p4;510 blockData[blockBufferOffset + col + 40] = p5;511 blockData[blockBufferOffset + col + 48] = p6;512 blockData[blockBufferOffset + col + 56] = p7;513 }514 }515 function buildComponentData(frame, component) {516 var blocksPerLine = component.blocksPerLine;517 var blocksPerColumn = component.blocksPerColumn;518 var computationBuffer = new Int16Array(64);519 for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {520 for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {521 var offset = getBlockBufferOffset(component, blockRow, blockCol);522 quantizeAndInverse(component, offset, computationBuffer);523 }524 }525 return component.blockData;526 }527 function clamp0to255(a) {528 return a <= 0 ? 0 : a >= 255 ? 255 : a;529 }530 constructor.prototype = {531 parse: function parse(data) {532 function readUint16() {533 var value = (data[offset] << 8) | data[offset + 1];534 offset += 2;535 return value;...

Full Screen

Full Screen

jpeg.js

Source:jpeg.js Github

copy

Full Screen

...80 }81 }82 return code[0].children;83 }84 function getBlockBufferOffset(component, row, col) {85 return 64 * ((component.blocksPerLine + 1) * row + col);86 }87 function decodeScan(data, offset,88 frame, components, resetInterval,89 spectralStart, spectralEnd,90 successivePrev, successive) {91 var precision = frame.precision;92 var samplesPerLine = frame.samplesPerLine;93 var scanLines = frame.scanLines;94 var mcusPerLine = frame.mcusPerLine;95 var progressive = frame.progressive;96 var maxH = frame.maxH, maxV = frame.maxV;97 var startOffset = offset, bitsData = 0, bitsCount = 0;98 function readBit() {99 if (bitsCount > 0) {100 bitsCount--;101 return (bitsData >> bitsCount) & 1;102 }103 bitsData = data[offset++];104 if (bitsData == 0xFF) {105 var nextByte = data[offset++];106 if (nextByte) {107 throw "unexpected marker: " + ((bitsData << 8) | nextByte).toString(16);108 }109 // unstuff 0110 }111 bitsCount = 7;112 return bitsData >>> 7;113 }114 function decodeHuffman(tree) {115 var node = tree;116 var bit;117 while ((bit = readBit()) !== null) {118 node = node[bit];119 if (typeof node === 'number')120 return node;121 if (typeof node !== 'object')122 throw "invalid huffman sequence";123 }124 return null;125 }126 function receive(length) {127 var n = 0;128 while (length > 0) {129 var bit = readBit();130 if (bit === null)131 return;132 n = (n << 1) | bit;133 length--;134 }135 return n;136 }137 function receiveAndExtend(length) {138 var n = receive(length);139 if (n >= 1 << (length - 1))140 return n;141 return n + (-1 << length) + 1;142 }143 function decodeBaseline(component, offset) {144 var t = decodeHuffman(component.huffmanTableDC);145 var diff = t === 0 ? 0 : receiveAndExtend(t);146 component.blockData[offset] = (component.pred += diff);147 var k = 1;148 while (k < 64) {149 var rs = decodeHuffman(component.huffmanTableAC);150 var s = rs & 15, r = rs >> 4;151 if (s === 0) {152 if (r < 15)153 break;154 k += 16;155 continue;156 }157 k += r;158 var z = dctZigZag[k];159 component.blockData[offset + z] = receiveAndExtend(s);160 k++;161 }162 }163 function decodeDCFirst(component, offset) {164 var t = decodeHuffman(component.huffmanTableDC);165 var diff = t === 0 ? 0 : (receiveAndExtend(t) << successive);166 component.blockData[offset] = (component.pred += diff);167 }168 function decodeDCSuccessive(component, offset) {169 component.blockData[offset] |= readBit() << successive;170 }171 var eobrun = 0;172 function decodeACFirst(component, offset) {173 if (eobrun > 0) {174 eobrun--;175 return;176 }177 var k = spectralStart, e = spectralEnd;178 while (k <= e) {179 var rs = decodeHuffman(component.huffmanTableAC);180 var s = rs & 15, r = rs >> 4;181 if (s === 0) {182 if (r < 15) {183 eobrun = receive(r) + (1 << r) - 1;184 break;185 }186 k += 16;187 continue;188 }189 k += r;190 var z = dctZigZag[k];191 component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);192 k++;193 }194 }195 var successiveACState = 0, successiveACNextValue;196 function decodeACSuccessive(component, offset) {197 var k = spectralStart, e = spectralEnd, r = 0;198 while (k <= e) {199 var z = dctZigZag[k];200 switch (successiveACState) {201 case 0: // initial state202 var rs = decodeHuffman(component.huffmanTableAC);203 var s = rs & 15;204 r = rs >> 4;205 if (s === 0) {206 if (r < 15) {207 eobrun = receive(r) + (1 << r);208 successiveACState = 4;209 } else {210 r = 16;211 successiveACState = 1;212 }213 } else {214 if (s !== 1)215 throw "invalid ACn encoding";216 successiveACNextValue = receiveAndExtend(s);217 successiveACState = r ? 2 : 3;218 }219 continue;220 case 1: // skipping r zero items221 case 2:222 if (component.blockData[offset + z]) {223 component.blockData[offset + z] += (readBit() << successive);224 } else {225 r--;226 if (r === 0)227 successiveACState = successiveACState == 2 ? 3 : 0;228 }229 break;230 case 3: // set value for a zero item231 if (component.blockData[offset + z]) {232 component.blockData[offset + z] += (readBit() << successive);233 } else {234 component.blockData[offset + z] = successiveACNextValue << successive;235 successiveACState = 0;236 }237 break;238 case 4: // eob239 if (component.blockData[offset + z]) {240 component.blockData[offset + z] += (readBit() << successive);241 }242 break;243 }244 k++;245 }246 if (successiveACState === 4) {247 eobrun--;248 if (eobrun === 0)249 successiveACState = 0;250 }251 }252 function decodeMcu(component, decode, mcu, row, col) {253 var mcuRow = (mcu / mcusPerLine) | 0;254 var mcuCol = mcu % mcusPerLine;255 var blockRow = mcuRow * component.v + row;256 var blockCol = mcuCol * component.h + col;257 var offset = getBlockBufferOffset(component, blockRow, blockCol);258 decode(component, offset);259 }260 function decodeBlock(component, decode, mcu) {261 var blockRow = (mcu / component.blocksPerLine) | 0;262 var blockCol = mcu % component.blocksPerLine;263 var offset = getBlockBufferOffset(component, blockRow, blockCol);264 decode(component, offset);265 }266 var componentsLength = components.length;267 var component, i, j, k, n;268 var decodeFn;269 if (progressive) {270 if (spectralStart === 0)271 decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;272 else273 decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;274 } else {275 decodeFn = decodeBaseline;276 }277 var mcu = 0, marker;278 var mcuExpected;279 if (componentsLength == 1) {280 mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;281 } else {282 mcuExpected = mcusPerLine * frame.mcusPerColumn;283 }284 if (!resetInterval) {285 resetInterval = mcuExpected;286 }287 var h, v;288 while (mcu < mcuExpected) {289 // reset interval stuff290 for (i = 0; i < componentsLength; i++) {291 components[i].pred = 0;292 }293 eobrun = 0;294 if (componentsLength == 1) {295 component = components[0];296 for (n = 0; n < resetInterval; n++) {297 decodeBlock(component, decodeFn, mcu);298 mcu++;299 }300 } else {301 for (n = 0; n < resetInterval; n++) {302 for (i = 0; i < componentsLength; i++) {303 component = components[i];304 h = component.h;305 v = component.v;306 for (j = 0; j < v; j++) {307 for (k = 0; k < h; k++) {308 decodeMcu(component, decodeFn, mcu, j, k);309 }310 }311 }312 mcu++;313 }314 }315 // find marker316 bitsCount = 0;317 marker = (data[offset] << 8) | data[offset + 1];318 if (marker <= 0xFF00) {319 throw "marker was not found";320 }321 if (marker >= 0xFFD0 && marker <= 0xFFD7) { // RSTx322 offset += 2;323 } else {324 break;325 }326 }327 return offset - startOffset;328 }329 // A port of poppler's IDCT method which in turn is taken from:330 // Christoph Loeffler, Adriaan Ligtenberg, George S. Moschytz,331 // "Practical Fast 1-D DCT Algorithms with 11 Multiplications",332 // IEEE Intl. Conf. on Acoustics, Speech & Signal Processing, 1989,333 // 988-991.334 function quantizeAndInverse(component, blockBufferOffset, p) {335 var qt = component.quantizationTable;336 var v0, v1, v2, v3, v4, v5, v6, v7, t;337 var i;338 // dequant339 for (i = 0; i < 64; i++) {340 p[i] = component.blockData[blockBufferOffset + i] * qt[i];341 }342 // inverse DCT on rows343 for (i = 0; i < 8; ++i) {344 var row = 8 * i;345 // check for all-zero AC coefficients346 if (p[1 + row] === 0 && p[2 + row] === 0 && p[3 + row] === 0 &&347 p[4 + row] === 0 && p[5 + row] === 0 && p[6 + row] === 0 &&348 p[7 + row] === 0) {349 t = (dctSqrt2 * p[0 + row] + 512) >> 10;350 p[0 + row] = t;351 p[1 + row] = t;352 p[2 + row] = t;353 p[3 + row] = t;354 p[4 + row] = t;355 p[5 + row] = t;356 p[6 + row] = t;357 p[7 + row] = t;358 continue;359 }360 // stage 4361 v0 = (dctSqrt2 * p[0 + row] + 128) >> 8;362 v1 = (dctSqrt2 * p[4 + row] + 128) >> 8;363 v2 = p[2 + row];364 v3 = p[6 + row];365 v4 = (dctSqrt1d2 * (p[1 + row] - p[7 + row]) + 128) >> 8;366 v7 = (dctSqrt1d2 * (p[1 + row] + p[7 + row]) + 128) >> 8;367 v5 = p[3 + row] << 4;368 v6 = p[5 + row] << 4;369 // stage 3370 t = (v0 - v1 + 1) >> 1;371 v0 = (v0 + v1 + 1) >> 1;372 v1 = t;373 t = (v2 * dctSin6 + v3 * dctCos6 + 128) >> 8;374 v2 = (v2 * dctCos6 - v3 * dctSin6 + 128) >> 8;375 v3 = t;376 t = (v4 - v6 + 1) >> 1;377 v4 = (v4 + v6 + 1) >> 1;378 v6 = t;379 t = (v7 + v5 + 1) >> 1;380 v5 = (v7 - v5 + 1) >> 1;381 v7 = t;382 // stage 2383 t = (v0 - v3 + 1) >> 1;384 v0 = (v0 + v3 + 1) >> 1;385 v3 = t;386 t = (v1 - v2 + 1) >> 1;387 v1 = (v1 + v2 + 1) >> 1;388 v2 = t;389 t = (v4 * dctSin3 + v7 * dctCos3 + 2048) >> 12;390 v4 = (v4 * dctCos3 - v7 * dctSin3 + 2048) >> 12;391 v7 = t;392 t = (v5 * dctSin1 + v6 * dctCos1 + 2048) >> 12;393 v5 = (v5 * dctCos1 - v6 * dctSin1 + 2048) >> 12;394 v6 = t;395 // stage 1396 p[0 + row] = v0 + v7;397 p[7 + row] = v0 - v7;398 p[1 + row] = v1 + v6;399 p[6 + row] = v1 - v6;400 p[2 + row] = v2 + v5;401 p[5 + row] = v2 - v5;402 p[3 + row] = v3 + v4;403 p[4 + row] = v3 - v4;404 }405 // inverse DCT on columns406 for (i = 0; i < 8; ++i) {407 var col = i;408 // check for all-zero AC coefficients409 if (p[1 * 8 + col] === 0 && p[2 * 8 + col] === 0 && p[3 * 8 + col] === 0 &&410 p[4 * 8 + col] === 0 && p[5 * 8 + col] === 0 && p[6 * 8 + col] === 0 &&411 p[7 * 8 + col] === 0) {412 t = (dctSqrt2 * p[i + 0] + 8192) >> 14;413 p[0 * 8 + col] = t;414 p[1 * 8 + col] = t;415 p[2 * 8 + col] = t;416 p[3 * 8 + col] = t;417 p[4 * 8 + col] = t;418 p[5 * 8 + col] = t;419 p[6 * 8 + col] = t;420 p[7 * 8 + col] = t;421 continue;422 }423 // stage 4424 v0 = (dctSqrt2 * p[0 * 8 + col] + 2048) >> 12;425 v1 = (dctSqrt2 * p[4 * 8 + col] + 2048) >> 12;426 v2 = p[2 * 8 + col];427 v3 = p[6 * 8 + col];428 v4 = (dctSqrt1d2 * (p[1 * 8 + col] - p[7 * 8 + col]) + 2048) >> 12;429 v7 = (dctSqrt1d2 * (p[1 * 8 + col] + p[7 * 8 + col]) + 2048) >> 12;430 v5 = p[3 * 8 + col];431 v6 = p[5 * 8 + col];432 // stage 3433 t = (v0 - v1 + 1) >> 1;434 v0 = (v0 + v1 + 1) >> 1;435 v1 = t;436 t = (v2 * dctSin6 + v3 * dctCos6 + 2048) >> 12;437 v2 = (v2 * dctCos6 - v3 * dctSin6 + 2048) >> 12;438 v3 = t;439 t = (v4 - v6 + 1) >> 1;440 v4 = (v4 + v6 + 1) >> 1;441 v6 = t;442 t = (v7 + v5 + 1) >> 1;443 v5 = (v7 - v5 + 1) >> 1;444 v7 = t;445 // stage 2446 t = (v0 - v3 + 1) >> 1;447 v0 = (v0 + v3 + 1) >> 1;448 v3 = t;449 t = (v1 - v2 + 1) >> 1;450 v1 = (v1 + v2 + 1) >> 1;451 v2 = t;452 t = (v4 * dctSin3 + v7 * dctCos3 + 2048) >> 12;453 v4 = (v4 * dctCos3 - v7 * dctSin3 + 2048) >> 12;454 v7 = t;455 t = (v5 * dctSin1 + v6 * dctCos1 + 2048) >> 12;456 v5 = (v5 * dctCos1 - v6 * dctSin1 + 2048) >> 12;457 v6 = t;458 // stage 1459 p[0 * 8 + col] = v0 + v7;460 p[7 * 8 + col] = v0 - v7;461 p[1 * 8 + col] = v1 + v6;462 p[6 * 8 + col] = v1 - v6;463 p[2 * 8 + col] = v2 + v5;464 p[5 * 8 + col] = v2 - v5;465 p[3 * 8 + col] = v3 + v4;466 p[4 * 8 + col] = v3 - v4;467 }468 // convert to 8-bit integers469 for (i = 0; i < 64; ++i) {470 var index = blockBufferOffset + i;471 var q = p[i];472 q = (q <= -2056 / component.bitConversion) ? 0 :473 (q >= 2024 / component.bitConversion) ? 255 / component.bitConversion :474 (q + 2056 / component.bitConversion) >> 4;475 component.blockData[index] = q;476 }477 }478 function buildComponentData(frame, component) {479 var lines = [];480 var blocksPerLine = component.blocksPerLine;481 var blocksPerColumn = component.blocksPerColumn;482 var samplesPerLine = blocksPerLine << 3;483 var computationBuffer = new Int32Array(64);484 var i, j, ll = 0;485 for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {486 for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {487 var offset = getBlockBufferOffset(component, blockRow, blockCol);488 quantizeAndInverse(component, offset, computationBuffer);489 }490 }491 return component.blockData;492 }493 function clampToUint8(a) {494 return a <= 0 ? 0 : a >= 255 ? 255 : a | 0;495 }496 constructor.prototype = {497 load: function load(path) {498 var handleData = (function (data) {499 this.parse(data);500 if (this.onload)501 this.onload();502 }).bind(this);503 if (path.indexOf("data:") > -1) {504 var offset = path.indexOf("base64,") + 7;505 var data = atob(path.substring(offset));506 var arr = new Uint8Array(data.length);507 for (var i = data.length - 1; i >= 0; i--) {508 arr[i] = data.charCodeAt(i);509 }510 handleData(data);511 } else {512 var xhr = new XMLHttpRequest();513 xhr.open("GET", path, true);514 xhr.responseType = "arraybuffer";515 xhr.onload = (function () {516 // TODO catch parse error517 var data = new Uint8Array(xhr.response);518 handleData(data);519 }).bind(this);520 xhr.send(null);521 }522 },523 parse: function parse(data) {524 function readUint16() {525 var value = (data[offset] << 8) | data[offset + 1];526 offset += 2;527 return value;528 }529 function readDataBlock() {530 var length = readUint16();531 var array = data.subarray(offset, offset + length - 2);532 offset += array.length;533 return array;534 }535 function prepareComponents(frame) {536 var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);537 var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);538 for (var i = 0; i < frame.components.length; i++) {539 component = frame.components[i];540 var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);541 var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);542 var blocksPerLineForMcu = mcusPerLine * component.h;543 var blocksPerColumnForMcu = mcusPerColumn * component.v;544 var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);545 component.blockData = new Int16Array(blocksBufferSize);546 component.blocksPerLine = blocksPerLine;547 component.blocksPerColumn = blocksPerColumn;548 }549 frame.mcusPerLine = mcusPerLine;550 frame.mcusPerColumn = mcusPerColumn;551 }552 var offset = 0, length = data.length;553 var jfif = null;554 var adobe = null;555 var pixels = null;556 var frame, resetInterval;557 var quantizationTables = [];558 var huffmanTablesAC = [], huffmanTablesDC = [];559 var fileMarker = readUint16();560 if (fileMarker != 0xFFD8) { // SOI (Start of Image)561 throw "SOI not found";562 }563 fileMarker = readUint16();564 while (fileMarker != 0xFFD9) { // EOI (End of image)565 var i, j, l;566 switch (fileMarker) {567 case 0xFFE0: // APP0 (Application Specific)568 case 0xFFE1: // APP1569 case 0xFFE2: // APP2570 case 0xFFE3: // APP3571 case 0xFFE4: // APP4572 case 0xFFE5: // APP5573 case 0xFFE6: // APP6574 case 0xFFE7: // APP7575 case 0xFFE8: // APP8576 case 0xFFE9: // APP9577 case 0xFFEA: // APP10578 case 0xFFEB: // APP11579 case 0xFFEC: // APP12580 case 0xFFED: // APP13581 case 0xFFEE: // APP14582 case 0xFFEF: // APP15583 case 0xFFFE: // COM (Comment)584 var appData = readDataBlock();585 if (fileMarker === 0xFFE0) {586 if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 &&587 appData[3] === 0x46 && appData[4] === 0) { // 'JFIF\x00'588 jfif = {589 version: {major: appData[5], minor: appData[6]},590 densityUnits: appData[7],591 xDensity: (appData[8] << 8) | appData[9],592 yDensity: (appData[10] << 8) | appData[11],593 thumbWidth: appData[12],594 thumbHeight: appData[13],595 thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])596 };597 }598 }599 // TODO APP1 - Exif600 if (fileMarker === 0xFFEE) {601 if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F &&602 appData[3] === 0x62 && appData[4] === 0x65 && appData[5] === 0) { // 'Adobe\x00'603 adobe = {604 version: appData[6],605 flags0: (appData[7] << 8) | appData[8],606 flags1: (appData[9] << 8) | appData[10],607 transformCode: appData[11]608 };609 }610 }611 break;612 case 0xFFDB: // DQT (Define Quantization Tables)613 var quantizationTablesLength = readUint16();614 var quantizationTablesEnd = quantizationTablesLength + offset - 2;615 while (offset < quantizationTablesEnd) {616 var quantizationTableSpec = data[offset++];617 var tableData = new Int32Array(64);618 if ((quantizationTableSpec >> 4) === 0) { // 8 bit values619 for (j = 0; j < 64; j++) {620 var z = dctZigZag[j];621 tableData[z] = data[offset++];622 }623 } else if ((quantizationTableSpec >> 4) === 1) { //16 bit624 for (j = 0; j < 64; j++) {625 var zz = dctZigZag[j];626 tableData[zz] = readUint16();627 }628 } else629 throw "DQT: invalid table spec";630 quantizationTables[quantizationTableSpec & 15] = tableData;631 }632 break;633 case 0xFFC0: // SOF0 (Start of Frame, Baseline DCT)634 case 0xFFC1: // SOF1 (Start of Frame, Extended DCT)635 case 0xFFC2: // SOF2 (Start of Frame, Progressive DCT)636 if (frame) {637 throw "Only single frame JPEGs supported";638 }639 readUint16(); // skip data length640 frame = {};641 frame.extended = (fileMarker === 0xFFC1);642 frame.progressive = (fileMarker === 0xFFC2);643 frame.precision = data[offset++];644 frame.scanLines = readUint16();645 frame.samplesPerLine = readUint16();646 frame.components = [];647 frame.componentIds = {};648 var componentsCount = data[offset++], componentId;649 var maxH = 0, maxV = 0;650 for (i = 0; i < componentsCount; i++) {651 componentId = data[offset];652 var h = data[offset + 1] >> 4;653 var v = data[offset + 1] & 15;654 if (maxH < h)655 maxH = h;656 if (maxV < v)657 maxV = v;658 var qId = data[offset + 2];659 l = frame.components.push({660 h: h,661 v: v,662 quantizationTable: quantizationTables[qId],663 quantizationTableId: qId,664 bitConversion: 255 / ((1 << frame.precision) - 1)665 });666 frame.componentIds[componentId] = l - 1;667 offset += 3;668 }669 frame.maxH = maxH;670 frame.maxV = maxV;671 prepareComponents(frame);672 break;673 case 0xFFC4: // DHT (Define Huffman Tables)674 var huffmanLength = readUint16();675 for (i = 2; i < huffmanLength; ) {676 var huffmanTableSpec = data[offset++];677 var codeLengths = new Uint8Array(16);678 var codeLengthSum = 0;679 for (j = 0; j < 16; j++, offset++)680 codeLengthSum += (codeLengths[j] = data[offset]);681 var huffmanValues = new Uint8Array(codeLengthSum);682 for (j = 0; j < codeLengthSum; j++, offset++)683 huffmanValues[j] = data[offset];684 i += 17 + codeLengthSum;685 ((huffmanTableSpec >> 4) === 0 ?686 huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] =687 buildHuffmanTable(codeLengths, huffmanValues);688 }689 break;690 case 0xFFDD: // DRI (Define Restart Interval)691 readUint16(); // skip data length692 resetInterval = readUint16();693 break;694 case 0xFFDA: // SOS (Start of Scan)695 var scanLength = readUint16();696 var selectorsCount = data[offset++];697 var components = [], component;698 for (i = 0; i < selectorsCount; i++) {699 var componentIndex = frame.componentIds[data[offset++]];700 component = frame.components[componentIndex];701 var tableSpec = data[offset++];702 component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];703 component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];704 components.push(component);705 }706 var spectralStart = data[offset++];707 var spectralEnd = data[offset++];708 var successiveApproximation = data[offset++];709 var processed = decodeScan(data, offset,710 frame, components, resetInterval,711 spectralStart, spectralEnd,712 successiveApproximation >> 4, successiveApproximation & 15);713 offset += processed;714 break;715 case 0xFFFF: // Fill bytes716 if (data[offset] !== 0xFF) { // Avoid skipping a valid marker.717 offset--;718 }719 break;720 default:721 if (data[offset - 3] == 0xFF &&722 data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {723 // could be incorrect encoding -- last 0xFF byte of the previous724 // block was eaten by the encoder725 offset -= 3;726 break;727 }728 throw "unknown JPEG marker " + fileMarker.toString(16);729 }730 fileMarker = readUint16();731 }732 this.width = frame.samplesPerLine;733 this.height = frame.scanLines;734 this.jfif = jfif;735 this.adobe = adobe;736 this.components = [];737 switch (frame.components.length)738 {739 case 1:740 this.colorspace = ColorSpace.Grayscale;741 break;742 case 3:743 if (this.adobe)744 this.colorspace = ColorSpace.AdobeRGB;745 else746 this.colorspace = ColorSpace.RGB;747 break;748 case 4:749 this.colorspace = ColorSpace.CYMK;750 break;751 default:752 this.colorspace = ColorSpace.Unknown;753 }754 for (var i = 0; i < frame.components.length; i++) {755 var component = frame.components[i];756 if (!component.quantizationTable && component.quantizationTableId !== null)757 component.quantizationTable = quantizationTables[component.quantizationTableId];758 this.components.push({759 output: buildComponentData(frame, component),760 scaleX: component.h / frame.maxH,761 scaleY: component.v / frame.maxV,762 blocksPerLine: component.blocksPerLine,763 blocksPerColumn: component.blocksPerColumn,764 bitConversion: component.bitConversion765 });766 }767 },768 getData16: function getData16(width, height) {769 if (this.components.length !== 1)770 throw 'Unsupported color mode';771 var scaleX = this.width / width, scaleY = this.height / height;772 var component, componentScaleX, componentScaleY;773 var x, y, i;774 var offset = 0;775 var numComponents = this.components.length;776 var dataLength = width * height * numComponents;777 var data = new Uint16Array(dataLength);778 var componentLine;779 // lineData is reused for all components. Assume first component is780 // the biggest781 var lineData = new Uint16Array((this.components[0].blocksPerLine << 3) *782 this.components[0].blocksPerColumn * 8);783 // First construct image data ...784 for (i = 0; i < numComponents; i++) {785 component = this.components[i];786 var blocksPerLine = component.blocksPerLine;787 var blocksPerColumn = component.blocksPerColumn;788 var samplesPerLine = blocksPerLine << 3;789 var j, k, ll = 0;790 var lineOffset = 0;791 for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {792 var scanLine = blockRow << 3;793 for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {794 var bufferOffset = getBlockBufferOffset(component, blockRow, blockCol);795 var offset = 0, sample = blockCol << 3;796 for (j = 0; j < 8; j++) {797 var lineOffset = (scanLine + j) * samplesPerLine;798 for (k = 0; k < 8; k++) {799 lineData[lineOffset + sample + k] =800 component.output[bufferOffset + offset++];801 }802 }803 }804 }805 componentScaleX = component.scaleX * scaleX;806 componentScaleY = component.scaleY * scaleY;807 offset = i;808 var cx, cy;809 var index;810 for (y = 0; y < height; y++) {811 for (x = 0; x < width; x++) {812 cy = 0 | (y * componentScaleY);813 cx = 0 | (x * componentScaleX);814 index = cy * samplesPerLine + cx;815 data[offset] = lineData[index];816 offset += numComponents;817 }818 }819 }820 return data;821 },822 getData: function getData(width, height) {823 var scaleX = this.width / width, scaleY = this.height / height;824 var component, componentScaleX, componentScaleY;825 var x, y, i;826 var offset = 0;827 var Y, Cb, Cr, K, C, M, Ye, R, G, B;828 var colorTransform;829 var numComponents = this.components.length;830 var dataLength = width * height * numComponents;831 var data = new Uint8Array(dataLength);832 var componentLine;833 // lineData is reused for all components. Assume first component is834 // the biggest835 var lineData = new Uint8Array((this.components[0].blocksPerLine << 3) *836 this.components[0].blocksPerColumn * 8);837 // First construct image data ...838 for (i = 0; i < numComponents; i++) {839 component = this.components[i];840 var blocksPerLine = component.blocksPerLine;841 var blocksPerColumn = component.blocksPerColumn;842 var samplesPerLine = blocksPerLine << 3;843 var j, k, ll = 0;844 var lineOffset = 0;845 for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {846 var scanLine = blockRow << 3;847 for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {848 var bufferOffset = getBlockBufferOffset(component, blockRow, blockCol);849 var offset = 0, sample = blockCol << 3;850 for (j = 0; j < 8; j++) {851 var lineOffset = (scanLine + j) * samplesPerLine;852 for (k = 0; k < 8; k++) {853 lineData[lineOffset + sample + k] =854 component.output[bufferOffset + offset++] * component.bitConversion;855 }856 }857 }858 }859 componentScaleX = component.scaleX * scaleX;860 componentScaleY = component.scaleY * scaleY;861 offset = i;862 var cx, cy;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = new WPT();2var offset = wpt.getBlockBufferOffset(0);3console.log(offset);4WPT.prototype.getBlockBufferOffset = function(blockIndex) {5 return blockIndex * this.blockSize;6};

Full Screen

Using AI Code Generation

copy

Full Screen

1const WpToolkit = require('wp-toolkit');2const path = require('path');3const fs = require('fs');4const wptoolkit = new WpToolkit({5 wpRoot: path.resolve(__dirname, 'wp'),6 wpConfig: path.resolve(__dirname, 'wp-config.php'),7 wpContent: path.resolve(__dirname, 'wp-content')8});9console.log(wptoolkit.getBlockBufferOffset('core/image'));10console.log(wptoolkit.getBlockBufferOffset('core/paragraph'));11console.log(wptoolkit.getBlockBufferOffset('core/heading'));12console.log(wptoolkit.getBlockBufferOffset('core/quote'));13console.log(wptoolkit.getBlockBufferOffset('core/gallery'));14console.log(wptoolkit.getBlockBufferOffset('core/audio'));15console.log(wptoolkit.getBlockBufferOffset('core/video'));16console.log(wptoolkit.getBlockBufferOffset('core/cover'));17console.log(wptoolkit.getBlockBufferOffset('core/file'));18console.log(wptoolkit.getBlockBufferOffset('core/list'));19console.log(wptoolkit.getBlockBufferOffset('core/shortcode'));20console.log(wptoolkit.getBlockBufferOffset('core/archives'));21console.log(wptoolkit.getBlockBufferOffset('core/categories'));22console.log(wptoolkit.getBlockBufferOffset('core/latest-comments'));23console.log(wptoolkit.getBlockBufferOffset('core/latest-posts'));24console.log(wptoolkit.getBlockBufferOffset('core/separator'));25console.log(wptoolkit.getBlockBufferOffset('core/spacer'));26console.log(wptoolkit.getBlockBufferOffset('core/code'));27console.log(wptoolkit.getBlockBufferOffset('core/html'));28console.log(wptoolkit.getBlockBufferOffset('core/preformatted'));29console.log(wptoolkit.getBlockBufferOffset('core/pullquote'));30console.log(wptoolkit.getBlockBuffer

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptools = require('wp-tools');2const blockBuffer = wptools.getBlockBufferOffset('minecraft:stone', 0, 0, 0, 0, 0, 0);3console.log(blockBuffer);4const wptools = require('wp-tools');5const blockBuffer = wptools.getBlockBufferOffset('minecraft:stone', 0, 0, 0, 0, 0, 0);6console.log(blockBuffer);7const wptools = require('wp-tools');8const blockBuffer = wptools.getBlockBufferOffset('minecraft:stone', 0, 0, 0, 0, 0, 0);9console.log(blockBuffer);10const wptools = require('wp-tools');11const blockBuffer = wptools.getBlockBufferOffset('minecraft:stone', 0, 0, 0, 0, 0, 0);12console.log(blockBuffer);13const wptools = require('wp-tools');14const blockBuffer = wptools.getBlockBufferOffset('minecraft:stone', 0, 0, 0, 0, 0, 0);15console.log(blockBuffer);16const wptools = require('wp-tools');17const blockBuffer = wptools.getBlockBufferOffset('minecraft:stone', 0, 0, 0, 0, 0, 0);18console.log(blockBuffer);19const wptools = require('wp-tools');20const blockBuffer = wptools.getBlockBufferOffset('minecraft:stone', 0, 0, 0, 0, 0, 0);21console.log(blockBuffer);22const wptools = require('wp-tools');23const blockBuffer = wptools.getBlockBufferOffset('

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptc = require('wptc');2var blockId = 123;3var bufferOffset = wptc.getBlockBufferOffset(blockId);4console.log("Buffer offset of block " + blockId + " is " + bufferOffset);5var wptc = require('wptc');6var blockId = 123;7var bufferOffset = wptc.getBlockBufferOffset(blockId);8console.log("Buffer offset of block " + blockId + " is " + bufferOffset);9var wptc = require('wptc');10var blockId = 123;11var bufferOffset = wptc.getBlockBufferOffset(blockId);12console.log("Buffer offset of block " + blockId + " is " + bufferOffset);13var wptc = require('wptc');14var blockId = 123;15var bufferOffset = wptc.getBlockBufferOffset(blockId);16console.log("Buffer offset of block " + blockId + " is " + bufferOffset);17var wptc = require('wptc');18var blockId = 123;19var bufferOffset = wptc.getBlockBufferOffset(blockId);20console.log("Buffer offset of block " + blockId + " is " + bufferOffset);21var wptc = require('wptc');22var blockId = 123;23var bufferOffset = wptc.getBlockBufferOffset(blockId);24console.log("Buffer offset of block " + blockId + " is " + bufferOffset);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('./wptools.js');2var blockBuffer = wptools.loadBlockBuffer("block00000.dat");3var offset = wptools.getBlockBufferOffset(blockBuffer, "0000000000000000000e9a9c6d7f6a0f0a7b1b8c0ba7a1d1c3a3e3b3d3a3e3b");4console.log(offset);5wptools.closeBlockBuffer(blockBuffer);6var native = require('./build/Release/wptools.node');7exports.loadBlockBuffer = function(path) {8 return native.loadBlockBuffer(path);9}10exports.closeBlockBuffer = function(blockBuffer) {11 native.closeBlockBuffer(blockBuffer);12}13exports.getBlockBufferOffset = function(blockBuffer, hash) {14 return native.getBlockBufferOffset(blockBuffer, hash);15}16var native = require('./native.node');17exports.loadBlockBuffer = function(path) {18 return native.loadBlockBuffer(path);19}20exports.closeBlockBuffer = function(blockBuffer) {21 native.closeBlockBuffer(blockBuffer);22}23exports.getBlockBufferOffset = function(blockBuffer, hash) {24 return native.getBlockBufferOffset(blockBuffer, hash);25}26var native = require('./native.node');27exports.loadBlockBuffer = function(path) {28 return native.loadBlockBuffer(path);29}30exports.closeBlockBuffer = function(blockBuffer) {31 native.closeBlockBuffer(blockBuffer);32}33exports.getBlockBufferOffset = function(blockBuffer, hash) {34 return native.getBlockBufferOffset(blockBuffer, hash

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2var wpt = new wpt();3var block = wpt.getBlockBufferOffset(0);4console.log(block);5var block = wpt.getBlockBufferOffset(1);6console.log(block);7var block = wpt.getBlockBufferOffset(2);8console.log(block);9var block = wpt.getBlockBufferOffset(3);10console.log(block);11var block = wpt.getBlockBufferOffset(4);12console.log(block);13var block = wpt.getBlockBufferOffset(5);14console.log(block);15var block = wpt.getBlockBufferOffset(6);16console.log(block);17var block = wpt.getBlockBufferOffset(7);18console.log(block);19var block = wpt.getBlockBufferOffset(8);20console.log(block);21var block = wpt.getBlockBufferOffset(9);22console.log(block);23var block = wpt.getBlockBufferOffset(10);24console.log(block);25var block = wpt.getBlockBufferOffset(11);26console.log(block);27var block = wpt.getBlockBufferOffset(12);28console.log(block);29var block = wpt.getBlockBufferOffset(13);30console.log(block);31var block = wpt.getBlockBufferOffset(14);32console.log(block);33var block = wpt.getBlockBufferOffset(15);34console.log(block);35var block = wpt.getBlockBufferOffset(16);36console.log(block);37var block = wpt.getBlockBufferOffset(17);38console.log(block);39var block = wpt.getBlockBufferOffset(18);40console.log(block);41var block = wpt.getBlockBufferOffset(19);42console.log(block);43var block = wpt.getBlockBufferOffset(20);44console.log(block);45var block = wpt.getBlockBufferOffset(

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2var wptObj = new wpt();3var block = {4 "blockBuffer": new Buffer(512),5};6block.blockBufferOffset = wptObj.getBlockBufferOffset(block.blockNumber, block.blockSize);7block.blockBuffer.write("Hello World", block.blockBufferOffset);8console.log(block.blockBuffer.toString('utf8', block.blockBufferOffset, block.blockBufferOffset + block.blockSize));9Buffer.write()10Buffer.toString()11Buffer.slice()12Buffer.copy()13Buffer.concat()14Buffer.isEncoding()15Buffer.isBuffer()16Buffer.byteLength()17Buffer.compare()18Buffer.alloc()19Buffer.allocUnsafe()20Buffer.allocUnsafeSlow()21Buffer.from()22Buffer.isEncoding()23Buffer.isBuffer()24Buffer.byteLength()25Buffer.compare()26Buffer.alloc()27Buffer.allocUnsafe()28Buffer.allocUnsafeSlow()29Buffer.from()30Buffer.alloc()31Buffer.allocUnsafe()32Buffer.allocUnsafeSlow()33Buffer.from()34Buffer.alloc()

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful