Difference between revisions of "File:Example.ogg"

From CDOT Wiki
Jump to: navigation, search
(Created page with '#include <time.h> #include "lzw.h" /******************************************************************** ** ** This program gets a file name from the command line. It comp…')
(No difference)

Revision as of 15:36, 20 February 2013

  1. include <time.h>
  1. include "lzw.h"


/********************************************************************

    • This program gets a file name from the command line. It compresses the
    • file, placing its output in a file named test.lzw. It then expands
    • test.lzw into test.out. Test.out should then be an exact duplicate of
    • the input file.
                                                                                                                                                  • /


main(int argc, char *argv[])

{

clock_t timer;

CLZWCompressFile lzw;


/*

    • Get the file name, open it up, and open up the lzw output file.
  • /
 if (argc==1)
 {
   printf("Input file name to compress?\n");

return 0;

 }


 printf("testing %s...\n", argv[1]);

/*

    • Compress the file.
  • /
 timer = clock();
 int crunch = lzw.Compress(argv[1], "test.lzw");
 timer = clock() - timer; //CLOCKS_PER_SEC
 printf("compress time=%d ms, encoding=%d, size=%u", timer, lzw.get_bits(), crunch);
 int filesize = lzw.u_io;
 printf(" (ratio=%d%%)\n", filesize ? (filesize-crunch)*100/filesize : 0);
 if(lzw.AnyIOErrors())

printf("***I/O ERROR***\n");


/*

    • Expand the file.
  • /
  timer = clock();
 int orig = lzw.Expand("test.lzw", "test.out");
 timer = clock() - timer; //CLOCKS_PER_SEC
 printf("expand time=%d ms, encoding=%d\n", timer, lzw.get_bits());

if(lzw.AnyIOErrors())

printf("***I/O ERROR***\n");


 ATLASSERT(filesize == orig); // did we mangle the file?
 return 0;

}

The following 2 pages link to this file: