doubled symbols and payload size

This commit is contained in:
Ahmet Inan 2023-12-15 20:17:38 +01:00
commit 7a87215eb3
5 changed files with 31 additions and 31 deletions

4
README.md vendored
View file

@ -3,10 +3,10 @@
Quick start:
Create file ```uncoded.dat``` with ```1360``` bits of random data:
Create file ```uncoded.dat``` with ```2720``` bits of random data:
```
dd if=/dev/urandom of=uncoded.dat bs=1 count=170
dd if=/dev/urandom of=uncoded.dat bs=1 count=340
```
Encode file ```uncoded.dat``` to ```encoded.wav``` [WAV](https://en.wikipedia.org/wiki/WAV) audio file with 8000 Hz sample rate, 16 bits and only 1 (real) channel:

View file

@ -172,16 +172,16 @@ struct Decoder
typedef SIMD<code_type, 16 / sizeof(code_type)> mesg_type;
#endif
typedef DSP::Const<value> Const;
static const int code_order = 11;
static const int code_order = 12;
static const int mod_bits = 4;
static const int code_len = 1 << code_order;
static const int symbol_len = (1280 * rate) / 8000;
static const int filter_len = (((21 * rate) / 8000) & ~3) | 1;
static const int guard_len = symbol_len / 8;
static const int extended_len = symbol_len + guard_len;
static const int max_bits = 1360 + 32;
static const int max_bits = 2720 + 32;
static const int cons_cols = 256;
static const int cons_rows = 2;
static const int cons_rows = 4;
static const int cons_total = cons_rows * cons_cols;
static const int code_off = - cons_cols / 2;
static const int mls0_len = 127;
@ -427,16 +427,16 @@ struct Decoder
int data_bits = 0;
switch (oper_mode) {
case 17:
data_bits = 1360;
frozen_bits = frozen_2048_1392;
data_bits = 2720;
frozen_bits = frozen_4096_2752;
break;
case 18:
data_bits = 1024;
frozen_bits = frozen_2048_1056;
data_bits = 2048;
frozen_bits = frozen_4096_2080;
break;
case 19:
data_bits = 680;
frozen_bits = frozen_2048_712;
data_bits = 1360;
frozen_bits = frozen_4096_1392;
break;
default:
return;
@ -506,7 +506,7 @@ int main(int argc, char **argv)
if (argc > 3)
skip_count = std::atoi(argv[3]);
const int data_max = 1360 / 8;
const int data_max = 340;
uint8_t *output_data = new uint8_t[data_max];
int data_len = 0;

View file

@ -29,13 +29,13 @@ struct Encoder
{
typedef int8_t code_type;
static const int mod_bits = 4;
static const int code_order = 11;
static const int code_order = 12;
static const int code_len = 1 << code_order;
static const int symbol_len = (1280 * rate) / 8000;
static const int guard_len = symbol_len / 8;
static const int max_bits = 1360 + 32;
static const int max_bits = 2720 + 32;
static const int cons_cols = 256;
static const int cons_rows = 2;
static const int cons_rows = 4;
static const int mls0_len = 127;
static const int mls0_poly = 0b10001001;
static const int mls1_len = 255;
@ -218,16 +218,16 @@ struct Encoder
int data_bits = 0;
switch (oper_mode) {
case 17:
data_bits = 1360;
frozen_bits = frozen_2048_1392;
data_bits = 2720;
frozen_bits = frozen_4096_2752;
break;
case 18:
data_bits = 1024;
frozen_bits = frozen_2048_1056;
data_bits = 2048;
frozen_bits = frozen_4096_2080;
break;
case 19:
data_bits = 680;
frozen_bits = frozen_2048_712;
data_bits = 1360;
frozen_bits = frozen_4096_1392;
break;
default:
return;
@ -324,18 +324,18 @@ int main(int argc, char **argv)
std::cerr << "Couldn't open file \"" << input_name << "\" for reading." << std::endl;
return 1;
}
const int data_len = 1360 / 8;
const int data_len = 340;
uint8_t *input_data = new uint8_t[data_len];
for (int i = 0; i < data_len; ++i)
input_data[i] = std::max(input_file.get(), 0);
int oper_mode = 0;
for (int i = 128; i < 170; ++i)
for (int i = 256; i < 340; ++i)
if (!oper_mode && input_data[i])
oper_mode = 17;
for (int i = 85; i < 128; ++i)
for (int i = 170; i < 256; ++i)
if (!oper_mode && input_data[i])
oper_mode = 18;
for (int i = 0; i < 85; ++i)
for (int i = 0; i < 170; ++i)
if (!oper_mode && input_data[i])
oper_mode = 19;
CODE::Xorshift32 scrambler;

View file

@ -33,8 +33,8 @@ void code(int N, int K)
int main()
{
code<11>(2048, 1360+32);
code<11>(2048, 1024+32);
code<11>(2048, 680+32);
code<12>(4096, 2720+32);
code<12>(4096, 2048+32);
code<12>(4096, 1360+32);
return 0;
}

View file

@ -1,3 +1,3 @@
static const uint32_t frozen_2048_1392[64] = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x7fffffff, 0x11f7fff, 0xffffffff, 0x7fffffff, 0x17ffffff, 0x117177f, 0x177f7fff, 0x1037f, 0x1011f, 0x1, 0xffffffff, 0x177fffff, 0x77f7fff, 0x1011f, 0x1173fff, 0x10117, 0x10117, 0x0, 0x117177f, 0x17, 0x3, 0x0, 0x1, 0x0, 0x0, 0x0, 0x7fffffff, 0x11f7fff, 0x11717ff, 0x117, 0x17177f, 0x3, 0x1, 0x0, 0x1037f, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1011f, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, };
static const uint32_t frozen_2048_1056[64] = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x7fffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x7fffffff, 0xffffffff, 0x177fffff, 0x177f7fff, 0x1017f, 0xffffffff, 0xffffffff, 0xffffffff, 0x177f7fff, 0x7fffffff, 0x13f7fff, 0x1171fff, 0x117, 0x3fffffff, 0x11717ff, 0x7177f, 0x1, 0x1017f, 0x1, 0x1, 0x0, 0xffffffff, 0x7fffffff, 0x7fffffff, 0x1171fff, 0x17ffffff, 0x7177f, 0x1037f, 0x1, 0x77f7fff, 0x1013f, 0x10117, 0x1, 0x10117, 0x0, 0x0, 0x0, 0x1173fff, 0x10117, 0x117, 0x0, 0x7, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, };
static const uint32_t frozen_2048_712[64] = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x177fffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x7fffffff, 0x11f7fff, 0xffffffff, 0x7fffffff, 0x1fffffff, 0x17177f, 0x177fffff, 0x1037f, 0x1011f, 0x1, 0xffffffff, 0xffffffff, 0xffffffff, 0x7fffffff, 0xffffffff, 0x1fffffff, 0x177fffff, 0x1077f, 0xffffffff, 0x177f7fff, 0x13f7fff, 0x10117, 0x1171fff, 0x117, 0x7, 0x0, 0x7fffffff, 0x1173fff, 0x11717ff, 0x7, 0x3077f, 0x1, 0x1, 0x0, 0x1013f, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, };
static const uint32_t frozen_4096_2752[128] = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x7fffffff, 0xffffffff, 0x7fffffff, 0x17ffffff, 0x117177f, 0xffffffff, 0xffffffff, 0xffffffff, 0x17ffffff, 0xffffffff, 0x177f7fff, 0x37f7fff, 0x1011f, 0x7fffffff, 0x11f7fff, 0x11717ff, 0x10117, 0x117177f, 0x7, 0x1, 0x0, 0xffffffff, 0xffffffff, 0x7fffffff, 0x17f7fff, 0x7fffffff, 0x11717ff, 0x117177f, 0x17, 0x177fffff, 0x17177f, 0x1077f, 0x1, 0x1011f, 0x1, 0x1, 0x0, 0x77f7fff, 0x1013f, 0x10117, 0x1, 0x10117, 0x1, 0x1, 0x0, 0x10117, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xffffffff, 0x7fffffff, 0x17ffffff, 0x117177f, 0x177f7fff, 0x1037f, 0x1011f, 0x1, 0x11f7fff, 0x10117, 0x10117, 0x1, 0x10117, 0x0, 0x0, 0x0, 0x11717ff, 0x10117, 0x17, 0x0, 0x3, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x17177f, 0x7, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, };
static const uint32_t frozen_4096_2080[128] = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x7fffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x17ffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x77f7fff, 0x7fffffff, 0x1173fff, 0x11717ff, 0x117, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x7fffffff, 0x11f7fff, 0xffffffff, 0x7fffffff, 0x1fffffff, 0x117177f, 0x177fffff, 0x1077f, 0x1013f, 0x1, 0xffffffff, 0x177fffff, 0x177f7fff, 0x1013f, 0x11f7fff, 0x10117, 0x10117, 0x1, 0x11717ff, 0x117, 0x7, 0x0, 0x1, 0x0, 0x0, 0x0, 0xffffffff, 0xffffffff, 0xffffffff, 0x7fffffff, 0xffffffff, 0x17ffffff, 0x177fffff, 0x1077f, 0xffffffff, 0x177f7fff, 0x11f7fff, 0x10117, 0x11717ff, 0x10117, 0x17, 0x0, 0x7fffffff, 0x1171fff, 0x117177f, 0x17, 0x3177f, 0x1, 0x1, 0x0, 0x1017f, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x177fffff, 0x7177f, 0x1037f, 0x1, 0x1011f, 0x1, 0x1, 0x0, 0x10117, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10117, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, };
static const uint32_t frozen_4096_1392[128] = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x7fffffff, 0x13f7fff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x7fffffff, 0xffffffff, 0x7fffffff, 0x17ffffff, 0x17177f, 0xffffffff, 0xffffffff, 0xffffffff, 0x1fffffff, 0xffffffff, 0x177fffff, 0x37f7fff, 0x1011f, 0x7fffffff, 0x13f7fff, 0x1171fff, 0x117, 0x17177f, 0x3, 0x1, 0x0, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x7fffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x177fffff, 0xffffffff, 0x37f7fff, 0x1173fff, 0x10117, 0xffffffff, 0xffffffff, 0x7fffffff, 0x11f7fff, 0x3fffffff, 0x11717ff, 0x7177f, 0x1, 0x177fffff, 0x1077f, 0x1013f, 0x1, 0x10117, 0x1, 0x1, 0x0, 0xffffffff, 0x3fffffff, 0x177fffff, 0x7177f, 0x77f7fff, 0x1013f, 0x10117, 0x1, 0x1177fff, 0x10117, 0x117, 0x0, 0x7, 0x0, 0x0, 0x0, 0x117177f, 0x17, 0x3, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, };