ref: 338f0fbd294ee0dc9cbfabd7a15cce0ac657a708
parent: df910b6ffff7ae54db6c2d2430709ebb911eda49
author: giles <giles@ded80894-8fb9-0310-811b-c03f3676ab4d>
date: Tue Aug 16 16:38:03 EDT 2005
Remove huffman debugging printouts. Preserve the state dump functions for future use, but #ifdef protect them. git-svn-id: http://svn.ghostscript.com/jbig2dec/trunk@426 ded80894-8fb9-0310-811b-c03f3676ab4d
--- a/jbig2_huffman.c
+++ b/jbig2_huffman.c
@@ -25,7 +25,10 @@
#include "os_types.h"
#include <stdlib.h>
+
+#ifdef JBIG2_DEBUG
#include <stdio.h>
+#endif
#include "jbig2.h"
#include "jbig2_priv.h"
@@ -85,7 +88,9 @@
return;
}
-/** 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",
@@ -92,7 +97,7 @@
hs->this_word, hs->next_word, hs->offset, hs->offset_bits);
}
-/** debug routine */
+/** print the binary string we're reading from */
void jbig2_dump_huffman_binary(Jbig2HuffmanState *hs)
{
const uint32_t word = hs->this_word;
@@ -103,6 +108,7 @@
fprintf(stderr, ((word >> i) & 1) ? "1" : "0");
fprintf(stderr, "\n");
}
+#endif /* JBIG2_DEBUG */
/** Skip bits up to the next byte boundary
*/
@@ -116,8 +122,6 @@
hs->offset_bits += bits;
hs->this_word = (hs->this_word << bits) |
(hs->next_word >> (32 - hs->offset_bits));
- printf("jbig2_huffman_skip() advancing %d bits (offset now %d)\n",
- bits, hs->offset_bits);
}
if (hs->offset_bits >= 32) {
@@ -139,7 +143,6 @@
{
Jbig2WordStream *ws = hs->ws;
- printf("jbig2_huffman_advance() advancing %d bytes\n", offset);
hs->offset += offset & ~3;
hs->offset_bits += (offset & 3) << 3;
if (hs->offset_bits >= 32) {
@@ -149,7 +152,7 @@
hs->this_word = ws->get_next_word (ws, hs->offset);
hs->next_word = ws->get_next_word (ws, hs->offset + 4);
if (hs->offset_bits > 0)
- hs->this_word = (hs->this_word << hs->offset_bits) |
+ hs->this_word = (hs->this_word << hs->offset_bits) |
(hs->next_word >> (32 - hs->offset_bits));
}
@@ -200,13 +203,6 @@
flags = entry->flags;
PREFLEN = entry->PREFLEN;
-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 = hs->next_word;
offset_bits += PREFLEN;
if (offset_bits >= 32)
@@ -219,13 +215,9 @@
hs->next_word = next_word;
PREFLEN = offset_bits;
}
-fprintf(stderr, "huffman state %08x %08x after prefix read\n",
- this_word, next_word);
if (PREFLEN)
this_word = (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 = entry->u.ext_table;
@@ -245,9 +237,6 @@
else
result += HTOFFSET;
-fprintf(stderr, "huffman reading range %x (%d bits)\n",
- HTOFFSET, RANGELEN);
-
offset_bits += RANGELEN;
if (offset_bits >= 32)
{
@@ -269,9 +258,6 @@
if (oob != NULL)
*oob = (flags & JBIG2_HUFFMAN_FLAGS_ISOOB);
-
-fprintf(stderr, "huffman value is %d%s\n", result,
- (flags & JBIG2_HUFFMAN_FLAGS_ISOOB) ? " (oob)" : "");
return result;
}
--- a/jbig2_huffman.h
+++ b/jbig2_huffman.h
@@ -76,6 +76,11 @@
int32_t
jbig2_huffman_get_bits (Jbig2HuffmanState *hs, const int bits);
+#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 *params);
--- a/jbig2_symbol_dict.c
+++ b/jbig2_symbol_dict.c
@@ -278,9 +278,7 @@
/* 6.5.6 */
if (params->SDHUFF) {
- jbig2_dump_huffman_state(hs);
HCDH = jbig2_huffman_get(hs, params->SDHUFFDH, &code);
- jbig2_dump_huffman_state(hs);
} else {
code = 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 = 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 = params->SDINSYMS->n_symbols;
if (params->SDHUFF) {
- jbig2_dump_huffman_state(hs);
ID = jbig2_huffman_get_bits(hs, SBSYMCODELEN);
- jbig2_dump_huffman_state(hs);
RDX = jbig2_huffman_get(hs, SDHUFFRDX, &code);
- jbig2_dump_huffman_state(hs);
RDY = jbig2_huffman_get(hs, SDHUFFRDX, &code);
- jbig2_dump_huffman_state(hs);
} else {
code = jbig2_arith_iaid_decode(IAID, as, (int32_t*)&ID);
code = jbig2_arith_int_decode(IARDX, as, &RDX);
@@ -475,18 +467,11 @@
/* 6.5.5 (4c.iv) */
NSYMSDECODED = NSYMSDECODED + 1;
-#ifdef JBIG2_DEBUG
jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number,
"%d of %d decoded", NSYMSDECODED, params->SDNUMNEWSYMS);
-#endif
- jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number,
- "at end of height class decode loop...");
} /* end height class decode loop */
- 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 = jbig2_image_new(ctx, TOTWIDTH, HCHEIGHT);
if (image == 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);
}
} /* end of symbol decode loop */