ref: 3fb9f08036565d4bd4147283e2e685217b6e4b55
parent: 45a5c57347f7b7569808933207bb03c8edf30315
author: giles <giles@ded80894-8fb9-0310-811b-c03f3676ab4d>
date: Thu Aug 4 03:03:05 EDT 2005
bstract the GB_stats size calculation into a function. Also some comment cleanup. git-svn-id: http://svn.ghostscript.com/jbig2dec/trunk@422 ded80894-8fb9-0310-811b-c03f3676ab4d
--- a/jbig2_arith.h
+++ b/jbig2_arith.h
@@ -13,7 +13,7 @@
Artifex Software, Inc., 101 Lucas Valley Road #110,
San Rafael, CA 94903, U.S.A., +1(415)492-9861.
- $Id: jbig2_arith.h,v 1.4 2002/02/16 07:25:36 raph Exp $
+ $Id$
*/
typedef struct _Jbig2ArithState Jbig2ArithState;
@@ -23,8 +23,12 @@
MPS in the top bit. */
typedef unsigned char Jbig2ArithCx;
+/* allocate and initialize a new arithmetic coding state */
Jbig2ArithState *
jbig2_arith_new (Jbig2Ctx *ctx, Jbig2WordStream *ws);
+/* decode a bit */
bool
jbig2_arith_decode (Jbig2ArithState *as, Jbig2ArithCx *pcx);
+
+
--- a/jbig2_generic.c
+++ b/jbig2_generic.c
@@ -41,6 +41,16 @@
#include "jbig2_generic.h"
#include "jbig2_mmr.h"
+/* return the appropriate context size for the given template */
+int
+jbig2_generic_stats_size(Jbig2Ctx *ctx, int template)
+{
+ int stats_size = template == 0 ? 1 << 16 :
+ template == 1 ? 1 << 1 << 13 : 1 << 10;
+ return stats_size;
+}
+
+
static int
jbig2_decode_generic_template0(Jbig2Ctx *ctx,
Jbig2Segment *segment,
@@ -600,8 +610,7 @@
}
else
{
- int stats_size = params.GBTEMPLATE == 0 ? 65536 :
- params.GBTEMPLATE == 1 ? 8192 : 1024;
+ int stats_size = jbig2_generic_stats_size(ctx, params.GBTEMPLATE);
GB_stats = jbig2_alloc(ctx->allocator, stats_size);
memset(GB_stats, 0, stats_size);
--- a/jbig2_generic.h
+++ b/jbig2_generic.h
@@ -32,6 +32,10 @@
int8_t gbat[8];
} Jbig2GenericRegionParams;
+/* return the appropriate context size for the given template */
+int
+jbig2_generic_stats_size(Jbig2Ctx *ctx, int template);
+
int
jbig2_decode_generic_region(Jbig2Ctx *ctx,
Jbig2Segment *segment,
--- a/jbig2_text.c
+++ b/jbig2_text.c
@@ -341,7 +341,7 @@
}
/**
- * jbig2_read_text_info: read a text region segment header
+ * jbig2_parse_text_region: read a text region segment header
**/
int
jbig2_parse_text_region(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte *segment_data)