Reverting r6531 and replacing with correct fix

The WSPR  message is unpacked  into a symbol  per byte array  which is
processed  by  encoding a  whole  number  of  bytes of  message,  this
requires the output  array to be bigger than the  number of symbols to
accommodate  extra values  that are  not part  of the  message due  to
rounding up to whole bytes. I.e.  176 (11*8*2) elements to contain the
162 symbols.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6532 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville 2016-03-15 11:46:26 +00:00
parent e81f018ed5
commit 4de778c4e7
2 changed files with 5 additions and 6 deletions

View File

@ -60,7 +60,7 @@ struct node {
* and easier than trying to pack them more compactly.
*/
int encode(
unsigned char *symbols, // Output buffer, 2*nbytes
unsigned char *symbols, // Output buffer, 2*nbytes*8
unsigned char *data, // Input buffer, nbytes
unsigned int nbytes) // Number of bytes in data
{
@ -69,7 +69,7 @@ int encode(
int i;
encstate = 0;
while(--nbytes != 0) {
while(nbytes-- != 0) {
for(i=7;i>=0;i--) {
encstate = (encstate << 1) | ((*data >> i) & 1);
ENCODE(sym,encstate);

View File

@ -296,10 +296,9 @@ int get_wspr_channel_symbols(char* rawmessage, char* hashtab, unsigned char* sym
unpk_(check_data,hashtab,check_call_loc_pow,check_callsign);
// printf("Will decode as: %s\n",check_call_loc_pow);
unsigned int nbytes=11; // The message with tail is packed into 11 bytes.
unsigned int nencoded=162;
unsigned char channelbits[nencoded];
memset(channelbits,0,sizeof(char)*nencoded);
unsigned int nbytes=11; // The message with tail is packed into almost 11 bytes.
unsigned char channelbits[nbytes*8*2]; /* 162 rounded up */
memset(channelbits,0,sizeof channelbits);
encode(channelbits,data,nbytes);