Leptonica 1.68
C Image Processing Library

arrayaccess.h File Reference

Macro access to pixels in 32-bit arrays. More...

Go to the source code of this file.

Defines

#define USE_INLINE_ACCESSORS   1
#define GET_DATA_BIT(pdata, n)   ((*((l_uint32 *)(pdata) + ((n) >> 5)) >> (31 - ((n) & 31))) & 1)
#define SET_DATA_BIT(pdata, n)   (*((l_uint32 *)(pdata) + ((n) >> 5)) |= (0x80000000 >> ((n) & 31)))
#define CLEAR_DATA_BIT(pdata, n)   (*((l_uint32 *)(pdata) + ((n) >> 5)) &= ~(0x80000000 >> ((n) & 31)))
#define SET_DATA_BIT_VAL(pdata, n, val)
#define GET_DATA_DIBIT(pdata, n)   ((*((l_uint32 *)(pdata) + ((n) >> 4)) >> (2 * (15 - ((n) & 15)))) & 3)
#define SET_DATA_DIBIT(pdata, n, val)
#define CLEAR_DATA_DIBIT(pdata, n)   (*((l_uint32 *)(pdata) + ((n) >> 4)) &= ~(0xc0000000 >> (2 * ((n) & 15))))
#define GET_DATA_QBIT(pdata, n)   ((*((l_uint32 *)(pdata) + ((n) >> 3)) >> (4 * (7 - ((n) & 7)))) & 0xf)
#define SET_DATA_QBIT(pdata, n, val)
#define CLEAR_DATA_QBIT(pdata, n)   (*((l_uint32 *)(pdata) + ((n) >> 3)) &= ~(0xf0000000 >> (4 * ((n) & 7))))
#define GET_DATA_BYTE(pdata, n)   (*(l_uint8 *)((l_uintptr_t)((l_uint8 *)(pdata) + (n)) ^ 3))
#define SET_DATA_BYTE(pdata, n, val)   (*(l_uint8 *)((l_uintptr_t)((l_uint8 *)(pdata) + (n)) ^ 3) = (val))
#define GET_DATA_TWO_BYTES(pdata, n)   (*(l_uint16 *)((l_uintptr_t)((l_uint16 *)(pdata) + (n)) ^ 2))
#define SET_DATA_TWO_BYTES(pdata, n, val)   (*(l_uint16 *)((l_uintptr_t)((l_uint16 *)(pdata) + (n)) ^ 2) = (val))
#define GET_DATA_FOUR_BYTES(pdata, n)   (*((l_uint32 *)(pdata) + (n)))
#define SET_DATA_FOUR_BYTES(pdata, n, val)   (*((l_uint32 *)(pdata) + (n)) = (val))

Detailed Description

Macro access to pixels in 32-bit arrays.

1, 2, 4, 8, 16 and 32 bit data access within an array of 32-bit words

This is used primarily to access 1, 2, 4, 8, 16 and 32 bit pixels
in a line of image data, represented as an array of 32-bit words.

   pdata:  pointer to first 32-bit word in the array
   n:      index of the pixel in the array

Function calls for these accessors are defined in arrayaccess.c.

However, for efficiency we use the inline macros for all accesses.
Even though the 2 and 4 bit set* accessors are more complicated,
they are about 10% faster than the function calls.

The 32 bit access is just a cast and ptr arithmetic.  We include
it so that the input ptr can be void*.

At the end of this file is code for invoking the function calls
instead of inlining.

The macro SET_DATA_BIT_VAL(pdata, n, val) is a bit slower than
    if (val == 0)
        CLEAR_DATA_BIT(pdata, n);
    else
        SET_DATA_BIT(pdata, n);

Definition in file arrayaccess.h.


Define Documentation

#define USE_INLINE_ACCESSORS   1

Definition at line 52 of file arrayaccess.h.

