pdf_prim.c

changeset 91
e63762afae80
parent 82
abb03c7f4aab
child 101
385a2f77a5d8
     1.1 --- a/pdf_prim.c	Sat Mar 08 10:02:13 2003 +0000
     1.2 +++ b/pdf_prim.c	Mon Mar 10 09:49:50 2003 +0000
     1.3 @@ -4,7 +4,7 @@
     1.4   *      will be compressed using ITU-T T.6 (G4) fax encoding.
     1.5   *
     1.6   * PDF routines
     1.7 - * $Id: pdf_prim.c,v 1.7 2003/03/07 03:02:31 eric Exp $
     1.8 + * $Id: pdf_prim.c,v 1.8 2003/03/10 01:49:50 eric Exp $
     1.9   * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
    1.10   *
    1.11   * This program is free software; you can redistribute it and/or modify
    1.12 @@ -66,8 +66,6 @@
    1.13  };
    1.14  
    1.15  
    1.16 -#define STREAM_BUF_SIZE 4096
    1.17 -
    1.18  struct pdf_stream
    1.19  {
    1.20    struct pdf_obj *stream_dict;
    1.21 @@ -76,13 +74,6 @@
    1.22    void *app_data;  /* arg to pass to callback */
    1.23    struct pdf_obj *filters;  /* name or array of names */
    1.24    struct pdf_obj *decode_parms;
    1.25 -
    1.26 -  /* The following fields are used by pdf_stream_write_bits() and
    1.27 -     pdf_stream_flush_bits(). */
    1.28 -  uint32_t byte_idx;  /* index to next byte position in data buffer */
    1.29 -  uint32_t bit_idx;   /* index to next bit position in data buffer,
    1.30 -			 0 = MSB, 7 = LSB */
    1.31 -  uint8_t data [STREAM_BUF_SIZE];
    1.32  };
    1.33  
    1.34  
    1.35 @@ -494,65 +485,6 @@
    1.36  }
    1.37  
    1.38  
    1.39 -void pdf_stream_flush_bits (pdf_file_handle pdf_file,
    1.40 -			    struct pdf_obj *stream)
    1.41 -{
    1.42 -  struct pdf_stream *s = & stream->val.stream;
    1.43 -
    1.44 -  if (s->bit_idx)
    1.45 -    {
    1.46 -      /* zero remaining bits in last byte */
    1.47 -      s->data [s->byte_idx] &= ~ ((1 << (8 - s->bit_idx)) - 1);
    1.48 -      s->byte_idx++;
    1.49 -      s->bit_idx = 0;
    1.50 -    }
    1.51 -  pdf_stream_write_data (pdf_file, stream, 
    1.52 -			 (char *) & s->data [0],
    1.53 -			 s->byte_idx);
    1.54 -  s->byte_idx = 0;
    1.55 -}
    1.56 -
    1.57 -
    1.58 -static void pdf_stream_advance_byte (pdf_file_handle pdf_file,
    1.59 -				     struct pdf_obj *stream)
    1.60 -{
    1.61 -  struct pdf_stream *s = & stream->val.stream;
    1.62 -
    1.63 -  s->byte_idx++;
    1.64 -  s->bit_idx = 0;
    1.65 -  if (s->byte_idx == STREAM_BUF_SIZE)
    1.66 -    pdf_stream_flush_bits (pdf_file, stream);
    1.67 -}
    1.68 -
    1.69 -
    1.70 -void pdf_stream_write_bits (pdf_file_handle pdf_file,
    1.71 -			    struct pdf_obj *stream,
    1.72 -			    uint32_t count,
    1.73 -			    uint32_t bits)
    1.74 -{
    1.75 -  struct pdf_stream *s = & stream->val.stream;
    1.76 -
    1.77 -  uint32_t b2;  /* how many bits will fit in byte in data buffer */
    1.78 -  uint32_t c2;  /* how many bits to transfer on this iteration */
    1.79 -  uint32_t d2;  /* bits to transfer on this iteration */
    1.80 -
    1.81 -  while (count)
    1.82 -    {
    1.83 -      b2 = 8 - s->bit_idx;
    1.84 -      if (b2 >= count)
    1.85 -	c2 = count;
    1.86 -      else
    1.87 -	c2 = b2;
    1.88 -      d2 = bits >> (count - c2);
    1.89 -      s->data [s->byte_idx] |= (d2 << (b2 + c2));
    1.90 -      s->bit_idx += c2;
    1.91 -      if (s->bit_idx > 7)
    1.92 -	pdf_stream_advance_byte (pdf_file, stream);
    1.93 -      count -= c2;
    1.94 -    }
    1.95 -}
    1.96 -
    1.97 -
    1.98  void pdf_stream_printf (pdf_file_handle pdf_file,
    1.99  			struct pdf_obj *stream,
   1.100  			char *fmt, ...)