MCPcopy Create free account
hub / github.com/creatale/node-dv / thresholdTo2bppLow

Function thresholdTo2bppLow

deps/leptonica/src/grayquant.c:1436–1462  ·  view source on GitHub ↗

! * \brief thresholdTo2bppLow() * * Low-level function for thresholding from 8 bpp (datas) to * 2 bpp (datad), using thresholds implicitly defined through %tab, * a 256-entry lookup table that gives a 2-bit output value * for each possible input. * * For each line, unroll the loop so that for each 32 bit src word, * representing four consecutive 8-bit pixels, we compose one byte

Source from the content-addressed store, hash-verified

1434 * of output consisiting of four 2-bit pixels.
1435 */
1436static void
1437thresholdTo2bppLow(l_uint32 *datad,
1438 l_int32 h,
1439 l_int32 wpld,
1440 l_uint32 *datas,
1441 l_int32 wpls,
1442 l_int32 *tab)
1443{
1444l_uint8 sval1, sval2, sval3, sval4, dval;
1445l_int32 i, j, k;
1446l_uint32 *lines, *lined;
1447
1448 for (i = 0; i < h; i++) {
1449 lines = datas + i * wpls;
1450 lined = datad + i * wpld;
1451 for (j = 0; j < wpls; j++) {
1452 k = 4 * j;
1453 sval1 = GET_DATA_BYTE(lines, k);
1454 sval2 = GET_DATA_BYTE(lines, k + 1);
1455 sval3 = GET_DATA_BYTE(lines, k + 2);
1456 sval4 = GET_DATA_BYTE(lines, k + 3);
1457 dval = (tab[sval1] << 6) | (tab[sval2] << 4) |
1458 (tab[sval3] << 2) | tab[sval4];
1459 SET_DATA_BYTE(lined, j, dval);
1460 }
1461 }
1462}
1463
1464
1465/*----------------------------------------------------------------------*

Callers 2

pixThresholdTo2bppFunction · 0.85
pixThresholdGrayArbFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected