jabcode
 All Classes Files Functions Variables Enumerations Macros
decoder.c File Reference

Data decoding. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "jabcode.h"
#include "detector.h"
#include "decoder.h"
#include "ldpc.h"
#include "encoder.h"

Functions

void copyAndInterpolateSubblockFrom16To32 (jab_byte *palette, jab_int32 dst_offset, jab_int32 src_offset)
 Copy 16-color sub-blocks of 64-color palette into 32-color blocks of 256-color palette and interpolate into 32 colors. More...
 
void interpolatePalette (jab_byte *palette, jab_int32 color_number)
 Interpolate 64-color palette into 128-/256-color palette. More...
 
jab_int32 readColorPaletteInMaster (jab_bitmap *matrix, jab_decoded_symbol *symbol, jab_byte *data_map, jab_int32 *module_count, jab_int32 *x, jab_int32 *y)
 Read the color palettes in master symbol. More...
 
jab_int32 readColorPaletteInSlave (jab_bitmap *matrix, jab_decoded_symbol *symbol, jab_byte *data_map)
 Read the color palettes in master symbol. More...
 
jab_byte decodeModuleHD (jab_byte *palette, jab_int32 color_number, jab_byte r, jab_byte g, jab_byte b)
 Decode a module using hard decision. More...
 
jab_byte decodeModule (jab_byte *palette, jab_int32 color_number, jab_float *ths, jab_float *rp, jab_byte *rgb, jab_float *p)
 Decode a module using soft decision. More...
 
jab_boolean getPaletteThreshold (jab_byte *palette, jab_int32 color_number, jab_float **palette_ths, jab_float **palette_rp)
 Get the pixel value thresholds and reference points for each channel of the colors in the palette. More...
 
void getNextMetadataModuleInMaster (jab_int32 matrix_height, jab_int32 matrix_width, jab_int32 next_module_count, jab_int32 *x, jab_int32 *y)
 Get the coordinate of the next metadata module in master symbol. More...
 
jab_int32 decodeSlaveMetadata (jab_decoded_symbol *host_symbol, jab_int32 docked_position, jab_data *data, jab_int32 offset)
 Decode slave symbol metadata. More...
 
jab_int32 decodeMasterMetadata (jab_bitmap *matrix, jab_decoded_symbol *symbol, jab_byte *data_map)
 Decode master symbol metadata. More...
 
jab_datareadRawModuleData (jab_bitmap *matrix, jab_decoded_symbol *symbol, jab_byte *data_map, jab_float **bits_p)
 Decode data modules. More...
 
jab_datarawModuleData2RawData (jab_data *raw_module_data, jab_int32 bits_per_module)
 Convert multi-bit-per-byte raw module data to one-bit-per-byte raw data. More...
 
void fillDataMap (jab_byte *data_map, jab_int32 width, jab_int32 height, jab_int32 type)
 Mark the positions of finder patterns and alignment patterns in the data map. More...
 
jab_int32 loadDefaultMasterMetadata (jab_bitmap *matrix, jab_decoded_symbol *symbol, jab_byte *data_map)
 Load default metadata values and color palettes for master symbol. More...
 
jab_int32 decodeSymbol (jab_bitmap *matrix, jab_decoded_symbol *symbol, jab_byte *data_map, jab_int32 type)
 Decode symbol. More...
 
jab_int32 decodeMaster (jab_bitmap *matrix, jab_decoded_symbol *symbol)
 Decode master symbol. More...
 
jab_int32 decodeSlave (jab_bitmap *matrix, jab_decoded_symbol *symbol)
 Decode slave symbol. More...
 
jab_int32 readData (jab_data *data, jab_int32 start, jab_int32 length, jab_int32 *value)
 Read bit data. More...
 
jab_datadecodeData (jab_data *bits)
 Interpret decoded bits. More...
 

Detailed Description

Data decoding.

libjabcode - JABCode Encoding/Decoding Library

Copyright 2016 by Fraunhofer SIT. All rights reserved. See LICENSE file for full terms of use and distribution.

Contact: Huajian Liu liu@s.nosp@m.it.f.nosp@m.raunh.nosp@m.ofer.nosp@m..de Waldemar Berchtold walde.nosp@m.mar..nosp@m.berch.nosp@m.told.nosp@m.@sit..nosp@m.frau.nosp@m.nhofe.nosp@m.r.de

Function Documentation

void copyAndInterpolateSubblockFrom16To32 ( jab_byte *  palette,
jab_int32  dst_offset,
jab_int32  src_offset 
)

Copy 16-color sub-blocks of 64-color palette into 32-color blocks of 256-color palette and interpolate into 32 colors.

Parameters
palettethe color palette
dst_offsetthe start offset in the destination palette
src_offsetthe start offset in the source palette
jab_data* decodeData ( jab_data bits)

Interpret decoded bits.

Parameters
bitsthe input bits
Returns
the data message
jab_int32 decodeMaster ( jab_bitmap matrix,
jab_decoded_symbol symbol 
)

Decode master symbol.

Parameters
matrixthe symbol matrix
symbolthe master symbol
Returns
JAB_SUCCESS | JAB_FAILURE | FATAL_ERROR
jab_int32 decodeMasterMetadata ( jab_bitmap matrix,
jab_decoded_symbol symbol,
jab_byte *  data_map 
)

Decode master symbol metadata.

Parameters
matrixthe symbol matrix
symbolthe master symbol
data_mapthe data module positions
Returns
JAB_SUCCESS | JAB_FAILURE | DECODE_METADATA_FAILED | FATAL_ERROR
jab_byte decodeModule ( jab_byte *  palette,
jab_int32  color_number,
jab_float *  ths,
jab_float *  rp,
jab_byte *  rgb,
jab_float *  p 
)

