Examples of Arithcode


Examples of com.nr.lna.Arithcode

    for (i=0;i<N;i++) nfreq[c[i]]++;
//    for (i=0;i<NCHAR;i++) System.out.printf(nfreq[i] << "  ";
//    System.out.printf(endl;

    // Test codeone
    Arithcode arith = new Arithcode (nfreq,NCHAR,256);
    arith.messageinit();
    lcd.val=0;
    byte[] code = new byte[N];
    for (i=0;i<N;i++) arith.codeone(c[i],code,lcd);
    arith.codeone(NCHAR,code,lcd);    // EOM character
//    System.out.println("Number of bytes used: %f\n", lcd);
//    System.out.println("Compression ratio: %f\n", double(N*3)/8/lcd); // Normally 3 bits each for 5 characters

    // Recover the text
    arith.messageinit();
    lcd.val=0;
    char[] d=new char[N];
    i=0;
    while ((d[i]=(char)arith.decodeone(code,lcd)) != NCHAR) {
      System.out.printf("%x  %x\n", (int)c[i] ,(int)d[i]);
      localflag = localflag || (c[i] != d[i]);
      i++;
    }
    globalflag = globalflag || localflag;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.