ReactOS 0.4.16-dev-252-g9ccafe8
jdatadst.c File Reference
#include "jinclude.h"
#include "jpeglib.h"
#include "jerror.h"
Include dependency graph for jdatadst.c:

Go to the source code of this file.

Classes

struct  my_destination_mgr
 
struct  my_mem_destination_mgr
 

Macros

#define OUTPUT_BUF_SIZE   4096 /* choose an efficiently fwrite'able size */
 

Typedefs

typedef my_destination_mgrmy_dest_ptr
 
typedef my_mem_destination_mgrmy_mem_dest_ptr
 

Functions

void *malloc JPP ((size_t size))
 
void free JPP ((void *ptr))
 
 init_destination (j_compress_ptr cinfo)
 
 init_mem_destination (j_compress_ptr cinfo)
 
 empty_output_buffer (j_compress_ptr cinfo)
 
 empty_mem_output_buffer (j_compress_ptr cinfo)
 
 term_destination (j_compress_ptr cinfo)
 
 term_mem_destination (j_compress_ptr cinfo)
 
 jpeg_stdio_dest (j_compress_ptr cinfo, FILE *outfile)
 
 jpeg_mem_dest (j_compress_ptr cinfo, unsigned char **outbuffer, size_t *outsize)
 

Macro Definition Documentation

◆ OUTPUT_BUF_SIZE

#define OUTPUT_BUF_SIZE   4096 /* choose an efficiently fwrite'able size */

Definition at line 40 of file jdatadst.c.

Typedef Documentation

◆ my_dest_ptr

Definition at line 38 of file jdatadst.c.

◆ my_mem_dest_ptr

Definition at line 55 of file jdatadst.c.

Function Documentation

◆ empty_mem_output_buffer()

empty_mem_output_buffer ( j_compress_ptr  cinfo)

Definition at line 122 of file jdatadst.c.

123{
124 size_t nextsize;
125 JOCTET * nextbuffer;
127
128 /* Try to allocate new buffer with double size */
129 nextsize = dest->bufsize * 2;
130 nextbuffer = (JOCTET *) malloc(nextsize);
131
132 if (nextbuffer == NULL)
133 ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 11);
134
135 MEMCOPY(nextbuffer, dest->buffer, dest->bufsize);
136
137 if (dest->newbuffer != NULL)
138 free(dest->newbuffer);
139
140 dest->newbuffer = nextbuffer;
141
142 dest->pub.next_output_byte = nextbuffer + dest->bufsize;
143 dest->pub.free_in_buffer = dest->bufsize;
144
145 dest->buffer = nextbuffer;
146 dest->bufsize = nextsize;
147
148 return TRUE;
149}
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
my_mem_destination_mgr * my_mem_dest_ptr
Definition: jdatadst.c:55
#define ERREXIT1(cinfo, code, p1)
Definition: jerror.h:212
#define MEMCOPY(dest, src, size)
Definition: jinclude.h:69
char JOCTET
Definition: jmorecfg.h:167
static char * dest
Definition: rtl.c:135
struct jpeg_destination_mgr * dest
Definition: jpeglib.h:295

Referenced by jpeg_mem_dest().

◆ empty_output_buffer()

empty_output_buffer ( j_compress_ptr  cinfo)

Definition at line 107 of file jdatadst.c.

108{
109 my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
110
111 if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) !=
113 ERREXIT(cinfo, JERR_FILE_WRITE);
114
115 dest->pub.next_output_byte = dest->buffer;
116 dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
117
118 return TRUE;
119}
__kernel_size_t size_t
Definition: linux.h:237
#define OUTPUT_BUF_SIZE
Definition: jdatadst.c:40
my_destination_mgr * my_dest_ptr
Definition: jdatadst.c:38
#define JFWRITE(file, buf, sizeofbuf)
Definition: jinclude.h:94
if(dx< 0)
Definition: linetemp.h:194
#define ERREXIT(msg)
Definition: rdjpgcom.c:72

Referenced by jpeg_stdio_dest().

◆ init_destination()

init_destination ( j_compress_ptr  cinfo)

Definition at line 64 of file jdatadst.c.

65{
67
68 /* Allocate the output buffer --- it will be released when done with image */
69 dest->buffer = (JOCTET *) (*cinfo->mem->alloc_small)
71
72 dest->pub.next_output_byte = dest->buffer;
73 dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
74}
#define SIZEOF(_ar)
Definition: calc.h:97
#define JPOOL_IMAGE
Definition: jpeglib.h:808

Referenced by jpeg_stdio_dest().

◆ init_mem_destination()

init_mem_destination ( j_compress_ptr  cinfo)

Definition at line 77 of file jdatadst.c.

78{
79 /* no work necessary here */
80}

