[gs-cvs] rev 8429 - in trunk/gs: jbig2dec src

ken at ghostscript.com ken at ghostscript.com
Mon Dec 10 01:45:04 PST 2007


Author: ken
Date: 2007-12-10 01:45:03 -0800 (Mon, 10 Dec 2007)
New Revision: 8429

Added:
   trunk/gs/jbig2dec/jbig2_text.h
Modified:
   trunk/gs/jbig2dec/jbig2_symbol_dict.c
   trunk/gs/jbig2dec/jbig2_text.c
   trunk/gs/src/jbig2.mak
Log:
Fix (jbig2dec): Missing support for decoding multiple symbols
from a symbol dictionary, when using refinement/aggregation.

Details:
Bug #688945 "jbig2dec FATAL ERROR decoding image: aggregate
coding with REFAGGNINST=2 (segment 0x03)".

Added missing support. When decoding a symbol dictionary, using
refinement/aggregation, and decoding multiple symbols, we need
to use text region decoding (single symbols use refinement
region decoding, already implemented).

This required making the text region decoding procedure available
to the symbol dictionary decoding routine, and correctly
initialising the parameters.

(jbig2_text.h) New include file. The 'Jbig2TextRegionParams'
structure and Jbig2RefCorner enum have been moved here from
jbig2_text.c, and a prototype for 'jbig2_decode_text_region'
created.

Added pointers for the adaptive arithmetic decoder tables to the
Jbig2TextRegionParams structure, as these tables must now be passed
to the decoder routine (see below) rather than initialised in it.

(jbig2_text.c) Modified the 'jbig2_decode_text_region' routine to
take the arithmetic decoder state or data stream (for Huffman
decoding) as a parameter. When being called from the symbol
dictionary decoder we must use the current decoder state; removed
the initialisation of the decoder state, this is passed as a
parameter Removed the initialisation of the adaptive arithmetic
decoder tables, these are now passed as part of the
Jbig2TextRegionParams structure.

Modified 'jbig2_parse_text_region' to create and initialise the
arithmetic decoder state (or data stream for Huffman). If
using adaptive arithmetic encoding, create and initialise the
tables.Required now that these are parameters to the text
region decoder.

(jbig2_symbol_dict.c) 'jbig2_decode_symbol_dict', when we
encounter refinement/aggregation with REFAGGNINST > 1, instead of
flagging an error create a Jbig2TextRegionParams structure (if
not already present), initialise the arithmetic decoder tables, and
call the text region decoder to create the bitmap. If we already
have a Jbig2TextRegionParams structure (because we have already
decoded a symbol this way) just use it as the argument to the
text region decoder.

EXPECTED DIFFERENCES:
None.


Modified: trunk/gs/jbig2dec/jbig2_symbol_dict.c
===================================================================
--- trunk/gs/jbig2dec/jbig2_symbol_dict.c	2007-12-09 06:33:00 UTC (rev 8428)
+++ trunk/gs/jbig2dec/jbig2_symbol_dict.c	2007-12-10 09:45:03 UTC (rev 8429)
@@ -35,6 +35,7 @@
 #include "jbig2_generic.h"
 #include "jbig2_mmr.h"
 #include "jbig2_symbol_dict.h"
+#include "jbig2_text.h"
 
 #if defined(OUTPUT_PBM) || defined(DUMP_SYMDICT)
 #include <stdio.h>
@@ -237,6 +238,8 @@
   Jbig2ArithIntCtx *IARDY = NULL;
   int code = 0;
 
+  Jbig2TextRegionParams *tparams = NULL;
+
   /* 6.5.5 (3) */
   HCHEIGHT = 0;
   NSYMSDECODED = 0;
