diff options
author | Leo Howell <leo@lwh.jp> | 2009-11-03 15:29:45 +0900 |
---|---|---|
committer | Leo Howell <leo@lwh.jp> | 2009-11-03 15:30:57 +0900 |
commit | cca340e1b1017f1f565c5c53920e450d75164d51 (patch) | |
tree | d7716d4738f66decdf7258e447042e8967eb8037 /lpg/libqr | |
parent | 688c1b52ed356d024ba2e72ba52f7da64b7d74ed (diff) | |
download | pdf-simple-sign-cca340e1b1017f1f565c5c53920e450d75164d51.tar.gz pdf-simple-sign-cca340e1b1017f1f565c5c53920e450d75164d51.tar.xz pdf-simple-sign-cca340e1b1017f1f565c5c53920e450d75164d51.zip |
Fix the output block order
Diffstat (limited to 'lpg/libqr')
-rw-r--r-- | lpg/libqr/code-create.c | 24 | ||||
-rw-r--r-- | lpg/libqr/rs-encode.c | 1 |
2 files changed, 18 insertions, 7 deletions
diff --git a/lpg/libqr/code-create.c b/lpg/libqr/code-create.c index ae23acc..1a38967 100644 --- a/lpg/libqr/code-create.c +++ b/lpg/libqr/code-create.c @@ -179,7 +179,7 @@ static struct qr_bitstream * make_data(int version, const size_t total_words = total_bits / 8; const size_t total_data = QR_DATA_WORD_COUNT[version - 1][ec ^ 0x1]; size_t total_blocks, block_count[2], data_words, rs_words; - size_t i; + size_t i, w; struct qr_bitstream * dcopy = 0; struct qr_bitstream * out = 0; struct qr_bitstream ** blocks = 0; @@ -235,12 +235,24 @@ static struct qr_bitstream * make_data(int version, } /* Finally, write everything out in the correct order */ - qr_bitstream_seek(dcopy, 0); - for (i = 0; i < total_blocks; ++i) { - size_t dw = data_words + (i >= block_count[0]); - qr_bitstream_copy(out, dcopy, dw * 8); - qr_bitstream_cat(out, blocks[i]); + for (w = 0; w < data_words + 1; ++w) { + for (i = (w == data_words ? block_count[0] : 0); i < total_blocks; ++i) { + size_t di = w + (i < block_count[0] ? + i * data_words : + i * (data_words + 1) - block_count[0]); + + qr_bitstream_seek(dcopy, di * 8); + qr_bitstream_write(out, + qr_bitstream_read(dcopy, 8), 8); + } } + for (i = 0; i < total_blocks; ++i) + qr_bitstream_seek(blocks[i], 0); + for (w = 0; w < rs_words; ++w) + for (i = 0; i < total_blocks; ++i) + qr_bitstream_write(out, + qr_bitstream_read(blocks[i], 8), 8); + qr_bitstream_write(out, 0, total_bits - total_words * 8); fputs("Final bitstream:\n", stderr); diff --git a/lpg/libqr/rs-encode.c b/lpg/libqr/rs-encode.c index 42b404f..a8ecc73 100644 --- a/lpg/libqr/rs-encode.c +++ b/lpg/libqr/rs-encode.c @@ -74,7 +74,6 @@ struct qr_bitstream * rs_generate_words(struct qr_bitstream * data, goto fail; /* First, prepare the registers (b) with data bits */ - qr_bitstream_seek(data, 0); for (i = 0; i < data_words; ++i) { unsigned int x = b[n-1] ^ qr_bitstream_read(data, 8); for (r = n-1; r > 0; --r) |