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

Symbol encoding. More...

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

Functions

void genColorPalette (jab_int32 color_number, jab_byte *palette)
 Generate color palettes with more than 8 colors. More...
 
void setDefaultPalette (jab_int32 color_number, jab_byte *palette)
 Set default color palette. More...
 
void setDefaultEccLevels (jab_int32 symbol_number, jab_byte *ecc_levels)
 Set default error correction levels. More...
 
void swap_int (jab_int32 *a, jab_int32 *b)
 Swap two integer elements. More...
 
void swap_byte (jab_byte *a, jab_byte *b)
 Swap two byte elements. More...
 
void convert_dec_to_bin (jab_int32 dec, jab_char *bin, jab_int32 start_position, jab_int32 length)
 Convert decimal to binary. More...
 
jab_encodecreateEncode (jab_int32 color_number, jab_int32 symbol_number)
 Create encode object. More...
 
void destroyEncode (jab_encode *enc)
 Destroy encode object. More...
 
jab_int32 * analyzeInputData (jab_data *input, jab_int32 *encoded_length)
 Analyze the input data and determine the optimal encoding modes for each character. More...
 
jab_boolean isDefaultMode (jab_encode *enc)
 Check if master symbol shall be encoded in default mode. More...
 
jab_int32 getMetadataLength (jab_encode *enc, jab_int32 index)
 Calculate the (encoded) metadata length. More...
 
jab_int32 getSymbolCapacity (jab_encode *enc, jab_int32 index)
 Calculate the data capacity of a symbol. More...
 
void getOptimalECC (jab_int32 capacity, jab_int32 net_data_length, jab_int32 *wcwr)
 Get the optimal error correction capability. More...
 
jab_dataencodeData (jab_data *data, jab_int32 encoded_length, jab_int32 *encode_seq)
 Encode the input data. More...
 
jab_boolean encodeMasterMetadata (jab_encode *enc)
 Encode metadata. More...
 
jab_boolean updateMasterMetadataPartII (jab_encode *enc, jab_int32 mask_ref)
 Update master symbol metadata PartII if the default masking reference is changed. More...
 
void placeMasterMetadataPartII (jab_encode *enc)
 Update master symbol metadata PartII if the default masking reference is changed. More...
 
void getColorPaletteIndex (jab_byte *index, jab_int32 index_size, jab_int32 color_number)
 Get color index for the color palette. More...
 
jab_boolean createMatrix (jab_encode *enc, jab_int32 index, jab_data *ecc_encoded_data)
 Create symbol matrix. More...
 
void swap_symbols (jab_encode *enc, jab_int32 index1, jab_int32 index2)
 Swap two symbols. More...
 
jab_boolean assignDockedSymbols (jab_encode *enc)
 Assign docked symbols to their hosts. More...
 
jab_codegetCodePara (jab_encode *enc)
 Calculate the code parameters according to the input symbols. More...
 
jab_boolean createBitmap (jab_encode *enc, jab_code *cp)
 Create bitmap for the code. More...
 
jab_boolean checkDockedSymbolSize (jab_encode *enc)
 Checks if the docked symbol sizes are valid. More...
 
jab_boolean setMasterSymbolVersion (jab_encode *enc, jab_data *encoded_data)
 Set the minimal master symbol version. More...
 
jab_boolean addE2SlaveMetadata (jab_symbol *slave)
 Add variable E to slave symbol metadata the data payload for each symbol. More...
 
void updateSlaveMetadataE (jab_encode *enc, jab_int32 host_index, jab_int32 slave_index)
 Update slave metadata E in its host data stream. More...
 
jab_boolean fitDataIntoSymbols (jab_encode *enc, jab_data *encoded_data)
 Set the data payload for each symbol. More...
 
jab_boolean InitSymbols (jab_encode *enc)
 Initialize symbols. More...
 
jab_boolean setSlaveMetadata (jab_encode *enc)
 Set metadata for slave symbols. More...
 
jab_int32 generateJABCode (jab_encode *enc, jab_data *data)
 Generate JABCode. More...
 
void reportError (jab_char *message)
 Report error message. More...
 

Detailed Description

Symbol encoding.

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

jab_boolean addE2SlaveMetadata ( jab_symbol slave)

Add variable E to slave symbol metadata the data payload for each symbol.

Parameters
slavethe slave symbol
Returns
JAB_SUCCESS | JAB_FAILURE
jab_int32* analyzeInputData ( jab_data input,
jab_int32 *  encoded_length 
)

Analyze the input data and determine the optimal encoding modes for each character.

Parameters
inputthe input character data
encoded_lengththe shortest encoding length
Returns
the optimal encoding sequence | NULL: fatal error (out of memory)
jab_boolean assignDockedSymbols ( jab_encode enc)

Assign docked symbols to their hosts.

Parameters
encthe encode parameters
Returns
JAB_SUCCESS | JAB_FAILURE
jab_boolean checkDockedSymbolSize ( jab_encode enc)

Checks if the docked symbol sizes are valid.

Parameters
encthe encode parameters
Returns
JAB_SUCCESS | JAB_FAILURE
void convert_dec_to_bin ( jab_int32  dec,
jab_char *  bin,
jab_int32  start_position,
jab_int32  length 
)

Convert decimal to binary.

Parameters
decthe decimal value
binthe data in binary representation
start_positionthe position to write in encoded data array
lengththe length of the converted binary sequence
jab_boolean createBitmap ( jab_encode enc,
jab_code cp 
)

Create bitmap for the code.

