Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/jbig2dec/jbig2.h @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 /* Copyright (C) 2001-2023 Artifex Software, Inc. | |
| 2 All Rights Reserved. | |
| 3 | |
| 4 This software is provided AS-IS with no warranty, either express or | |
| 5 implied. | |
| 6 | |
| 7 This software is distributed under license and may not be copied, | |
| 8 modified or distributed except as expressly authorized under the terms | |
| 9 of the license contained in the file LICENSE in this distribution. | |
| 10 | |
| 11 Refer to licensing information at http://www.artifex.com or contact | |
| 12 Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, | |
| 13 CA 94129, USA, for further information. | |
| 14 */ | |
| 15 | |
| 16 /* | |
| 17 jbig2dec | |
| 18 */ | |
| 19 | |
| 20 #ifndef _JBIG2_H | |
| 21 #define _JBIG2_H | |
| 22 | |
| 23 #ifdef __cplusplus | |
| 24 extern "C" | |
| 25 { | |
| 26 #endif | |
| 27 | |
| 28 #define JBIG2_VERSION_MAJOR (0) | |
| 29 #define JBIG2_VERSION_MINOR (20) | |
| 30 | |
| 31 /* warning levels */ | |
| 32 typedef enum { | |
| 33 JBIG2_SEVERITY_DEBUG, | |
| 34 JBIG2_SEVERITY_INFO, | |
| 35 JBIG2_SEVERITY_WARNING, | |
| 36 JBIG2_SEVERITY_FATAL | |
| 37 } Jbig2Severity; | |
| 38 | |
| 39 typedef enum { | |
| 40 JBIG2_OPTIONS_EMBEDDED = 1 | |
| 41 } Jbig2Options; | |
| 42 | |
| 43 /* forward public structure declarations */ | |
| 44 typedef struct _Jbig2Allocator Jbig2Allocator; | |
| 45 typedef struct _Jbig2Ctx Jbig2Ctx; | |
| 46 typedef struct _Jbig2GlobalCtx Jbig2GlobalCtx; | |
| 47 | |
| 48 /* | |
| 49 this is the general image structure used by the jbig2dec library | |
| 50 images are 1 bpp, packed into rows a byte at a time. stride gives | |
| 51 the byte offset to the next row, while width and height define | |
| 52 the size of the image area in pixels. | |
| 53 */ | |
| 54 typedef struct _Jbig2Image Jbig2Image; | |
| 55 struct _Jbig2Image { | |
| 56 uint32_t width; | |
| 57 uint32_t height; | |
| 58 uint32_t stride; | |
| 59 uint8_t *data; | |
| 60 int refcount; | |
| 61 }; | |
| 62 | |
| 63 /* errors are returned from the library via a callback. If no callback | |
| 64 is provided (a NULL argument is passed to jbig2_ctx_new) a default | |
| 65 handler is used which prints fatal errors to the stderr stream. */ | |
| 66 | |
| 67 /* error callback */ | |
| 68 #define JBIG2_UNKNOWN_SEGMENT_NUMBER ~0U | |
| 69 typedef void (*Jbig2ErrorCallback)(void *data, const char *msg, Jbig2Severity severity, uint32_t seg_idx); | |
| 70 | |
| 71 /* memory allocation is likewise done via a set of callbacks so that | |
| 72 clients can better control memory usage. If a NULL is passed for | |
| 73 this argument of jbig2_ctx_new, a default allocator based on malloc() | |
| 74 is used. */ | |
| 75 | |
| 76 /* dynamic memory callbacks */ | |
| 77 struct _Jbig2Allocator { | |
| 78 void *(*alloc)(Jbig2Allocator *allocator, size_t size); | |
| 79 void (*free)(Jbig2Allocator *allocator, void *p); | |
| 80 void *(*realloc)(Jbig2Allocator *allocator, void *p, size_t size); | |
| 81 }; | |
| 82 | |
| 83 /* decoder context */ | |
| 84 #define jbig2_ctx_new(allocator, options, global_ctx, error_callback, error_callback_data) jbig2_ctx_new_imp((allocator), (options), (global_ctx), (error_callback), (error_callback_data), JBIG2_VERSION_MAJOR, JBIG2_VERSION_MINOR) | |
| 85 Jbig2Ctx *jbig2_ctx_new_imp(Jbig2Allocator *allocator, | |
| 86 Jbig2Options options, | |
| 87 Jbig2GlobalCtx *global_ctx, | |
| 88 Jbig2ErrorCallback error_callback, | |
| 89 void *error_callback_data, | |
| 90 int jbig2_version_major, | |
| 91 int jbig2_version_minor); | |
| 92 Jbig2Allocator *jbig2_ctx_free(Jbig2Ctx *ctx); | |
| 93 | |
| 94 /* global context for embedded streams */ | |
| 95 Jbig2GlobalCtx *jbig2_make_global_ctx(Jbig2Ctx *ctx); | |
| 96 Jbig2Allocator *jbig2_global_ctx_free(Jbig2GlobalCtx *global_ctx); | |
| 97 | |
| 98 /* submit data to the decoder */ | |
| 99 int jbig2_data_in(Jbig2Ctx *ctx, const unsigned char *data, size_t size); | |
| 100 | |
| 101 /* get the next available decoded page image. NULL means there isn't one. */ | |
| 102 Jbig2Image *jbig2_page_out(Jbig2Ctx *ctx); | |
| 103 /* mark a returned page image as no longer needed. */ | |
| 104 void jbig2_release_page(Jbig2Ctx *ctx, Jbig2Image *image); | |
| 105 /* mark the current page as complete, simulating an end-of-page segment (for broken streams) */ | |
| 106 int jbig2_complete_page(Jbig2Ctx *ctx); | |
| 107 | |
| 108 #ifdef __cplusplus | |
| 109 } | |
| 110 #endif | |
| 111 | |
| 112 #endif /* _JBIG2_H */ |
