Try APtype 4, 3, 2, 1, 0.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6929 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Joe Taylor 2016-07-19 15:24:15 +00:00
parent 920fd25537
commit f92afadc6c
3 changed files with 119 additions and 107 deletions

View File

@ -35,33 +35,35 @@
#define QRA64_m 6 // bits per symbol
// packed predefined callsigns and fields as defined in JT65
#define CALL_CQ 0xFA08319
#define CALL_QRZ 0xFA0831A
#define CALL_CQ 0xFA08319
#define CALL_QRZ 0xFA0831A
#define CALL_CQ000 0xFA0831B
#define CALL_CQ999 0xFA08702
#define CALL_CQDX 0x5624C39
#define CALL_DE 0xFF641D1
#define GRID_BLANK 0x7E91
#define CALL_CQDX 0x5624C39
#define CALL_DE 0xFF641D1
#define GRID_BLANK 0x7E91
// Types of a-priori knowledge messages
#define APTYPE_CQQRZ 0 // [cq/qrz ? ?/blank]
#define APTYPE_MYCALL 1 // [mycall ? ?/blank]
#define APTYPE_CQQRZ 0 // [cq/qrz ? ?/blank]
#define APTYPE_MYCALL 1 // [mycall ? ?/blank]
#define APTYPE_HISCALL 2 // [? hiscall ?/blank]
#define APTYPE_BOTHCALLS 3 // [mycall hiscall ?]
#define APTYPE_FULL 4 // [mycall hiscall grid]
#define APTYPE_SIZE (APTYPE_FULL+1)
#define APTYPE_FULL 4 // [mycall hiscall grid]
#define APTYPE_SIZE (APTYPE_FULL+1)
typedef struct {
float decEsNoMetric;
int apflags;
int apmsg_set[APTYPE_SIZE]; // indicate which ap type knowledge has been set by the user
// ap messages buffers
int apmsg_set[APTYPE_SIZE]; // indicate which ap type knowledge has
// been set by the user
// ap messages buffers
int apmsg_cqqrz[12]; // [cq/qrz ? ?/blank]
int apmsg_call1[12]; // [mycall ? ?/blank]
int apmsg_call2[12]; // [? hiscall ?/blank]
int apmsg_call1_call2[12]; // [mycall hiscall ?]
int apmsg_call1_call2_grid[12]; // [mycall hiscall grid]
// ap messages masks
int apmsg_call1_call2[12]; // [mycall hiscall ?]
int apmsg_call1_call2_grid[12]; // [mycall hiscall grid]
// ap messages masks
int apmask_cqqrz[12];
int apmask_cqqrz_ooo[12];
int apmask_call1[12];
@ -79,41 +81,39 @@ extern "C" {
qra64codec *qra64_init(int flags);
// QRA64 mode initialization function
// arguments:
// flags: set the decoder mode
// When flags = QRA_NOAP no a-priori information will be used by the decoder
// When flags = QRA_AUTOAP the decoder will attempt to decode with the amount
// of available a-priori information
// When flags = QRA_USERAP the decoder will attempt to decode with the amount
// of a-priori information as provided by the caller with the function qra64_apset(...)
// flags: set the decoder mode
// QRA_NOAP use no a-priori information
// QRA_AUTOAP use any relevant previous decodes
// QRA_USERAP use a-priori information provided via qra64_apset(...)
// returns:
// Pointer to the qra64codec data structure allocated and inizialized by the function
// this handle should be passed to the encoding/decoding functions
// Pointer to initialized qra64codec data structure
// this pointer should be passed to the encoding/decoding functions
//
// 0 if unsuccessful (can't allocate memory)
// -------------------------------------------------------------------------------------------
// 0 if unsuccessful (can't allocate memory)
// ----------------------------------------------------------------------------
void qra64_encode(qra64codec *pcodec, int *y, const int *x);
// QRA64 mode encoder
// QRA64 encoder
// arguments:
// pcodec = pointer to a qra64codec data structure as returned by qra64_init
// x = pointer to the message to encode
// x must point to an array of integers (i.e. defined as int x[12])
// y = pointer to the encoded message
// y must point to an array of integers of lenght 63 (i.e. defined as int y[63])
// -------------------------------------------------------------------------------------------
// pcodec = pointer to a qra64codec data structure as returned by qra64_init
// x = pointer to the message to be encoded, int x[12]
// x must point to an array of integers (i.e. defined as int x[12])
// y = pointer to encoded message, int y[63]=
// ----------------------------------------------------------------------------
int qra64_decode(qra64codec *pcodec, float *ebno, int *x, const float *r);
// QRA64 mode decoder
// arguments:
// pcodec = pointer to a qra64codec data structure as returned by qra64_init
// ebno = pointer to a float number where the avg Eb/No (in dB) will be stored
// in case of successfull decoding (pass a null pointer if not interested)
// x = pointer to the array of integers where the decoded message will be stored
// x must point to an array of integers (i.e. defined as int x[12])
// r = pointer to the received symbols energies (squared amplitudes)
// r must point to an array of QRA64_M*QRA64_N (=64*63=4032) float numbers.
// The first QRA_M entries should be the energies of the first symbol in the codeword
// The last QRA_M entries should be the energies of the last symbol in the codeword
// pcodec = pointer to a qra64codec data structure as returned by qra64_init
// ebno = pointer to a float where the avg Eb/No (in dB) will be stored
// in case of successfull decoding
// (pass a null pointer if not interested)
// x = pointer to decoded message, int x[12]
// r = pointer to received symbol energies (squared amplitudes)
// r must point to an array of length QRA64_M*QRA64_N (=64*63=4032)
// The first QRA_M entries should be the energies of the first
// symbol in the codeword; the last QRA_M entries should be the
// energies of the last symbol in the codeword
//
// return code:
//
@ -129,46 +129,46 @@ int qra64_decode(qra64codec *pcodec, float *ebno, int *x, const float *r);
// rc=6 [? CALL ?] AP29
// rc=7 [? CALL ] AP45
// rc=8 [CALL CALL GRID] AP72
// return codes in the range 1-8 indicate the amount and the type of a-priori information
// which was required to decode the received message
// return codes in the range 1-8 indicate the amount and the type of a-priori
// information was required to decode the received message.
int qra64_apset(qra64codec *pcodec, const int mycall, const int hiscall, const int grid, const int aptype);
// Set decoder a-priori knowledge accordingly to the type of the message to look up for
// Set decoder a-priori knowledge accordingly to the type of the message to
// look up for
// arguments:
// pcodec = pointer to a qra64codec data structure as returned by qra64_init
// mycall = mycall to look for
// hiscall = hiscall to look for
// grid = grid to look for
// aptype = define the type of AP to be set accordingly to the following table:
// APTYPE_CQQRZ set [cq/qrz ? ?/blank]
// APTYPE_MYCALL set [mycall ? ?/blank]
// APTYPE_HISCALL set [? hiscall ?/blank]
// APTYPE_BOTHCALLS set [mycall hiscall ?]
// APTYPE_FULL set [mycall hiscall grid]
// pcodec = pointer to a qra64codec data structure as returned by qra64_init
// mycall = mycall to look for
// hiscall = hiscall to look for
// grid = grid to look for
// aptype = define the type of AP to be set:
// APTYPE_CQQRZ set [cq/qrz ? ?/blank]
// APTYPE_MYCALL set [mycall ? ?/blank]
// APTYPE_HISCALL set [? hiscall ?/blank]
// APTYPE_BOTHCALLS set [mycall hiscall ?]
// APTYPE_FULL set [mycall hiscall grid]
// returns:
// 0 on success
// 0 on success
// -1 when qra64_init was called with the QRA_NOAP flag
// -2 invalid apytpe (aptype must be in the range [APTYPE_MYCALL..APTYPE_FULL]
// (APTYPE_CQQRZ [cq/qrz ? ?] is set during the initialization function and
// doesn't need to be set by the user
// -2 invalid apytpe (valid range [APTYPE_MYCALL..APTYPE_FULL]
// (APTYPE_CQQRZ [cq/qrz ? ?] is set by default )
void qra64_apdisable(qra64codec *pcodec, const int aptype);
// disable specific AP type
// arguments:
// pcodec = pointer to a qra64codec data structure as returned by qra64_init
// aptype = define the type of AP to be disabled
// APTYPE_CQQRZ disable [cq/qrz ? ?/blank]
// APTYPE_MYCALL disable [mycall ? ?/blank]
// APTYPE_HISCALL disable [? hiscall ?/blank]
// APTYPE_BOTHCALLS disable [mycall hiscall ?]
// APTYPE_FULL disable [mycall hiscall grid]
// pcodec = pointer to a qra64codec data structure as returned by qra64_init
// aptype = define the type of AP to be disabled
// APTYPE_CQQRZ disable [cq/qrz ? ?/blank]
// APTYPE_MYCALL disable [mycall ? ?/blank]
// APTYPE_HISCALL disable [ ? hiscall ?/blank]
// APTYPE_BOTHCALLS disable [mycall hiscall ? ]
// APTYPE_FULL disable [mycall hiscall grid]
void qra64_close(qra64codec *pcodec);
// Free memory allocated by qra64_init
// arguments:
// pcodec = pointer to a qra64codec data structure as returned by qra64_init
// pcodec = pointer to a qra64codec data structure as returned by qra64_init
// -------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// encode/decode std msgs in 12 symbols as done in jt65
void encodemsg_jt65(int *y, const int call1, const int call2, const int grid);

View File

@ -10,44 +10,48 @@ static qra64codec *pqra64codec = NULL;
void qra64_enc_(int x[], int y[])
{
if (pqra64codec==NULL) pqra64codec = qra64_init(QRA_AUTOAP);
if (pqra64codec==NULL) pqra64codec = qra64_init(QRA_USERAP);
qra64_encode(pqra64codec, y, x);
}
void qra64_dec_(float r[], int* nmycall, int* nhiscall, int* nhisgrid,
void qra64_dec_(float r[], int* nc1, int* nc2, int* ng2, int* APtype,
int xdec[], float* snr, int* rc)
{
// Return codes:
// rc=-16 failed sanity check
// rc=-2 decoded, but crc check failed
// rc=-1 no decode
// rc=0 [? ? ?] AP0 (decoding with no a-priori information)
// rc=1 [CQ ? ?] AP27
// rc=2 [CQ ? ] AP42
// rc=3 [CALL ? ?] AP29
// rc=4 [CALL ? ] AP44
// rc=5 [CALL CALL ?] AP57
// rc=6 [? CALL ?] AP29
// rc=7 [? CALL ] AP44
// rc=8 [CALL CALL G] AP72
/*
APtype:
-1 (no AP information)
0 [CQ/QRZ * ?_] (* means 26 or 28 bit info)
1 [call1 * ?_] (?_ means 16-bit info or "blank")
2 [* call2 ?_]
3 [call1 call2 ?_]
4 [call1 call2 grid]
static ncall0=-1;
int ncall=*nmycall;
Return codes:
-16 Failed sanity check
-2 Decoded, but crc check failed
-1 No decode
0 [? ? ?] AP0 (decoding with no a-priori information)
1 [CQ ? ?] AP27
2 [CQ ? ] AP42
3 [CALL ? ?] AP29
4 [CALL ? ] AP44
5 [CALL CALL ?] AP57
6 [? CALL ?] AP29
7 [? CALL ] AP44
8 [CALL CALL G] AP72
*/
static int nc1z=-1;
float EbNodBEstimated;
int err=0;
#ifdef NICO_WANTS_SNR_DUMP
FILE *fout;
#endif
if(ncall!=ncall0) {
if (pqra64codec!=NULL) qra64_close(pqra64codec);
pqra64codec = qra64_init(QRA_AUTOAP);
// the following apset call is not strictly necessary
// It enables AP decoding of messages directed to our call
// also in the case we have never made a CQ
qra64_apset(pqra64codec,ncall,0,0,APTYPE_MYCALL);
ncall0=ncall;
}
if(pqra64codec==NULL) pqra64codec = qra64_init(QRA_USERAP);
err=qra64_apset(pqra64codec,*nc1,*nc2,*ng2,*APtype);
if(err<0) printf("ERROR: qra64_apset returned %d\n",err);
*rc = qra64_decode(pqra64codec,&EbNodBEstimated,xdec,r);
*snr = EbNodBEstimated - 31.0;

View File

@ -8,6 +8,7 @@ subroutine qra64a(dd,nf1,nf2,nfqso,ntol,mycall_12,hiscall_12,hisgrid_6, &
character*6 mycall,hiscall,hisgrid_6
character*4 hisgrid
logical ltext
integer*8 count0,count1,clkfreq
integer icos7(0:6)
integer ipk(1)
integer jpk(1)
@ -126,19 +127,26 @@ subroutine qra64a(dd,nf1,nf2,nfqso,ntol,mycall_12,hiscall_12,hisgrid_6, &
call packcall(hiscall,nhiscall,ltext)
call packgrid(hisgrid,nhisgrid,ltext)
snr2=-99.
call qra64_dec(s3,nmycall,nhiscall,nhisgrid,dat4,snr2,irc) !Attempt decoding
if(irc.ge.0) then
call unpackmsg(dat4,decoded) !Unpack the user message
call fmtmsg(decoded,iz)
nft=100 + irc
nsnr=nint(snr2)
else
snr2=0.
endif
ttot=0.
do naptype=4,0,-1
call system_clock(count0,clkfreq)
call qra64_dec(s3,nmycall,nhiscall,nhisgrid,naptype,dat4,snr2,irc)
if(irc.ge.0) then
call unpackmsg(dat4,decoded) !Unpack the user message
call fmtmsg(decoded,iz)
nft=100 + irc
nsnr=nint(snr2)
else
snr2=0.
endif
call system_clock(count1,clkfreq)
tsec=float(count1-count0)/float(clkfreq)
ttot=ttot+tsec
write(78,3900) sync,snr1,snr2,snr2-snr1,dtx,nfreq,nhard,naptype,irc, &
tsec,ttot,decoded
3900 format(4f6.1,f6.2,i5,i3,i2,i3,2f6.3,1x,a22)
if(irc.ge.0) exit
enddo
900 continue
write(78,3900) sync,snr1,snr2,snr2-snr1,dtx,nfreq,nhard,irc,decoded
3900 format(4f7.1,f7.2,i6,2i4,2x,a22)
return
900 return
end subroutine qra64a