#define GET_DATA_BIT (   pdata,
 
)    ((*((l_uint32 *)(pdata) + ((n) >> 5)) >> (31 - ((n) & 31))) & 1)
#define CLEAR_DATA_BIT (   pdata,
 
)    (*((l_uint32 *)(pdata) + ((n) >> 5)) &= ~(0x80000000 >> ((n) & 31)))
#define SET_DATA_BIT_VAL (   pdata,
  n,
  val 
)
Value:
({l_uint32 *_TEMP_WORD_PTR_; \
     _TEMP_WORD_PTR_ = (l_uint32 *)(pdata) + ((n) >> 5); \
     *_TEMP_WORD_PTR_ &= ~(0x80000000 >> ((n) & 31)); \
     *_TEMP_WORD_PTR_ |= ((val) << (31 - ((n) & 31))); \
    })

Definition at line 69 of file arrayaccess.h.

Referenced by pixAffineSampled(), pixBilinearSampled(), and pixProjectiveSampled().

#define CLEAR_DATA_DIBIT (   pdata,
 
)    (*((l_uint32 *)(pdata) + ((n) >> 4)) &= ~(0xc0000000 >> (2 * ((n) & 15))))

Definition at line 90 of file arrayaccess.h.

Referenced by pixClearPixel().

#define CLEAR_DATA_QBIT (   pdata,
 
)    (*((l_uint32 *)(pdata) + ((n) >> 3)) &= ~(0xf0000000 >> (4 * ((n) & 7))))

Definition at line 107 of file arrayaccess.h.

Referenced by pixClearPixel().

#define GET_DATA_BYTE (   pdata,
 
)    (*(l_uint8 *)((l_uintptr_t)((l_uint8 *)(pdata) + (n)) ^ 3))

Definition at line 118 of file arrayaccess.h.

