shithub: jbig2

Download patch

ref: d48429529c894d2402edbf4bd718be316bea12c1
parent: 64763d5e222479931ae569f3db0adf7588147233
author: Sebastian Rasmussen <sebras@gmail.com>
date: Tue May 22 20:04:55 EDT 2018

jbig2dec: Move declarations from jbig2_priv.h to their respective headers.

Due to this some .c-files now need new includes.

--- a/jbig2.c
+++ b/jbig2.c
@@ -29,6 +29,7 @@
 
 #include "jbig2.h"
 #include "jbig2_priv.h"
+#include "jbig2_image.h"
 #include "jbig2_page.h"
 #include "jbig2_segment.h"
 
--- a/jbig2.h
+++ b/jbig2.h
@@ -41,13 +41,7 @@
 typedef struct _Jbig2Allocator Jbig2Allocator;
 typedef struct _Jbig2Ctx Jbig2Ctx;
 typedef struct _Jbig2GlobalCtx Jbig2GlobalCtx;
-typedef struct _Jbig2Segment Jbig2Segment;
-typedef struct _Jbig2Image Jbig2Image;
 
-/* private structures */
-typedef struct _Jbig2Page Jbig2Page;
-typedef struct _Jbig2SymbolDictionary Jbig2SymbolDictionary;
-
 /*
    this is the general image structure used by the jbig2dec library
    images are 1 bpp, packed into rows a byte at a time. stride gives
@@ -54,7 +48,7 @@
    the byte offset to the next row, while width and height define
    the size of the image area in pixels.
 */
-
+typedef struct _Jbig2Image Jbig2Image;
 struct _Jbig2Image {
     uint32_t width;
     uint32_t height;
@@ -62,13 +56,6 @@
     uint8_t *data;
     int refcount;
 };
-
-Jbig2Image *jbig2_image_new(Jbig2Ctx *ctx, uint32_t width, uint32_t height);
-Jbig2Image *jbig2_image_clone(Jbig2Ctx *ctx, Jbig2Image *image);
-void jbig2_image_release(Jbig2Ctx *ctx, Jbig2Image *image);
-void jbig2_image_free(Jbig2Ctx *ctx, Jbig2Image *image);
-void jbig2_image_clear(Jbig2Ctx *ctx, Jbig2Image *image, int value);
-Jbig2Image *jbig2_image_resize(Jbig2Ctx *ctx, Jbig2Image *image, uint32_t width, uint32_t height);
 
 /* errors are returned from the library via a callback. If no callback
    is provided (a NULL argument is passed to jbig2_ctx_new) a default
--- a/jbig2_generic.c
+++ b/jbig2_generic.c
@@ -35,9 +35,9 @@
 
 #include "jbig2.h"
 #include "jbig2_priv.h"
-#include "jbig2_image.h"
 #include "jbig2_arith.h"
 #include "jbig2_generic.h"
+#include "jbig2_image.h"
 #include "jbig2_mmr.h"
 #include "jbig2_page.h"
 #include "jbig2_segment.h"
--- a/jbig2_generic.h
+++ b/jbig2_generic.h
@@ -43,4 +43,7 @@
 jbig2_decode_generic_region(Jbig2Ctx *ctx,
                             Jbig2Segment *segment, const Jbig2GenericRegionParams *params, Jbig2ArithState *as, Jbig2Image *image, Jbig2ArithCx *GB_stats);
 
+/* 7.4 */
+int jbig2_immediate_generic_region(Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment_data);
+
 #endif /* _JBIG2_GENERIC_H */
--- a/jbig2_halftone.c
+++ b/jbig2_halftone.c
@@ -30,9 +30,9 @@
 #include "jbig2_priv.h"
 #include "jbig2_arith.h"
 #include "jbig2_generic.h"
-#include "jbig2_mmr.h"
 #include "jbig2_image.h"
 #include "jbig2_halftone.h"
+#include "jbig2_mmr.h"
 #include "jbig2_page.h"
 #include "jbig2_segment.h"
 
