Main MRPT website > C++ reference for MRPT 1.5.6
jcomapi.cpp
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #define JPEG_INTERNALS
11 #include "jinclude.h"
12 #include "mrpt_jpeglib.h"
13 
14 
15 /*
16  * Abort processing of a JPEG compression or decompression operation,
17  * but don't destroy the object itself.
18  *
19  * For this, we merely clean up all the nonpermanent memory pools.
20  * Note that temp files (virtual arrays) are not allowed to belong to
21  * the permanent pool, so we will be able to close all temp files here.
22  * Closing a data source or destination, if necessary, is the application's
23  * responsibility.
24  */
25 
26 GLOBAL(void)
28 {
29  int pool;
30 
31  /* Do nothing if called on a not-initialized or destroyed JPEG object. */
32  if (cinfo->mem == NULL)
33  return;
34 
35  /* Releasing pools in reverse order might help avoid fragmentation
36  * with some (brain-damaged) malloc libraries.
37  */
38  for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) {
39  (*cinfo->mem->free_pool) (cinfo, pool);
40  }
41 
42  /* Reset overall state for possible reuse of object */
43  if (cinfo->is_decompressor) {
44  cinfo->global_state = DSTATE_START;
45  /* Try to keep application from accessing now-deleted marker list.
46  * A bit kludgy to do it here, but this is the most central place.
47  */
48  ((j_decompress_ptr) cinfo)->marker_list = NULL;
49  } else {
50  cinfo->global_state = CSTATE_START;
51  }
52 }
53 
54 
55 /*
56  * Destruction of a JPEG object.
57  *
58  * Everything gets deallocated except the master jpeg_compress_struct itself
59  * and the error manager struct. Both of these are supplied by the application
60  * and must be freed, if necessary, by the application. (Often they are on
61  * the stack and so don't need to be freed anyway.)
62  * Closing a data source or destination, if necessary, is the application's
63  * responsibility.
64  */
65 
66 GLOBAL(void)
68 {
69  /* We need only tell the memory manager to release everything. */
70  /* NB: mem pointer is NULL if memory mgr failed to initialize. */
71  if (cinfo->mem != NULL)
72  (*cinfo->mem->self_destruct) (cinfo);
73  cinfo->mem = NULL; /* be safe if jpeg_destroy is called twice */
74  cinfo->global_state = 0; /* mark it destroyed */
75 }
76 
77 
78 /*
79  * Convenience routines for allocating quantization and Huffman tables.
80  * (Would jutils.c be a more reasonable place to put these?)
81  */
82 
85 {
86  JQUANT_TBL *tbl;
87 
88  tbl = (JQUANT_TBL *)
89  (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JQUANT_TBL));
90  tbl->sent_table = FALSE; /* make sure this is false in any new table */
91  return tbl;
92 }
93 
94 
97 {
98  JHUFF_TBL *tbl;
99 
100  tbl = (JHUFF_TBL *)
101  (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JHUFF_TBL));
102  tbl->sent_table = FALSE; /* make sure this is false in any new table */
103  return tbl;
104 }
#define CSTATE_START
Definition: jpegint.h:22
#define JPOOL_PERMANENT
Definition: mrpt_jpeglib.h:745
boolean sent_table
Definition: mrpt_jpeglib.h:91
jpeg_destroy(j_common_ptr cinfo)
Definition: jcomapi.cpp:67
#define SIZEOF(object)
Definition: jinclude.h:73
struct jpeg_decompress_struct * j_decompress_ptr
Definition: mrpt_jpeglib.h:260
jpeg_abort(j_common_ptr cinfo)
Definition: jcomapi.cpp:27
#define FALSE
Definition: jmorecfg.h:227
#define DSTATE_START
Definition: jpegint.h:26
jpeg_alloc_huff_table(j_common_ptr cinfo)
Definition: jcomapi.cpp:96
#define JPOOL_NUMPOOLS
Definition: mrpt_jpeglib.h:747
jpeg_alloc_quant_table(j_common_ptr cinfo)
Definition: jcomapi.cpp:84
boolean sent_table
Definition: mrpt_jpeglib.h:107
#define GLOBAL(type)
Definition: jmorecfg.h:185



Page generated by Doxygen 1.8.14 for MRPT 1.5.6 Git: 4c65e8431 Tue Apr 24 08:18:17 2018 +0200 at lun oct 28 01:35:26 CET 2019