source: golgotha/src/i4/loaders/jpg/jcomapi.cc @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 11 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 3.3 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9/*
10 * jcomapi.c
11 *
12 * Copyright (C) 1994-1996, Thomas G. Lane.
13 * This file is part of the Independent JPEG Group's software.
14 * For conditions of distribution and use, see the accompanying README file.
15 *
16 * This file contains application interface routines that are used for both
17 * compression and decompression.
18 */
19
20#define JPEG_INTERNALS
21#include "loaders/jpg/jinclude.h"
22#include "loaders/jpg/jpeglib.h"
23
24
25/*
26 * Abort processing of a JPEG compression or decompression operation,
27 * but don't destroy the object itself.
28 *
29 * For this, we merely clean up all the nonpermanent memory pools.
30 * Note that temp files (virtual arrays) are not allowed to belong to
31 * the permanent pool, so we will be able to close all temp files here.
32 * Closing a data source or destination, if necessary, is the application's
33 * responsibility.
34 */
35
36GLOBAL(void)
37jpeg_abort (j_common_ptr cinfo)
38{
39  int pool;
40
41  /* Releasing pools in reverse order might help avoid fragmentation
42   * with some (brain-damaged) malloc libraries.
43   */
44  for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) {
45    (*cinfo->mem->free_pool) (cinfo, pool);
46  }
47
48  /* Reset overall state for possible reuse of object */
49  cinfo->global_state = (cinfo->is_decompressor ? DSTATE_START : CSTATE_START);
50}
51
52
53/*
54 * Destruction of a JPEG object.
55 *
56 * Everything gets deallocated except the master jpeg_compress_struct itself
57 * and the error manager struct.  Both of these are supplied by the application
58 * and must be freed, if necessary, by the application.  (Often they are on
59 * the stack and so don't need to be freed anyway.)
60 * Closing a data source or destination, if necessary, is the application's
61 * responsibility.
62 */
63
64GLOBAL(void)
65jpeg_destroy (j_common_ptr cinfo)
66{
67  /* We need only tell the memory manager to release everything. */
68  /* NB: mem pointer is NULL if memory mgr failed to initialize. */
69  if (cinfo->mem != NULL)
70    (*cinfo->mem->self_destruct) (cinfo);
71  cinfo->mem = NULL;            /* be safe if jpeg_destroy is called twice */
72  cinfo->global_state = 0;      /* mark it destroyed */
73}
74
75
76/*
77 * Convenience routines for allocating quantization and Huffman tables.
78 * (Would jutils.c be a more reasonable place to put these?)
79 */
80
81GLOBAL(JQUANT_TBL *)
82jpeg_alloc_quant_table (j_common_ptr cinfo)
83{
84  JQUANT_TBL *tbl;
85
86  tbl = (JQUANT_TBL *)
87    (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JQUANT_TBL));
88  tbl->sent_table = FALSE;      /* make sure this is false in any new table */
89  return tbl;
90}
91
92
93GLOBAL(JHUFF_TBL *)
94jpeg_alloc_huff_table (j_common_ptr cinfo)
95{
96  JHUFF_TBL *tbl;
97
98  tbl = (JHUFF_TBL *)
99    (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JHUFF_TBL));
100  tbl->sent_table = FALSE;      /* make sure this is false in any new table */
101  return tbl;
102}
Note: See TracBrowser for help on using the repository browser.