--- a/jbig2_halftone.h
+++ b/jbig2_halftone.h
@@ -66,4 +66,7 @@
 jbig2_decode_halftone_region(Jbig2Ctx *ctx, Jbig2Segment *segment,
                              Jbig2HalftoneRegionParams *params, const byte *data, const size_t size, Jbig2Image *image, Jbig2ArithCx *GB_stats);
 
+int jbig2_halftone_region(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte *segment_data);
+int jbig2_pattern_dictionary(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte *segment_data);
+
 #endif /* _JBIG2_HALFTONE_H */
--- a/jbig2_huffman.c
+++ b/jbig2_huffman.c
@@ -36,6 +36,7 @@
 #include "jbig2_priv.h"
 #include "jbig2_huffman.h"
 #include "jbig2_hufftab.h"
+#include "jbig2_image.h"
 #include "jbig2_segment.h"
 
 #define JBIG2_HUFFMAN_FLAGS_ISOOB 1
--- a/jbig2_image.h
+++ b/jbig2_image.h
@@ -20,6 +20,22 @@
 #ifndef _JBIG2_IMAGE_H
 #define _JBIG2_IMAGE_H
 
+typedef enum {
+    JBIG2_COMPOSE_OR = 0,
+    JBIG2_COMPOSE_AND = 1,
+    JBIG2_COMPOSE_XOR = 2,
+    JBIG2_COMPOSE_XNOR = 3,
+    JBIG2_COMPOSE_REPLACE = 4
+} Jbig2ComposeOp;
+
+Jbig2Image *jbig2_image_new(Jbig2Ctx *ctx, uint32_t width, uint32_t height);
+void jbig2_image_release(Jbig2Ctx *ctx, Jbig2Image *image);
+Jbig2Image *jbig2_image_clone(Jbig2Ctx *ctx, Jbig2Image *image);
+void jbig2_image_free(Jbig2Ctx *ctx, Jbig2Image *image);
+void jbig2_image_clear(Jbig2Ctx *ctx, Jbig2Image *image, int value);
+Jbig2Image *jbig2_image_resize(Jbig2Ctx *ctx, Jbig2Image *image, uint32_t width, uint32_t height);
+int jbig2_image_compose(Jbig2Ctx *ctx, Jbig2Image *dst, Jbig2Image *src, int x, int y, Jbig2ComposeOp op);
+
 int jbig2_image_get_pixel(Jbig2Image *image, int x, int y);
 void jbig2_image_set_pixel(Jbig2Image *image, int x, int y, bool value);
 
--- a/jbig2_metadata.c
+++ b/jbig2_metadata.c
@@ -28,6 +28,7 @@
 #include "jbig2.h"
 #include "jbig2_priv.h"
 #include "jbig2_metadata.h"
+#include "jbig2_image.h"
 #include "jbig2_segment.h"
 
 /* metadata key,value list object */
--- a/jbig2_page.c
+++ b/jbig2_page.c
@@ -24,15 +24,15 @@
 
 #include <stdlib.h>
 
+#ifdef OUTPUT_PBM
+#include <stdio.h>
+#endif
+
 #include "jbig2.h"
 #include "jbig2_priv.h"
+#include "jbig2_image.h"
 #include "jbig2_page.h"
 #include "jbig2_segment.h"
-
-#ifdef OUTPUT_PBM
-#include <stdio.h>
-#include "jbig2_image.h"
-#endif
 
 /* dump the page struct info */
 static void
--- a/jbig2_priv.h
+++ b/jbig2_priv.h
@@ -56,6 +56,9 @@
 #define NULL ((void*)0)
 #endif
 
