Back to index

tetex-bin  3.0
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
JArithmeticDecoder Class Reference

#include <JArithmeticDecoder.h>

Collaboration diagram for JArithmeticDecoder:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 JArithmeticDecoder ()
 ~JArithmeticDecoder ()
void setStream (Stream *strA)
void setStream (Stream *strA, int dataLenA)
void start ()
int decodeBit (Guint context, JArithmeticDecoderStats *stats)
int decodeByte (Guint context, JArithmeticDecoderStats *stats)
GBool decodeInt (int *x, JArithmeticDecoderStats *stats)
Guint decodeIAID (Guint codeLen, JArithmeticDecoderStats *stats)

Private Member Functions

Guint readByte ()
int decodeIntBit (JArithmeticDecoderStats *stats)
void byteIn ()

Private Attributes

Guint buf0
Guint buf1
Guint c
Guint a
int ct
Guint prev
Streamstr
int dataLen

Static Private Attributes

static Guint qeTab [47]
static int nmpsTab [47]
static int nlpsTab [47]
static int switchTab [47]

Detailed Description

Definition at line 51 of file JArithmeticDecoder.h.


Constructor & Destructor Documentation

Definition at line 90 of file JArithmeticDecoder.cc.

                                       {
  str = NULL;
}

Definition at line 104 of file JArithmeticDecoder.cc.

                                        {
  while (dataLen > 0) {
    readByte();
  }
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 284 of file JArithmeticDecoder.cc.

                                {
  if (buf0 == 0xff) {
    if (buf1 > 0x8f) {
      ct = 8;
    } else {
      buf0 = buf1;
      buf1 = readByte();
      c = c + 0xfe00 - (buf0 << 9);
      ct = 7;
    }
  } else {
    buf0 = buf1;
    buf1 = readByte();
    c = c + 0xff00 - (buf0 << 8);
    ct = 8;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 122 of file JArithmeticDecoder.cc.

                                                              {
  int bit;
  Guint qe;
  int iCX, mpsCX;

  iCX = stats->cxTab[context] >> 1;
  mpsCX = stats->cxTab[context] & 1;
  qe = qeTab[iCX];
  a -= qe;
  if (c < a) {
    if (a & 0x80000000) {
      bit = mpsCX;
    } else {
      // MPS_EXCHANGE
      if (a < qe) {
       bit = 1 - mpsCX;
       if (switchTab[iCX]) {
         stats->cxTab[context] = (nlpsTab[iCX] << 1) | (1 - mpsCX);
       } else {
         stats->cxTab[context] = (nlpsTab[iCX] << 1) | mpsCX;
       }
      } else {
       bit = mpsCX;
       stats->cxTab[context] = (nmpsTab[iCX] << 1) | mpsCX;
      }
      // RENORMD
      do {
       if (ct == 0) {
         byteIn();
       }
       a <<= 1;
       c <<= 1;
       --ct;
      } while (!(a & 0x80000000));
    }
  } else {
    c -= a;
    // LPS_EXCHANGE
    if (a < qe) {
      bit = mpsCX;
      stats->cxTab[context] = (nmpsTab[iCX] << 1) | mpsCX;
    } else {
      bit = 1 - mpsCX;
      if (switchTab[iCX]) {
       stats->cxTab[context] = (nlpsTab[iCX] << 1) | (1 - mpsCX);
      } else {
       stats->cxTab[context] = (nlpsTab[iCX] << 1) | mpsCX;
      }
    }
    a = qe;
    // RENORMD
    do {
      if (ct == 0) {
       byteIn();
      }
      a <<= 1;
      c <<= 1;
      --ct;
    } while (!(a & 0x80000000));
  }
  return bit;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 186 of file JArithmeticDecoder.cc.

                                                               {
  int byte;
  int i;

  byte = 0;
  for (i = 0; i < 8; ++i) {
    byte = (byte << 1) | decodeBit(context, stats);
  }
  return byte;
}

Here is the call graph for this function:

Definition at line 271 of file JArithmeticDecoder.cc.

                                                                 {
  Guint i;
  int bit;

  prev = 1;
  for (i = 0; i < codeLen; ++i) {
    bit = decodeBit(prev, stats);
    prev = (prev << 1) | bit;
  }
  return prev - (1 << codeLen);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 198 of file JArithmeticDecoder.cc.

                                                                          {
  int s;
  Guint v;
  int i;

  prev = 1;
  s = decodeIntBit(stats);
  if (decodeIntBit(stats)) {
    if (decodeIntBit(stats)) {
      if (decodeIntBit(stats)) {
       if (decodeIntBit(stats)) {
         if (decodeIntBit(stats)) {
           v = 0;
           for (i = 0; i < 32; ++i) {
             v = (v << 1) | decodeIntBit(stats);
           }
           v += 4436;
         } else {
           v = 0;
           for (i = 0; i < 12; ++i) {
             v = (v << 1) | decodeIntBit(stats);
           }
           v += 340;
         }
       } else {
         v = 0;
         for (i = 0; i < 8; ++i) {
           v = (v << 1) | decodeIntBit(stats);
         }
         v += 84;
       }
      } else {
       v = 0;
       for (i = 0; i < 6; ++i) {
         v = (v << 1) | decodeIntBit(stats);
       }
       v += 20;
      }
    } else {
      v = decodeIntBit(stats);
      v = (v << 1) | decodeIntBit(stats);
      v = (v << 1) | decodeIntBit(stats);
      v = (v << 1) | decodeIntBit(stats);
      v += 4;
    }
  } else {
    v = decodeIntBit(stats);
    v = (v << 1) | decodeIntBit(stats);
  }

  if (s) {
    if (v == 0) {
      return gFalse;
    }
    *x = -(int)v;
  } else {
    *x = (int)v;
  }
  return gTrue;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 259 of file JArithmeticDecoder.cc.

                                                                   {
  int bit;

  bit = decodeBit(prev, stats);
  if (prev < 0x100) {
    prev = (prev << 1) | bit;
  } else {
    prev = (((prev << 1) | bit) & 0x1ff) | 0x100;
  }
  return bit;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Guint JArithmeticDecoder::readByte ( ) [inline, private]

Definition at line 94 of file JArithmeticDecoder.cc.

                                          {
  if (dataLen == 0) {
    return 0xff;
  }
  if (dataLen > 0) {
    --dataLen;
  }
  return (Guint)str->getChar() & 0xff;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 56 of file JArithmeticDecoder.h.

    { str = strA; dataLen = -1; }

Here is the caller graph for this function:

void JArithmeticDecoder::setStream ( Stream strA,
int  dataLenA 
) [inline]

Definition at line 58 of file JArithmeticDecoder.h.

    { str = strA; dataLen = dataLenA; }

Definition at line 110 of file JArithmeticDecoder.cc.

                               {
  buf0 = readByte();
  buf1 = readByte();

  // INITDEC
  c = (buf0 ^ 0xff) << 16;
  byteIn();
  c <<= 7;
  ct -= 7;
  a = 0x80000000;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 82 of file JArithmeticDecoder.h.

Definition at line 81 of file JArithmeticDecoder.h.

Definition at line 81 of file JArithmeticDecoder.h.

Definition at line 82 of file JArithmeticDecoder.h.

Definition at line 83 of file JArithmeticDecoder.h.

Definition at line 88 of file JArithmeticDecoder.h.

int JArithmeticDecoder::nlpsTab [static, private]
Initial value:
 {
   1,  6,  9, 12, 29, 33,  6, 14, 14, 14, 17, 18, 20, 21, 14, 14,
  15, 16, 17, 18, 19, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
  30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 46
}

Definition at line 78 of file JArithmeticDecoder.h.

int JArithmeticDecoder::nmpsTab [static, private]
Initial value:
 {
   1,  2,  3,  4,  5, 38,  7,  8,  9, 10, 11, 12, 13, 29, 15, 16,
  17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
  33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 45, 46
}

Definition at line 77 of file JArithmeticDecoder.h.

Definition at line 85 of file JArithmeticDecoder.h.

Guint JArithmeticDecoder::qeTab [static, private]
Initial value:
 {
  0x56010000, 0x34010000, 0x18010000, 0x0AC10000,
  0x05210000, 0x02210000, 0x56010000, 0x54010000,
  0x48010000, 0x38010000, 0x30010000, 0x24010000,
  0x1C010000, 0x16010000, 0x56010000, 0x54010000,
  0x51010000, 0x48010000, 0x38010000, 0x34010000,
  0x30010000, 0x28010000, 0x24010000, 0x22010000,
  0x1C010000, 0x18010000, 0x16010000, 0x14010000,
  0x12010000, 0x11010000, 0x0AC10000, 0x09C10000,
  0x08A10000, 0x05210000, 0x04410000, 0x02A10000,
  0x02210000, 0x01410000, 0x01110000, 0x00850000,
  0x00490000, 0x00250000, 0x00150000, 0x00090000,
  0x00050000, 0x00010000, 0x56010000
}

Definition at line 76 of file JArithmeticDecoder.h.

Definition at line 87 of file JArithmeticDecoder.h.

Initial value:
 {
  1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}

Definition at line 79 of file JArithmeticDecoder.h.


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