/* Get a position value according to Position Huffman Table. */
UINT32 DecodeP(IN SCRATCH_DATA *Sd)
/* Get a position value according to Position Huffman Table. */
UINT32 DecodeP(IN SCRATCH_DATA *Sd)
{
  UINT16  Val;
  UINT32  Mask;
  UINT32  Pos;
  Val = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];
  if (Val >= MAXNP) {
    Mask = 1U << (BITBUFSIZ - 1 - 8);
    do {
      if ((Sd->mBitBuf & Mask) != 0) {
        Val = Sd->mRight[Val];
      } else {
        Val = Sd->mLeft[Val];
      }
      Mask >>= 1;
    } while (Val >= MAXNP);
  }
  FillBuf (Sd, Sd->mPTLen[Val]);
  Pos = Val;
  if (Val > 1) {
    Pos = (UINT32)((1U << (Val - 1)) + GetBits (Sd, (UINT16)(Val - 1)));
  }
  return Pos;
}