+typedef struct _Jbig2Page Jbig2Page;
+typedef struct _Jbig2Segment Jbig2Segment;
+
 typedef enum {
     JBIG2_FILE_HEADER,
     JBIG2_FILE_SEQUENTIAL_HEADER,
@@ -114,23 +117,6 @@
 #define jbig2_renew(ctx, p, t, size) ((t *)jbig2_realloc(ctx->allocator, (p), size, sizeof(t)))
 
 int jbig2_error(Jbig2Ctx *ctx, Jbig2Severity severity, int32_t seg_idx, const char *fmt, ...);
-
-typedef enum {
-    JBIG2_COMPOSE_OR = 0,
-    JBIG2_COMPOSE_AND = 1,
-    JBIG2_COMPOSE_XOR = 2,
-    JBIG2_COMPOSE_XNOR = 3,
-    JBIG2_COMPOSE_REPLACE = 4
-} Jbig2ComposeOp;
-
-int jbig2_image_compose(Jbig2Ctx *ctx, Jbig2Image *dst, Jbig2Image *src, int x, int y, Jbig2ComposeOp op);
-int jbig2_text_region(Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment_data);
-
-/* 7.4 */
-int jbig2_immediate_generic_region(Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment_data);
-
-int jbig2_pattern_dictionary(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte *segment_data);
-int jbig2_halftone_region(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte *segment_data);
 
 /* The word stream design is a compromise between simplicity and
    trying to amortize the number of method calls. Each ::get_next_word
--- a/jbig2_segment.c
+++ b/jbig2_segment.c
@@ -26,14 +26,19 @@
 
 #include "jbig2.h"
 #include "jbig2_priv.h"
-#include "jbig2_huffman.h"
-#include "jbig2_page.h"
-#include "jbig2_symbol_dict.h"
-#include "jbig2_metadata.h"
 #include "jbig2_arith.h"
+#include "jbig2_arith_int.h"
+#include "jbig2_arith_iaid.h"
+#include "jbig2_generic.h"
+#include "jbig2_image.h"
 #include "jbig2_halftone.h"
+#include "jbig2_huffman.h"
+#include "jbig2_metadata.h"
+#include "jbig2_page.h"
 #include "jbig2_refinement.h"
 #include "jbig2_segment.h"
+#include "jbig2_symbol_dict.h"
+#include "jbig2_text.h"
 
 Jbig2Segment *
 jbig2_parse_segment_header(Jbig2Ctx *ctx, uint8_t *buf, size_t buf_size, size_t *p_header_size)
--- a/jbig2_symbol_dict.c
+++ b/jbig2_symbol_dict.c
@@ -27,23 +27,23 @@
 #include <stddef.h>
 #include <string.h>             /* memset() */
 
+#if defined(OUTPUT_PBM) || defined(DUMP_SYMDICT)
+#include <stdio.h>
+#endif
+
 #include "jbig2.h"
 #include "jbig2_priv.h"
 #include "jbig2_arith.h"
 #include "jbig2_arith_int.h"
 #include "jbig2_arith_iaid.h"
-#include "jbig2_huffman.h"
 #include "jbig2_generic.h"
+#include "jbig2_huffman.h"
+#include "jbig2_image.h"
 #include "jbig2_mmr.h"
-#include "jbig2_symbol_dict.h"
-#include "jbig2_text.h"
 #include "jbig2_refinement.h"
 #include "jbig2_segment.h"
-
-#if defined(OUTPUT_PBM) || defined(DUMP_SYMDICT)
-#include <stdio.h>
-#include "jbig2_image.h"
-#endif
+#include "jbig2_symbol_dict.h"
+#include "jbig2_text.h"
 
 /* Table 13 */
 typedef struct {
--- a/jbig2_text.c
+++ b/jbig2_text.c
@@ -30,8 +30,9 @@
 #include "jbig2_arith.h"
 #include "jbig2_arith_int.h"
 #include "jbig2_arith_iaid.h"
-#include "jbig2_huffman.h"
 #include "jbig2_generic.h"
+#include "jbig2_huffman.h"
+#include "jbig2_image.h"
 #include "jbig2_page.h"
 #include "jbig2_refinement.h"
 #include "jbig2_segment.h"
--- a/jbig2_text.h
+++ b/jbig2_text.h
@@ -76,4 +76,6 @@
                          const Jbig2SymbolDict *const *dicts, const uint32_t n_dicts,
                          Jbig2Image *image, const byte *data, const size_t size, Jbig2ArithCx *GR_stats, Jbig2ArithState *as, Jbig2WordStream *ws);
 
+int jbig2_text_region(Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment_data);
+
 #endif /* _JBIG2_TEXT_H */