int 
initialize_lookup_tables(int rng, int rng_nyq_prod)
{
   int tab_num, nyq1, nyq2, i, j, pri_index;
   int mk_status = 0;
   int table_status = 0;
   short nyq_table[MAX_PRFS];
     
/* Determine which crystal set the radar uses */

   pri_index = INITIAL_PRI_INDEX;
   
   for(i=0;i<DELPRI_MAX;i++)
      {
      for(j=0;j<PRFMAX;j++)
         if (rng==range_table[i][j])
         {
         pri_index = i;
         break;
         }
      if (pri_index != INITIAL_PRI_INDEX)
         break;
      }

   if (pri_index == INITIAL_PRI_INDEX)
      pri_index = MIDDLE_TABLE;


/* Generate Nyquists vels from the crystal set and known range and nyquist */

   for(i=2;i<MAX_PRFS+2;i++)
      {
      nyq_table[i-2] =(float)(rng_nyq_prod)/(float)(range_table[pri_index][i]);
      fix_nyq_value(&nyq_table[i-2]);
      }

/* Build unfold table */

   tab_num = 0;
   for(i=0;i<MAX_PRFS-1;i++)
      {
      nyq1=nyq_table[i];
      for(j=i+1;j<MAX_PRFS;j++)
         {
         nyq2=nyq_table[j];
         prf_pairs_table[MAX_PRFS*j+i]=tab_num;
         memset(lookup_table[tab_num].value, MISSING_BYTE,
                sizeof(lookup_table[tab_num].value));
         table_status = build_lookup_table(nyq1, nyq2, tab_num);
         mk_status = mk_status || table_status;
         ++tab_num;
         }
      }
      return mk_status;
}
Exemple #2
0
huffman_error huffman_context_base::import_tree_rle(bitstream_in &bitbuf)
{
	// bits per entry depends on the maxbits
	int numbits;
	if (m_maxbits >= 16)
		numbits = 5;
	else if (m_maxbits >= 8)
		numbits = 4;
	else
		numbits = 3;

	// loop until we read all the nodes
	int curnode;
	for (curnode = 0; curnode < m_numcodes; )
	{
		// a non-one value is just raw
		int nodebits = bitbuf.read(numbits);
		if (nodebits != 1)
			m_huffnode[curnode++].m_numbits = nodebits;

		// a one value is an escape code
		else
		{
			// a double 1 is just a single 1
			nodebits = bitbuf.read(numbits);
			if (nodebits == 1)
				m_huffnode[curnode++].m_numbits = nodebits;

			// otherwise, we need one for value for the repeat count
			else
			{
				int repcount = bitbuf.read(numbits) + 3;
				while (repcount--)
					m_huffnode[curnode++].m_numbits = nodebits;
			}
		}
	}

	// make sure we ended up with the right number
	if (curnode != m_numcodes)
		return HUFFERR_INVALID_DATA;

	// assign canonical codes for all nodes based on their code lengths
	huffman_error error = assign_canonical_codes();
	if (error != HUFFERR_NONE)
		return error;

	// build the lookup table
	build_lookup_table();

	// determine final input length and report errors
	return bitbuf.overflow() ? HUFFERR_INPUT_BUFFER_TOO_SMALL : HUFFERR_NONE;
}
Exemple #3
0
huffman_error huffman_context_base::import_tree_huffman(bitstream_in &bitbuf)
{
	// start by parsing the lengths for the small tree
	huffman_decoder<24, 6> smallhuff;
	smallhuff.m_huffnode[0].m_numbits = bitbuf.read(3);
	int start = bitbuf.read(3) + 1;
	int count = 0;
	for (int index = 1; index < 24; index++)
	{
		if (index < start || count == 7)
			smallhuff.m_huffnode[index].m_numbits = 0;
		else
		{
			count = bitbuf.read(3);
			smallhuff.m_huffnode[index].m_numbits = (count == 7) ? 0 : count;
		}
	}

	// then regenerate the tree
	huffman_error error = smallhuff.assign_canonical_codes();
	if (error != HUFFERR_NONE)
		return error;
	smallhuff.build_lookup_table();

	// determine the maximum length of an RLE count
	UINT32 temp = m_numcodes - 9;
	UINT8 rlefullbits = 0;
	while (temp != 0)
		temp >>= 1, rlefullbits++;

	// now process the rest of the data
	int last = 0;
	int curcode;
	for (curcode = 0; curcode < m_numcodes; )
	{
		int value = smallhuff.decode_one(bitbuf);
		if (value != 0)
			m_huffnode[curcode++].m_numbits = last = value - 1;
		else
		{
			int count = bitbuf.read(3) + 2;
			if (count == 7+2)
				count += bitbuf.read(rlefullbits);
			for ( ; count != 0 && curcode < m_numcodes; count--)
				m_huffnode[curcode++].m_numbits = last;
		}
	}

	// make sure we ended up with the right number
	if (curcode != m_numcodes)
		return HUFFERR_INVALID_DATA;

	// assign canonical codes for all nodes based on their code lengths
	error = assign_canonical_codes();
	if (error != HUFFERR_NONE)
		return error;

	// build the lookup table
	build_lookup_table();

	// determine final input length and report errors
	return bitbuf.overflow() ? HUFFERR_INPUT_BUFFER_TOO_SMALL : HUFFERR_NONE;
}