shithub: jbig2

Download patch

ref: f93bc27cbd73b33ac30122d2ca64aab63ce0e327
parent: ce9531e0941d40cd301d1c1dfd15d6b0a4289cc8
author: giles <giles@ded80894-8fb9-0310-811b-c03f3676ab4d>
date: Wed Mar 5 09:29:35 EST 2003

Make jbig2_find_segment() part of the public api and move it to jbig2_segment.c.


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

--- 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.16 2003/02/05 15:09:59 giles Exp $
+    $Id: jbig2.h,v 1.17 2003/03/05 14:29:35 giles Exp $
 */
 
 #ifdef __cplusplus
@@ -118,6 +118,8 @@
 int jbig2_parse_segment (Jbig2Ctx *ctx, Jbig2Segment *segment,
 			 const uint8_t *segment_data);
 void jbig2_free_segment (Jbig2Ctx *ctx, Jbig2Segment *segment);
+
+Jbig2Segment *jbig2_find_segment(Jbig2Ctx *ctx, uint32_t number);
 
 #endif /* _JBIG2_H */
 
--- 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.21 2003/03/05 02:44:43 giles Exp $
+    $Id: jbig2_segment.c,v 1.22 2003/03/05 14:29:35 giles Exp $
 */
 
 #ifdef HAVE_CONFIG_H
@@ -122,6 +122,27 @@
   }
   /* todo: free result */
   jbig2_free (ctx->allocator, segment);
+}
+
+/* find a segment by number */
+Jbig2Segment *
+jbig2_find_segment(Jbig2Ctx *ctx, uint32_t number)
+{
+    int index, index_max = ctx->segment_index - 1;
+    const Jbig2Ctx *global_ctx = ctx->global_ctx;
+
+    /* FIXME: binary search would be better? */
+    for (index = index_max; index >= 0; index--)
+        if (ctx->segments[index]->number == number)
+            return (ctx->segments[index]);
+        
+    if (global_ctx)
+	for (index = global_ctx->segment_index - 1; index >= 0; index--)
+	    if (global_ctx->segments[index]->number == number)
+		return (global_ctx->segments[index]);
+    
+    /* didn't find a match */
+    return NULL;
 }
 
 void
--- a/jbig2_text.c
+++ b/jbig2_text.c
@@ -8,7 +8,7 @@
     the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.
 
-    $Id: jbig2_text.c,v 1.21 2003/02/07 05:06:46 raph Exp $
+    $Id: jbig2_text.c,v 1.22 2003/03/05 14:29:35 giles Exp $
 */
 
 #ifdef HAVE_CONFIG_H
@@ -274,27 +274,6 @@
     return 0;
 }
 
-/* find a segment by number */
-static Jbig2Segment *
-find_segment(Jbig2Ctx *ctx, uint32_t number)
-{
-    int index, index_max = ctx->segment_index - 1;
-    const Jbig2Ctx *global_ctx = ctx->global_ctx;
-
-    /* FIXME: binary search would be better? */
-    for (index = index_max; index >= 0; index--)
-        if (ctx->segments[index]->number == number)
-            return (ctx->segments[index]);
-        
-    if (global_ctx)
-	for (index = global_ctx->segment_index - 1; index >= 0; index--)
-	    if (global_ctx->segments[index]->number == number)
-		return (global_ctx->segments[index]);
-    
-    /* didn't find a match */
-    return NULL;
-}
-
 /* count the number of dictionary segments referred to by the given segment */
 static int
 count_referred_dicts(Jbig2Ctx *ctx, Jbig2Segment *segment)
@@ -304,7 +283,7 @@
     int n_dicts = 0;
 
     for (index = 0; index < segment->referred_to_segment_count; index++) {
-        rsegment = find_segment(ctx, segment->referred_to_segments[index]);
+        rsegment = jbig2_find_segment(ctx, segment->referred_to_segments[index]);
         if (rsegment && ((rsegment->flags & 63) == 0))
             n_dicts++;
     }
@@ -324,7 +303,7 @@
     
     dicts = jbig2_alloc(ctx->allocator, sizeof(Jbig2SymbolDict *) * n_dicts);
     for (index = 0; index < segment->referred_to_segment_count; index++) {
-        rsegment = find_segment(ctx, segment->referred_to_segments[index]);
+        rsegment = jbig2_find_segment(ctx, segment->referred_to_segments[index]);
         if (rsegment && ((rsegment->flags & 63) == 0))
             dicts[dindex++] = (Jbig2SymbolDict *)rsegment->result;
     }