shithub: jbig2

Download patch

ref: fe50e6202700ad508c7f91e04330a962970ead5f
parent: d2849e9e31de7cb3a921f9c69a9a4ecfd06feb02
author: Ralph Giles <giles@ghostscript.com>
date: Wed Oct 28 09:45:00 EDT 2009

Remove _parse_ from the segment decode routines.

Our use wasn't consistent here; some decoders were jbig2_foo() and
others were jbig2_parse_bar(). Prefer the shorter names and keep
_parse_ only for the header and dispatch routines which don't themselves
decode the segment bodies.

--- a/jbig2_metadata.c
+++ b/jbig2_metadata.c
@@ -104,7 +104,7 @@
 
 
 /* decode an ascii comment segment 7.4.15.1 */
-int jbig2_parse_comment_ascii(Jbig2Ctx *ctx, Jbig2Segment *segment,
+int jbig2_comment_ascii(Jbig2Ctx *ctx, Jbig2Segment *segment,
                                const uint8_t *segment_data)
 {
     char *s = (char *)(segment_data + 4);
@@ -147,7 +147,7 @@
 }
 
 /* decode a UCS-16 comment segement 7.4.15.2 */
-int jbig2_parse_comment_unicode(Jbig2Ctx *ctx, Jbig2Segment *segment,
+int jbig2_comment_unicode(Jbig2Ctx *ctx, Jbig2Segment *segment,
                                const uint8_t *segment_data)
 {
     return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number,
--- a/jbig2_metadata.h
+++ b/jbig2_metadata.h
@@ -40,9 +40,9 @@
 };
 
 /* these bits can go to jbig2_priv.h */
-int jbig2_parse_comment_ascii(Jbig2Ctx *ctx, Jbig2Segment *segment,
+int jbig2_comment_ascii(Jbig2Ctx *ctx, Jbig2Segment *segment,
                                 const uint8_t *segment_data);
-int jbig2_parse_comment_unicode(Jbig2Ctx *ctx, Jbig2Segment *segment,
+int jbig2_comment_unicode(Jbig2Ctx *ctx, Jbig2Segment *segment,
                                const uint8_t *segment_data);
 
 #endif /* _JBIG2_METADATA_H */
--- a/jbig2_page.c
+++ b/jbig2_page.c
@@ -54,14 +54,14 @@
 }
 
 /**
- * jbig2_read_page_info: parse page info segment
+ * jbig2_page_info: parse page info segment
  *
- * parse the page info segment data and fill out a corresponding
- * Jbig2Page struct is returned, including allocating an image
- * buffer for the page (or the first stripe)
+ * Parse the page info segment data and fill out a corresponding
+ * Jbig2Page struct and ready it for subsequent rendered data,
+ * including allocating an image buffer for the page (or the first stripe)
  **/
 int
-jbig2_parse_page_info (Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment_data)
+jbig2_page_info (Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment_data)
 {
     Jbig2Page *page;
 
@@ -160,10 +160,10 @@
 }
 
 /**
- * jbig2_parse_end_of_stripe: parse an end of stripe segment
+ * jbig2_end_of_stripe: parse and implement an end of stripe segment
  **/
 int
-jbig2_parse_end_of_stripe(Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment_data)
+jbig2_end_of_stripe(Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment_data)
 {
     Jbig2Page page = ctx->pages[ctx->current_page];
     int end_row;
@@ -219,10 +219,10 @@
 }
 
 /**
- * jbig2_parse_end_of_page: parse an end of page segment
+ * jbig2_end_of_page: parse and implement an end of page segment
  **/
 int
-jbig2_parse_end_of_page(Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment_data)
+jbig2_end_of_page(Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment_data)
 {
     uint32_t page_number = ctx->pages[ctx->current_page].number;
 
--- a/jbig2_priv.h
+++ b/jbig2_priv.h
@@ -117,10 +117,10 @@
     Jbig2Image *image;
 };
 
-int jbig2_parse_page_info (Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment_data);
-int jbig2_parse_end_of_stripe(Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment_data);
-int jbig2_parse_end_of_page(Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment_data);
-int jbig2_parse_extension_segment(Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment_data);
+int jbig2_page_info (Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment_data);
+int jbig2_end_of_stripe(Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment_data);
+int jbig2_end_of_page(Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment_data);
+int jbig2_extension_segment(Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment_data);
 
 typedef enum {
     JBIG2_COMPOSE_OR = 0,
@@ -145,7 +145,7 @@
 } Jbig2RegionSegmentInfo;
 
 void jbig2_get_region_segment_info(Jbig2RegionSegmentInfo *info, const uint8_t *segment_data);
-int jbig2_parse_text_region(Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment_data);
+int jbig2_text_region(Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment_data);
 
 /* 7.4 */
 int jbig2_immediate_generic_region(Jbig2Ctx *ctx, Jbig2Segment *segment,
--- a/jbig2_segment.c
+++ b/jbig2_segment.c
@@ -207,8 +207,8 @@
     }
 
     switch (type) {
-        case 0x20000000: return jbig2_parse_comment_ascii(ctx, segment, segment_data);
-        case 0x20000002: return jbig2_parse_comment_unicode(ctx, segment, segment_data);
+        case 0x20000000: return jbig2_comment_ascii(ctx, segment, segment_data);
+        case 0x20000002: return jbig2_comment_unicode(ctx, segment, segment_data);
         default:
             if (necessary) {
                 return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number,
@@ -237,7 +237,7 @@
     case 4: /* intermediate text region */
     case 6: /* immediate text region */
     case 7: /* immediate lossless text region */
-      return jbig2_parse_text_region(ctx, segment, segment_data);
+      return jbig2_text_region(ctx, segment, segment_data);
 #ifdef JBIG2_HALFTONE
     case 16:
       return jbig2_pattern_dictionary(ctx, segment, segment_data);
@@ -270,11 +270,11 @@
     case 43: /* immediate lossless generic refinement region */
       return jbig2_refinement_region(ctx, segment, segment_data);
     case 48:
-      return jbig2_parse_page_info(ctx, segment, segment_data);
+      return jbig2_page_info(ctx, segment, segment_data);
     case 49:
-      return jbig2_parse_end_of_page(ctx, segment, segment_data);
+      return jbig2_end_of_page(ctx, segment, segment_data);
     case 50:
-      return jbig2_parse_end_of_stripe(ctx, segment, segment_data);
+      return jbig2_end_of_stripe(ctx, segment, segment_data);
     case 51:
       ctx->state = JBIG2_FILE_EOF;
       return jbig2_error(ctx, JBIG2_SEVERITY_INFO, segment->number,
--- a/jbig2_text.c
+++ b/jbig2_text.c
@@ -402,10 +402,10 @@
 }
 
 /**
- * jbig2_parse_text_region: read a text region segment header
+ * jbig2_text_region: read a text region segment header
  **/
 int
-jbig2_parse_text_region(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte *segment_data)
+jbig2_text_region(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte *segment_data)
 {
     int offset = 0;
     Jbig2RegionSegmentInfo region_info;