Back to index

tetex-bin  3.0
Public Member Functions | Private Attributes
JBIG2HuffmanDecoder Class Reference
Collaboration diagram for JBIG2HuffmanDecoder:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 JBIG2HuffmanDecoder ()
 ~JBIG2HuffmanDecoder ()
void setStream (Stream *strA)
void reset ()
GBool decodeInt (int *x, JBIG2HuffmanTable *table)
Guint readBits (Guint n)
Guint readBit ()
void buildTable (JBIG2HuffmanTable *table, Guint len)

Private Attributes

Streamstr
Guint buf
Guint bufLen

Detailed Description

Definition at line 292 of file JBIG2Stream.cc.


Constructor & Destructor Documentation

Definition at line 317 of file JBIG2Stream.cc.

                                         {
  str = NULL;
  reset();
}

Here is the call graph for this function:

Definition at line 322 of file JBIG2Stream.cc.

                                          {
}

Member Function Documentation

Definition at line 393 of file JBIG2Stream.cc.

                                                                        {
  Guint i, j, k, prefix;
  JBIG2HuffmanTable tab;

  // stable selection sort:
  // - entries with prefixLen > 0, in ascending prefixLen order
  // - entry with prefixLen = 0, rangeLen = EOT
  // - all other entries with prefixLen = 0
  // (on entry, table[len] has prefixLen = 0, rangeLen = EOT)
  for (i = 0; i < len; ++i) {
    for (j = i; j < len && table[j].prefixLen == 0; ++j) ;
    if (j == len) {
      break;
    }
    for (k = j + 1; k < len; ++k) {
      if (table[k].prefixLen > 0 &&
         table[k].prefixLen < table[j].prefixLen) {
       j = k;
      }
    }
    if (j != i) {
      tab = table[j];
      for (k = j; k > i; --k) {
       table[k] = table[k - 1];
      }
      table[i] = tab;
    }
  }
  table[i] = table[len];

  // assign prefixes
  i = 0;
  prefix = 0;
  table[i++].prefix = prefix++;
  for (; table[i].rangeLen != jbig2HuffmanEOT; ++i) {
    prefix <<= table[i].prefixLen - table[i-1].prefixLen;
    table[i].prefix = prefix++;
  }
}

Here is the caller graph for this function:

Definition at line 331 of file JBIG2Stream.cc.

                                                                     {
  Guint i, len, prefix;

  i = 0;
  len = 0;
  prefix = 0;
  while (table[i].rangeLen != jbig2HuffmanEOT) {
    while (len < table[i].prefixLen) {
      prefix = (prefix << 1) | readBit();
      ++len;
    }
    if (prefix == table[i].prefix) {
      if (table[i].rangeLen == jbig2HuffmanOOB) {
       return gFalse;
      }
      if (table[i].rangeLen == jbig2HuffmanLOW) {
       *x = table[i].val - readBits(32);
      } else if (table[i].rangeLen > 0) {
       *x = table[i].val + readBits(table[i].rangeLen);
      } else {
       *x = table[i].val;
      }
      return gTrue;
    }
    ++i;
  }
  return gFalse;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 384 of file JBIG2Stream.cc.

                                   {
  if (bufLen == 0) {
    buf = str->getChar();
    bufLen = 8;
  }
  --bufLen;
  return (buf >> bufLen) & 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 360 of file JBIG2Stream.cc.

                                           {
  Guint x, mask, nLeft;

  mask = (n == 32) ? 0xffffffff : ((1 << n) - 1);
  if (bufLen >= n) {
    x = (buf >> (bufLen - n)) & mask;
    bufLen -= n;
  } else {
    x = buf & ((1 << bufLen) - 1);
    nLeft = n - bufLen;
    bufLen = 0;
    while (nLeft >= 8) {
      x = (x << 8) | (str->getChar() & 0xff);
      nLeft -= 8;
    }
    if (nLeft > 0) {
      buf = str->getChar();
      bufLen = 8 - nLeft;
      x = (x << nLeft) | ((buf >> bufLen) & ((1 << nLeft) - 1));
    }
  }
  return x;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 325 of file JBIG2Stream.cc.

                                {
  buf = 0;
  bufLen = 0;
}

Here is the caller graph for this function:

Definition at line 297 of file JBIG2Stream.cc.

{ str = strA; }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 313 of file JBIG2Stream.cc.

Definition at line 314 of file JBIG2Stream.cc.

Definition at line 312 of file JBIG2Stream.cc.


The documentation for this class was generated from the following file: