rev 426 - trunk
[email protected] Tue, 16 Aug 2005 13:38:03 -0700 (PDT)
| Newsgroups | gmane.comp.printing.ghostscript.jbig2dec.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: giles
Date: 2005-08-16 13:38:03 -0700 (Tue, 16 Aug 2005)
New Revision: 426
Modified:
trunk/jbig2_huffman.c
trunk/jbig2_huffman.h
trunk/jbig2_symbol_dict.c
Log:
Remove huffman debugging printouts. Preserve the state dump functions
for future use, but #ifdef protect them.
Modified: trunk/jbig2_huffman.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/jbig2_huffman.c 2005-08-16 20:20:08 UTC (rev 425)
+++ trunk/jbig2_huffman.c 2005-08-16 20:38:03 UTC (rev 426)
@@ -25,7 +25,10 @@
#include "os_types.h"
=20
#include <stdlib.h>
+
+#ifdef JBIG2_DEBUG
#include <stdio.h>
+#endif
=20
#include "jbig2.h"
#include "jbig2_priv.h"
@@ -85,14 +88,16 @@
return;
}
=20
-/** debug routine */
+/** debug routines **/
+#ifdef JBIG2_DEBUG
+/** print current huffman state */
void jbig2_dump_huffman_state(Jbig2HuffmanState *hs)
{
fprintf(stderr, "huffman state %08x %08x offset %d.%d\n",
hs->this_word, hs->next_word, hs->offset, hs->offset_bits);=20
}
=20
-/** debug routine */
+/** print the binary string we're reading from */
void jbig2_dump_huffman_binary(Jbig2HuffmanState *hs)
{
const uint32_t word =3D hs->this_word;
@@ -103,6 +108,7 @@
fprintf(stderr, ((word >> i) & 1) ? "1" : "0");
fprintf(stderr, "\n");
}
+#endif /* JBIG2_DEBUG */
=20
/** Skip bits up to the next byte boundary
*/
@@ -116,8 +122,6 @@
hs->offset_bits +=3D bits;
hs->this_word =3D (hs->this_word << bits) |=20
(hs->next_word >> (32 - hs->offset_bits));
- printf("jbig2_huffman_skip() advancing %d bits (offset now %d)\n",=20
- bits, hs->offset_bits);
}
=20
if (hs->offset_bits >=3D 32) {
@@ -139,7 +143,6 @@
{
Jbig2WordStream *ws =3D hs->ws;
=20
- printf("jbig2_huffman_advance() advancing %d bytes\n", offset);
hs->offset +=3D offset & ~3;
hs->offset_bits +=3D (offset & 3) << 3;
if (hs->offset_bits >=3D 32) {
@@ -149,7 +152,7 @@
hs->this_word =3D ws->get_next_word (ws, hs->offset);
hs->next_word =3D ws->get_next_word (ws, hs->offset + 4);
if (hs->offset_bits > 0)
- hs->this_word =3D (hs->this_word << hs->offset_bits) |
+ hs->this_word =3D (hs->this_word << hs->offset_bits) |
(hs->next_word >> (32 - hs->offset_bits));
}
=20
@@ -200,13 +203,6 @@
flags =3D entry->flags;
PREFLEN =3D entry->PREFLEN;
=20
-fprintf(stderr, "huffman reading prefix %x (entry %d len %d) flags %d\n"=
,
- (this_word >> (32 - PREFLEN)),
- (this_word >> (32 - log_table_size)), PREFLEN, flags);
-
-fprintf(stderr, "huffman state %08x %08x before prefix read\n",
- this_word, hs->next_word);
-
next_word =3D hs->next_word;
offset_bits +=3D PREFLEN;
if (offset_bits >=3D 32)
@@ -219,13 +215,9 @@
hs->next_word =3D next_word;
PREFLEN =3D offset_bits;
}
-fprintf(stderr, "huffman state %08x %08x after prefix read\n",
- this_word, next_word);
if (PREFLEN)
this_word =3D (this_word << PREFLEN) |
(next_word >> (32 - offset_bits));
-fprintf(stderr, "huffman state %08x %08x after prefix update\n",
- this_word, next_word);
if (flags & JBIG2_HUFFMAN_FLAGS_ISEXT)
{
table =3D entry->u.ext_table;
@@ -245,9 +237,6 @@
else
result +=3D HTOFFSET;
=20
-fprintf(stderr, "huffman reading range %x (%d bits)\n",
- HTOFFSET, RANGELEN);
-
offset_bits +=3D RANGELEN;
if (offset_bits >=3D 32)
{
@@ -270,9 +259,6 @@
if (oob !=3D NULL)
*oob =3D (flags & JBIG2_HUFFMAN_FLAGS_ISOOB);
=20
-fprintf(stderr, "huffman value is %d%s\n", result,
- (flags & JBIG2_HUFFMAN_FLAGS_ISOOB) ? " (oob)" : "");
-
return result;
}
=20
Modified: trunk/jbig2_huffman.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/jbig2_huffman.h 2005-08-16 20:20:08 UTC (rev 425)
+++ trunk/jbig2_huffman.h 2005-08-16 20:38:03 UTC (rev 426)
@@ -76,6 +76,11 @@
int32_t
jbig2_huffman_get_bits (Jbig2HuffmanState *hs, const int bits);
=20
+#ifdef JBIG2_DEBUG
+void jbig2_dump_huffman_state(Jbig2HuffmanState *hs);
+void jbig2_dump_huffman_binary(Jbig2HuffmanState *hs);
+#endif
+
Jbig2HuffmanTable *
jbig2_build_huffman_table (Jbig2Ctx *ctx, const Jbig2HuffmanParams *para=
ms);
=20
Modified: trunk/jbig2_symbol_dict.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/jbig2_symbol_dict.c 2005-08-16 20:20:08 UTC (rev 425)
+++ trunk/jbig2_symbol_dict.c 2005-08-16 20:38:03 UTC (rev 426)
@@ -278,9 +278,7 @@
=20
/* 6.5.6 */
if (params->SDHUFF) {
- jbig2_dump_huffman_state(hs);
HCDH =3D jbig2_huffman_get(hs, params->SDHUFFDH, &code);
- jbig2_dump_huffman_state(hs);
} else {
code =3D jbig2_arith_int_decode(IADH, as, &HCDH);
}
@@ -320,8 +318,6 @@
}
/* 6.5.7 */
if (params->SDHUFF) {
- jbig2_dump_huffman_state(hs);
- jbig2_dump_huffman_binary(hs);
DW =3D jbig2_huffman_get(hs, params->SDHUFFDW, &code);
jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number,
"decoded symbol delta width %d", DW);
@@ -409,13 +405,9 @@
int ninsyms =3D params->SDINSYMS->n_symbols;
=20
if (params->SDHUFF) {
- jbig2_dump_huffman_state(hs);
ID =3D jbig2_huffman_get_bits(hs, SBSYMCODELEN);
- jbig2_dump_huffman_state(hs);
RDX =3D jbig2_huffman_get(hs, SDHUFFRDX, &code);
- jbig2_dump_huffman_state(hs);
RDY =3D jbig2_huffman_get(hs, SDHUFFRDX, &code);
- jbig2_dump_huffman_state(hs);
} else {
code =3D jbig2_arith_iaid_decode(IAID, as, (int32_t*)&ID);
code =3D jbig2_arith_int_decode(IARDX, as, &RDX);
@@ -475,18 +467,11 @@
/* 6.5.5 (4c.iv) */
NSYMSDECODED =3D NSYMSDECODED + 1;
=20
-#ifdef JBIG2_DEBUG
jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number,
"%d of %d decoded", NSYMSDECODED, params->SDNUMNEWSYMS);
-#endif
=20
- jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number,
- "at end of height class decode loop...");
} /* end height class decode loop */
=20
- jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number,
- "left height class decode loop");
-
/* 6.5.5 (4d) */
if (params->SDHUFF && !params->SDREFAGG) {
/* 6.5.9 */
@@ -499,9 +484,7 @@
/* todo: memory cleanup */
return NULL;
}
- jbig2_dump_huffman_state(hs);
jbig2_huffman_skip(hs);
- jbig2_dump_huffman_state(hs);
image =3D jbig2_image_new(ctx, TOTWIDTH, HCHEIGHT);
if (image =3D=3D NULL) {
jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number,
@@ -526,9 +509,7 @@
#ifdef OUTPUT_PBM
jbig2_image_write_pbm_file(image, "collective.pbm");
#endif
- jbig2_dump_huffman_state(hs);
jbig2_huffman_advance(hs, BMSIZE);
- jbig2_dump_huffman_state(hs);
}
=20
} /* end of symbol decode loop */