How to use ReversibleTransform method in wpt

Best JavaScript code snippet using wpt

jpx.js

Source:jpx.js Github

copy

Full Screen

...1272 var guardBits = quantizationParameters.guardBits;1273 var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;1274 var precision = context.components[c].precision;1275 var reversible = codingStyleParameters.reversibleTransformation;1276 var transform = (reversible ? new ReversibleTransform() :1277 new IrreversibleTransform());1278 var subbandCoefficients = [];1279 var b = 0;1280 for (var i = 0; i <= decompositionLevelsCount; i++) {1281 var resolution = component.resolutions[i];1282 var width = resolution.trx1 - resolution.trx0;1283 var height = resolution.try1 - resolution.try0;1284 // Allocate space for the whole sublevel.1285 var coefficients = new Float32Array(width * height);1286 for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {1287 var mu, epsilon;1288 if (!scalarExpounded) {1289 // formula E-51290 mu = spqcds[0].mu;1291 epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);1292 } else {1293 mu = spqcds[b].mu;1294 epsilon = spqcds[b].epsilon;1295 b++;1296 }1297 var subband = resolution.subbands[j];1298 var gainLog2 = SubbandsGainLog2[subband.type];1299 // calulate quantization coefficient (Section E.1.1.1)1300 var delta = (reversible ? 1 :1301 Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048));1302 var mb = (guardBits + epsilon - 1);1303 // In the first resolution level, copyCoefficients will fill the1304 // whole array with coefficients. In the succeding passes,1305 // copyCoefficients will consecutively fill in the values that belong1306 // to the interleaved positions of the HL, LH, and HH coefficients.1307 // The LL coefficients will then be interleaved in Transform.iterate().1308 copyCoefficients(coefficients, width, height, subband, delta, mb,1309 reversible, segmentationSymbolUsed);1310 }1311 subbandCoefficients.push({1312 width: width,1313 height: height,1314 items: coefficients1315 });1316 }1317 var result = transform.calculate(subbandCoefficients,1318 component.tcx0, component.tcy0);1319 return {1320 left: component.tcx0,1321 top: component.tcy0,1322 width: result.width,1323 height: result.height,1324 items: result.items1325 };1326 }1327 function transformComponents(context) {1328 var siz = context.SIZ;1329 var components = context.components;1330 var componentsCount = siz.Csiz;1331 var resultImages = [];1332 for (var i = 0, ii = context.tiles.length; i < ii; i++) {1333 var tile = context.tiles[i];1334 var transformedTiles = [];1335 var c;1336 for (c = 0; c < componentsCount; c++) {1337 transformedTiles[c] = transformTile(context, tile, c);1338 }1339 var tile0 = transformedTiles[0];1340 var out = new Uint8Array(tile0.items.length * componentsCount);1341 var result = {1342 left: tile0.left,1343 top: tile0.top,1344 width: tile0.width,1345 height: tile0.height,1346 items: out1347 };1348 // Section G.2.2 Inverse multi component transform1349 var shift, offset, max, min, maxK;1350 var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;1351 if (tile.codingStyleDefaultParameters.multipleComponentTransform) {1352 var fourComponents = componentsCount === 4;1353 var y0items = transformedTiles[0].items;1354 var y1items = transformedTiles[1].items;1355 var y2items = transformedTiles[2].items;1356 var y3items = fourComponents ? transformedTiles[3].items : null;1357 // HACK: The multiple component transform formulas below assume that1358 // all components have the same precision. With this in mind, we1359 // compute shift and offset only once.1360 shift = components[0].precision - 8;1361 offset = (128 << shift) + 0.5;1362 max = 255 * (1 << shift);1363 maxK = max * 0.5;1364 min = -maxK;1365 var component0 = tile.components[0];1366 var alpha01 = componentsCount - 3;1367 jj = y0items.length;1368 if (!component0.codingStyleParameters.reversibleTransformation) {1369 // inverse irreversible multiple component transform1370 for (j = 0; j < jj; j++, pos += alpha01) {1371 y0 = y0items[j] + offset;1372 y1 = y1items[j];1373 y2 = y2items[j];1374 r = y0 + 1.402 * y2;1375 g = y0 - 0.34413 * y1 - 0.71414 * y2;1376 b = y0 + 1.772 * y1;1377 out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;1378 out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;1379 out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;1380 }1381 } else {1382 // inverse reversible multiple component transform1383 for (j = 0; j < jj; j++, pos += alpha01) {1384 y0 = y0items[j] + offset;1385 y1 = y1items[j];1386 y2 = y2items[j];1387 g = y0 - ((y2 + y1) >> 2);1388 r = g + y2;1389 b = g + y1;1390 out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;1391 out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;1392 out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;1393 }1394 }1395 if (fourComponents) {1396 for (j = 0, pos = 3; j < jj; j++, pos += 4) {1397 k = y3items[j];1398 out[pos] = k <= min ? 0 : k >= maxK ? 255 : (k + offset) >> shift;1399 }1400 }1401 } else { // no multi-component transform1402 for (c = 0; c < componentsCount; c++) {1403 var items = transformedTiles[c].items;1404 shift = components[c].precision - 8;1405 offset = (128 << shift) + 0.5;1406 max = (127.5 * (1 << shift));1407 min = -max;1408 for (pos = c, j = 0, jj = items.length; j < jj; j++) {1409 val = items[j];1410 out[pos] = val <= min ? 0 :1411 val >= max ? 255 : (val + offset) >> shift;1412 pos += componentsCount;1413 }1414 }1415 }1416 resultImages.push(result);1417 }1418 return resultImages;1419 }1420 function initializeTile(context, tileIndex) {1421 var siz = context.SIZ;1422 var componentsCount = siz.Csiz;1423 var tile = context.tiles[tileIndex];1424 for (var c = 0; c < componentsCount; c++) {1425 var component = tile.components[c];1426 var qcdOrQcc = (context.currentTile.QCC[c] !== undefined ?1427 context.currentTile.QCC[c] : context.currentTile.QCD);1428 component.quantizationParameters = qcdOrQcc;1429 var codOrCoc = (context.currentTile.COC[c] !== undefined ?1430 context.currentTile.COC[c] : context.currentTile.COD);1431 component.codingStyleParameters = codOrCoc;1432 }1433 tile.codingStyleDefaultParameters = context.currentTile.COD;1434 }1435 // Section B.10.2 Tag trees1436 var TagTree = (function TagTreeClosure() {1437 function TagTree(width, height) {1438 var levelsLength = log2(Math.max(width, height)) + 1;1439 this.levels = [];1440 for (var i = 0; i < levelsLength; i++) {1441 var level = {1442 width: width,1443 height: height,1444 items: []1445 };1446 this.levels.push(level);1447 width = Math.ceil(width / 2);1448 height = Math.ceil(height / 2);1449 }1450 }1451 TagTree.prototype = {1452 reset: function TagTree_reset(i, j) {1453 var currentLevel = 0, value = 0, level;1454 while (currentLevel < this.levels.length) {1455 level = this.levels[currentLevel];1456 var index = i + j * level.width;1457 if (level.items[index] !== undefined) {1458 value = level.items[index];1459 break;1460 }1461 level.index = index;1462 i >>= 1;1463 j >>= 1;1464 currentLevel++;1465 }1466 currentLevel--;1467 level = this.levels[currentLevel];1468 level.items[level.index] = value;1469 this.currentLevel = currentLevel;1470 delete this.value;1471 },1472 incrementValue: function TagTree_incrementValue() {1473 var level = this.levels[this.currentLevel];1474 level.items[level.index]++;1475 },1476 nextLevel: function TagTree_nextLevel() {1477 var currentLevel = this.currentLevel;1478 var level = this.levels[currentLevel];1479 var value = level.items[level.index];1480 currentLevel--;1481 if (currentLevel < 0) {1482 this.value = value;1483 return false;1484 }1485 this.currentLevel = currentLevel;1486 level = this.levels[currentLevel];1487 level.items[level.index] = value;1488 return true;1489 }1490 };1491 return TagTree;1492 })();1493 var InclusionTree = (function InclusionTreeClosure() {1494 function InclusionTree(width, height, defaultValue) {1495 var levelsLength = log2(Math.max(width, height)) + 1;1496 this.levels = [];1497 for (var i = 0; i < levelsLength; i++) {1498 var items = new Uint8Array(width * height);1499 for (var j = 0, jj = items.length; j < jj; j++) {1500 items[j] = defaultValue;1501 }1502 var level = {1503 width: width,1504 height: height,1505 items: items1506 };1507 this.levels.push(level);1508 width = Math.ceil(width / 2);1509 height = Math.ceil(height / 2);1510 }1511 }1512 InclusionTree.prototype = {1513 reset: function InclusionTree_reset(i, j, stopValue) {1514 var currentLevel = 0;1515 while (currentLevel < this.levels.length) {1516 var level = this.levels[currentLevel];1517 var index = i + j * level.width;1518 level.index = index;1519 var value = level.items[index];1520 if (value === 0xFF) {1521 break;1522 }1523 if (value > stopValue) {1524 this.currentLevel = currentLevel;1525 // already know about this one, propagating the value to top levels1526 this.propagateValues();1527 return false;1528 }1529 i >>= 1;1530 j >>= 1;1531 currentLevel++;1532 }1533 this.currentLevel = currentLevel - 1;1534 return true;1535 },1536 incrementValue: function InclusionTree_incrementValue(stopValue) {1537 var level = this.levels[this.currentLevel];1538 level.items[level.index] = stopValue + 1;1539 this.propagateValues();1540 },1541 propagateValues: function InclusionTree_propagateValues() {1542 var levelIndex = this.currentLevel;1543 var level = this.levels[levelIndex];1544 var currentValue = level.items[level.index];1545 while (--levelIndex >= 0) {1546 level = this.levels[levelIndex];1547 level.items[level.index] = currentValue;1548 }1549 },1550 nextLevel: function InclusionTree_nextLevel() {1551 var currentLevel = this.currentLevel;1552 var level = this.levels[currentLevel];1553 var value = level.items[level.index];1554 level.items[level.index] = 0xFF;1555 currentLevel--;1556 if (currentLevel < 0) {1557 return false;1558 }1559 this.currentLevel = currentLevel;1560 level = this.levels[currentLevel];1561 level.items[level.index] = value;1562 return true;1563 }1564 };1565 return InclusionTree;1566 })();1567 // Section D. Coefficient bit modeling1568 var BitModel = (function BitModelClosure() {1569 var UNIFORM_CONTEXT = 17;1570 var RUNLENGTH_CONTEXT = 18;1571 // Table D-11572 // The index is binary presentation: 0dddvvhh, ddd - sum of Di (0..4),1573 // vv - sum of Vi (0..2), and hh - sum of Hi (0..2)1574 var LLAndLHContextsLabel = new Uint8Array([1575 0, 5, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 1, 6, 8, 0, 3, 7, 8, 0, 4,1576 7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6,1577 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 81578 ]);1579 var HLContextLabel = new Uint8Array([1580 0, 3, 4, 0, 5, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 1, 3, 4, 0, 6, 7, 7, 0, 8,1581 8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3,1582 4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 81583 ]);1584 var HHContextLabel = new Uint8Array([1585 0, 1, 2, 0, 1, 2, 2, 0, 2, 2, 2, 0, 0, 0, 0, 0, 3, 4, 5, 0, 4, 5, 5, 0, 5,1586 5, 5, 0, 0, 0, 0, 0, 6, 7, 7, 0, 7, 7, 7, 0, 7, 7, 7, 0, 0, 0, 0, 0, 8, 8,1587 8, 0, 8, 8, 8, 0, 8, 8, 8, 0, 0, 0, 0, 0, 8, 8, 8, 0, 8, 8, 8, 0, 8, 8, 81588 ]);1589 function BitModel(width, height, subband, zeroBitPlanes, mb) {1590 this.width = width;1591 this.height = height;1592 this.contextLabelTable = (subband === 'HH' ? HHContextLabel :1593 (subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel));1594 var coefficientCount = width * height;1595 // coefficients outside the encoding region treated as insignificant1596 // add border state cells for significanceState1597 this.neighborsSignificance = new Uint8Array(coefficientCount);1598 this.coefficentsSign = new Uint8Array(coefficientCount);1599 this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) :1600 mb > 6 ? new Uint16Array(coefficientCount) :1601 new Uint8Array(coefficientCount);1602 this.processingFlags = new Uint8Array(coefficientCount);1603 var bitsDecoded = new Uint8Array(coefficientCount);1604 if (zeroBitPlanes !== 0) {1605 for (var i = 0; i < coefficientCount; i++) {1606 bitsDecoded[i] = zeroBitPlanes;1607 }1608 }1609 this.bitsDecoded = bitsDecoded;1610 this.reset();1611 }1612 BitModel.prototype = {1613 setDecoder: function BitModel_setDecoder(decoder) {1614 this.decoder = decoder;1615 },1616 reset: function BitModel_reset() {1617 // We have 17 contexts that are accessed via context labels,1618 // plus the uniform and runlength context.1619 this.contexts = new Int8Array(19);1620 // Contexts are packed into 1 byte:1621 // highest 7 bits carry the index, lowest bit carries mps1622 this.contexts[0] = (4 << 1) | 0;1623 this.contexts[UNIFORM_CONTEXT] = (46 << 1) | 0;1624 this.contexts[RUNLENGTH_CONTEXT] = (3 << 1) | 0;1625 },1626 setNeighborsSignificance:1627 function BitModel_setNeighborsSignificance(row, column, index) {1628 var neighborsSignificance = this.neighborsSignificance;1629 var width = this.width, height = this.height;1630 var left = (column > 0);1631 var right = (column + 1 < width);1632 var i;1633 if (row > 0) {1634 i = index - width;1635 if (left) {1636 neighborsSignificance[i - 1] += 0x10;1637 }1638 if (right) {1639 neighborsSignificance[i + 1] += 0x10;1640 }1641 neighborsSignificance[i] += 0x04;1642 }1643 if (row + 1 < height) {1644 i = index + width;1645 if (left) {1646 neighborsSignificance[i - 1] += 0x10;1647 }1648 if (right) {1649 neighborsSignificance[i + 1] += 0x10;1650 }1651 neighborsSignificance[i] += 0x04;1652 }1653 if (left) {1654 neighborsSignificance[index - 1] += 0x01;1655 }1656 if (right) {1657 neighborsSignificance[index + 1] += 0x01;1658 }1659 neighborsSignificance[index] |= 0x80;1660 },1661 runSignificancePropogationPass:1662 function BitModel_runSignificancePropogationPass() {1663 var decoder = this.decoder;1664 var width = this.width, height = this.height;1665 var coefficentsMagnitude = this.coefficentsMagnitude;1666 var coefficentsSign = this.coefficentsSign;1667 var neighborsSignificance = this.neighborsSignificance;1668 var processingFlags = this.processingFlags;1669 var contexts = this.contexts;1670 var labels = this.contextLabelTable;1671 var bitsDecoded = this.bitsDecoded;1672 var processedInverseMask = ~1;1673 var processedMask = 1;1674 var firstMagnitudeBitMask = 2;1675 for (var i0 = 0; i0 < height; i0 += 4) {1676 for (var j = 0; j < width; j++) {1677 var index = i0 * width + j;1678 for (var i1 = 0; i1 < 4; i1++, index += width) {1679 var i = i0 + i1;1680 if (i >= height) {1681 break;1682 }1683 // clear processed flag first1684 processingFlags[index] &= processedInverseMask;1685 if (coefficentsMagnitude[index] ||1686 !neighborsSignificance[index]) {1687 continue;1688 }1689 var contextLabel = labels[neighborsSignificance[index]];1690 var decision = decoder.readBit(contexts, contextLabel);1691 if (decision) {1692 var sign = this.decodeSignBit(i, j, index);1693 coefficentsSign[index] = sign;1694 coefficentsMagnitude[index] = 1;1695 this.setNeighborsSignificance(i, j, index);1696 processingFlags[index] |= firstMagnitudeBitMask;1697 }1698 bitsDecoded[index]++;1699 processingFlags[index] |= processedMask;1700 }1701 }1702 }1703 },1704 decodeSignBit: function BitModel_decodeSignBit(row, column, index) {1705 var width = this.width, height = this.height;1706 var coefficentsMagnitude = this.coefficentsMagnitude;1707 var coefficentsSign = this.coefficentsSign;1708 var contribution, sign0, sign1, significance1;1709 var contextLabel, decoded;1710 // calculate horizontal contribution1711 significance1 = (column > 0 && coefficentsMagnitude[index - 1] !== 0);1712 if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {1713 sign1 = coefficentsSign[index + 1];1714 if (significance1) {1715 sign0 = coefficentsSign[index - 1];1716 contribution = 1 - sign1 - sign0;1717 } else {1718 contribution = 1 - sign1 - sign1;1719 }1720 } else if (significance1) {1721 sign0 = coefficentsSign[index - 1];1722 contribution = 1 - sign0 - sign0;1723 } else {1724 contribution = 0;1725 }1726 var horizontalContribution = 3 * contribution;1727 // calculate vertical contribution and combine with the horizontal1728 significance1 = (row > 0 && coefficentsMagnitude[index - width] !== 0);1729 if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {1730 sign1 = coefficentsSign[index + width];1731 if (significance1) {1732 sign0 = coefficentsSign[index - width];1733 contribution = 1 - sign1 - sign0 + horizontalContribution;1734 } else {1735 contribution = 1 - sign1 - sign1 + horizontalContribution;1736 }1737 } else if (significance1) {1738 sign0 = coefficentsSign[index - width];1739 contribution = 1 - sign0 - sign0 + horizontalContribution;1740 } else {1741 contribution = horizontalContribution;1742 }1743 if (contribution >= 0) {1744 contextLabel = 9 + contribution;1745 decoded = this.decoder.readBit(this.contexts, contextLabel);1746 } else {1747 contextLabel = 9 - contribution;1748 decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;1749 }1750 return decoded;1751 },1752 runMagnitudeRefinementPass:1753 function BitModel_runMagnitudeRefinementPass() {1754 var decoder = this.decoder;1755 var width = this.width, height = this.height;1756 var coefficentsMagnitude = this.coefficentsMagnitude;1757 var neighborsSignificance = this.neighborsSignificance;1758 var contexts = this.contexts;1759 var bitsDecoded = this.bitsDecoded;1760 var processingFlags = this.processingFlags;1761 var processedMask = 1;1762 var firstMagnitudeBitMask = 2;1763 var length = width * height;1764 var width4 = width * 4;1765 for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {1766 indexNext = Math.min(length, index0 + width4);1767 for (var j = 0; j < width; j++) {1768 for (var index = index0 + j; index < indexNext; index += width) {1769 // significant but not those that have just become1770 if (!coefficentsMagnitude[index] ||1771 (processingFlags[index] & processedMask) !== 0) {1772 continue;1773 }1774 var contextLabel = 16;1775 if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {1776 processingFlags[index] ^= firstMagnitudeBitMask;1777 // first refinement1778 var significance = neighborsSignificance[index] & 127;1779 contextLabel = significance === 0 ? 15 : 14;1780 }1781 var bit = decoder.readBit(contexts, contextLabel);1782 coefficentsMagnitude[index] =1783 (coefficentsMagnitude[index] << 1) | bit;1784 bitsDecoded[index]++;1785 processingFlags[index] |= processedMask;1786 }1787 }1788 }1789 },1790 runCleanupPass: function BitModel_runCleanupPass() {1791 var decoder = this.decoder;1792 var width = this.width, height = this.height;1793 var neighborsSignificance = this.neighborsSignificance;1794 var coefficentsMagnitude = this.coefficentsMagnitude;1795 var coefficentsSign = this.coefficentsSign;1796 var contexts = this.contexts;1797 var labels = this.contextLabelTable;1798 var bitsDecoded = this.bitsDecoded;1799 var processingFlags = this.processingFlags;1800 var processedMask = 1;1801 var firstMagnitudeBitMask = 2;1802 var oneRowDown = width;1803 var twoRowsDown = width * 2;1804 var threeRowsDown = width * 3;1805 var iNext;1806 for (var i0 = 0; i0 < height; i0 = iNext) {1807 iNext = Math.min(i0 + 4, height);1808 var indexBase = i0 * width;1809 var checkAllEmpty = i0 + 3 < height;1810 for (var j = 0; j < width; j++) {1811 var index0 = indexBase + j;1812 // using the property: labels[neighborsSignificance[index]] === 01813 // when neighborsSignificance[index] === 01814 var allEmpty = (checkAllEmpty &&1815 processingFlags[index0] === 0 &&1816 processingFlags[index0 + oneRowDown] === 0 &&1817 processingFlags[index0 + twoRowsDown] === 0 &&1818 processingFlags[index0 + threeRowsDown] === 0 &&1819 neighborsSignificance[index0] === 0 &&1820 neighborsSignificance[index0 + oneRowDown] === 0 &&1821 neighborsSignificance[index0 + twoRowsDown] === 0 &&1822 neighborsSignificance[index0 + threeRowsDown] === 0);1823 var i1 = 0, index = index0;1824 var i = i0, sign;1825 if (allEmpty) {1826 var hasSignificantCoefficent =1827 decoder.readBit(contexts, RUNLENGTH_CONTEXT);1828 if (!hasSignificantCoefficent) {1829 bitsDecoded[index0]++;1830 bitsDecoded[index0 + oneRowDown]++;1831 bitsDecoded[index0 + twoRowsDown]++;1832 bitsDecoded[index0 + threeRowsDown]++;1833 continue; // next column1834 }1835 i1 = (decoder.readBit(contexts, UNIFORM_CONTEXT) << 1) |1836 decoder.readBit(contexts, UNIFORM_CONTEXT);1837 if (i1 !== 0) {1838 i = i0 + i1;1839 index += i1 * width;1840 }1841 sign = this.decodeSignBit(i, j, index);1842 coefficentsSign[index] = sign;1843 coefficentsMagnitude[index] = 1;1844 this.setNeighborsSignificance(i, j, index);1845 processingFlags[index] |= firstMagnitudeBitMask;1846 index = index0;1847 for (var i2 = i0; i2 <= i; i2++, index += width) {1848 bitsDecoded[index]++;1849 }1850 i1++;1851 }1852 for (i = i0 + i1; i < iNext; i++, index += width) {1853 if (coefficentsMagnitude[index] ||1854 (processingFlags[index] & processedMask) !== 0) {1855 continue;1856 }1857 var contextLabel = labels[neighborsSignificance[index]];1858 var decision = decoder.readBit(contexts, contextLabel);1859 if (decision === 1) {1860 sign = this.decodeSignBit(i, j, index);1861 coefficentsSign[index] = sign;1862 coefficentsMagnitude[index] = 1;1863 this.setNeighborsSignificance(i, j, index);1864 processingFlags[index] |= firstMagnitudeBitMask;1865 }1866 bitsDecoded[index]++;1867 }1868 }1869 }1870 },1871 checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {1872 var decoder = this.decoder;1873 var contexts = this.contexts;1874 var symbol = (decoder.readBit(contexts, UNIFORM_CONTEXT) << 3) |1875 (decoder.readBit(contexts, UNIFORM_CONTEXT) << 2) |1876 (decoder.readBit(contexts, UNIFORM_CONTEXT) << 1) |1877 decoder.readBit(contexts, UNIFORM_CONTEXT);1878 if (symbol !== 0xA) {1879 throw new Error('JPX Error: Invalid segmentation symbol');1880 }1881 }1882 };1883 return BitModel;1884 })();1885 // Section F, Discrete wavelet transformation1886 var Transform = (function TransformClosure() {1887 function Transform() {}1888 Transform.prototype.calculate =1889 function transformCalculate(subbands, u0, v0) {1890 var ll = subbands[0];1891 for (var i = 1, ii = subbands.length; i < ii; i++) {1892 ll = this.iterate(ll, subbands[i], u0, v0);1893 }1894 return ll;1895 };1896 Transform.prototype.extend = function extend(buffer, offset, size) {1897 // Section F.3.7 extending... using max extension of 41898 var i1 = offset - 1, j1 = offset + 1;1899 var i2 = offset + size - 2, j2 = offset + size;1900 buffer[i1--] = buffer[j1++];1901 buffer[j2++] = buffer[i2--];1902 buffer[i1--] = buffer[j1++];1903 buffer[j2++] = buffer[i2--];1904 buffer[i1--] = buffer[j1++];1905 buffer[j2++] = buffer[i2--];1906 buffer[i1] = buffer[j1];1907 buffer[j2] = buffer[i2];1908 };1909 Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh,1910 u0, v0) {1911 var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;1912 var width = hl_lh_hh.width;1913 var height = hl_lh_hh.height;1914 var items = hl_lh_hh.items;1915 var i, j, k, l, u, v;1916 // Interleave LL according to Section F.3.31917 for (k = 0, i = 0; i < llHeight; i++) {1918 l = i * 2 * width;1919 for (j = 0; j < llWidth; j++, k++, l += 2) {1920 items[l] = llItems[k];1921 }1922 }1923 // The LL band is not needed anymore.1924 llItems = ll.items = null;1925 var bufferPadding = 4;1926 var rowBuffer = new Float32Array(width + 2 * bufferPadding);1927 // Section F.3.4 HOR_SR1928 if (width === 1) {1929 // if width = 1, when u0 even keep items as is, when odd divide by 21930 if ((u0 & 1) !== 0) {1931 for (v = 0, k = 0; v < height; v++, k += width) {1932 items[k] *= 0.5;1933 }1934 }1935 } else {1936 for (v = 0, k = 0; v < height; v++, k += width) {1937 rowBuffer.set(items.subarray(k, k + width), bufferPadding);1938 this.extend(rowBuffer, bufferPadding, width);1939 this.filter(rowBuffer, bufferPadding, width);1940 items.set(1941 rowBuffer.subarray(bufferPadding, bufferPadding + width),1942 k);1943 }1944 }1945 // Accesses to the items array can take long, because it may not fit into1946 // CPU cache and has to be fetched from main memory. Since subsequent1947 // accesses to the items array are not local when reading columns, we1948 // have a cache miss every time. To reduce cache misses, get up to1949 // 'numBuffers' items at a time and store them into the individual1950 // buffers. The colBuffers should be small enough to fit into CPU cache.1951 var numBuffers = 16;1952 var colBuffers = [];1953 for (i = 0; i < numBuffers; i++) {1954 colBuffers.push(new Float32Array(height + 2 * bufferPadding));1955 }1956 var b, currentBuffer = 0;1957 ll = bufferPadding + height;1958 // Section F.3.5 VER_SR1959 if (height === 1) {1960 // if height = 1, when v0 even keep items as is, when odd divide by 21961 if ((v0 & 1) !== 0) {1962 for (u = 0; u < width; u++) {1963 items[u] *= 0.5;1964 }1965 }1966 } else {1967 for (u = 0; u < width; u++) {1968 // if we ran out of buffers, copy several image columns at once1969 if (currentBuffer === 0) {1970 numBuffers = Math.min(width - u, numBuffers);1971 for (k = u, l = bufferPadding; l < ll; k += width, l++) {1972 for (b = 0; b < numBuffers; b++) {1973 colBuffers[b][l] = items[k + b];1974 }1975 }1976 currentBuffer = numBuffers;1977 }1978 currentBuffer--;1979 var buffer = colBuffers[currentBuffer];1980 this.extend(buffer, bufferPadding, height);1981 this.filter(buffer, bufferPadding, height);1982 // If this is last buffer in this group of buffers, flush all buffers.1983 if (currentBuffer === 0) {1984 k = u - numBuffers + 1;1985 for (l = bufferPadding; l < ll; k += width, l++) {1986 for (b = 0; b < numBuffers; b++) {1987 items[k + b] = colBuffers[b][l];1988 }1989 }1990 }1991 }1992 }1993 return {1994 width: width,1995 height: height,1996 items: items1997 };1998 };1999 return Transform;2000 })();2001 // Section 3.8.2 Irreversible 9-7 filter2002 var IrreversibleTransform = (function IrreversibleTransformClosure() {2003 function IrreversibleTransform() {2004 Transform.call(this);2005 }2006 IrreversibleTransform.prototype = Object.create(Transform.prototype);2007 IrreversibleTransform.prototype.filter =2008 function irreversibleTransformFilter(x, offset, length) {2009 var len = length >> 1;2010 offset = offset | 0;2011 var j, n, current, next;2012 var alpha = -1.586134342059924;2013 var beta = -0.052980118572961;2014 var gamma = 0.882911075530934;2015 var delta = 0.443506852043971;2016 var K = 1.230174104914001;2017 var K_ = 1 / K;2018 // step 1 is combined with step 32019 // step 22020 j = offset - 3;2021 for (n = len + 4; n--; j += 2) {2022 x[j] *= K_;2023 }2024 // step 1 & 32025 j = offset - 2;2026 current = delta * x[j -1];2027 for (n = len + 3; n--; j += 2) {2028 next = delta * x[j + 1];2029 x[j] = K * x[j] - current - next;2030 if (n--) {2031 j += 2;2032 current = delta * x[j + 1];2033 x[j] = K * x[j] - current - next;2034 } else {2035 break;2036 }2037 }2038 // step 42039 j = offset - 1;2040 current = gamma * x[j - 1];2041 for (n = len + 2; n--; j += 2) {2042 next = gamma * x[j + 1];2043 x[j] -= current + next;2044 if (n--) {2045 j += 2;2046 current = gamma * x[j + 1];2047 x[j] -= current + next;2048 } else {2049 break;2050 }2051 }2052 // step 52053 j = offset;2054 current = beta * x[j - 1];2055 for (n = len + 1; n--; j += 2) {2056 next = beta * x[j + 1];2057 x[j] -= current + next;2058 if (n--) {2059 j += 2;2060 current = beta * x[j + 1];2061 x[j] -= current + next;2062 } else {2063 break;2064 }2065 }2066 // step 62067 if (len !== 0) {2068 j = offset + 1;2069 current = alpha * x[j - 1];2070 for (n = len; n--; j += 2) {2071 next = alpha * x[j + 1];2072 x[j] -= current + next;2073 if (n--) {2074 j += 2;2075 current = alpha * x[j + 1];2076 x[j] -= current + next;2077 } else {2078 break;2079 }2080 }2081 }2082 };2083 return IrreversibleTransform;2084 })();2085 // Section 3.8.1 Reversible 5-3 filter2086 var ReversibleTransform = (function ReversibleTransformClosure() {2087 function ReversibleTransform() {2088 Transform.call(this);2089 }2090 ReversibleTransform.prototype = Object.create(Transform.prototype);2091 ReversibleTransform.prototype.filter =2092 function reversibleTransformFilter(x, offset, length) {2093 var len = length >> 1;2094 offset = offset | 0;2095 var j, n;2096 for (j = offset, n = len + 1; n--; j += 2) {2097 x[j] -= (x[j - 1] + x[j + 1] + 2) >> 2;2098 }2099 for (j = offset + 1, n = len; n--; j += 2) {2100 x[j] += (x[j - 1] + x[j + 1]) >> 1;2101 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var fs = require('fs');3var path = require('path');4var input = fs.createReadStream('input.txt');5var output = fs.createWriteStream('output.txt');6var transform = wptools.ReversibleTransform();7input.pipe(transform).pipe(output);8var wptools = require('wptools');9var fs = require('fs');10var path = require('path');11var input = fs.createReadStream('input.txt');12var output = fs.createWriteStream('output.txt');13var transform = wptools.ReversibleTransform();14input.pipe(transform).pipe(output);15var wptools = require('wptools');16var fs = require('fs');17var path = require('path');18var input = fs.createReadStream('input.txt');19var output = fs.createWriteStream('output.txt');20var transform = wptools.ReversibleTransform();21input.pipe(transform).pipe(output);22var wptools = require('wptools');23var fs = require('fs');24var path = require('path');25var input = fs.createReadStream('input.txt');26var output = fs.createWriteStream('output.txt');27var transform = wptools.ReversibleTransform();28input.pipe(transform).pipe(output);29var wptools = require('wptools');30var fs = require('fs');31var path = require('path');32var input = fs.createReadStream('input.txt');33var output = fs.createWriteStream('output.txt');34var transform = wptools.ReversibleTransform();35input.pipe(transform).pipe(output);36var wptools = require('wptools');37var fs = require('fs');38var path = require('path');39var input = fs.createReadStream('input.txt');40var output = fs.createWriteStream('output.txt');41var transform = wptools.ReversibleTransform();42input.pipe(transform).pipe(output);43var wptools = require('wptools');44var fs = require('fs');45var path = require('path');46var input = fs.createReadStream('input.txt');

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptools = require('wptools');2wptools.page('Albert Einstein').get().then((page) => {3 return page.images();4}).then((images) => {5 console.log(images);6}).catch((error) => {7 console.log(error);8});9const wptools = require('wptools');10wptools.page('Albert Einstein').get().then((page) => {11 return page.links();12}).then((links) => {13 console.log(links);14}).catch((error) => {15 console.log(error);16});17const wptools = require('wptools');18wptools.page('Albert Einstein').get().then((page) => {19 return page.references();20}).then((references) => {21 console.log(references);22}).catch((error) => {23 console.log(error);24});25const wptools = require('wptools');26wptools.page('Albert Einstein').get().then((page) => {27 return page.sections();28}).then((sections) => {29 console.log(sections);30}).catch((error) => {31 console.log(error);32});33const wptools = require('wptools');34wptools.page('Albert Einstein').get().then((page) => {35 return page.templates();36}).then((templates) => {37 console.log(templates);38}).catch((error) => {39 console.log(error);40});41const wptools = require('wptools');42wptools.page('Albert Einstein').get().then((page) => {43 return page.text();44}).then((text) => {45 console.log(text);46}).catch((error) => {47 console.log(error);48});49const wptools = require('wptools');50wptools.page('Albert Einstein').get().then((page) => {51 return page.wikibase();52}).then((wikibase

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wptoolkit');2var transform = wptoolkit.ReversibleTransform();3transform.setTransform( 100, 100, 0.5, 0.5, 0, 0);4var x = 100;5var y = 100;6var result = transform.transform(x, y);7console.log(result);8I am trying to use the ReversibleTransform method of wptoolkit. The code is below. I am getting an error at the line transform.setTransform( 100, 100, 0.5, 0.5, 0, 0);. The error is "TypeError: transform.setTransform is not a function". I am new to nodejs. Can someone please help me in fixing this issue?

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptk = require('wptoolkit');2var NAD83 = new wptk.Coordinate(0,0,0);3var Reverse = new wptk.ReversibleTransform();4Reverse.WGS84ToNAD83(WGS84,NAD83);5console.log(NAD83.toString());6console.log(WGS84.toString());7var wptk = require('wptoolkit');8var NAD83 = new wptk.Coordinate(0,0,0);9var Reverse = new wptk.ReversibleTransform();10Reverse.WGS84ToNAD83(WGS84,NAD83);11console.log(NAD83.toString());12console.log(WGS84.toString());13var wptk = require('./wptoolkit.js');

Full Screen

Using AI Code Generation

copy

Full Screen

1require([2], function(3) {4 var wgs84 = new SpatialReference({ wkid: 4326 });5 var mapProjection = new SpatialReference({ wkid: 102100 });6 var mapPoint = new Point({7 });8 var mapPoint = new Point({9 });10 var transform = projection.project(11 new Point(),12 );13 console.log(transform.x);14 console.log(transform.y);15});16 #map {17 height: 100%;18 width: 100%;19 margin: 0;20 padding: 0;21 }22 var dojoConfig = {23 {24 }25 };

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var wiki = wptools.page('Barack Obama');3wiki.get(function(err, data) {4 console.log(data);5 var rev = data.revision;6 var rev_id = rev.revid;7 var rev_time = rev.timestamp;8 var rev_user = rev.user;9 var rev_user_id = rev.userid;10 var rev_comment = rev.comment;11 var rev_text = rev.text;12 var rev_sha1 = rev.sha1;13 var rev_parent_id = rev.parentid;14 var rev_size = rev.size;15 var rev_content_model = rev.contentmodel;16 var rev_format = rev.contentformat;17 var rev_page_id = rev.pageid;18 var rev_page_title = rev.pagetitle;19 var rev_page_ns = rev.pagenamespace;20 var rev_page_len = rev.pagelength;21 var rev_page_redirect = rev.pageredirect;22 var rev_page_restrictions = rev.pagerestrictions;23 var rev_page_content_model = rev.pagecontentmodel;24 var rev_page_content_format = rev.pagecontentformat;25 var rev_page_categories = rev.pagecategories;26 var rev_page_links = rev.pagelinks;27 var rev_page_templates = rev.pagetemplates;28 var rev_page_images = rev.pageimages;29 var rev_page_extlinks = rev.pageextlinks;30 var rev_page_langlinks = rev.pagelanglinks;31 var rev_page_headings = rev.pageheadings;32 var rev_page_html = rev.pagehtml;33 var rev_page_wikitext = rev.pagewikitext;34 var rev_page_text = rev.pagetext;35 var rev_page_json = rev.pagejson;36 var rev_page_xml = rev.pagexml;37 var rev_page_html_old = rev.pagehtmlold;38 var rev_page_wikitext_old = rev.pagewikitextold;39 var rev_page_text_old = rev.pagetextold;40 var rev_page_json_old = rev.pagejsonold;41 var rev_page_xml_old = rev.pagexmlold;42 var rev_page_html_diff = rev.pagehtmldiff;43 var rev_page_wikitext_diff = rev.pagewikitextdiff;44 var rev_page_text_diff = rev.pagetextdiff;

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