@@ -391,10 +394,106 @@
 		    "aggregate symbol coding (%d instances)", REFAGGNINST);
 
 		  if (REFAGGNINST > 1) {
-		      code = jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number,
-			"aggregate coding with REFAGGNINST=%d", REFAGGNINST);
-		      return NULL;
-		      /* todo: multiple symbols are like a text region */
+		      Jbig2Image *image;
+		      Jbig2SymbolDict **dicts;
+		      int n_dicts = 1, i;
+
+		      dicts = jbig2_alloc(ctx->allocator, sizeof(Jbig2SymbolDict *) * n_dicts);
+		      if (dicts == NULL) {
+			  code = jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number,
+			   "Out of memory allocating dictionary array");
+		          return NULL;
+		      }
+		      dicts[0] = jbig2_sd_new(ctx, params->SDNUMINSYMS + params->SDNUMNEWSYMS);
+		      if (dicts[0] == NULL) {
+			  code = jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number,
+			   "Out of memory allocating symbol dictionary");
+		          jbig2_free(ctx->allocator, dicts);
+		          return NULL;
+		      }
+		      dicts[0]->n_symbols = params->SDNUMINSYMS + params->SDNUMNEWSYMS;
+		      for (i=0;i < params->SDNUMINSYMS;i++)
+		      {
+			  dicts[0]->glyphs[i] = jbig2_image_clone(ctx, params->SDINSYMS->glyphs[i]);
+		      }
+		      for (i=0;i < (int)NSYMSDECODED;i++)
+		      {
+			  dicts[0]->glyphs[params->SDNUMINSYMS + i] = jbig2_image_clone(ctx, SDNEWSYMS->glyphs[i]);
+		      }
+
+      		      image = jbig2_image_new(ctx, SYMWIDTH, HCHEIGHT);
+		      if (image == NULL) {
+			  code = jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number,
+			   "Out of memory creating symbol image");
+			  jbig2_sd_release(ctx, dicts[0]);
+		          jbig2_free(ctx->allocator, dicts);
+		          return NULL;
+		      }
+
+		      if (tparams == NULL) {
+			  /* First time through, we need to initialise the */
+			  /* various tables for Huffman or adaptive encoding */
+			  /* as well as the text region parameters structure */
+		          tparams = jbig2_alloc(ctx->allocator, sizeof(Jbig2TextRegionParams));
+			  if (tparams == NULL) {
+			      code = jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number,
+			      "Out of memory creating text region params");
+			      jbig2_free(ctx->allocator, image);
+			      jbig2_sd_release(ctx, dicts[0]);
+			      jbig2_free(ctx->allocator, dicts);
+			      return NULL;
+			  }
+    		          if (!params->SDHUFF) {
+			      /* Values from Table 17, section 6.5.8.2 (2) */
+			      tparams->IADT = jbig2_arith_int_ctx_new(ctx);
+			      tparams->IAFS = jbig2_arith_int_ctx_new(ctx);
+			      tparams->IADS = jbig2_arith_int_ctx_new(ctx);
+			      tparams->IAIT = jbig2_arith_int_ctx_new(ctx);
+			      /* Table 31 */
+			      for (SBSYMCODELEN = 0; (1 << SBSYMCODELEN) < 
+				  (int)(params->SDNUMINSYMS + params->SDNUMNEWSYMS); SBSYMCODELEN++);
+			      tparams->IAID = jbig2_arith_iaid_ctx_new(ctx, SBSYMCODELEN);
+			      tparams->IARI = jbig2_arith_int_ctx_new(ctx);
+			      tparams->IARDW = jbig2_arith_int_ctx_new(ctx);
+			      tparams->IARDH = jbig2_arith_int_ctx_new(ctx);
+			      tparams->IARDX = jbig2_arith_int_ctx_new(ctx);
+			      tparams->IARDY = jbig2_arith_int_ctx_new(ctx);
+			  } else {
+			      tparams->SBHUFFFS = jbig2_build_huffman_table(ctx,
+				&jbig2_huffman_params_F);   /* Table B.6 */
+			      tparams->SBHUFFDS = jbig2_build_huffman_table(ctx,
+				&jbig2_huffman_params_H);  /* Table B.8 */
+			      tparams->SBHUFFDT = jbig2_build_huffman_table(ctx,
+				&jbig2_huffman_params_K);  /* Table B.11 */
+			      tparams->SBHUFFRDW = jbig2_build_huffman_table(ctx,
+				&jbig2_huffman_params_O); /* Table B.15 */
+			      tparams->SBHUFFRDH = jbig2_build_huffman_table(ctx,
+				&jbig2_huffman_params_O); /* Table B.15 */
+			      tparams->SBHUFFRDX = jbig2_build_huffman_table(ctx,
+				&jbig2_huffman_params_O); /* Table B.15 */
+			      tparams->SBHUFFRDY = jbig2_build_huffman_table(ctx,
+				&jbig2_huffman_params_O); /* Table B.15 */
+			  }
+			  tparams->SBHUFF = params->SDHUFF;
+			  tparams->SBREFINE = 1;
+			  tparams->SBSTRIPS = 1;
+			  tparams->SBDEFPIXEL = 0;
+			  tparams->SBCOMBOP = JBIG2_COMPOSE_OR;
+			  tparams->TRANSPOSED = 0;
+			  tparams->REFCORNER = JBIG2_CORNER_TOPLEFT;
+			  tparams->SBDSOFFSET = 0;
+			  tparams->SBRTEMPLATE = params->SDRTEMPLATE;
+		      }
+		      tparams->SBNUMINSTANCES = REFAGGNINST;
+
+
+		      /* multiple symbols are handled as a text region */
+		      jbig2_decode_text_region(ctx, segment, tparams, (const Jbig2SymbolDict * const *)dicts, 
+			  n_dicts, image, data, size, GR_stats, as, (Jbig2WordStream *)NULL);
+
+		      SDNEWSYMS->glyphs[NSYMSDECODED] = image;
+		      jbig2_sd_release(ctx, dicts[0]);
+		      jbig2_free(ctx->allocator, dicts);
 		  } else {
 		      /* 6.5.8.2.2 */
 		      /* bool SBHUFF = params->SDHUFF; */
@@ -553,6 +652,22 @@
 
   } /* end of symbol decode loop */
 
