shithub: jbig2

Download patch

ref: d85ffd487d624754ce5784fb970e939bc8b9dd5c
parent: f94a083d0d5f35721a1fbdd61f2b908ae41b9189
author: giles <giles@ded80894-8fb9-0310-811b-c03f3676ab4d>
date: Thu Jul 4 12:33:44 EDT 2002

API renames. Main loop is now jbig_data_in(data); image=jbig2_page_out();


git-svn-id: http://svn.ghostscript.com/jbig2dec/trunk@109 ded80894-8fb9-0310-811b-c03f3676ab4d

--- a/jbig2.c
+++ b/jbig2.c
@@ -8,7 +8,7 @@
     the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.
         
-    $Id: jbig2.c,v 1.11 2002/07/04 13:34:29 giles Exp $
+    $Id: jbig2.c,v 1.12 2002/07/04 16:33:44 giles Exp $
 */
 
 #include <stdint.h>
@@ -66,7 +66,7 @@
 }
 
 int
-jbig2_error (Jbig2Ctx *ctx, Jbig2Severity severity, int seg_idx,
+jbig2_error (Jbig2Ctx *ctx, Jbig2Severity severity, int segment_number,
 	     const char *fmt, ...)
 {
   char buf[1024];
@@ -79,7 +79,7 @@
   va_end (ap);
   if (n < 0 || n == sizeof(buf))
     strcpy (buf, "jbig2_error: error in generating error string");
-  code = ctx->error_callback (ctx->error_callback_data, buf, severity, seg_idx);
+  code = ctx->error_callback (ctx->error_callback_data, buf, severity, segment_number);
   if (severity == JBIG2_SEVERITY_FATAL)
     code = -1;
   return code;
@@ -144,7 +144,7 @@
 
 
 /**
- * jbig2_write: submit data for decoding
+ * jbig2_data_in: submit data for decoding
  * @ctx: The jbig2dec decoder context
  * @data: a pointer to the data buffer
  * @size: the size of the data buffer in bytes
@@ -155,7 +155,7 @@
  * Return code: 0 on success
  **/
 int
-jbig2_write (Jbig2Ctx *ctx, const unsigned char *data, size_t size)
+jbig2_data_in (Jbig2Ctx *ctx, const unsigned char *data, size_t size)
 {
   const size_t initial_buf_size = 1024;
 
@@ -274,7 +274,7 @@
 	  segment = ctx->segments[ctx->segment_index];
 	  if (segment->data_length > ctx->buf_wr_ix - ctx->buf_rd_ix)
 	    return 0;
-	  code = jbig2_write_segment(ctx, segment, ctx->buf + ctx->buf_rd_ix);
+	  code = jbig2_parse_segment(ctx, segment, ctx->buf + ctx->buf_rd_ix);
 	  ctx->buf_rd_ix += segment->data_length;
 //	  jbig2_free_segment(ctx, segment);
 //	  ctx->segments[ctx->segment_index] = NULL;
--- a/jbig2.h
+++ b/jbig2.h
@@ -8,7 +8,7 @@
     the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.
         
-    $Id: jbig2.h,v 1.11 2002/07/03 19:43:21 giles Exp $
+    $Id: jbig2.h,v 1.12 2002/07/04 16:33:44 giles Exp $
 */
 
 #ifdef __cplusplus
@@ -81,12 +81,12 @@
 void jbig2_global_ctx_free (Jbig2GlobalCtx *global_ctx);
 
 /* submit data to the decoder */
-int jbig2_write (Jbig2Ctx *ctx, const unsigned char *data, size_t size);
+int jbig2_data_in (Jbig2Ctx *ctx, const unsigned char *data, size_t size);
 
 /* get the next available decoded page image */
-Jbig2Image *jbig2_get_page(Jbig2Ctx *ctx);
+Jbig2Image *jbig2_page_out (Jbig2Ctx *ctx);
 /* mark a returned page image as read */
-int jbig2_release_page(Jbig2Ctx *ctx, Jbig2Image *image);
+int jbig2_release_page (Jbig2Ctx *ctx, Jbig2Image *image);
 
 /* segment header routines */
 
@@ -94,15 +94,15 @@
   uint32_t number;
   uint8_t flags;
   uint32_t page_association;
-  int data_length;
+  size_t data_length;
   int referred_to_segment_count;
-  int32_t *referred_to_segments;
+  uint32_t *referred_to_segments;
   void *result;
 };
 
 Jbig2Segment *jbig2_parse_segment_header (Jbig2Ctx *ctx, uint8_t *buf, size_t buf_size,
 			    size_t *p_header_size);
-int jbig2_write_segment (Jbig2Ctx *ctx, Jbig2Segment *segment,
+int jbig2_parse_segment (Jbig2Ctx *ctx, Jbig2Segment *segment,
 			 const uint8_t *segment_data);
 void jbig2_free_segment (Jbig2Ctx *ctx, Jbig2Segment *segment);
 
--- a/jbig2_page.c
+++ b/jbig2_page.c
@@ -8,7 +8,7 @@
     the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.
 
-    $Id: jbig2_page.c,v 1.7 2002/07/04 13:34:29 giles Exp $
+    $Id: jbig2_page.c,v 1.8 2002/07/04 16:33:44 giles Exp $
 */
 
 #include <stdlib.h>
@@ -190,7 +190,7 @@
  * return an image structure pointer, even though the function
  * name refers to a page; the page structure is private.
  **/
-Jbig2Image *jbig2_get_page(Jbig2Ctx *ctx)
+Jbig2Image *jbig2_page_out(Jbig2Ctx *ctx)
 {
     int index;
 
--- a/jbig2_segment.c
+++ b/jbig2_segment.c
@@ -8,7 +8,7 @@
     the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.
 
-    $Id: jbig2_segment.c,v 1.10 2002/07/04 13:34:29 giles Exp $
+    $Id: jbig2_segment.c,v 1.11 2002/07/04 16:33:44 giles Exp $
 */
 
 #include <stdlib.h> /* size_t */
@@ -127,7 +127,7 @@
   info->flags = segment_data[16];
 }
 
-int jbig2_write_segment (Jbig2Ctx *ctx, Jbig2Segment *segment,
+int jbig2_parse_segment (Jbig2Ctx *ctx, Jbig2Segment *segment,
 			 const uint8_t *segment_data)
 {
   jbig2_error(ctx, JBIG2_SEVERITY_INFO, segment->number,
--- a/jbig2dec.c
+++ b/jbig2dec.c
@@ -8,7 +8,7 @@
     the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.
 
-    $Id: jbig2dec.c,v 1.25 2002/06/22 10:08:43 giles Exp $
+    $Id: jbig2dec.c,v 1.26 2002/07/04 16:33:44 giles Exp $
 */
 
 #include <stdio.h>
@@ -228,7 +228,7 @@
       int n_bytes = fread(buf, 1, sizeof(buf), f);
       if (n_bytes <= 0)
 	break;
-      jbig2_write(ctx, buf, n_bytes);
+      jbig2_data_in(ctx, buf, n_bytes);
     }
   fclose(f);
 
@@ -243,7 +243,7 @@
 	  int n_bytes = fread(buf, 1, sizeof(buf), f_page);
 	  if (n_bytes <= 0)
 	    break;
-	  jbig2_write(ctx, buf, n_bytes);
+	  jbig2_data_in(ctx, buf, n_bytes);
 	}
       fclose(f_page);
       jbig2_global_ctx_free(global_ctx);
@@ -253,7 +253,7 @@
   {
     Jbig2Image *image;
     
-    while ((image = jbig2_get_page(ctx)) != NULL) {
+    while ((image = jbig2_page_out(ctx)) != NULL) {
       write_page_image(&params, image);
       jbig2_release_page(ctx, image);
     }