hx_define_mode() if/else; qr.h tabs

This commit is contained in:
gitlost 2020-11-27 15:24:37 +00:00
parent cd214addba
commit 8e0078695c
2 changed files with 23 additions and 20 deletions

View File

@ -396,11 +396,13 @@ static void hx_define_mode(char *mode, const unsigned int gbdata[], const int le
if (in_numeric(gbdata, length, i, &numeric_end, &numeric_cost)) { if (in_numeric(gbdata, length, i, &numeric_end, &numeric_cost)) {
cur_costs[HX_N] = prev_costs[HX_N] + numeric_cost; cur_costs[HX_N] = prev_costs[HX_N] + numeric_cost;
char_modes[cm_i + HX_N] = 'n'; char_modes[cm_i + HX_N] = 'n';
text1 = 1;
text2 = 0;
} else {
text1 = lookup_text1(gbdata[i]) != -1;
text2 = lookup_text2(gbdata[i]) != -1;
} }
text1 = lookup_text1(gbdata[i]) != -1;
text2 = lookup_text2(gbdata[i]) != -1;
if (text1 || text2) { if (text1 || text2) {
if ((text_submode == 1 && text2) || (text_submode == 2 && text1)) { if ((text_submode == 1 && text2) || (text_submode == 2 && text1)) {
cur_costs[HX_T] = prev_costs[HX_T] + 72; /* (6 + 6) * HX_MULT */ cur_costs[HX_T] = prev_costs[HX_T] + 72; /* (6 + 6) * HX_MULT */
@ -417,21 +419,21 @@ static void hx_define_mode(char *mode, const unsigned int gbdata[], const int le
cur_costs[HX_B] = prev_costs[HX_B] + (gbdata[i] > 0xFF ? 96 : 48); /* (16 : 8) * HX_MULT */ cur_costs[HX_B] = prev_costs[HX_B] + (gbdata[i] > 0xFF ? 96 : 48); /* (16 : 8) * HX_MULT */
char_modes[cm_i + HX_B] = 'b'; char_modes[cm_i + HX_B] = 'b';
if (isRegion1(gbdata[i])) {
cur_costs[HX_1] = prev_costs[HX_1] + 72; /* 12 * HX_MULT */
char_modes[cm_i + HX_1] = '1';
}
if (isRegion2(gbdata[i])) {
cur_costs[HX_2] = prev_costs[HX_2] + 72; /* 12 * HX_MULT */
char_modes[cm_i + HX_2] = '2';
}
if (isDoubleByte(gbdata[i])) {
cur_costs[HX_D] = prev_costs[HX_D] + 90; /* 15 * HX_MULT */
char_modes[cm_i + HX_D] = 'd';
}
if (in_fourbyte(gbdata, length, i, &fourbyte_end, &fourbyte_cost)) { if (in_fourbyte(gbdata, length, i, &fourbyte_end, &fourbyte_cost)) {
cur_costs[HX_F] = prev_costs[HX_F] + fourbyte_cost; cur_costs[HX_F] = prev_costs[HX_F] + fourbyte_cost;
char_modes[cm_i + HX_F] = 'f'; char_modes[cm_i + HX_F] = 'f';
} else {
if (isDoubleByte(gbdata[i])) {
cur_costs[HX_D] = prev_costs[HX_D] + 90; /* 15 * HX_MULT */
char_modes[cm_i + HX_D] = 'd';
if (isRegion1(gbdata[i])) { /* Subset */
cur_costs[HX_1] = prev_costs[HX_1] + 72; /* 12 * HX_MULT */
char_modes[cm_i + HX_1] = '1';
} else if (isRegion2(gbdata[i])) { /* Subset */
cur_costs[HX_2] = prev_costs[HX_2] + 72; /* 12 * HX_MULT */
char_modes[cm_i + HX_2] = '2';
}
}
} }
if (i == length - 1) { /* Add end of data costs if last character */ if (i == length - 1) { /* Add end of data costs if last character */

View File

@ -29,20 +29,21 @@
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE. SUCH DAMAGE.
*/ */
/* vim: set ts=4 sw=4 et : */
#define LEVEL_L 1 #define LEVEL_L 1
#define LEVEL_M 2 #define LEVEL_M 2
#define LEVEL_Q 3 #define LEVEL_Q 3
#define LEVEL_H 4 #define LEVEL_H 4
#define QR_PERCENT 38 /* Alphanumeric mode % */ #define QR_PERCENT 38 /* Alphanumeric mode % */
/* From ISO/IEC 18004:2015 Table 5 Encoding/decoding table for Alphanumeric mode */ /* From ISO/IEC 18004:2015 Table 5 Encoding/decoding table for Alphanumeric mode */
static const char qr_alphanumeric[59] = { static const char qr_alphanumeric[59] = {
36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, /* SP-/ */ 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, /* SP-/ */
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, /* 0-? */ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, /* 0-? */
-1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, /* @-O */ -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, /* @-O */
25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 /* P-Z */ 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 /* P-Z */
}; };
#define RMQR_VERSION 100 #define RMQR_VERSION 100