+  if (!params->SDHUFF && tparams != NULL)
+  {
+      jbig2_arith_int_ctx_free(ctx, tparams->IADT);
+      jbig2_arith_int_ctx_free(ctx, tparams->IAFS);
+      jbig2_arith_int_ctx_free(ctx, tparams->IADS);
+      jbig2_arith_int_ctx_free(ctx, tparams->IAIT);
+      jbig2_arith_iaid_ctx_free(ctx, tparams->IAID);
+      jbig2_arith_int_ctx_free(ctx, tparams->IARI);
+      jbig2_arith_int_ctx_free(ctx, tparams->IARDW);
+      jbig2_arith_int_ctx_free(ctx, tparams->IARDH);
+      jbig2_arith_int_ctx_free(ctx, tparams->IARDX);
+      jbig2_arith_int_ctx_free(ctx, tparams->IARDY);
+      jbig2_free(ctx->allocator, tparams);
+      tparams = NULL;
+  }
+
   jbig2_free(ctx->allocator, GB_stats);
   
   /* 6.5.10 */

Modified: trunk/gs/jbig2dec/jbig2_text.c
===================================================================
--- trunk/gs/jbig2dec/jbig2_text.c	2007-12-09 06:33:00 UTC (rev 8428)
+++ trunk/gs/jbig2dec/jbig2_text.c	2007-12-10 09:45:03 UTC (rev 8429)
@@ -32,44 +32,9 @@
 #include "jbig2_huffman.h"
 #include "jbig2_generic.h"
 #include "jbig2_symbol_dict.h"
+#include "jbig2_text.h"
 
-typedef enum {
-    JBIG2_CORNER_BOTTOMLEFT = 0,
-    JBIG2_CORNER_TOPLEFT = 1,
-    JBIG2_CORNER_BOTTOMRIGHT = 2,
-    JBIG2_CORNER_TOPRIGHT = 3
-} Jbig2RefCorner;
 
