From: drowe67 Date: Thu, 19 Apr 2018 05:04:59 +0000 (+0000) Subject: first pass working with Codec 2 700C! However only works on 1 or 2 frame interleaver... X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=55fd2c0a218d8d1deffa889475972af188c8ea35;p=freetel-svn-tracking.git first pass working with Codec 2 700C! However only works on 1 or 2 frame interleaver, interleaver sync makes mistakes sometimes and needs work git-svn-id: https://svn.code.sf.net/p/freetel/code@3503 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/README_ofdm.txt b/codec2-dev/README_ofdm.txt index da02ee44..7564f213 100644 --- a/codec2-dev/README_ofdm.txt +++ b/codec2-dev/README_ofdm.txt @@ -35,18 +35,17 @@ Built as part of codec2-dev, see README for build instructions. 1. Generate 10 seconds of test frame bits, modulate, and play audio out of sound device: - build_linux/src$ ./ofdm_get_test_bits - 10 | ./ofdm_mod - - | play -t raw -r 8000 -s -2 - + build_linux/src$ ./ofdm_get_test_bits - 10 | ./ofdm_mod - - | play -t raw -r 8000 -s -2 - 2. Generate 10 seconds of uncoded test frame bits, modulate, demodulate, count errors: - build_linux/src$ ./ofdm_get_test_bits - 10 | ./ofdm_mod - - | ./ofdm_demod - /dev/null -t + build_linux/src$ ./ofdm_get_test_bits - 10 | ./ofdm_mod - - | ./ofdm_demod - /dev/null -t - (TODO write ofdm_demod_c.m) - Use Octave to look at plots of C modem operation: + Use Octave to look at plots of C modem operation: - $ cd ../octave - $ octave - octave:1> ofdm_demod_c("../src/demod_dump.txt") + $ cd ../octave + $ octave + octave:1> ofdm_demod_c("../src/demod_dump.txt") 4. Run Octave versions of mod and demod (called tx and rx to avoid namespace clashes in Octave): @@ -77,7 +76,16 @@ Built as part of codec2-dev, see README for build instructions. C demodulator/LDPC decoder: build_linux/src$ ./ofdm_demod ../../octave/ofdm_test.raw /dev/null -v -t --ldpc --interleave 4 - + +6. Run C mod/demod with LDPC and 2 frames interleaving: + + build_linux/src$ ./ofdm_mod /dev/zero - --ldpc -t 2 --interleave 2 | ./ofdm_demod - /dev/null -t --ldpc -v --interleave 2 + +7. Pass Codec 2 700C through modem: + + build_linux/src$ ./c2enc 700C ../../raw/ve9qrp_10s.raw - --bitperchar | ./ofdm_mod - - --ldpc --interleave 2 | ./ofdm_demod - - --ldpc --interleave 2 | ./c2dec 700C - - --bitperchar | play -t raw -r 8000 -s -2 - + + Acceptance Tests ---------------- diff --git a/codec2-dev/src/c2dec.c b/codec2-dev/src/c2dec.c index cbcd2ee7..59e24d1d 100644 --- a/codec2-dev/src/c2dec.c +++ b/codec2-dev/src/c2dec.c @@ -100,29 +100,25 @@ int main(int argc, char *argv[]) exit(1); } - mode = -1; - // Attempt to detect a .c2 file with a header struct c2_header in_hdr; char *ext = strrchr(argv[2], '.'); - if (ext != NULL) { - if (strcmp(ext, ".c2") == 0) { - fread(&in_hdr,sizeof(in_hdr),1,fin); + if ((ext != NULL) && (strcmp(ext, ".c2") == 0)) { + fread(&in_hdr,sizeof(in_hdr),1,fin); - if (memcmp(in_hdr.magic, c2_file_magic, sizeof(c2_file_magic)) == 0) { - fprintf(stderr, "Detected Codec2 file version %d.%d in mode %d\n", - in_hdr.version_major, - in_hdr.version_minor, - in_hdr.mode); + if (memcmp(in_hdr.magic, c2_file_magic, sizeof(c2_file_magic)) == 0) { + fprintf(stderr, "Detected Codec2 file version %d.%d in mode %d\n", + in_hdr.version_major, + in_hdr.version_minor, + in_hdr.mode); - mode = in_hdr.mode; - } else { - fprintf(stderr, "Codec2 file specified but no header detected\n"); - // Rewind the input file so we can try to decode - // based on command line mode selection - fseek(fin,0,SEEK_SET); - } /* end if - magic detection */ - }; + mode = in_hdr.mode; + } else { + fprintf(stderr, "Codec2 file specified but no header detected\n"); + // Rewind the input file so we can try to decode + // based on command line mode selection + fseek(fin,0,SEEK_SET); + } /* end if - magic detection */ } else { // If we got here, we need to honor the command line mode if (strcmp(argv[1],"3200") == 0) diff --git a/codec2-dev/src/interldpc.c b/codec2-dev/src/interldpc.c index 9d4b2ec7..a7ff46c7 100644 --- a/codec2-dev/src/interldpc.c +++ b/codec2-dev/src/interldpc.c @@ -79,7 +79,7 @@ void set_up_hra_112_112(struct LDPC *ldpc) { } void ldpc_encode_frame(struct LDPC *ldpc, int codeword[], unsigned char tx_bits_char[]) { - unsigned char pbits[ldpc->coded_bits_per_frame]; + unsigned char pbits[ldpc->NumberParityBits]; int i,j; encode(ldpc, tx_bits_char, pbits); @@ -87,7 +87,7 @@ void ldpc_encode_frame(struct LDPC *ldpc, int codeword[], unsigned char tx_bits_ codeword[i] = tx_bits_char[i]; } for(j=0; icoded_bits_per_frame; i++,j++) { - codeword[i] = pbits[i]; + codeword[i] = pbits[j]; } } diff --git a/codec2-dev/src/ofdm_demod.c b/codec2-dev/src/ofdm_demod.c index c1219be1..8fc12874 100644 --- a/codec2-dev/src/ofdm_demod.c +++ b/codec2-dev/src/ofdm_demod.c @@ -250,8 +250,11 @@ int main(int argc, char *argv[]) symbols_to_llrs(llr, codeword_symbols_de, codeword_amps_de, EsNo, coded_syms_per_frame); iter = run_ldpc_decoder(&ldpc, out_char, llr, &parityCheckCount); Nerrs = data_bits_per_frame - parityCheckCount; - //fprintf(stderr, "iter: %d pcc: %d Nerrs: %d\n", iter, parityCheckCount, Nerrs); - if (Nerrs < 10) { + for(i=0; i<20; i++) + fprintf(stderr,"%d ", out_char[i]); + fprintf(stderr,"\n"); + fprintf(stderr, "iter: %d pcc: %d Nerrs: %d\n", iter, parityCheckCount, Nerrs); + if ((Nerrs < 10)) { /* sucessful decode! */ strcpy(next_sync_state_interleaver, "synced"); ofdm->frame_count_interleaver = interleave_frames; @@ -296,7 +299,7 @@ int main(int argc, char *argv[]) &codeword_amps_de[j*coded_syms_per_frame], EsNo, coded_syms_per_frame); iter = run_ldpc_decoder(&ldpc, out_char, llr, &parityCheckCount); - + fprintf(stderr,"j: %d iter: %d parityCheckCount: %d\n", j, iter, parityCheckCount); if (testframes) { Nerrs = 0; for(i=0; i= Nframes)) { + goto finished; + } } + finished: fclose(fin); fclose(fout); ofdm_destroy(ofdm);