Skip to content

Commit

Permalink
Remove defines from public block headers
Browse files Browse the repository at this point in the history
  • Loading branch information
argilo committed Jul 19, 2023
1 parent 902d621 commit 92e56c0
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 67 deletions.
3 changes: 0 additions & 3 deletions include/nrsc5/hdc_encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
#include <gnuradio/block.h>
#include <nrsc5/api.h>

#define HDC_SAMPLE_RATE 44100
#define SAMPLES_PER_FRAME 2048

namespace gr {
namespace nrsc5 {

Expand Down
11 changes: 0 additions & 11 deletions include/nrsc5/l1_am_encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@
#include <gnuradio/block.h>
#include <nrsc5/api.h>

#define AM_BLOCKS_PER_FRAME 8
#define SYMBOLS_PER_BLOCK 32
#define AM_SYMBOLS_PER_FRAME (8 * 32)
#define AM_FFT_SIZE 256
#define SIS_BITS 80
#define DIVERSITY_DELAY (18000 * 3)

#define CONV_E1 1
#define CONV_E2 2
#define CONV_E3 3

namespace gr {
namespace nrsc5 {

Expand Down
10 changes: 0 additions & 10 deletions include/nrsc5/l1_fm_encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@
#include <gnuradio/block.h>
#include <nrsc5/api.h>

#define FM_BLOCKS_PER_FRAME 16
#define SYMBOLS_PER_BLOCK 32
#define FM_SYMBOLS_PER_FRAME (16 * 32)
#define FM_FFT_SIZE 2048
#define SIS_BITS 80
#define FM_P1_BITS 146176

#define CONV_2_5 1
#define CONV_1_2 2

namespace gr {
namespace nrsc5 {

Expand Down
2 changes: 0 additions & 2 deletions include/nrsc5/psd_encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#include <gnuradio/sync_block.h>
#include <nrsc5/api.h>

#define BASIC_PACKET_FORMAT 0x21

namespace gr {
namespace nrsc5 {

Expand Down
3 changes: 3 additions & 0 deletions lib/hdc_encoder_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ extern "C" {
namespace gr {
namespace nrsc5 {

constexpr int HDC_SAMPLE_RATE = 44100;
constexpr int SAMPLES_PER_FRAME = 2048;

class hdc_encoder_impl : public hdc_encoder
{
private:
Expand Down
25 changes: 13 additions & 12 deletions lib/l1_am_encoder_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,20 @@ int l1_am_encoder_impl::general_work(int noutput_items,
int out_off = 0;
for (int frame = 0; frame < frames; frame++) {
for (int block = 0; block < AM_BLOCKS_PER_FRAME; block++) {
encode_l2_pdu(CONV_E1, p1 + p1_off, p1_g + p1_off * 12 / 5, p1_bits);
encode_l2_pdu(CONV_E3, pids + pids_off, pids_g, SIS_BITS);
encode_l2_pdu(
conv_mode::CONV_E1, p1 + p1_off, p1_g + p1_off * 12 / 5, p1_bits);
encode_l2_pdu(conv_mode::CONV_E3, pids + pids_off, pids_g, SIS_BITS);
interleaver_pids(pids_g, pids_matrix, block);
p1_off += p1_bits;
pids_off += SIS_BITS;
}
switch (sm) {
case 1:
encode_l2_pdu(CONV_E2, p3 + p3_off, p3_g, p3_bits);
encode_l2_pdu(conv_mode::CONV_E2, p3 + p3_off, p3_g, p3_bits);
interleaver_ma1();
break;
case 3:
encode_l2_pdu(CONV_E1, p3 + p3_off, p3_g, p3_bits);
encode_l2_pdu(conv_mode::CONV_E1, p3 + p3_off, p3_g, p3_bits);
interleaver_ma3();
break;
}
Expand Down Expand Up @@ -233,7 +234,7 @@ void l1_am_encoder_impl::scramble(unsigned char* buf, int len)
}

/* 1012s.pdf section 9.1 */
void l1_am_encoder_impl::conv_enc(int mode,
void l1_am_encoder_impl::conv_enc(conv_mode mode,
const unsigned char* in,
unsigned char* out,
int len)
Expand All @@ -244,13 +245,13 @@ void l1_am_encoder_impl::conv_enc(int mode,
unsigned int* poly;

switch (mode) {
case CONV_E1:
case conv_mode::CONV_E1:
poly = poly_e1;
break;
case CONV_E2:
case conv_mode::CONV_E2:
poly = poly_e2;
break;
case CONV_E3:
case conv_mode::CONV_E3:
poly = poly_e3;
break;
}
Expand All @@ -264,13 +265,13 @@ void l1_am_encoder_impl::conv_enc(int mode,
for (int i = 0; i < 3; i++) {
bool use;
switch (mode) {
case CONV_E1:
case conv_mode::CONV_E1:
use = (i == 0) || (i == 2) || (in_off % 5 >= 3);
break;
case CONV_E2:
case conv_mode::CONV_E2:
use = (i == 0) || ((i == 2) && (in_off % 2 == 0));
break;
case CONV_E3:
case conv_mode::CONV_E3:
use = true;
break;
}
Expand All @@ -281,7 +282,7 @@ void l1_am_encoder_impl::conv_enc(int mode,
}
}

void l1_am_encoder_impl::encode_l2_pdu(int mode,
void l1_am_encoder_impl::encode_l2_pdu(conv_mode mode,
const unsigned char* in,
unsigned char* out,
int len)
Expand Down
15 changes: 13 additions & 2 deletions lib/l1_am_encoder_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@

namespace gr {
namespace nrsc5 {

constexpr int AM_BLOCKS_PER_FRAME = 8;
constexpr int SYMBOLS_PER_BLOCK = 32;
constexpr int AM_SYMBOLS_PER_FRAME = 8 * 32;
constexpr int AM_FFT_SIZE = 256;
constexpr int SIS_BITS = 80;
constexpr int DIVERSITY_DELAY = 18000 * 3;

enum class conv_mode { CONV_E1, CONV_E2, CONV_E3 };

/* 1012s.pdf table 12-10 */
gr_complex bpsk_am[] = { { 0, -0.5 }, { 0, 0.5 } };

Expand Down Expand Up @@ -95,8 +105,9 @@ class l1_am_encoder_impl : public l1_am_encoder

void reverse_bytes(const unsigned char* in, unsigned char* out, int len);
void scramble(unsigned char* buf, int len);
void conv_enc(int mode, const unsigned char* in, unsigned char* out, int len);
void encode_l2_pdu(int mode, const unsigned char* in, unsigned char* out, int len);
void conv_enc(conv_mode mode, const unsigned char* in, unsigned char* out, int len);
void
encode_l2_pdu(conv_mode mode, const unsigned char* in, unsigned char* out, int len);
void bit_map(unsigned char matrix[25][AM_SYMBOLS_PER_FRAME], int b, int k, int bits);
void interleaver_ma1();
void interleaver_ma3();
Expand Down
42 changes: 26 additions & 16 deletions lib/l1_fm_encoder_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -223,19 +223,23 @@ int l1_fm_encoder_impl::general_work(int noutput_items,
int out_off = 0;
for (int frame = 0; frame < frames; frame++) {
for (int i = 0; i < FM_BLOCKS_PER_FRAME; i++) {
encode_l2_pdu(
CONV_2_5, pids + pids_off, pids_g + (SIS_BITS * 5 / 2 * i), SIS_BITS);
encode_l2_pdu(conv_mode::CONV_2_5,
pids + pids_off,
pids_g + (SIS_BITS * 5 / 2 * i),
SIS_BITS);
pids_off += SIS_BITS;
}

if (p1_mod == 1) {
encode_l2_pdu(CONV_2_5, p1 + p1_off, p1_g, p1_bits);
encode_l2_pdu(conv_mode::CONV_2_5, p1 + p1_off, p1_g, p1_bits);
p1_off += p1_bits;
} else {
for (int i = 0; i < p1_mod; i++) {
encode_l2_pdu(
CONV_2_5, p1 + p1_off, p1_g + (p1_bits * 5 / 2 * i), p1_bits);
encode_l2_pdu(CONV_1_2,
encode_l2_pdu(conv_mode::CONV_2_5,
p1 + p1_off,
p1_g + (p1_bits * 5 / 2 * i),
p1_bits);
encode_l2_pdu(conv_mode::CONV_1_2,
p1_prime + p1_prime_off,
p1_prime_g + (p1_bits * 2 * i),
p1_bits);
Expand Down Expand Up @@ -264,25 +268,31 @@ int l1_fm_encoder_impl::general_work(int noutput_items,
p1_off += p1_bits;
p1_prime_off = (p1_prime_off + p1_bits) % (p1_bits * p1_mod * 3);
}
encode_l2_pdu(
CONV_2_5, p2 + p2_off, p1_g + (p1_bits * 5 / 2 * p1_mod), p2_bits);
encode_l2_pdu(conv_mode::CONV_2_5,
p2 + p2_off,
p1_g + (p1_bits * 5 / 2 * p1_mod),
p2_bits);
p2_off += p2_bits;
}
interleaver_i(p1_g, pm_matrix, 20, 16, 36, 1, V_PM, 365440);
interleaver_ii(pids_g, pm_matrix, 20, 16, 36, 1, V_PM, 200, 365440, 3200);

if (p3_bits) {
for (int i = 0; i < p3_mod; i++) {
encode_l2_pdu(
CONV_1_2, p3 + p3_off, p3_p4_g + (p3_bits * 2 * i), p3_bits);
encode_l2_pdu(conv_mode::CONV_1_2,
p3 + p3_off,
p3_p4_g + (p3_bits * 2 * i),
p3_bits);
p3_off += p3_bits;
}
interleaver_iv(px1_matrix, px1_internal, internal_half);
}
if (p4_bits) {
for (int i = 0; i < p4_mod; i++) {
encode_l2_pdu(
CONV_1_2, p4 + p4_off, p3_p4_g + (p4_bits * 2 * i), p4_bits);
encode_l2_pdu(conv_mode::CONV_1_2,
p4 + p4_off,
p3_p4_g + (p4_bits * 2 * i),
p4_bits);
p4_off += p4_bits;
}
interleaver_iv(px2_matrix, px2_internal, internal_half);
Expand Down Expand Up @@ -369,7 +379,7 @@ void l1_fm_encoder_impl::scramble(unsigned char* buf, int len)
}

/* 1011s.pdf section 9.3 */
void l1_fm_encoder_impl::conv_enc(int mode,
void l1_fm_encoder_impl::conv_enc(conv_mode mode,
const unsigned char* in,
unsigned char* out,
int len)
Expand All @@ -379,10 +389,10 @@ void l1_fm_encoder_impl::conv_enc(int mode,
unsigned char* poly;

switch (mode) {
case CONV_2_5:
case conv_mode::CONV_2_5:
poly = poly_2_5;
break;
case CONV_1_2:
case conv_mode::CONV_1_2:
poly = poly_1_2;
break;
}
Expand All @@ -398,7 +408,7 @@ void l1_fm_encoder_impl::conv_enc(int mode,
}
}

void l1_fm_encoder_impl::encode_l2_pdu(int mode,
void l1_fm_encoder_impl::encode_l2_pdu(conv_mode mode,
const unsigned char* in,
unsigned char* out,
int len)
Expand Down
15 changes: 13 additions & 2 deletions lib/l1_fm_encoder_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@

namespace gr {
namespace nrsc5 {

constexpr int FM_BLOCKS_PER_FRAME = 16;
constexpr int SYMBOLS_PER_BLOCK = 32;
constexpr int FM_SYMBOLS_PER_FRAME = 16 * 32;
constexpr int FM_FFT_SIZE = 2048;
constexpr int SIS_BITS = 80;
constexpr int FM_P1_BITS = 146176;

enum class conv_mode { CONV_2_5, CONV_1_2 };

/* 1011s.pdf table 12-1 */
gr_complex qpsk_fm[] = { { -1, -1 }, { -1, 1 }, { 1, -1 }, { 1, 1 } };

Expand Down Expand Up @@ -67,8 +77,9 @@ class l1_fm_encoder_impl : public l1_fm_encoder

void reverse_bytes(const unsigned char* in, unsigned char* out, int len);
void scramble(unsigned char* buf, int len);
void conv_enc(int mode, const unsigned char* in, unsigned char* out, int len);
void encode_l2_pdu(int mode, const unsigned char* in, unsigned char* out, int len);
void conv_enc(conv_mode mode, const unsigned char* in, unsigned char* out, int len);
void
encode_l2_pdu(conv_mode mode, const unsigned char* in, unsigned char* out, int len);
void interleaver_i(unsigned char* in,
unsigned char* matrix,
int J,
Expand Down
8 changes: 5 additions & 3 deletions lib/psd_encoder_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@

namespace gr {
namespace nrsc5 {
unsigned short PORT[] = {
0x5100, 0x5201, 0x5202, 0x5203, 0x5204, 0x5205, 0x5206, 0x5207
};

constexpr unsigned short PORT[] = { 0x5100, 0x5201, 0x5202, 0x5203,
0x5204, 0x5205, 0x5206, 0x5207 };

constexpr int BASIC_PACKET_FORMAT = 0x21;

class psd_encoder_impl : public psd_encoder
{
Expand Down
4 changes: 2 additions & 2 deletions python/bindings/hdc_encoder_python.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/* BINDTOOL_GEN_AUTOMATIC(0) */
/* BINDTOOL_USE_PYGCCXML(0) */
/* BINDTOOL_HEADER_FILE(hdc_encoder.h) */
/* BINDTOOL_HEADER_FILE_HASH(f7e77e35bc86ed3f077e62231fefa850) */
/* BINDTOOL_HEADER_FILE_HASH(189e984318a00d48a752b2e0010ef257) */
/***********************************************************************************/

#include <pybind11/complex.h>
Expand All @@ -41,7 +41,7 @@ void bind_hdc_encoder(py::module& m)
py::arg("bitrate") = 64000,
D(hdc_encoder,make)
)




Expand Down
4 changes: 2 additions & 2 deletions python/bindings/l1_am_encoder_python.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/* BINDTOOL_GEN_AUTOMATIC(0) */
/* BINDTOOL_USE_PYGCCXML(0) */
/* BINDTOOL_HEADER_FILE(l1_am_encoder.h) */
/* BINDTOOL_HEADER_FILE_HASH(8f35b0e3bb969cf26bd31eaeb535215b) */
/* BINDTOOL_HEADER_FILE_HASH(abd9b28201d6b1e13eaa2ebe1d06646c) */
/***********************************************************************************/

#include <pybind11/complex.h>
Expand All @@ -40,7 +40,7 @@ void bind_l1_am_encoder(py::module& m)
py::arg("sm"),
D(l1_am_encoder,make)
)




Expand Down
2 changes: 1 addition & 1 deletion python/bindings/l1_fm_encoder_python.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/* BINDTOOL_GEN_AUTOMATIC(0) */
/* BINDTOOL_USE_PYGCCXML(0) */
/* BINDTOOL_HEADER_FILE(l1_fm_encoder.h) */
/* BINDTOOL_HEADER_FILE_HASH(49790fbb047a3cf118b8bdfed5793d3f) */
/* BINDTOOL_HEADER_FILE_HASH(28b4c2c78049aedef3c35cd91abd7142) */
/***********************************************************************************/

#include <pybind11/complex.h>
Expand Down
2 changes: 1 addition & 1 deletion python/bindings/psd_encoder_python.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/* BINDTOOL_GEN_AUTOMATIC(0) */
/* BINDTOOL_USE_PYGCCXML(0) */
/* BINDTOOL_HEADER_FILE(psd_encoder.h) */
/* BINDTOOL_HEADER_FILE_HASH(b858db9ba66114cfa2952d20cd3dcc59) */
/* BINDTOOL_HEADER_FILE_HASH(aa3c914cdda9eeb1f25aa5201cb775bd) */
/***********************************************************************************/

#include <pybind11/complex.h>
Expand Down

0 comments on commit 92e56c0

Please sign in to comment.