-typedef struct {
-    bool SBHUFF;
-    bool SBREFINE;
-    bool SBDEFPIXEL;
-    Jbig2ComposeOp SBCOMBOP;
-    bool TRANSPOSED;
-    Jbig2RefCorner REFCORNER;
-    int SBDSOFFSET;
-    /* SBW */
-    /* SBH */
-    uint32_t SBNUMINSTANCES;
-    int LOGSBSTRIPS;
-    int SBSTRIPS;
-    /* SBNUMSYMS */
-    /* SBSYMCODES */
-    /* SBSYMCODELEN */
-    /* SBSYMS */
-    Jbig2HuffmanTable *SBHUFFFS;
-    Jbig2HuffmanTable *SBHUFFDS;
-    Jbig2HuffmanTable *SBHUFFDT;
-    Jbig2HuffmanTable *SBHUFFRDW;
-    Jbig2HuffmanTable *SBHUFFRDH;
-    Jbig2HuffmanTable *SBHUFFRDX;
-    Jbig2HuffmanTable *SBHUFFRDY;
-    Jbig2HuffmanTable *SBHUFFRSIZE;
-    bool SBRTEMPLATE;
-    int8_t sbrat[4];
-} Jbig2TextRegionParams;
-
-
 /**
  * jbig2_decode_text_region: decode a text region segment
  *
@@ -87,13 +52,13 @@
  *
  * returns: 0 on success
  **/
-static int
+int
 jbig2_decode_text_region(Jbig2Ctx *ctx, Jbig2Segment *segment,
                              const Jbig2TextRegionParams *params,
                              const Jbig2SymbolDict * const *dicts, const int n_dicts,
                              Jbig2Image *image,
                              const byte *data, const size_t size,
-			     Jbig2ArithCx *GR_stats)
+			     Jbig2ArithCx *GR_stats, Jbig2ArithState *as, Jbig2WordStream *ws)
 {
     /* relevent bits of 6.4.4 */
     uint32_t NINSTANCES;
@@ -110,20 +75,8 @@
     bool first_symbol;
     uint32_t index, SBNUMSYMS;
     Jbig2Image *IB;
-    Jbig2WordStream *ws = NULL;
     Jbig2HuffmanState *hs = NULL;
     Jbig2HuffmanTable *SBSYMCODES = NULL;
-    Jbig2ArithState *as = NULL;
-    Jbig2ArithIntCtx *IADT = NULL;
-    Jbig2ArithIntCtx *IAFS = NULL;
-    Jbig2ArithIntCtx *IADS = NULL;
-    Jbig2ArithIntCtx *IAIT = NULL;
-    Jbig2ArithIaidCtx *IAID = NULL;
-    Jbig2ArithIntCtx *IARI = NULL;
-    Jbig2ArithIntCtx *IARDW = NULL;
-    Jbig2ArithIntCtx *IARDH = NULL;
-    Jbig2ArithIntCtx *IARDX = NULL;
-    Jbig2ArithIntCtx *IARDY = NULL;
     int code = 0;
     int RI;
     
@@ -134,24 +87,7 @@
     jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number,
         "symbol list contains %d glyphs in %d dictionaries", SBNUMSYMS, n_dicts);
     
