summaryrefslogtreecommitdiff
path: root/lib/HTree.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/HTree.cc')
-rw-r--r--lib/HTree.cc29
1 files changed, 28 insertions, 1 deletions
diff --git a/lib/HTree.cc b/lib/HTree.cc
index b8731e4..682ac14 100644
--- a/lib/HTree.cc
+++ b/lib/HTree.cc
@@ -30,10 +30,18 @@ HTree::~HTree()
ostream & HTree::Trace(ostream & os, int d)
{
static char cmpr[MAX_HDEPTH + 1];
+ static int tsize;
+ static int rsize;
+ static int dsize;
+
+ if (!d) tsize = rsize = dsize = 0;
if (objet) {
cmpr[d] = '\0';
- os << objet << " = " << cmpr << endl;
+ os << objet << " (" << freq << ") = " << cmpr << endl;
+ tsize += freq * strlen(cmpr);
+ rsize += freq * strlen(objet);
+ dsize += ((strlen(cmpr) >> 3) + (strlen(cmpr) & 7 ? 1 : 0)) + strlen(objet) + 2;
} else {
if (left) {
cmpr[d] = '0';
@@ -44,5 +52,24 @@ ostream & HTree::Trace(ostream & os, int d)
right->Trace(os, d + 1);
}
}
+
+ if (!d) {
+ os << _("Bitstream length : ") << tsize << _(" bits (= ") << ((tsize >> 3) + (tsize & 7 ? 1 : 0)) << _(" bytes)\n");
+ os << _("Real size input : ") << (rsize << 3) << _(" bits (= ") << rsize << _(" bytes)\n");
+ os << _("Size squeezed by : ") << 100.0 - 100.0 * tsize / (rsize << 3) << _(" percents\n");
+ os << _("Dictionnary size : ") << (dsize << 3) << _(" bits (= ") << dsize << _(" bytes)\n");
+ os << _("Total bitstream length : ") << tsize + (dsize << 3) << _(" bits (= ") << ((tsize >> 3) + (tsize & 7 ? 1 : 0) + dsize) << _(" bytes)\n");
+ os << _("Real gain (4 bytes header) : ") << 100.0 - 100.0 * ((tsize >> 3) + (tsize & 7 ? 1 : 0) + dsize + 4) / rsize << _(" percents\n");
+ }
return os;
}
+
+int HTree::ReadFreq(void)
+{
+ return freq;
+}
+
+char *HTree::ReadObj(void)
+{
+ return objet;
+}