Referenced by jpeg_mem_dest().

◆ jpeg_mem_dest()

jpeg_mem_dest ( j_compress_ptr  cinfo,
unsigned char **  outbuffer,
size_t outsize 
)

Definition at line 233 of file jdatadst.c.

235{
237
238 if (outbuffer == NULL || outsize == NULL) /* sanity check */
239 ERREXIT(cinfo, JERR_BUFFER_SIZE);
240
241 /* The destination object is made permanent so that multiple JPEG images
242 * can be written to the same buffer without re-executing jpeg_mem_dest.
243 */
244 if (cinfo->dest == NULL) { /* first time for this JPEG object? */
245 cinfo->dest = (struct jpeg_destination_mgr *) (*cinfo->mem->alloc_small)
247 }
248
249 dest = (my_mem_dest_ptr) cinfo->dest;
250 dest->pub.init_destination = init_mem_destination;
251 dest->pub.empty_output_buffer = empty_mem_output_buffer;
252 dest->pub.term_destination = term_mem_destination;
253 dest->outbuffer = outbuffer;
254 dest->outsize = outsize;
255 dest->newbuffer = NULL;
256
257 if (*outbuffer == NULL || *outsize == 0) {
258 /* Allocate initial buffer */
259 dest->newbuffer = *outbuffer = (unsigned char *) malloc(OUTPUT_BUF_SIZE);
260 if (dest->newbuffer == NULL)
261 ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
263 }
264
265 dest->pub.next_output_byte = dest->buffer = *outbuffer;
266 dest->pub.free_in_buffer = dest->bufsize = *outsize;
267}
term_mem_destination(j_compress_ptr cinfo)
Definition: jdatadst.c:179
init_mem_destination(j_compress_ptr cinfo)
Definition: jdatadst.c:77
empty_mem_output_buffer(j_compress_ptr cinfo)
Definition: jdatadst.c:122
struct jpeg_common_struct * j_common_ptr
Definition: jpeglib.h:284
unsigned char ** outbuffer
Definition: jpeglib.h:980
#define JPOOL_PERMANENT
Definition: jpeglib.h:807
unsigned char size_t * outsize
Definition: jpeglib.h:981

◆ jpeg_stdio_dest()

jpeg_stdio_dest ( j_compress_ptr  cinfo,
FILE outfile 
)

Definition at line 195 of file jdatadst.c.

196{
198
199 /* The destination object is made permanent so that multiple JPEG images
200 * can be written to the same file without re-executing jpeg_stdio_dest.
201 * This makes it dangerous to use this manager and a different destination
202 * manager serially with the same JPEG object, because their private object
203 * sizes may be different. Caveat programmer.
204 */
205 if (cinfo->dest == NULL) { /* first time for this JPEG object? */
206 cinfo->dest = (struct jpeg_destination_mgr *) (*cinfo->mem->alloc_small)
208 }
209
210 dest = (my_dest_ptr) cinfo->dest;
211 dest->pub.init_destination = init_destination;
212 dest->pub.empty_output_buffer = empty_output_buffer;
213 dest->pub.term_destination = term_destination;
214 dest->outfile = outfile;
215}
term_destination(j_compress_ptr cinfo)
Definition: jdatadst.c:162
init_destination(j_compress_ptr cinfo)
Definition: jdatadst.c:64
empty_output_buffer(j_compress_ptr cinfo)
Definition: jdatadst.c:107
static FILE * outfile
Definition: wrjpgcom.c:81

Referenced by main(), and write_JPEG_file().

◆ JPP() [1/2]

void *malloc JPP ( (size_t size )

◆ JPP() [2/2]

void free JPP ( (void *ptr )

◆ term_destination()

term_destination ( j_compress_ptr  cinfo)

Definition at line 162 of file jdatadst.c.

163{
164 my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
165 size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer;
166
167 /* Write any data remaining in the buffer */
168 if (datacount > 0) {
169 if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount)
170 ERREXIT(cinfo, JERR_FILE_WRITE);
171 }
172 JFFLUSH(dest->outfile);
173 /* Make sure we wrote the output file OK */
174 if (JFERROR(dest->outfile))
175 ERREXIT(cinfo, JERR_FILE_WRITE);
176}
#define JFFLUSH(file)
Definition: jinclude.h:96
#define JFERROR(file)
Definition: jinclude.h:97

Referenced by jpeg_stdio_dest().

◆ term_mem_destination()

term_mem_destination ( j_compress_ptr  cinfo)

Definition at line 179 of file jdatadst.c.

180{
182
183 *dest->outbuffer = dest->buffer;
184 *dest->outsize = dest->bufsize - dest->pub.free_in_buffer;
185}

Referenced by jpeg_mem_dest().