-    ws = jbig2_word_stream_buf_new(ctx, data, size);
-    if (!params->SBHUFF) {
-	int SBSYMCODELEN;
-
-        as = jbig2_arith_new(ctx, ws);
-        IADT = jbig2_arith_int_ctx_new(ctx);
-        IAFS = jbig2_arith_int_ctx_new(ctx);
-        IADS = jbig2_arith_int_ctx_new(ctx);
-        IAIT = jbig2_arith_int_ctx_new(ctx);
-	/* Table 31 */
-	for (SBSYMCODELEN = 0; (1 << SBSYMCODELEN) < SBNUMSYMS; SBSYMCODELEN++);
-        IAID = jbig2_arith_iaid_ctx_new(ctx, SBSYMCODELEN);
-	IARI = jbig2_arith_int_ctx_new(ctx);
-	IARDW = jbig2_arith_int_ctx_new(ctx);
-	IARDH = jbig2_arith_int_ctx_new(ctx);
-	IARDX = jbig2_arith_int_ctx_new(ctx);
-	IARDY = jbig2_arith_int_ctx_new(ctx);
-    } else {
+    if (params->SBHUFF) {
 	Jbig2HuffmanTable *runcodes;
 	Jbig2HuffmanParams runcodeparams;
 	Jbig2HuffmanLine runcodelengths[35];
@@ -263,7 +199,7 @@
     if (params->SBHUFF) {
         STRIPT = jbig2_huffman_get(hs, params->SBHUFFDT, &code);
     } else {
-        code = jbig2_arith_int_decode(IADT, as, &STRIPT);
+        code = jbig2_arith_int_decode(params->IADT, as, &STRIPT);
     }
 
     /* 6.4.5 (2) */
@@ -277,7 +213,7 @@
         if (params->SBHUFF) {
             DT = jbig2_huffman_get(hs, params->SBHUFFDT, &code);
         } else {
-            code = jbig2_arith_int_decode(IADT, as, &DT);
+            code = jbig2_arith_int_decode(params->IADT, as, &DT);
         }
         DT *= params->SBSTRIPS;
         STRIPT += DT;
@@ -291,7 +227,7 @@
 		if (params->SBHUFF) {
 		    DFS = jbig2_huffman_get(hs, params->SBHUFFFS, &code);
 		} else {
-		    code = jbig2_arith_int_decode(IAFS, as, &DFS);
+		    code = jbig2_arith_int_decode(params->IAFS, as, &DFS);
 		}
 		FIRSTS += DFS;
 		CURS = FIRSTS;
@@ -302,7 +238,7 @@
 		if (params->SBHUFF) {
 		    IDS = jbig2_huffman_get(hs, params->SBHUFFDS, &code);
 		} else {
-		    code = jbig2_arith_int_decode(IADS, as, &IDS);
+		    code = jbig2_arith_int_decode(params->IADS, as, &IDS);
 		}
 		if (code) {
 		    break;
@@ -316,7 +252,7 @@
 	    } else if (params->SBHUFF) {
 		CURT = jbig2_huffman_get_bits(hs, params->LOGSBSTRIPS);
 	    } else {
-		code = jbig2_arith_int_decode(IAIT, as, &CURT);
+		code = jbig2_arith_int_decode(params->IAIT, as, &CURT);
 	    }
 	    T = STRIPT + CURT;
 
@@ -324,7 +260,7 @@
 	    if (params->SBHUFF) {
 		ID = jbig2_huffman_get(hs, SBSYMCODES, &code);
 	    } else {
-		code = jbig2_arith_iaid_decode(IAID, as, (int *)&ID);
+		code = jbig2_arith_iaid_decode(params->IAID, as, (int *)&ID);
 	    }
 	    if (ID >= SBNUMSYMS) {
 		return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number,
@@ -344,7 +280,7 @@
 	      if (params->SBHUFF) {
 		RI = jbig2_huffman_get_bits(hs, 1);
 	      } else {
-		code = jbig2_arith_int_decode(IARI, as, &RI);
+		code = jbig2_arith_int_decode(params->IARI, as, &RI);
 	      }
 	    } else {
 		RI = 0;
@@ -358,10 +294,10 @@
 
 		/* 6.4.11 (1, 2, 3, 4) */
 		if (!params->SBHUFF) {
-		  code = jbig2_arith_int_decode(IARDW, as, &RDW);
-		  code = jbig2_arith_int_decode(IARDH, as, &RDH);
-		  code = jbig2_arith_int_decode(IARDX, as, &RDX);
-		  code = jbig2_arith_int_decode(IARDY, as, &RDY);
+		  code = jbig2_arith_int_decode(params->IARDW, as, &RDW);
+		  code = jbig2_arith_int_decode(params->IARDH, as, &RDH);
+		  code = jbig2_arith_int_decode(params->IARDX, as, &RDX);
+		  code = jbig2_arith_int_decode(params->IARDY, as, &RDY);
 		} else {
 		  RDW = jbig2_huffman_get(hs, params->SBHUFFRDW, &code);
 		  RDH = jbig2_huffman_get(hs, params->SBHUFFRDH, &code);
@@ -450,20 +386,7 @@
 
     if (params->SBHUFF) {
       jbig2_release_huffman_table(ctx, SBSYMCODES);
-    } else {
-	jbig2_arith_int_ctx_free(ctx, IADT);
-	jbig2_arith_int_ctx_free(ctx, IAFS);
-	jbig2_arith_int_ctx_free(ctx, IADS);
-	jbig2_arith_int_ctx_free(ctx, IAIT);
-	jbig2_arith_iaid_ctx_free(ctx, IAID);
-	jbig2_arith_int_ctx_free(ctx, IARI);
-	jbig2_arith_int_ctx_free(ctx, IARDW);
-	jbig2_arith_int_ctx_free(ctx, IARDH);
-	jbig2_arith_int_ctx_free(ctx, IARDX);
-	jbig2_arith_int_ctx_free(ctx, IARDY);
-	jbig2_free(ctx->allocator, as);
-	jbig2_word_stream_buf_free(ctx, ws);
-    }
+    } 
     
     return 0;
 }
@@ -484,6 +407,8 @@
     uint16_t huffman_flags = 0;
     Jbig2ArithCx *GR_stats = NULL;
     int code = 0;
+    Jbig2WordStream *ws = NULL; 
+    Jbig2ArithState *as = NULL; 
     
     /* 7.4.1 */
     if (segment->data_length < 17)
@@ -748,10 +673,35 @@
 
     image = jbig2_image_new(ctx, region_info.width, region_info.height);
 
+    ws = jbig2_word_stream_buf_new(ctx, segment_data + offset, segment->data_length - offset);
+    if (!params.SBHUFF) {
+	int SBSYMCODELEN, index;
+        int SBNUMSYMS = 0;
+	for (index = 0; index < n_dicts; index++) {
+	    SBNUMSYMS += dicts[index]->n_symbols;
+	}
+
+	as = jbig2_arith_new(ctx, ws);
+	ws = 0;
+
+        params.IADT = jbig2_arith_int_ctx_new(ctx);
+        params.IAFS = jbig2_arith_int_ctx_new(ctx);
+        params.IADS = jbig2_arith_int_ctx_new(ctx);
+        params.IAIT = jbig2_arith_int_ctx_new(ctx);
+	/* Table 31 */
+	for (SBSYMCODELEN = 0; (1 << SBSYMCODELEN) < SBNUMSYMS; SBSYMCODELEN++);
+        params.IAID = jbig2_arith_iaid_ctx_new(ctx, SBSYMCODELEN);
+	params.IARI = jbig2_arith_int_ctx_new(ctx);
+	params.IARDW = jbig2_arith_int_ctx_new(ctx);
+	params.IARDH = jbig2_arith_int_ctx_new(ctx);
+	params.IARDX = jbig2_arith_int_ctx_new(ctx);
+	params.IARDY = jbig2_arith_int_ctx_new(ctx);
+    }
+
     code = jbig2_decode_text_region(ctx, segment, &params,
                 (const Jbig2SymbolDict * const *)dicts, n_dicts, image,
                 segment_data + offset, segment->data_length - offset,
-		GR_stats);
+		GR_stats, as, ws);
 
     if (!params.SBHUFF && params.SBREFINE) {
 	jbig2_free(ctx->allocator, GR_stats);
@@ -767,6 +717,20 @@
       jbig2_release_huffman_table(ctx, params.SBHUFFRDH);
       jbig2_release_huffman_table(ctx, params.SBHUFFRSIZE);
     }
+    else {
+	jbig2_arith_int_ctx_free(ctx, params.IADT);
+	jbig2_arith_int_ctx_free(ctx, params.IAFS);
+	jbig2_arith_int_ctx_free(ctx, params.IADS);
+	jbig2_arith_int_ctx_free(ctx, params.IAIT);
+	jbig2_arith_iaid_ctx_free(ctx, params.IAID);
+	jbig2_arith_int_ctx_free(ctx, params.IARI);
+	jbig2_arith_int_ctx_free(ctx, params.IARDW);
+	jbig2_arith_int_ctx_free(ctx, params.IARDH);
+	jbig2_arith_int_ctx_free(ctx, params.IARDX);
+	jbig2_arith_int_ctx_free(ctx, params.IARDY);
+	jbig2_free(ctx->allocator, as);
+	jbig2_word_stream_buf_free(ctx, ws);
+    }
 
     jbig2_free(ctx->allocator, dicts);
 

Added: trunk/gs/jbig2dec/jbig2_text.h
===================================================================
--- trunk/gs/jbig2dec/jbig2_text.h	2007-12-09 06:33:00 UTC (rev 8428)
+++ trunk/gs/jbig2dec/jbig2_text.h	2007-12-10 09:45:03 UTC (rev 8429)
@@ -0,0 +1,76 @@
+/*
+    jbig2dec
+    
+    Copyright (C) 2002-2004 Artifex Software, Inc.
+    
+    This software is distributed under license and may not
+    be copied, modified or distributed except as expressly
+    authorized under the terms of the license contained in
+    the file LICENSE in this distribution.
+                                                                                
+    For information on commercial licensing, go to
+    http://www.artifex.com/licensing/ or contact
+    Artifex Software, Inc.,  101 Lucas Valley Road #110,
+    San Rafael, CA  94903, U.S.A., +1(415)492-9861.
+        
+    $Id: jbig2_text.h 8022 2007-06-05 22:23:38Z giles $
+*/
+
+/**
+ * Headers for Text region handling
+ **/
+
+typedef enum {
+    JBIG2_CORNER_BOTTOMLEFT = 0,
+    JBIG2_CORNER_TOPLEFT = 1,
+    JBIG2_CORNER_BOTTOMRIGHT = 2,
+    JBIG2_CORNER_TOPRIGHT = 3
+} Jbig2RefCorner;
+
+typedef struct {
+    bool SBHUFF;
+    bool SBREFINE;
+    bool SBDEFPIXEL;
+    Jbig2ComposeOp SBCOMBOP;
+    bool TRANSPOSED;
+    Jbig2RefCorner REFCORNER;
+    int SBDSOFFSET;
+    /* int SBW; */
+    /* int SBH; */
+    uint32_t SBNUMINSTANCES;
+    int LOGSBSTRIPS;
+    int SBSTRIPS;
+    /* int SBNUMSYMS; */
+    /* SBSYMCODES */
+    /* SBSYMCODELEN */
+    /* SBSYMS */
+    Jbig2HuffmanTable *SBHUFFFS;
+    Jbig2HuffmanTable *SBHUFFDS;
+    Jbig2HuffmanTable *SBHUFFDT;
+    Jbig2HuffmanTable *SBHUFFRDW;
+    Jbig2HuffmanTable *SBHUFFRDH;
+    Jbig2HuffmanTable *SBHUFFRDX;
+    Jbig2HuffmanTable *SBHUFFRDY;
+    Jbig2HuffmanTable *SBHUFFRSIZE;
+    Jbig2ArithIntCtx *IADT;
+    Jbig2ArithIntCtx *IAFS;
+    Jbig2ArithIntCtx *IADS;
+    Jbig2ArithIntCtx *IAIT;
+    Jbig2ArithIaidCtx *IAID;
+    Jbig2ArithIntCtx *IARI;
+    Jbig2ArithIntCtx *IARDW;
+    Jbig2ArithIntCtx *IARDH;
+    Jbig2ArithIntCtx *IARDX;
+    Jbig2ArithIntCtx *IARDY;
+    bool SBRTEMPLATE;
+    int8_t sbrat[4];
+} Jbig2TextRegionParams;
+
+int
+jbig2_decode_text_region(Jbig2Ctx *ctx, Jbig2Segment *segment,
+                             const Jbig2TextRegionParams *params,
+                             const Jbig2SymbolDict * const *dicts, const int n_dicts,
+                             Jbig2Image *image,
+                             const byte *data, const size_t size,
+			     Jbig2ArithCx *GR_stats,
+			     Jbig2ArithState *as, Jbig2WordStream *ws);

Modified: trunk/gs/src/jbig2.mak
===================================================================
--- trunk/gs/src/jbig2.mak	2007-12-09 06:33:00 UTC (rev 8428)
+++ trunk/gs/src/jbig2.mak	2007-12-10 09:45:03 UTC (rev 8429)
@@ -70,6 +70,7 @@
         $(JBIG2SRC)jbig2_mmr.h \
         $(JBIG2SRC)jbig2_priv.h \
         $(JBIG2SRC)jbig2_symbol_dict.h \
+        $(JBIG2SRC)jbig2_text.h \
         $(JBIG2SRC)jbig2_metadata.h \
         $(JBIG2SRC)config_win32.h
 



More information about the gs-cvs mailing list