7 * Copyright (C) 1994, Thomas G. Lane.
\r
9 * This file is part of the Independent JPEG Group's software.
\r
11 * For conditions of distribution and use, see the accompanying README file.
\r
15 * This file contains application interface routines that are used for both
\r
17 * compression and decompression.
\r
23 #define JPEG_INTERNALS
\r
25 #include "jinclude.h"
\r
27 #include "radiant_jpeglib.h"
\r
35 * Abort processing of a JPEG compression or decompression operation,
\r
37 * but don't destroy the object itself.
\r
41 * For this, we merely clean up all the nonpermanent memory pools.
\r
43 * Note that temp files (virtual arrays) are not allowed to belong to
\r
45 * the permanent pool, so we will be able to close all temp files here.
\r
47 * Closing a data source or destination, if necessary, is the application's
\r
57 jpeg_abort (j_common_ptr cinfo)
\r
65 /* Releasing pools in reverse order might help avoid fragmentation
\r
67 * with some (brain-damaged) malloc libraries.
\r
71 for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) {
\r
73 (*cinfo->mem->free_pool) (cinfo, pool);
\r
79 /* Reset overall state for possible reuse of object */
\r
81 cinfo->global_state = (cinfo->is_decompressor ? DSTATE_START : CSTATE_START);
\r
91 * Destruction of a JPEG object.
\r
95 * Everything gets deallocated except the master jpeg_compress_struct itself
\r
97 * and the error manager struct. Both of these are supplied by the application
\r
99 * and must be freed, if necessary, by the application. (Often they are on
\r
101 * the stack and so don't need to be freed anyway.)
\r
103 * Closing a data source or destination, if necessary, is the application's
\r
113 jpeg_destroy (j_common_ptr cinfo)
\r
117 /* We need only tell the memory manager to release everything. */
\r
119 /* NB: mem pointer is NULL if memory mgr failed to initialize. */
\r
121 if (cinfo->mem != NULL)
\r
123 (*cinfo->mem->self_destruct) (cinfo);
\r
125 cinfo->mem = NULL; /* be safe if jpeg_destroy is called twice */
\r
127 cinfo->global_state = 0; /* mark it destroyed */
\r
137 * Convenience routines for allocating quantization and Huffman tables.
\r
139 * (Would jutils.c be a more reasonable place to put these?)
\r
145 GLOBAL JQUANT_TBL *
\r
147 jpeg_alloc_quant_table (j_common_ptr cinfo)
\r
155 tbl = (JQUANT_TBL *)
\r
157 (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JQUANT_TBL));
\r
159 tbl->sent_table = FALSE; /* make sure this is false in any new table */
\r
171 jpeg_alloc_huff_table (j_common_ptr cinfo)
\r
179 tbl = (JHUFF_TBL *)
\r
181 (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JHUFF_TBL));
\r
183 tbl->sent_table = FALSE; /* make sure this is false in any new table */
\r