Back to index

tetex-bin  3.0
Functions | Variables
unpack.c File Reference
#include "dvips.h"
#include "protos.h"

Go to the source code of this file.

Functions

shalfword getnyb P1H (void)
void flip P2C (register char *, s, register long, howmany)
long unpack P5C (quarterword *, pack, halfword *, raster, halfword, cwidth, halfword, cheight, halfword, cmd)

Variables

static halfword bitweight
static halfword dynf
static halfword gpower [17]
static long repeatcount
static quarterwordp
static halfword bftest = 1

Function Documentation

shalfword getnyb P1H ( void  ) [read]

Definition at line 30 of file unpack.c.

{
    if ( bitweight == 0 ) 
    { bitweight = 16 ; 
      return(*p++ & 15) ;
    } else {
      bitweight = 0 ;
      return(*p >> 4) ;
    }
} 
void flip P2C ( register char *  ,
s  ,
register  long,
howmany   
)

Definition at line 77 of file unpack.c.

{
   register char t ;

   while (howmany > 0) {
      t = *s ;
      *s = s[1] ;
      s[1] = t ;
      howmany-- ;
      s += 2 ;
   }
}
long unpack P5C ( quarterword ,
pack  ,
halfword ,
raster  ,
halfword  ,
cwidth  ,
halfword  ,
cheight  ,
halfword  ,
cmd   
)

Definition at line 94 of file unpack.c.

{ 
  register integer i, j ; 
  shalfword wordwidth ; 
  register halfword word, wordweight ;
  shalfword rowsleft ; 
  Boolean turnon ; 
  shalfword hbit, ww ; 
  long count ; 
  halfword *oraster ;

      oraster = raster ;
      p = pack ;
      dynf = cmd / 16 ; 
      turnon = cmd & 8 ; 
      wordwidth = (cwidth + 15)/16 ;
      if ( dynf == 14 ) 
      { bitweight = 256 ; 
        for ( i = 1 ; i <= cheight ; i ++ ) 
          { word = 0 ; 
            wordweight = 32768 ; 
            for ( j = 1 ; j <= cwidth ; j ++ ) 
              { if ( getbit () ) word += wordweight ; 
                wordweight >>= 1 ;
                if ( wordweight == 0 ) 
                { *raster++ = word ; 
                  word = 0 ;
                  wordweight = 32768 ; 
                  } 
                } 
              if ( wordweight != 32768 ) 
                 *raster++ = word ; 
            } 
      } else {
        rowsleft = cheight ; 
        hbit = cwidth ; 
        repeatcount = 0 ; 
        ww = 16 ; 
        word = 0 ; 
        bitweight = 16 ;
        while ( rowsleft > 0 ) 
          { count = pkpackednum() ; 
            while ( count != 0 ) 
              { if ( ( count <= ww ) && ( count < hbit ) ) 
                { if ( turnon ) word += gpower [ ww ] - gpower 
                  [ ww - count ] ; 
                  hbit -= count ; 
                  ww -= count ; 
                  count = 0 ; 
                  } 
                else if ( ( count >= hbit ) && ( hbit <= ww ) ) 
                { if ( turnon )
                     word += gpower[ww] - gpower[ww-hbit] ; 
                  *raster++ = word ; 
                  for ( i = 1 ; i <= repeatcount ; i ++ ) {
                    for ( j = 1 ; j <= wordwidth ; j ++ ) {
                      *raster = *(raster - wordwidth) ;
                      raster++ ;
                    }
                  }
                  rowsleft -= repeatcount + 1 ; 
                  repeatcount = 0 ; 
                  word = 0 ; 
                  ww = 16 ; 
                  count -= hbit ; 
                  hbit = cwidth ; 
                  } 
                else 
                { if ( turnon ) word += gpower [ ww ] ; 
                  *raster++ = word ;
                  word = 0 ; 
                  count -= ww ; 
                  hbit -= ww ; 
                  ww = 16 ; 
                  } 
                } 
              turnon = ! turnon ; 
            } 
          if ( ( rowsleft != 0 ) || ( (unsigned)hbit != cwidth ) ) 
             error ( "! error while unpacking; more bits than required" ) ; 
        } 
    if (*(char *)&bftest) /* is the hardware LittleEndian? */
       flip((char *)oraster, ((cwidth + 15) >> 4) * (long)cheight) ;
   return(p-pack) ;
}

Here is the call graph for this function:


Variable Documentation

halfword bftest = 1 [static]

Definition at line 92 of file unpack.c.

halfword bitweight [static]

Definition at line 17 of file unpack.c.

halfword dynf [static]

Definition at line 18 of file unpack.c.

halfword gpower[17] [static]
Initial value:
 { 0 , 1 , 3 , 7 , 15 , 31 , 63 , 127 ,
     255 , 511 , 1023 , 2047 , 4095 , 8191 , 16383 , 32767 , 65535 }

Definition at line 19 of file unpack.c.

quarterword* p [static]

Definition at line 22 of file unpack.c.

long repeatcount [static]

Definition at line 21 of file unpack.c.