diff options
| author | drowe67 <[email protected]> | 2024-04-03 17:16:58 +1030 |
|---|---|---|
| committer | David Rowe <[email protected]> | 2024-04-03 17:16:58 +1030 |
| commit | 735d7882764134f6982586683a42ed79f5e95951 (patch) | |
| tree | 41294beb67d66ea6226756327533de3d2eabbe34 /src/freedv_700.c | |
| parent | 23a7d60bf8269db6d11d106dc70df001e26f9933 (diff) | |
WIP freedv API support for custom raw data modes
Diffstat (limited to 'src/freedv_700.c')
| -rw-r--r-- | src/freedv_700.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/freedv_700.c b/src/freedv_700.c index 7c8536c..a7d7aac 100644 --- a/src/freedv_700.c +++ b/src/freedv_700.c @@ -189,7 +189,7 @@ void freedv_ofdm_voice_open(struct freedv *f, char *mode) { // open function for OFDM data modes, TODO consider moving to a new // (freedv_ofdm_data.c) file -void freedv_ofdm_data_open(struct freedv *f) { +void freedv_ofdm_data_open(struct freedv *f, struct freedv_advanced *adv) { struct OFDM_CONFIG ofdm_config; char mode[32]; if (f->mode == FREEDV_MODE_DATAC0) strcpy(mode, "datac0"); @@ -198,8 +198,14 @@ void freedv_ofdm_data_open(struct freedv *f) { if (f->mode == FREEDV_MODE_DATAC4) strcpy(mode, "datac4"); if (f->mode == FREEDV_MODE_DATAC13) strcpy(mode, "datac13"); if (f->mode == FREEDV_MODE_DATAC14) strcpy(mode, "datac14"); - - ofdm_init_mode(mode, &ofdm_config); + if (f->mode == FREEDV_MODE_DATA_CUSTOM) { + assert(adv != NULL); + assert(adv->config != NULL); + memcpy(&ofdm_config, (struct OFDM_CONFIG *)adv->config, + sizeof(struct OFDM_CONFIG)); + } else { + ofdm_init_mode(mode, &ofdm_config); + } f->ofdm = ofdm_create(&ofdm_config); assert(f->ofdm != NULL); @@ -219,8 +225,8 @@ void freedv_ofdm_data_open(struct freedv *f) { f->ofdm_ntxtbits = ofdm_config.txtbits; /* payload bits per FreeDV API "frame". In OFDM modem nomenclature this is - the number of payload data bits per packet, or the number of data bits in a - LDPC codeword */ + the number of payload data bits per packet, or the number of data bits in + a LDPC codeword */ f->bits_per_modem_frame = f->ldpc->data_bits_per_frame; // buffers for received symbols for one packet/LDPC codeword - may span many @@ -299,8 +305,8 @@ int freedv_comprx_700c(struct freedv *f, COMP demod_in_8kHz[]) { int rx_status = 0; - // quisk_cfInterpDecim() modifies input data so lets make a copy just in case - // there is no sync and we need to echo input to output + // quisk_cfInterpDecim() modifies input data so lets make a copy just in + // case there is no sync and we need to echo input to output // freedv_nin(f): input samples at Fs=8000 Hz // f->nin: input samples at Fs=7500 Hz @@ -332,7 +338,8 @@ int freedv_comprx_700c(struct freedv *f, COMP demod_in_8kHz[]) { rx_status |= FREEDV_RX_BITS; } else { if (f->test_frames_diversity) { - /* normal operation - error pattern on frame after diveristy combination + /* normal operation - error pattern on frame after diveristy + * combination */ short error_pattern[COHPSK_BITS_PER_FRAME]; int bit_errors; @@ -471,8 +478,8 @@ int freedv_comp_short_rx_ofdm(struct freedv *f, void *demod_in_8kHz, memcpy(&rx_amps[Nsymsperpacket - Nsymsperframe], ofdm->rx_amp, sizeof(float) * Nsymsperframe); - /* look for UW as frames enter packet buffer, note UW may span several modem - * frames */ + /* look for UW as frames enter packet buffer, note UW may span several + * modem frames */ int st_uw = Nsymsperpacket - ofdm->nuwframes * Nsymsperframe; ofdm_extract_uw(ofdm, &rx_syms[st_uw], &rx_amps[st_uw], rx_uw); @@ -510,8 +517,8 @@ int freedv_comp_short_rx_ofdm(struct freedv *f, void *demod_in_8kHz, else rx_status |= FREEDV_RX_BIT_ERRORS; } else { - // voice modes aren't as strict - pass everything through to the speech - // decoder, but flag frame with possible errors + // voice modes aren't as strict - pass everything through to the + // speech decoder, but flag frame with possible errors rx_status |= FREEDV_RX_BITS; if (parityCheckCount != ldpc->NumberParityBits) rx_status |= FREEDV_RX_BIT_ERRORS; |
