JasPer 4.0.0 |

Loading...
Searching...
No Matches
jas_init.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2001-2002 Michael David Adams.
3 * All rights reserved.
4 */
5
6/* __START_OF_JASPER_LICENSE__
7 *
8 * JasPer License Version 2.0
9 *
10 * Copyright (c) 2001-2006 Michael David Adams
11 * Copyright (c) 1999-2000 Image Power, Inc.
12 * Copyright (c) 1999-2000 The University of British Columbia
13 *
14 * All rights reserved.
15 *
16 * Permission is hereby granted, free of charge, to any person (the
17 * "User") obtaining a copy of this software and associated documentation
18 * files (the "Software"), to deal in the Software without restriction,
19 * including without limitation the rights to use, copy, modify, merge,
20 * publish, distribute, and/or sell copies of the Software, and to permit
21 * persons to whom the Software is furnished to do so, subject to the
22 * following conditions:
23 *
24 * 1. The above copyright notices and this permission notice (which
25 * includes the disclaimer below) shall be included in all copies or
26 * substantial portions of the Software.
27 *
28 * 2. The name of a copyright holder shall not be used to endorse or
29 * promote products derived from the Software without specific prior
30 * written permission.
31 *
32 * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS
33 * LICENSE. NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
34 * THIS DISCLAIMER. THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
35 * "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
36 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
37 * PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO
38 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
39 * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
40 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
41 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
42 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. NO ASSURANCES ARE
43 * PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE
44 * THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY.
45 * EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS
46 * BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL
47 * PROPERTY RIGHTS OR OTHERWISE. AS A CONDITION TO EXERCISING THE RIGHTS
48 * GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE
49 * ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY. THE SOFTWARE
50 * IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL
51 * SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES,
52 * AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL
53 * SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH
54 * THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH,
55 * PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH
56 * RISK ACTIVITIES"). THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY
57 * EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES.
58 *
59 * __END_OF_JASPER_LICENSE__
60 */
61
67#ifndef JAS_INIT_H
68#define JAS_INIT_H
69
70/* The configuration header file should be included first. */
71#include <jasper/jas_config.h>
72
73#include "jasper/jas_malloc.h"
74#include "jasper/jas_image.h"
75#include "jasper/jas_log.h"
76
77#include <stdarg.h>
78
79#ifdef __cplusplus
80 extern "C" {
81#endif
82
88#if defined(JAS_FOR_INTERNAL_USE_ONLY)
89/*
90 Per-thread library context.
91*/
92 typedef struct {
93
94 /*
95 The level of debugging checks/output enabled by the library.
96 A larger value corresponds to a greater level of debugging checks/output.
97 */
98 int debug_level;
99
100 /*
101 The function used to output error/warning/informational messages.
102 int (*vlogmsgf)(jas_logtype_t type, const char *format, va_list ap);
103 */
104 jas_vlogmsgf_t *vlogmsgf;
105
106 /*
107 The image format information to be used to populate the image format
108 table.
109 */
110 size_t image_numfmts;
111 jas_image_fmtinfo_t image_fmtinfos[JAS_IMAGE_MAXFMTS];
112
113 /* The maximum number of samples allowable in an image to be decoded. */
114 size_t dec_default_max_samples;
115
116} jas_ctx_t;
117#endif
118
123 typedef void *jas_context_t;
124
125/******************************************************************************\
126* Library Run-Time Configuration.
127\******************************************************************************/
128
143JAS_EXPORT
144 void jas_conf_clear(void);
145
151JAS_EXPORT
152 void jas_conf_set_multithread(int multithread);
153
163JAS_EXPORT
164 void jas_conf_set_allocator(jas_allocator_t *allocator);
165
171JAS_EXPORT
172 void jas_conf_set_debug_level(int debug_level);
173
187JAS_EXPORT
188 void jas_conf_set_max_mem_usage(size_t max_mem);
189
197JAS_EXPORT
198 void jas_conf_set_dec_default_max_samples(size_t max_samples);
199
207JAS_EXPORT
208 void jas_conf_set_vlogmsgf(jas_vlogmsgf_t *func);
209
210/******************************************************************************\
211* Library Initialization and Cleanup.
212\******************************************************************************/
213
232JAS_EXPORT
233 int jas_init_library(void);
234
247JAS_EXPORT
248 int jas_cleanup_library(void);
249
250/******************************************************************************\
251* Thread Initialization and Cleanup.
252\******************************************************************************/
253
267JAS_EXPORT
268 int jas_init_thread(void);
269
276JAS_EXPORT
277 int jas_cleanup_thread(void);
278
279/******************************************************************************\
280* Legacy Initialization and Cleanup Functions.
281\******************************************************************************/
282
309JAS_EXPORT
310 int jas_init(void);
311
326JAS_EXPORT
327 void jas_cleanup(void);
328
329/******************************************************************************\
330* Context Management
331\******************************************************************************/
332
339JAS_EXPORT
340 jas_context_t jas_context_create(void);
341
349JAS_EXPORT
350 void jas_context_destroy(jas_context_t context);
351
358JAS_EXPORT
359 jas_context_t jas_get_default_context(void);
360
367JAS_EXPORT
368 jas_context_t jas_get_context(void);
369
376JAS_EXPORT
377 void jas_set_context(jas_context_t context);
378
379/******************************************************************************\
380* Getting/Setting Context Properties
381\******************************************************************************/
382
383/* This function is only for internal use by the library. */
384JAS_EXPORT
385 int jas_get_debug_level_internal(void);
386
387/* This function is only for internal use by the library. */
388JAS_EXPORT
389 size_t jas_get_dec_default_max_samples_internal(void);
390
391/* This function is only for internal use by the library. */
392JAS_EXPORT
393 jas_vlogmsgf_t *jas_get_vlogmsgf_internal(void);
394
395#if defined(JAS_FOR_INTERNAL_USE_ONLY)
396#if defined(JAS_HAVE_THREAD_LOCAL)
397 extern _Thread_local jas_ctx_t *jas_cur_ctx;
398#endif
399
400/* This function is only for internal use by the library. */
401jas_ctx_t *jas_get_ctx_internal(void);
402
403/* This function is only for internal use by the library. */
404 static inline jas_ctx_t *jas_get_ctx(void)
405{
406#if defined(JAS_HAVE_THREAD_LOCAL)
407 return jas_cur_ctx ? jas_cur_ctx : jas_get_ctx_internal();
408#else
409 return JAS_CAST(jas_ctx_t *, jas_get_ctx_internal());
410#endif
411}
412#endif
413
420JAS_EXPORT
421 void jas_set_debug_level(int debug_level);
422
429 static inline int jas_get_debug_level(void)
430{
431#if defined(JAS_FOR_INTERNAL_USE_ONLY)
432 jas_ctx_t *ctx = jas_get_ctx();
433 return ctx->debug_level;
434#else
435 return jas_get_debug_level_internal();
436#endif
437}
438
446JAS_EXPORT
447 void jas_set_dec_default_max_samples(size_t max_samples);
448
456 static inline size_t jas_get_dec_default_max_samples(void)
457{
458#if defined(JAS_FOR_INTERNAL_USE_ONLY)
459 jas_ctx_t *ctx = jas_get_ctx();
460 return ctx->dec_default_max_samples;
461#else
462 return jas_get_dec_default_max_samples_internal();
463#endif
464}
465
472JAS_EXPORT
473 void jas_set_vlogmsgf(jas_vlogmsgf_t *func);
474
481 static inline
482 jas_vlogmsgf_t *jas_get_vlogmsgf(void)
483{
484#if defined(JAS_FOR_INTERNAL_USE_ONLY)
485 jas_ctx_t *ctx = jas_get_ctx();
486 return ctx->vlogmsgf;
487#else
488 return jas_get_vlogmsgf_internal();
489#endif
490}
491
496#ifdef __cplusplus
497}
498#endif
499
500#endif
JAS_IMAGE_MAXFMTS
#define JAS_IMAGE_MAXFMTS
The maximum number of image data formats supported.
Definition: jas_image.h:293
jas_get_context
JAS_EXPORT jas_context_t jas_get_context(void)
Get the current context for the calling thread.
Definition: jas_init.c:927
jas_cleanup_library
JAS_EXPORT int jas_cleanup_library(void)
Perform clean up for the JasPer library.
Definition: jas_init.c:636
jas_cleanup
JAS_EXPORT void jas_cleanup(void)
Perform any clean up for the JasPer library.
Definition: jas_init.c:822
jas_conf_set_vlogmsgf
JAS_EXPORT void jas_conf_set_vlogmsgf(jas_vlogmsgf_t *func)
Set the function used by the library to output error, warning, and informational messages.
jas_set_debug_level
JAS_EXPORT void jas_set_debug_level(int debug_level)
Set the debug level for a particular context.
Definition: jas_init.c:1002
jas_context_create
JAS_EXPORT jas_context_t jas_context_create(void)
Create a context.
Definition: jas_init.c:885
jas_conf_set_allocator
JAS_EXPORT void jas_conf_set_allocator(jas_allocator_t *allocator)
Set the memory allocator to be used by the library.
Definition: jas_init.c:425
jas_set_vlogmsgf
JAS_EXPORT void jas_set_vlogmsgf(jas_vlogmsgf_t *func)
Set the function to be used for log messages.
jas_conf_set_multithread
JAS_EXPORT void jas_conf_set_multithread(int multithread)
Set the multithreading flag for the library.
Definition: jas_init.c:419
jas_init
JAS_EXPORT int jas_init(void)
Configure and initialize the JasPer library using the default configuration settings.
Definition: jas_init.c:807
jas_set_dec_default_max_samples
JAS_EXPORT void jas_set_dec_default_max_samples(size_t max_samples)
Set the default maximum number of samples that a decoder is permitted to process.
Definition: jas_init.c:1016
jas_conf_set_dec_default_max_samples
JAS_EXPORT void jas_conf_set_dec_default_max_samples(size_t max_samples)
Set the default value for the maximum number of samples that is allowed in an image to be decoded.
Definition: jas_init.c:452
jas_conf_set_max_mem_usage
JAS_EXPORT void jas_conf_set_max_mem_usage(size_t max_mem)
Set the maximum amount of memory that can be used by the library (assuming the allocator wrapper is n...
Definition: jas_init.c:445
jas_cleanup_thread
JAS_EXPORT int jas_cleanup_thread(void)
Perform per-thread cleanup for the JasPer library.
Definition: jas_init.c:757
jas_get_default_context
JAS_EXPORT jas_context_t jas_get_default_context(void)
Get the current context for the calling thread.
Definition: jas_init.c:933
jas_conf_clear
JAS_EXPORT void jas_conf_clear(void)
Configure the JasPer library with the default configuration settings.
Definition: jas_init.c:397
jas_context_destroy
JAS_EXPORT void jas_context_destroy(jas_context_t context)
Destroy a context.
Definition: jas_init.c:902
jas_get_debug_level
static int jas_get_debug_level(void)
Get the debug level for a particular context.
Definition: jas_init.h:429
jas_get_dec_default_max_samples
static size_t jas_get_dec_default_max_samples(void)
Get the default maximum number of samples that a decoder is permitted to process.
Definition: jas_init.h:456
jas_init_thread
JAS_EXPORT int jas_init_thread(void)
Perform per-thread initialization for the JasPer library.
Definition: jas_init.c:696
jas_conf_set_debug_level
JAS_EXPORT void jas_conf_set_debug_level(int debug_level)
Set the initial debug level for the library.
Definition: jas_init.c:439
jas_context_t
void * jas_context_t
An opaque handle type used to represent a JasPer library context.
Definition: jas_init.h:123
jas_set_context
JAS_EXPORT void jas_set_context(jas_context_t context)
Set the current context for the calling thread.
Definition: jas_init.c:939
jas_init_library
JAS_EXPORT int jas_init_library(void)
Initialize the JasPer library with the current configuration settings.
Definition: jas_init.c:475
jas_get_vlogmsgf
static jas_vlogmsgf_t * jas_get_vlogmsgf(void)
Get the function to be used for log messages.
Definition: jas_init.h:482
jas_vlogmsgf_t
int() jas_vlogmsgf_t(jas_logtype_t, const char *, va_list)
Type used for formatted message logging function.
Definition: jas_log.h:117
jas_image.h
JasPer Image Class.
jas_log.h
JasPer Logging Functionality.
jas_malloc.h
JasPer Memory Allocator.
jas_allocator_s
A memory allocator.
Definition: jas_malloc.h:101
jas_image_fmtinfo_t
Image format information.
Definition: jas_image.h:314