Decode a module using soft decision.

Parameters
palettethe color palette
color_numberthe number of colors
thsthe pixel value thresholds
rpthe reference pixel values
rgbthe pixel value in RGB format
pthe probability of the reliability of the decoded bits
Returns
the decoded value
jab_byte decodeModuleHD ( jab_byte *  palette,
jab_int32  color_number,
jab_byte  r,
jab_byte  g,
jab_byte  b 
)

Decode a module using hard decision.

Parameters
palettethe color palette
color_numberthe number of colors
rthe red channel value
gthe green channel value
bthe blue channel value
Returns
the decoded value
jab_int32 decodeSlave ( jab_bitmap matrix,
jab_decoded_symbol symbol 
)

Decode slave symbol.

Parameters
matrixthe symbol matrix
symbolthe slave symbol
Returns
JAB_SUCCESS | JAB_FAILURE | FATAL_ERROR
jab_int32 decodeSlaveMetadata ( jab_decoded_symbol host_symbol,
jab_int32  docked_position,
jab_data data,
jab_int32  offset 
)

Decode slave symbol metadata.

Parameters
host_symbolthe host symbol
docked_positionthe docked position
datathe data stream of the host symbol
offsetthe metadata start offset in the data stream
Returns
the read metadata bit length | DECODE_METADATA_FAILED
jab_int32 decodeSymbol ( jab_bitmap matrix,
jab_decoded_symbol symbol,
jab_byte *  data_map,
jab_int32  type 
)

Decode symbol.

Parameters
matrixthe symbol matrix
symbolthe symbol to be decoded
data_mapthe data module positions
typethe symbol type, 0: master, 1: slave
Returns
JAB_SUCCESS | JAB_FAILURE | DECODE_METADATA_FAILED | FATAL_ERROR
void fillDataMap ( jab_byte *  data_map,
jab_int32  width,
jab_int32  height,
jab_int32  type 
)

Mark the positions of finder patterns and alignment patterns in the data map.

Parameters
data_mapthe data module positions
widththe width of the data map
heightthe height of the data map
typethe symbol type, 0: master, 1: slave
void getNextMetadataModuleInMaster ( jab_int32  matrix_height,
jab_int32  matrix_width,
jab_int32  next_module_count,
jab_int32 *  x,
jab_int32 *  y 
)

Get the coordinate of the next metadata module in master symbol.

Parameters
matrix_heightthe height of the matrix
matrix_widththe width of the matrix
next_module_countthe index number of the next module
xthe x coordinate of the current and the next module
ythe y coordinate of the current and the next module
jab_boolean getPaletteThreshold ( jab_byte *  palette,
jab_int32  color_number,
jab_float **  palette_ths,
jab_float **  palette_rp 
)

Get the pixel value thresholds and reference points for each channel of the colors in the palette.

Parameters
palettethe color palette
color_numberthe number of colors
palette_thsthe pixel value thresholds
palette_rpthe reference pixel values
Returns
JAB_SUCCESS | JAB_FAILURE
void interpolatePalette ( jab_byte *  palette,
jab_int32  color_number 
)

Interpolate 64-color palette into 128-/256-color palette.

Parameters
palettethe color palette
color_numberthe number of colors
jab_int32 loadDefaultMasterMetadata ( jab_bitmap matrix,
jab_decoded_symbol symbol,
jab_byte *  data_map 
)

Load default metadata values and color palettes for master symbol.

Parameters
matrixthe symbol matrix
symbolthe master symbol
data_mapthe data module positions
Returns
JAB_SUCCESS | FATAL_ERROR
jab_data* rawModuleData2RawData ( jab_data raw_module_data,
jab_int32  bits_per_module 
)

Convert multi-bit-per-byte raw module data to one-bit-per-byte raw data.

Parameters
raw_module_datathe input raw module data
bits_per_modulethe number of bits per module
Returns
the converted data | NULL if failed
jab_int32 readColorPaletteInMaster ( jab_bitmap matrix,
jab_decoded_symbol symbol,
jab_byte *  data_map,
jab_int32 *  module_count,
jab_int32 *  x,
jab_int32 *  y 
)

Read the color palettes in master symbol.

Parameters
matrixthe symbol matrix
symbolthe master symbol
data_mapthe data module positions
module_countthe start module index
xthe x coordinate of the start module
ythe y coordinate of the start module
Returns
JAB_SUCCESS | FATAL_ERROR
jab_int32 readColorPaletteInSlave ( jab_bitmap matrix,
jab_decoded_symbol symbol,
jab_byte *  data_map 
)

Read the color palettes in master symbol.

Parameters
matrixthe symbol matrix
symbolthe slave symbol
data_mapthe data module positions
Returns
JAB_SUCCESS | FATAL_ERROR
jab_int32 readData ( jab_data data,
jab_int32  start,
jab_int32  length,
jab_int32 *  value 
)

Read bit data.

Parameters
datathe data buffer
startthe start reading offset
lengththe length of the data to be read
valuethe read data
Returns
the length of the read data
jab_data* readRawModuleData ( jab_bitmap matrix,
jab_decoded_symbol symbol,
jab_byte *  data_map,
jab_float **  bits_p 
)

Decode data modules.

Parameters
matrixthe symbol matrix
symbolthe symbol to be decoded
data_mapthe data module positions
bits_pthe probability of the reliability of the decoded bits
Returns
the decoded data | NULL if failed