Parameters
encthe encode parameters
cpthe code parameters
Returns
JAB_SUCCESS | JAB_FAILURE
jab_encode* createEncode ( jab_int32  color_number,
jab_int32  symbol_number 
)

Create encode object.

Parameters
color_numberthe number of module colors
symbol_numberthe number of symbols
Returns
the created encode parameter object | NULL: fatal error (out of memory)
jab_boolean createMatrix ( jab_encode enc,
jab_int32  index,
jab_data ecc_encoded_data 
)

Create symbol matrix.

Parameters
encthe encode parameter
indexthe symbol index
ecc_encoded_dataencoded data
Returns
JAB_SUCCESS | JAB_FAILURE
void destroyEncode ( jab_encode enc)

Destroy encode object.

Parameters
encthe encode object
jab_data* encodeData ( jab_data data,
jab_int32  encoded_length,
jab_int32 *  encode_seq 
)

Encode the input data.

Parameters
datathe character input data
encoded_lengththe optimal encoding length
encode_seqthe optimal encoding sequence
Returns
the encoded data | NULL if failed
jab_boolean encodeMasterMetadata ( jab_encode enc)

Encode metadata.

Parameters
encthe encode parameters
Returns
JAB_SUCCESS | JAB_FAILURE
jab_boolean fitDataIntoSymbols ( jab_encode enc,
jab_data encoded_data 
)

Set the data payload for each symbol.

Parameters
encthe encode parameters
encoded_datathe encoded message
Returns
JAB_SUCCESS | JAB_FAILURE
void genColorPalette ( jab_int32  color_number,
jab_byte *  palette 
)

Generate color palettes with more than 8 colors.

Parameters
color_numberthe number of colors
palettethe color palette
jab_int32 generateJABCode ( jab_encode enc,
jab_data data 
)

Generate JABCode.

Parameters
encthe encode parameters
datathe input data
Returns
0:success | 1: out of memory | 2:no input data | 3:incorrect symbol version or position | 4: input data too long
jab_code* getCodePara ( jab_encode enc)

Calculate the code parameters according to the input symbols.

Parameters
encthe encode parameters
Returns
the code parameters
void getColorPaletteIndex ( jab_byte *  index,
jab_int32  index_size,
jab_int32  color_number 
)

Get color index for the color palette.

Parameters
indexthe color index in the palette
index_sizethe size of index
color_numberthe number of colors
jab_int32 getMetadataLength ( jab_encode enc,
jab_int32  index 
)

Calculate the (encoded) metadata length.

Parameters
encthe encode parameters
indexthe symbol index
Returns
the metadata length (encoded length for master symbol)
void getOptimalECC ( jab_int32  capacity,
jab_int32  net_data_length,
jab_int32 *  wcwr 
)

Get the optimal error correction capability.

Parameters
capacitythe symbol capacity
net_data_lengththe original data length
wcwrthe LPDC parameters wc and wr
Returns
JAB_SUCCESS | JAB_FAILURE
jab_int32 getSymbolCapacity ( jab_encode enc,
jab_int32  index 
)

Calculate the data capacity of a symbol.

Parameters
encthe encode parameters
indexthe symbol index
Returns
the data capacity
jab_boolean InitSymbols ( jab_encode enc)

Initialize symbols.

Parameters
encthe encode parameters
Returns
JAB_SUCCESS | JAB_FAILURE
jab_boolean isDefaultMode ( jab_encode enc)

Check if master symbol shall be encoded in default mode.

Parameters
encthe encode parameters
Returns
JAB_SUCCESS | JAB_FAILURE
void placeMasterMetadataPartII ( jab_encode enc)

Update master symbol metadata PartII if the default masking reference is changed.

Parameters
encthe encode parameter
void reportError ( jab_char *  message)

Report error message.

Parameters
messagethe error message
void setDefaultEccLevels ( jab_int32  symbol_number,
jab_byte *  ecc_levels 
)

Set default error correction levels.

Parameters
symbol_numberthe number of symbols
ecc_levelsthe ecc_level for each symbol
void setDefaultPalette ( jab_int32  color_number,
jab_byte *  palette 
)

Set default color palette.

Parameters
color_numberthe number of colors
palettethe color palette
jab_boolean setMasterSymbolVersion ( jab_encode enc,
jab_data encoded_data 
)

Set the minimal master symbol version.

Parameters
encthe encode parameters
encoded_datathe encoded message
Returns
JAB_SUCCESS | JAB_FAILURE
jab_boolean setSlaveMetadata ( jab_encode enc)

Set metadata for slave symbols.

Parameters
encthe encode parameters
Returns
JAB_SUCCESS | JAB_FAILURE
void swap_byte ( jab_byte *  a,
jab_byte *  b 
)

Swap two byte elements.

Parameters
athe first element
bthe second element
void swap_int ( jab_int32 *  a,
jab_int32 *  b 
)

Swap two integer elements.

Parameters
athe first element
bthe second element
void swap_symbols ( jab_encode enc,
jab_int32  index1,
jab_int32  index2 
)

Swap two symbols.

Parameters
encthe encode parameters
index1the index number of the first symbol
index2the index number of the second symbol
jab_boolean updateMasterMetadataPartII ( jab_encode enc,
jab_int32  mask_ref 
)

Update master symbol metadata PartII if the default masking reference is changed.

Parameters
encthe encode parameter
mask_refthe masking reference
Returns
JAB_SUCCESS | JAB_FAILURE
void updateSlaveMetadataE ( jab_encode enc,
jab_int32  host_index,
jab_int32  slave_index 
)

Update slave metadata E in its host data stream.

Parameters
encthe encode parameters
host_indexthe host symbol index
slave_indexthe slave symbol index