diff --git a/jcmaster.c b/jcmaster.c index dbd77c9a..6d89cad8 100644 --- a/jcmaster.c +++ b/jcmaster.c @@ -518,7 +518,7 @@ prepare_for_pass (j_compress_ptr cinfo) master->saved_dest = cinfo->dest; cinfo->dest = NULL; master->scan_size[master->scan_number] = 0; - jpeg_mem_dest(cinfo, &master->scan_buffer[master->scan_number], &master->scan_size[master->scan_number]); + jpeg_mem_dest_internal(cinfo, &master->scan_buffer[master->scan_number], &master->scan_size[master->scan_number], JPOOL_IMAGE); (*cinfo->dest->init_destination)(cinfo); } (*cinfo->entropy->start_pass) (cinfo, FALSE); diff --git a/jdatadst.c b/jdatadst.c index dcaf6f0f..355a46ca 100644 --- a/jdatadst.c +++ b/jdatadst.c @@ -208,9 +208,9 @@ jpeg_stdio_dest (j_compress_ptr cinfo, FILE *outfile) { my_dest_ptr dest; - /* The destination object is made permanent so that multiple JPEG images - * can be written to the same file without re-executing jpeg_stdio_dest. - */ + /* The destination object is made permanent so that multiple JPEG images + * can be written to the same file without re-executing jpeg_stdio_dest. + */ if (cinfo->dest == NULL) { /* first time for this JPEG object? */ cinfo->dest = (struct jpeg_destination_mgr *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, @@ -249,8 +249,8 @@ jpeg_stdio_dest (j_compress_ptr cinfo, FILE *outfile) */ GLOBAL(void) -jpeg_mem_dest (j_compress_ptr cinfo, - unsigned char **outbuffer, unsigned long *outsize) +jpeg_mem_dest_internal (j_compress_ptr cinfo, + unsigned char **outbuffer, unsigned long *outsize, int pool_id) { my_mem_dest_ptr dest; @@ -262,7 +262,7 @@ jpeg_mem_dest (j_compress_ptr cinfo, */ if (cinfo->dest == NULL) { /* first time for this JPEG object? */ cinfo->dest = (struct jpeg_destination_mgr *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, pool_id, sizeof(my_mem_destination_mgr)); } else if (cinfo->dest->init_destination != init_mem_destination) { /* It is unsafe to reuse the existing destination manager unless it was @@ -290,4 +290,15 @@ jpeg_mem_dest (j_compress_ptr cinfo, dest->pub.next_output_byte = dest->buffer = *outbuffer; dest->pub.free_in_buffer = dest->bufsize = *outsize; } + +GLOBAL(void) +jpeg_mem_dest (j_compress_ptr cinfo, + unsigned char **outbuffer, unsigned long *outsize) +{ + /* The destination object is made permanent so that multiple JPEG images + * can be written to the same file without re-executing jpeg_stdio_dest. + */ + jpeg_mem_dest_internal(cinfo, outbuffer, outsize, JPOOL_PERMANENT); +} + #endif diff --git a/jpegint.h b/jpegint.h index afa548fb..e32217b9 100644 --- a/jpegint.h +++ b/jpegint.h @@ -402,6 +402,12 @@ EXTERN(void) jinit_merged_upsampler (j_decompress_ptr cinfo); /* Memory manager initialization */ EXTERN(void) jinit_memory_mgr (j_common_ptr cinfo); +#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED) +EXTERN(void) +jpeg_mem_dest_internal (j_compress_ptr cinfo, + unsigned char **outbuffer, unsigned long *outsize, int pool_id); +#endif + /* Utility routines in jutils.c */ EXTERN(long) jdiv_round_up (long a, long b); EXTERN(long) jround_up (long a, long b);