pdf_prim.c

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