Referenced by absDifferenceLow(), accumulateLow(), addConstantGrayLow(), addGrayLow(), blockconvAccumLow(), blockconvLow(), blocksumLow(), dilateGrayLow(), distanceFunctionLow(), ditherTo2bppLineLow(), ditherToBinaryLineLow(), ditherToBinaryLineLUTLow(), erodeGrayLow(), expandBinaryPower2Low(), flipLRLow(), ftDrawBitmap(), identifyWatershedBasin(), linearInterpolatePixelGray(), main(), makeGrayQuantColormapArb(), multConstantGrayLow(), pixAddMinimalGrayColormap8(), pixaExtractColumnFromEachPix(), pixAffineSampled(), pixApplyHorizontalDisparity(), pixApplyInvBackgroundGrayMap(), pixApplyLocalThreshold(), pixApplyVariableGrayMap(), pixApplyVerticalDisparity(), pixAssignToNearestColor(), pixAverageOnLine(), pixAverageRasterScans(), pixBilinearSampled(), pixBlendCmap(), pixBlendGray(), pixBlendGrayAdapt(), pixBlendHardLight(), pixBlendWithGrayMask(), pixCensusTransform(), pixCentroid(), pixColorGrayCmap(), pixColorizeGray(), pixColorSegmentTryCluster(), pixColumnStats(), pixCombineMasked(), pixCombineMaskedGeneral(), pixConvert1To2(), pixConvert1To4(), pixConvert2To8(), pixConvert8To16(), pixConvert8To32(), pixConvertGrayToColormap8(), pixConvertGrayToSubpixelRGB(), pixConvertToFPix(), pixConvolve(), pixDilateGray3h(), pixDilateGray3v(), pixDisplayMatchedPattern(), pixErodeGray3h(), pixErodeGray3v(), pixExpandReplicate(), pixFadeWithGray(), pixFewColorsOctcubeQuantMixed(), pixFindEqualValues(), pixFlipPixel(), pixGenerateMaskByBand(), pixGenerateMaskByValue(), pixGetAverageMasked(), pixGetAverageTiled(), pixGetBackgroundGrayMap(), pixGetBinnedColor(), pixGetCmapHistogram(), pixGetCmapHistogramMasked(), pixGetColorHistogram(), pixGetColorHistogramMasked(), pixGetColumnStats(), pixGetDifferenceHistogram(), pixGetExtremeValue(), pixGetGrayHistogram(), pixGetGrayHistogramMasked(), pixGetInvBackgroundMap(), pixGetMaxValueInRect(), pixGetPixel(), pixGetPSNR(), pixGetRasterData(), pixGetRGBComponent(), pixGetRGBComponentCmap(), pixGetRGBLine(), pixGetRGBPixel(), pixGetRowStats(), pixGrayQuantFromCmap(), pixGrayQuantFromHisto(), pixHShearLI(), pixLinearTRCTiled(), pixMakeMaskFromLUT(), pixMaxDynamicRange(), pixMeanSquareAccum(), pixMedianCutQuantMixed(), pixMinOrMax(), pixNumColors(), pixOctreeQuantNumColors(), pixPlotAlongPta(), pixProjectiveSampled(), pixQuadraticVShearLI(), pixQuadraticVShearSampled(), pixQualifyLocalMinima(), pixRankColumnTransform(), pixRankFilterGray(), pixRankRowTransform(), pixRemoveColormap(), pixRemoveUnusedColors(), pixRenderContours(), pixRenderPtaBlend(), pixRotateBySampling(), pixRowStats(), pixSauvolaGetThreshold(), pixScaleGrayMinMax(), pixScaleGrayMinMax2(), pixScaleGrayRank2(), pixScaleGrayToBinaryFast(), pixSearchBinaryMaze(), pixSearchGrayMaze(), pixSelectMinInConnComp(), pixSetLowContrast(), pixSetRGBComponent(), pixSetSelectCmap(), pixSetSelectMaskedCmap(), pixSnapColor(), pixSobelEdgeFilter(), pixStretchHorizontalLI(), pixStretchHorizontalSampled(), pixSumPixelsByColumn(), pixSumPixelsByRow(), pixSumPixelValues(), pixThresholdGrayArb(), pixThresholdOn8bpp(), pixTRCMap(), pixTwoSidedEdgeFilter(), pixUnsharpMaskingGray1D(), pixUnsharpMaskingGray2D(), pixVarThresholdToBinary(), pixVShearLI(), pixWindowedVariance(), pixWriteStreamAsciiPnm(), pixWriteStreamGif(), pixWriteStreamJpeg(), pixWriteStreamPng(), pixWriteStreamPnm(), pixWriteStringPS(), pixWriteToTiffStream(), rotate90Low(), rotateAMGrayCornerLow(), rotateAMGrayLow(), scaleAreaMapLow2(), scaleBySamplingLow(), scaleGray2xLILineLow(), scaleGray4xLILineLow(), scaleGrayAreaMapLow(), scaleGrayLILow(), scaleMipmapLow(), scaleSmoothLow(), scaleToGray16Low(), scaleToGray2Low(), scaleToGray3Low(), scaleToGray4Low(), scaleToGray6Low(), scaleToGray8Low(), seedfillGrayInvLow(), seedfillGrayInvLowSimple(), seedfillGrayLow(), seedfillGrayLowSimple(), seedspreadLow(), selCreateFromColorPix(), subtractGrayLow(), thresholdTo2bppLow(), thresholdTo4bppLow(), thresholdToBinaryLineLow(), thresholdToValueLow(), and wshedApply().

#define SET_DATA_BYTE (   pdata,
  n,
  val 
)    (*(l_uint8 *)((l_uintptr_t)((l_uint8 *)(pdata) + (n)) ^ 3) = (val))

Definition at line 126 of file arrayaccess.h.

