Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  login

Cobol programmers are down in the dumps.


computers / comp.compression / Adaptive Huffman: What's Wrong with My Code?

SubjectAuthor
o Adaptive Huffman: What's Wrong with My Code?Harry Potter

1
Subject: Adaptive Huffman: What's Wrong with My Code?
From: Harry Potter
Newsgroups: comp.compression
Date: Sat, 14 Nov 2020 22:32 UTC
X-Received: by 2002:ac8:70cd:: with SMTP id g13mr7971634qtp.345.1605393135397;
Sat, 14 Nov 2020 14:32:15 -0800 (PST)
X-Received: by 2002:a25:4f45:: with SMTP id d66mr10280721ybb.390.1605393135252;
Sat, 14 Nov 2020 14:32:15 -0800 (PST)
Path: i2pn2.org!i2pn.org!aioe.org!peer01.ams4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.compression
Date: Sat, 14 Nov 2020 14:32:14 -0800 (PST)
Complaints-To: groups-abuse@google.com
Injection-Info: google-groups.googlegroups.com; posting-host=98.113.65.185; posting-account=xRocggoAAACFej4w6sQauoZjUP9yroE5
NNTP-Posting-Host: 98.113.65.185
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <da85b8f2-440d-4f83-9947-d2538359d484n@googlegroups.com>
Subject: Adaptive Huffman: What's Wrong with My Code?
From: rose.jos...@yahoo.com (Harry Potter)
Injection-Date: Sat, 14 Nov 2020 22:32:15 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2766
X-Received-Body-CRC: 3076239231
View all headers
Hi!  I am working on file compression and am having a problem with debugging my version of Adaptive Huffman codes.  Following is the code that recalculates the Huffman tree:
----------------------
static unsigned __fastcall GetHuffGreatestInBlock (unsigned c)
{
register struct HuffEnv_Entry* h=GetHuffEntry (512);
register unsigned j=GetHuffEntry (c)->occur;
register int c2=GetHuffEntry (c)->c;
for (tmpcptr=512; tmpcptr>=c; --tmpcptr){
if (h->occur==j /*&& c2^h->c>=0*/) return tmpcptr;
--h;
} return c;
}

void UpdateHuffCode (unsigned char c)
{
unsigned n, ch=HuffEnv.entrynum[c], x, y;
static struct HuffEnv_Entry* e1;
HuffEnv.Entry[512].parent=-1;
while (ch<512) {
n=GetHuffGreatestInBlock (ch);
e2=GetHuffEntry (ch);
e1=GetHuffEntry (n);
if (n!=ch &&
e2->parent!=n){
tmpcptr=(unsigned) e1;
if (((int)e2->c)>=0) {
HuffEnv.entrynum[e2->c]=n;
}
if (((int)e1->c)>=0) {
HuffEnv.entrynum[e1->c]=ch;
}
x=e1->c;
e1->c=e2->c;
e2->c=x;
x=e1->parent;
e1->parent=e2->parent;
e2->parent=x;
++e2->occur;
if (n>=512) break;
ch=e2->parent;
} else {
++e2->occur;
if (n>=512) break;
ch=e2->parent;
}
} HuffEnv.Entry[512].occur++;
}
--------------------------------------
GetHuffEntry() returns a pointer to the given Huffman tree entry.  e1 and e2 are temp. pointers.  In the Huffman tree entry struct, c is the character at the entry, or -1 if none.  x is a temp. variable.  Everything else should be self-explanatory.  If you need more information, just ask.


1
rocksolid light 0.7.2
clearneti2ptor