Exemplo n.º 1
0
int main (int argc, char **argv)
{
  write_prologue();

  write_verticals();
  write_horizontals();
  write_squares();

  write_wm_horiz();
  write_wm_vert();

  write_ab_orig();

  write_epilogue();
  return 0;
}
Exemplo n.º 2
0
int main (int argc, char **argv)/*{{{*/
{
  write_prologue();

  write_verticals();
  write_horizontals();
  draw_limits();
  write_squares();

  write_en_horiz();
  write_en_vert();

  write_ab_orig();

  write_epilogue();
  return 0;
}
Exemplo n.º 3
0
/* ************************************************************
   *                                                          *
   * main compression routine                                 *
   *                                                          *
   ********************************************************** */
void compress_file(void)
{
  void read_text(FILE *, bwi_input *s);
  void remap_alphabet(bwi_input *s);
  void build_sa(bwi_input *s);
  void compute_bwt(bwi_input *s);
  void compute_info_superbuckets(bwi_input *s);
  void compute_info_buckets(bwi_input *s);
  void write_prologue(bwi_input *s);
  void compress_superbucket(bwi_input *s, int);
  int compute_locations(bwi_input *s);
  int compute_locations_dict(bwi_input *s, int*);
  int compute_ranks_dict(bwi_input *s, int*);
  int compute_locations_huffword(bwi_input *s, int *);
  void bit_flush( void );
  void bit_write(int,int);  
  void init_bit_buffer(void);
  void write_susp_infos(bwi_input *s);
  bwi_input s;
  int i,len, retr_occ, retr_occ2, loc_occ_range;
  int Start_prologue_ranks;

  /* --------- Load the text file from disk ------- */  
  if(Verbose) fprintf(stderr,"Reading input file... ");  
  read_text(Infile, &s);
  if(Verbose) fprintf(stderr,"done! (%f seconds)\n",getTime());
  
  /* --------- Compact alphabet ------- */  
  if(Verbose>1) fprintf(stderr,"Remapping alphabet... ");  
  remap_alphabet(&s);
  if(Verbose>1) fprintf(stderr,"done! (%f seconds). ",getTime());
  if(Verbose>1) fprintf(stderr,"Compact alphabet size = %d\n",s.alpha_size);

  /* --------- Build suffix array ------- */  
  if(Verbose) fprintf(stderr,"Building suffix array");  
  build_sa(&s);
  if(Verbose) fprintf(stderr,"done! (%f seconds)\n",getTime());

  /* --------- Compute BWT ------- */  
  if(Verbose>1) fprintf(stderr,"Computing BWT... ");
  compute_bwt(&s);
  if(Verbose>1) fprintf(stderr,"done! (%f seconds)\n",getTime());

  /* ------- mark chars and compute locations ----- */ 
  if (Is_dictionary)
    retr_occ = compute_locations_dict(&s,&loc_occ_range);    // dictionary
  else if (Is_huffword)
    retr_occ = compute_locations_huffword(&s,&loc_occ_range);// huffword 
  else if (Is_URL)
    retr_occ = compute_ranks_dict(&s,&loc_occ_range);        // URL
  else
    retr_occ = compute_locations(&s);                        // standard


  /* --------- Compute various infos for each superbucket ------- */  
  if(Verbose>1) fprintf(stderr,"Computing infos superbukets... ");
  compute_info_superbuckets(&s);
  if(Verbose>1) fprintf(stderr,"done! (%f seconds)\n", getTime());

  /* --------- Compute various infos for each bucket ------- */  
  if(Verbose>1) fprintf(stderr,"Computing infos buckets... ");
  compute_info_buckets(&s);
  if(Verbose>1) fprintf(stderr,"done! (%f seconds)\n", getTime());

  /* --------- Writing the compressed file ------- */
  Infile_size = s.text_size; 
  Outfile_size=0;

  write_prologue(&s);
  if(Verbose) fprintf(stderr,"Prologue --> %d bytes!\n",Outfile_size);

  for(i=0;i<Num_bucs_lev1;i++)
    compress_superbucket(&s,i);

  /* ---- keep starting positions of occ-explicit list ---- */
  Start_prologue_occ = Outfile_size;

  /* -- write the starting position of buckets -- */
  write_susp_infos(&s);

  if (fseek(Outfile,Start_prologue_occ,SEEK_SET)) {
    fprintf(stderr, "Seek error on output file -compress_file-\n");
    exit(1);
  }


  /* -- write the position of the marked chars ---- */
  init_bit_buffer();
  if(Is_dictionary || Is_huffword || Is_URL)
    len = int_log2(loc_occ_range);     // bits required for each rank
  else  
    len = int_log2(s.text_size);       // bits required for each pos 

  for(i=0; i < retr_occ; i++)
    bit_write(len,s.loc_occ[i]);

  bit_flush();

  Start_prologue_ranks = (int)ftell(Outfile);

  if(Verbose)  
    fprintf(stderr,"List of %d marked ranks --> %d bytes!\n",
	    retr_occ,Start_prologue_ranks-Start_prologue_occ);

  /* -- in the case of URL we also store the DICT info -- */
  /* It should be put together with the computation above --*/
  /* Thus removing these differences in the code --*/
  /* Hence Start_prologue_occ indicates the starting position of RANKS. */
  /* After retr_occ RANKS start the LOCATIONS, which are again retr_occ */
  /* in number. The value of retr_occ can be computed at decompression time */
  /* by using the same formula adopted in compute_ranks_dict() */
  if (Is_URL) {
    retr_occ2 = compute_locations_dict(&s,&loc_occ_range);  // DICT
    
    if (retr_occ != retr_occ2)
      out_of_mem("Unequal number of sampled NULLs\n");

    for(i=0; i < retr_occ; i++)
      bit_write(len,s.loc_occ[i]);
    
    bit_flush();
  
    
  if(Verbose) 
    fprintf(stderr,"List of %d marked locations --> %d bytes!\n",
	    retr_occ2,(int)ftell(Outfile) - Start_prologue_ranks);
  }
}