Skip to content

Commit

Permalink
Reference encoder MSB/LSB bit order shifting changeable via MSB_FIRST
Browse files Browse the repository at this point in the history
  • Loading branch information
szabolor committed Aug 28, 2015
1 parent c9ae4ae commit 2876aeb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions smog_ref/v0.2/encode/enc_ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,13 @@ void encode_data_bit(uint8_t (*data)[256], uint8_t (*bit_encoded)[5200]) {

// convert to bit format: simply put 0 and 1 to the corresponding byte
for (i = 0; i < 5200; ++i) {
#if (MSBFIRST == 1)
// MSB first
(*bit_encoded)[i] = ( (encoded[i >> 3] & (1 << (7 - (i & 7)))) != 0 );
#else
// LSB first
(*bit_encoded)[i] = ( (encoded[i >> 3] & (1 << (i & 7))) != 0 );
#endif
}
}
#endif
3 changes: 2 additions & 1 deletion smog_ref/v0.2/encode/enc_ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#include <stdint.h>

#define LOW_MEMORY 1 // low memory workaround to avoid LUT (and preserve 512byte)
#define ENABLE_BIT_OUTPUT 0 // enable
#define ENABLE_BIT_OUTPUT 1 // enable
#define MSBFISRT 1 // the first bit of bytes of encode_data_bit is the MSB

void encode_data(uint8_t (*data)[256], uint8_t (*encoded)[650]);

Expand Down

0 comments on commit 2876aeb

Please sign in to comment.