rev 404 - trunk

[email protected] Mon, 2 May 2005 19:27:13 -0700 (PDT)
Newsgroups gmane.comp.printing.ghostscript.jbig2dec.cvs
Message-ID <[email protected]>
Author: giles
Date: 2005-05-02 19:27:12 -0700 (Mon, 02 May 2005)
New Revision: 404

Modified:
   trunk/jbig2_symbol_dict.c
Log:
Allocate a huffman decoder for symbol dictionaries that require it.


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-05-03 02:25:08 UTC (rev 403)
+++ trunk/jbig2_symbol_dict.c	2005-05-03 02:27:12 UTC (rev 404)
@@ -31,6 +31,7 @@
 #include "jbig2_arith.h"
 #include "jbig2_arith_int.h"
 #include "jbig2_arith_iaid.h"
+#include "jbig2_huffman.h"
 #include "jbig2_generic.h"
 #include "jbig2_symbol_dict.h"
=20
@@ -218,6 +219,7 @@
   int32_t SYMWIDTH, TOTWIDTH;
   uint32_t HCFIRSTSYM;
   Jbig2WordStream *ws =3D NULL;
+  Jbig2HuffmanState *hs =3D NULL;
   Jbig2ArithState *as =3D NULL;
   Jbig2ArithIntCtx *IADH =3D NULL;
   Jbig2ArithIntCtx *IADW =3D NULL;
@@ -232,8 +234,9 @@
   HCHEIGHT =3D 0;
   NSYMSDECODED =3D 0;
=20
+  ws =3D jbig2_word_stream_buf_new(ctx, data, size);
+
   if (!params->SDHUFF) {
-      ws =3D jbig2_word_stream_buf_new(ctx, data, size);
       as =3D jbig2_arith_new(ctx, ws);
       IADH =3D jbig2_arith_int_ctx_new(ctx);
       IADW =3D jbig2_arith_int_ctx_new(ctx);
@@ -248,9 +251,9 @@
 	  IARDY =3D jbig2_arith_int_ctx_new(ctx);
       }
   } else {
-      jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number,
-	"NYI: huffman coded symbol dictionary");
-      return NULL;
+      jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number,
+	"huffman coded symbol dictionary");
+      hs =3D jbig2_huffman_new(ctx, ws);
   }
=20
   SDNEWSYMS =3D jbig2_sd_new(ctx, params->SDNUMNEWSYMS);
@@ -489,18 +492,21 @@
   jbig2_sd_release(ctx, SDNEWSYMS);
  =20
   if (!params->SDHUFF) {
-    jbig2_arith_int_ctx_free(ctx, IADH);
-    jbig2_arith_int_ctx_free(ctx, IADW);
-    jbig2_arith_int_ctx_free(ctx, IAEX);
-    jbig2_arith_int_ctx_free(ctx, IAAI);
-    if (params->SDREFAGG) {
-      jbig2_arith_iaid_ctx_free(ctx, IAID);
-      jbig2_arith_int_ctx_free(ctx, IARDX);
-      jbig2_arith_int_ctx_free(ctx, IARDY);
-    }
-    jbig2_free(ctx->allocator, as); =20
-    jbig2_word_stream_buf_free(ctx, ws);
+      jbig2_arith_int_ctx_free(ctx, IADH);
+      jbig2_arith_int_ctx_free(ctx, IADW);
+      jbig2_arith_int_ctx_free(ctx, IAEX);
+      jbig2_arith_int_ctx_free(ctx, IAAI);
+      if (params->SDREFAGG) {
+        jbig2_arith_iaid_ctx_free(ctx, IAID);
+        jbig2_arith_int_ctx_free(ctx, IARDX);
+        jbig2_arith_int_ctx_free(ctx, IARDY);
+      }
+      jbig2_free(ctx->allocator, as); =20
+  } else {
+      jbig2_free(ctx->allocator, hs);
   }
+
+  jbig2_word_stream_buf_free(ctx, ws);
  =20
   return SDEXSYMS;
 }