14 #ifndef JABCODE_ENCODER_H 
   15 #define JABCODE_ENCODER_H 
   20 static const jab_byte jab_default_palette[] = {0,       0,              0,              
 
   33 #define FP0_CORE_COLOR  1 
   34 #define FP1_CORE_COLOR  2 
   35 #define FP2_CORE_COLOR  5 
   36 #define FP3_CORE_COLOR  6 
   41 #define AP0_CORE_COLOR  0 
   42 #define AP1_CORE_COLOR  0 
   43 #define AP2_CORE_COLOR  0 
   44 #define AP3_CORE_COLOR  0 
   45 #define APX_CORE_COLOR  7 
   50 static const jab_byte fp0_core_color_index[] = {0, 0, 
FP0_CORE_COLOR, 1, 1, 3, 3, 3};
 
   51 static const jab_byte fp1_core_color_index[] = {0, 1, FP1_CORE_COLOR, 2, 6, 12, 12, 28};
 
   52 static const jab_byte fp2_core_color_index[] = {0, 2, FP2_CORE_COLOR, 13, 25, 51, 115, 227};
 
   53 static const jab_byte fp3_core_color_index[] = {0, 3, FP3_CORE_COLOR, 14, 30, 60, 124, 252};
 
   57 static const jab_byte apn_core_color_index[] = {0, 4, 
AP0_CORE_COLOR, 0, 0, 0, 0, 0};
 
   58 static const jab_byte apx_core_color_index[] = {0, 5, APX_CORE_COLOR, 15, 31, 63, 127, 255};
 
   87         jab_int32*              row_height;
 
   94 static const jab_vector2d jab_symbol_pos[MAX_SYMBOL_NUMBER] =
 
   96                         { 0,-1}, { 0, 1}, {-1, 0}, { 1, 0}, { 0,-2}, {-1,-1}, { 1,-1}, { 0, 2}, {-1, 1}, { 1, 1},
 
   97                         {-2, 0}, { 2, 0}, { 0,-3}, {-1,-2}, { 1,-2}, {-2,-1}, { 2,-1}, { 0, 3}, {-1, 2}, { 1, 2},
 
   98                         {-2, 1}, { 2, 1}, {-3, 0}, { 3, 0},     { 0,-4}, {-1,-3}, { 1,-3}, {-2,-2}, { 2,-2}, {-3,-1},
 
   99                         { 3,-1}, { 0, 4}, {-1, 3}, { 1, 3}, {-2, 2}, { 2, 2}, {-3, 1}, { 3, 1}, {-4, 0}, { 4, 0},
 
  100                         { 0,-5}, {-1,-4}, { 1,-4}, {-2,-3}, { 2,-3}, {-3,-2}, { 3,-2}, {-4,-1}, { 4,-1}, { 0, 5},
 
  101                         {-1, 4}, { 1, 4}, {-2, 3}, { 2, 3}, {-3, 2}, { 3, 2}, {-4, 1}, { 4, 1}, {-5, 0}, { 5, 0}
 
  107 static const jab_int32 jab_enconing_table[MAX_SIZE_ENCODING_MODE][JAB_ENCODING_MODES]=
 
  108         {{-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  109          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,16,-1},
 
  110          {-1,-1,-1,-1,17,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-19,-1},{-1,-1,-1,-1,-1,-1},
 
  111          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  112          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  113          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  114          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, { 0, 0, 0,-1,-1, 0}, {-1,-1,-1, 0,-1,-1}, {-1,-1,-1, 1,-1,-1},
 
  115          {-1,-1,-1,-1, 0,-1}, {-1,-1,-1, 2,-1,-1}, {-1,-1,-1, 3,-1,-1}, {-1,-1,-1, 4,-1,-1}, {-1,-1,-1, 5,-1,-1},
 
  116          {-1,-1,-1, 6,-1,-1}, {-1,-1,-1, 7,-1,-1}, {-1,-1,-1,-1, 1,-1}, {-1,-1,-1,-1, 2,-1}, {-1,-1,11, 8,-20,-1},
 
  117          {-1,-1,-1, 9,-1,-1}, {-1,-1,12,10,-21,-1}, {-1,-1,-1,11,-1,-1},{-1,-1, 1,-1,-1, 1}, {-1,-1, 2,-1,-1, 2},
 
  118          {-1,-1, 3,-1,-1, 3}, {-1,-1, 4,-1,-1, 4}, {-1,-1, 5,-1,-1, 5}, {-1,-1, 6,-1,-1, 6}, {-1,-1, 7,-1,-1, 7},
 
  119          {-1,-1, 8,-1,-1, 8}, {-1,-1, 9,-1,-1, 9}, {-1,-1,10,-1,-1,10}, {-1,-1,-1,12,-22,-1}, {-1,-1,-1,13,-1,-1},
 
  120          {-1,-1,-1,-1, 3,-1}, {-1,-1,-1,-1, 4,-1}, {-1,-1,-1,-1, 5,-1}, {-1,-1,-1,14,-1,-1}, {-1,-1,-1,15,-1,-1},
 
  121          { 1,-1,-1,-1,-1,11}, { 2,-1,-1,-1,-1,12}, { 3,-1,-1,-1,-1,13}, { 4,-1,-1,-1,-1,14}, { 5,-1,-1,-1,-1,15},
 
  122          { 6,-1,-1,-1,-1,16}, { 7,-1,-1,-1,-1,17}, { 8,-1,-1,-1,-1,18}, { 9,-1,-1,-1,-1,19}, { 10,-1,-1,-1,-1,20},
 
  123          {11,-1,-1,-1,-1,21}, {12,-1,-1,-1,-1,22}, {13,-1,-1,-1,-1,23}, {14,-1,-1,-1,-1,24}, {15,-1,-1,-1,-1,25},
 
  124          {16,-1,-1,-1,-1,26}, {17,-1,-1,-1,-1,27}, {18,-1,-1,-1,-1,28}, {19,-1,-1,-1,-1,29}, {20,-1,-1,-1,-1,30},
 
  125          {21,-1,-1,-1,-1,31}, {22,-1,-1,-1,-1,32}, {23,-1,-1,-1,-1,33}, {24,-1,-1,-1,-1,34}, {25,-1,-1,-1,-1,35},
 
  126          {26,-1,-1,-1,-1,36}, {-1,-1,-1,-1, 6,-1}, {-1,-1,-1,-1, 7,-1}, {-1,-1,-1,-1, 8,-1}, {-1,-1,-1,-1, 9,-1},
 
  127          {-1,-1,-1,-1,10,-1}, {-1,-1,-1,-1,11,-1}, {-1, 1,-1,-1,-1,37}, {-1, 2,-1,-1,-1,38}, {-1, 3,-1,-1,-1,39},
 
  128          {-1, 4,-1,-1,-1,40}, {-1, 5,-1,-1,-1,41}, {-1, 6,-1,-1,-1,42}, {-1, 7,-1,-1,-1,43}, {-1, 8,-1,-1,-1,44},
 
  129          {-1, 9,-1,-1,-1,45}, {-1,10,-1,-1,-1,46}, {-1,11,-1,-1,-1,47}, {-1,12,-1,-1,-1,48}, {-1,13,-1,-1,-1,49},
 
  130          {-1,14,-1,-1,-1,50}, {-1,15,-1,-1,-1,51}, {-1,16,-1,-1,-1,52}, {-1,17,-1,-1,-1,53}, {-1,18,-1,-1,-1,54},
 
  131          {-1,19,-1,-1,-1,55}, {-1,20,-1,-1,-1,56}, {-1,21,-1,-1,-1,57}, {-1,22,-1,-1,-1,58}, {-1,23,-1,-1,-1,59},
 
  132          {-1,24,-1,-1,-1,60}, {-1,25,-1,-1,-1,61}, {-1,26,-1,-1,-1,62}, {-1,-1,-1,-1,12,-1}, {-1,-1,-1,-1,13,-1},
 
  133          {-1,-1,-1,-1,14,-1}, {-1,-1,-1,-1,15,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  134          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  135          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  136          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  137          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  138          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  139          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  140          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,23,-1},
 
  141          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,24,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  142          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  143          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  144          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  145          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  146          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  147          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,25,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  148          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  149          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  150          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,26,-1},
 
  151          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  152          {-1,-1,-1,-1,27,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,28,-1}, {-1,-1,-1,-1,-1,-1},
 
  153          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,29,-1}, {-1,-1,-1,-1,-1,-1},
 
  154          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  155          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  156          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  157          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,30,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  158          {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,31,-1}, {-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1},
 
  159          {-1,-1,-1,-1,-1,-1}};
 
  164 static const jab_int32 latch_shift_to[14][14]=
 
  165         {{0,5,5,ENC_MAX,ENC_MAX,5,ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,5,7,ENC_MAX,11},
 
  166          {7,0,5,ENC_MAX,ENC_MAX,5,ENC_MAX,5,ENC_MAX,ENC_MAX,5,7,ENC_MAX,11},
 
  167          {4,6,0,ENC_MAX,ENC_MAX,9,ENC_MAX,6,ENC_MAX,ENC_MAX,4,6,ENC_MAX,10},
 
  168          {ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,0,0,0,ENC_MAX,ENC_MAX,0,ENC_MAX},
 
  169          {ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,0,0,0,ENC_MAX,ENC_MAX,0,ENC_MAX},
 
  170          {8,13,13,ENC_MAX,ENC_MAX,0,ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,8,8,ENC_MAX,12},
 
  171          {ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,0,0,0,0,ENC_MAX,ENC_MAX,0,0},
 
  172          {0,5,5,ENC_MAX,ENC_MAX,5,ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,5,7,ENC_MAX,11},
 
  173          {7,0,5,ENC_MAX,ENC_MAX,5,ENC_MAX,5,ENC_MAX,ENC_MAX,5,7,ENC_MAX,11},
 
  174          {4,6,0,ENC_MAX,ENC_MAX,9,ENC_MAX,6,ENC_MAX,ENC_MAX,4,6,ENC_MAX,10},
 
  175          {ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,0,0,0,ENC_MAX,ENC_MAX,0,ENC_MAX},
 
  176          {ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,0,0,0,ENC_MAX,ENC_MAX,0,ENC_MAX},
 
  177          {8,13,13,ENC_MAX,ENC_MAX,0,ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,8,8,ENC_MAX,12},
 
  178          {ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,ENC_MAX,0,0,0,0,ENC_MAX,ENC_MAX,0,0}};
 
  185 static const jab_int32 character_size[7]={5,5,4,4,5,6,8};
 
  191 static const jab_int32 mode_switch[7][16]=
 
  192         {{-1,28,29,-1,-1,30,-1,-1,-1,-1,27,125,-1,124,126,-1},          
 
  193          {126,-1,29,-1,-1,30,-1,28,-1,127,27,125,-1,124,-1,127},        
 
  194          {14,63,-1,-1,-1,478,-1,62,-1,-1,13,61,-1,60,-1,-1},            
 
  195          {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},                     
 
  196          {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},                     
 
  197          {255,8188,8189,-1,-1,-1,-1,-1,-1,-1,254,253,-1,252,-1,-1},     
 
  198          {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}};            
 
  204 static const jab_float ecclevel2coderate[11] = {0.55f, 0.63f, 0.57f, 0.55f, 0.50f, 0.43f, 0.34f, 0.25f, 0.20f, 0.17f, 0.14f};
 
  209 static const jab_int32 ecclevel2wcwr[11][2] = {{4, 9}, {3, 8}, {3, 7}, {4, 9}, {3, 6}, {4, 7}, {4, 6}, {3, 4}, {4, 5}, {5, 6}, {6, 7}};
 
  215 extern void getNextMetadataModuleInMaster(jab_int32 matrix_height, jab_int32 matrix_width, jab_int32 next_module_count, jab_int32* x, jab_int32* y);
 
jab_vector2d code_size
Code size in symbol. 
Definition: encoder.h:82
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. 
Definition: decoder.c:755
#define FP0_CORE_COLOR
Finder pattern core color index in default palette. 
Definition: encoder.h:33
Code parameters. 
Definition: encoder.h:80
#define AP0_CORE_COLOR
Alignment pattern core color index in default palette. 
Definition: encoder.h:41
void interleaveData(jab_data *data)
In-place interleaving. 
Definition: interleave.c:26
Data structure. 
Definition: jabcode.h:87
void maskSymbols(jab_encode *enc, jab_int32 mask_type, jab_int32 *masked, jab_code *cp)
Mask the data modules in symbols. 
Definition: mask.c:289
2-dimensional integer vector 
Definition: jabcode.h:71
Encode parameters. 
Definition: jabcode.h:122
jab_int32 maskCode(jab_encode *enc, jab_code *cp)
Mask modules. 
Definition: mask.c:363
jab_int32 dimension
Module size in pixel. 
Definition: encoder.h:81