Referenced by absDifferenceLow(), addConstantGrayLow(), addGrayLow(), blockconvLow(), blocksumLow(), dilateGrayLow(), distanceFunctionLow(), ditherTo2bppLineLow(), ditherToBinaryLineLow(), ditherToBinaryLineLUTLow(), erodeGrayLow(), finalAccumulateLow(), flipLRLow(), fpixConvertToPix(), fpixDisplayMaxDynamicRange(), ftDrawBitmap(), main(), MakeGrayWash(), multConstantGrayLow(), pixAddMinimalGrayColormap8(), pixaExtractColumnFromEachPix(), pixAffineGray(), pixAffineSampled(), pixApplyHorizontalDisparity(), pixApplyInvBackgroundGrayMap(), pixApplyVariableGrayMap(), pixApplyVerticalDisparity(), pixAssignToNearestColor(), pixBilinearGray(), pixBilinearSampled(), pixBlendCmap(), pixBlendGray(), pixBlendGrayAdapt(), pixBlendHardLight(), pixBlendWithGrayMask(), pixBlockconvGrayTile(), pixClearPixel(), pixColorContent(), pixColorGrayCmap(), pixColorMagnitude(), pixColorSegmentTryCluster(), pixCombineMasked(), pixCombineMaskedGeneral(), pixConvert2To8(), pixConvert4To8(), pixConvertGrayToColormap8(), pixConvertLossless(), pixConvertRGBToGray(), pixConvertRGBToGrayFast(), pixConvertRGBToGrayMinMax(), pixConvertRGBToHue(), pixConvertRGBToSaturation(), pixConvertRGBToValue(), pixConvolve(), pixDilateGray3h(), pixDilateGray3v(), pixDitherOctindexWithCmap(), pixErodeGray3h(), pixErodeGray3v(), pixExpandReplicate(), pixFadeWithGray(), pixFewColorsOctcubeQuant1(), pixFewColorsOctcubeQuantMixed(), pixFixedOctcubeQuant256(), pixFlipPixel(), pixGetAverageTiled(), pixGetBackgroundGrayMap(), pixGetRGBComponent(), pixGetRGBComponentCmap(), pixGrayQuantFromCmap(), pixGrayQuantFromHisto(), pixHShearLI(), pixLinearTRCTiled(), pixMaxDynamicRange(), pixMedianCutQuantMixed(), pixMinOrMax(), pixOctcubeQuantFromCmapLUT(), pixOctcubeQuantMixedWithGray(), pixOctreeQuantByPopulation(), pixOctreeQuantizePixels(), pixOctreeQuantNumColors(), pixPaintThroughMask(), pixProjectiveGray(), pixProjectiveSampled(), pixQuadraticVShearLI(), pixQuadraticVShearSampled(), pixQuantizeWithColormap(), pixRandomHarmonicWarp(), pixRankColumnTransform(), pixRankFilterGray(), pixRankRowTransform(), pixReadStreamGif(), pixReadStreamJpeg(), pixReadStreamPng(), pixReadStreamPnm(), pixRemoveColormap(), pixRemoveUnusedColors(), pixRenderContours(), pixRotateBySampling(), pixRunlengthTransform(), pixSauvolaGetThreshold(), pixScaleGrayMinMax(), pixScaleGrayMinMax2(), pixScaleGrayRank2(), pixScaleRGBToGrayFast(), pixSearchBinaryMaze(), pixSearchGrayMaze(), pixSetBorderVal(), pixSetInRectArbitrary(), pixSetLowContrast(), pixSetMasked(), pixSetMaskedCmap(), pixSetPixel(), pixSetPixelColumn(), pixSetRGBComponent(), pixSetSelectCmap(), pixSetSelectMaskedCmap(), pixSnapColor(), pixSobelEdgeFilter(), pixStretchHorizontalLI(), pixStretchHorizontalSampled(), pixThresholdGrayArb(), pixThresholdOn8bpp(), pixTRCMap(), pixTwoSidedEdgeFilter(), pixUnsharpMaskingGray1D(), pixUnsharpMaskingGray2D(), pixVShearLI(), pixWindowedMean(), rotate90Low(), rotateAMGrayCornerLow(), rotateAMGrayLow(), scaleAreaMapLow2(), scaleBySamplingLow(), scaleGray2xLILineLow(), scaleGray4xLILineLow(), scaleGrayAreaMapLow(), scaleGrayLILow(), scaleMipmapLow(), scaleRGBToGray2Low(), scaleSmoothLow(), scaleToGray16Low(), scaleToGray2Low(), scaleToGray3Low(), scaleToGray4Low(), scaleToGray6Low(), scaleToGray8Low(), seedfillGrayInvLow(), seedfillGrayInvLowSimple(), seedfillGrayLow(), seedfillGrayLowSimple(), seedspreadLow(), setPixelLow(), subtractGrayLow(), thresholdTo2bppLow(), and thresholdToValueLow().

#define GET_DATA_FOUR_BYTES (   pdata,
 
)    (*((l_uint32 *)(pdata) + (n)))
#define SET_DATA_FOUR_BYTES (   pdata,
  n,
  val 
)    (*((l_uint32 *)(pdata) + (n)) = (val))
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines