Documentation
¶
Overview ¶
Package spec holds JAB Code symbol geometry, metadata layout, masking and finder core-color constants shared by the encoder and decoder.
Index ¶
- Constants
- Variables
- func BSIErrorCorrectionBitLength(sideVersion image.Point) int
- func Log2Int(n int) int
- func MaskValue(maskType, x, y int) int
- func NextMetadataModuleInPrimary(height, width, count int, x, y *int)
- func NextMetadataModuleInSecondary(count int, x, y *int)
- func PaletteCopies(colorNumber int) int
- func PaletteFinderColors(colorNumber int) int
- func SizeToVersion(s int) int
- func ValidSideSize(s int) bool
- func VersionToSize(v int) int
Constants ¶
const ( ModeUpper = iota ModeLower ModeNumeric ModePunct ModeMixed ModeAlphanumeric ModeByte )
Encoding modes shared by the encoder's mode optimizer and the decoder; they index the per-character cost and decoding tables (encoder.h, decoder.h).
const ( ColorPaletteNumber = 4 DistanceToBorder = 4 PrimaryMetadataX = 6 PrimaryMetadataY = 1 PrimaryMetadataPart1Length = 6 PrimaryMetadataPart2Length = 38 PrimaryMetadataPart1ModuleNumber = 4 )
Symbol layout constants (jabcode.h, decoder.h).
const ( FP0CoreColor = 0 // black FP1CoreColor = 0 // black FP2CoreColor = 6 // yellow FP3CoreColor = 3 // cyan )
Finder-pattern core color indices in the 8-color default palette, used as fixed scalars during detection and masking (the Nc=2 column of tables.FPCoreColor).
const DefaultECCLevel = 3
DefaultECCLevel is the error-correction level of a default-mode primary symbol.
const DefaultMaskingReference = 7
DefaultMaskingReference is the fixed mask pattern used in default mode.
const DefaultModuleColorMode = 2
DefaultModuleColorMode is the Nc of a default-mode primary symbol, so its color count is 2^(Nc+1) = 8.
const PalettePlacementSlots = 64
PalettePlacementSlots is how many palette colors a symbol embeds at most. The 128- and 256-color modes embed 64 representatives and interpolate the rest, so no mode ever walks more slots than this.
Variables ¶
var ECCWeights = [11][2]int{
{4, 9}, {3, 8}, {3, 7}, {4, 9}, {3, 6}, {4, 7}, {4, 6}, {3, 4}, {4, 5}, {5, 6}, {6, 7},
}
ECCWeights maps an error-correction level to its LDPC (wc, wr) weights.
Functions ¶
func BSIErrorCorrectionBitLength ¶
BSIErrorCorrectionBitLength returns the width of the BSI E metadata field for a symbol with the given side versions.
func NextMetadataModuleInPrimary ¶
NextMetadataModuleInPrimary advances (x, y) to the next metadata/palette module position in a primary symbol. count is the running module index.
func NextMetadataModuleInSecondary ¶
NextMetadataModuleInSecondary advances (x, y) along the metadata strip of a BSI-era secondary symbol. count is the running module index.
func PaletteCopies ¶
PaletteCopies returns how many redundant copies of the colour palette a symbol embeds. The 4- and 8-colour modes embed four, which ISO/IEC 23634 4.3.9 requires outright. The higher modes embed two: ISO covers them only in informative Annex G, whose budget is 128 modules for two palettes, while BSI TR-03137 Part 2 3.3.8 says normatively that two shall be placed. With two copies the up-to-64 embedded colours fit the primary symbol's fixed metadata region, which four copies overflow. The count is the same on encode and decode, so the palette round-trips.
func PaletteFinderColors ¶
PaletteFinderColors returns how many of a symbol's palette colors are carried by the finder (primary) or alignment (secondary) patterns rather than embedded in the metadata region. ISO/IEC 23634 4.3.9 has each embedded palette carry every colour "except the two colours used by the nearest finder pattern or alignment pattern U or L", so the 4- and 8-colour modes carry two there. The higher modes carry none, because their finder cores are not palette colors 0 and 1 (ISO/IEC 23634 Annex G embeds every color in the palettes).
func SizeToVersion ¶
SizeToVersion returns the side version of a symbol with the given module side length.
func ValidSideSize ¶
ValidSideSize reports whether s is a legal module side length, the size of some side version 1..32 (4v+17).
func VersionToSize ¶
VersionToSize returns the module side length of a symbol of the given side version.
Types ¶
This section is empty.