mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-22 08:27:31 +09:00
Issue #1933 - Part 2: Update libjpeg-turbo source.
This commit is contained in:
parent
75e223e3bf
commit
fc2133f4d1
321 changed files with 73829 additions and 50995 deletions
|
|
@ -4,7 +4,7 @@
|
|||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2016, D. R. Commander.
|
||||
* Copyright (C) 2016, 2021-2022, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
|
|
@ -32,18 +32,14 @@
|
|||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jmemsys.h" /* import the system-dependent declarations */
|
||||
#if !defined(_MSC_VER) || _MSC_VER > 1600
|
||||
#include <stdint.h>
|
||||
#include <limits.h> /* some NDKs define SIZE_MAX in limits.h */
|
||||
|
||||
#ifndef NO_GETENV
|
||||
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare getenv() */
|
||||
extern char *getenv (const char *name);
|
||||
#endif
|
||||
#endif
|
||||
#include <limits.h>
|
||||
|
||||
|
||||
LOCAL(size_t)
|
||||
round_up_pow2 (size_t a, size_t b)
|
||||
round_up_pow2(size_t a, size_t b)
|
||||
/* a rounded up to the next multiple of b, i.e. ceil(a/b)*b */
|
||||
/* Assumes a >= 0, b > 0, and b is a power of 2 */
|
||||
{
|
||||
|
|
@ -87,7 +83,9 @@ round_up_pow2 (size_t a, size_t b)
|
|||
#ifndef WITH_SIMD
|
||||
#define ALIGN_SIZE sizeof(double)
|
||||
#else
|
||||
#define ALIGN_SIZE 16 /* Most SIMD implementations require this */
|
||||
#define ALIGN_SIZE 32 /* Most of the SIMD instructions we support require
|
||||
16-byte (128-bit) alignment, but AVX2 requires
|
||||
32-byte alignment. */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
@ -102,7 +100,7 @@ round_up_pow2 (size_t a, size_t b)
|
|||
typedef struct small_pool_struct *small_pool_ptr;
|
||||
|
||||
typedef struct small_pool_struct {
|
||||
small_pool_ptr next; /* next in list of pools */
|
||||
small_pool_ptr next; /* next in list of pools */
|
||||
size_t bytes_used; /* how many bytes already used within pool */
|
||||
size_t bytes_left; /* bytes still available in this pool */
|
||||
} small_pool_hdr;
|
||||
|
|
@ -110,7 +108,7 @@ typedef struct small_pool_struct {
|
|||
typedef struct large_pool_struct *large_pool_ptr;
|
||||
|
||||
typedef struct large_pool_struct {
|
||||
large_pool_ptr next; /* next in list of pools */
|
||||
large_pool_ptr next; /* next in list of pools */
|
||||
size_t bytes_used; /* how many bytes already used within pool */
|
||||
size_t bytes_left; /* bytes still available in this pool */
|
||||
} large_pool_hdr;
|
||||
|
|
@ -189,9 +187,9 @@ struct jvirt_barray_control {
|
|||
#ifdef MEM_STATS /* optional extra stuff for statistics */
|
||||
|
||||
LOCAL(void)
|
||||
print_mem_stats (j_common_ptr cinfo, int pool_id)
|
||||
print_mem_stats(j_common_ptr cinfo, int pool_id)
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
small_pool_ptr shdr_ptr;
|
||||
large_pool_ptr lhdr_ptr;
|
||||
|
||||
|
|
@ -204,15 +202,13 @@ print_mem_stats (j_common_ptr cinfo, int pool_id)
|
|||
|
||||
for (lhdr_ptr = mem->large_list[pool_id]; lhdr_ptr != NULL;
|
||||
lhdr_ptr = lhdr_ptr->next) {
|
||||
fprintf(stderr, " Large chunk used %ld\n",
|
||||
(long) lhdr_ptr->bytes_used);
|
||||
fprintf(stderr, " Large chunk used %ld\n", (long)lhdr_ptr->bytes_used);
|
||||
}
|
||||
|
||||
for (shdr_ptr = mem->small_list[pool_id]; shdr_ptr != NULL;
|
||||
shdr_ptr = shdr_ptr->next) {
|
||||
fprintf(stderr, " Small chunk used %ld free %ld\n",
|
||||
(long) shdr_ptr->bytes_used,
|
||||
(long) shdr_ptr->bytes_left);
|
||||
(long)shdr_ptr->bytes_used, (long)shdr_ptr->bytes_left);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -220,7 +216,7 @@ print_mem_stats (j_common_ptr cinfo, int pool_id)
|
|||
|
||||
|
||||
LOCAL(void)
|
||||
out_of_memory (j_common_ptr cinfo, int which)
|
||||
out_of_memory(j_common_ptr cinfo, int which)
|
||||
/* Report an out-of-memory error and stop execution */
|
||||
/* If we compiled MEM_STATS support, report alloc requests before dying */
|
||||
{
|
||||
|
|
@ -248,26 +244,24 @@ out_of_memory (j_common_ptr cinfo, int which)
|
|||
* adjustment.
|
||||
*/
|
||||
|
||||
static const size_t first_pool_slop[JPOOL_NUMPOOLS] =
|
||||
{
|
||||
1600, /* first PERMANENT pool */
|
||||
16000 /* first IMAGE pool */
|
||||
static const size_t first_pool_slop[JPOOL_NUMPOOLS] = {
|
||||
1600, /* first PERMANENT pool */
|
||||
16000 /* first IMAGE pool */
|
||||
};
|
||||
|
||||
static const size_t extra_pool_slop[JPOOL_NUMPOOLS] =
|
||||
{
|
||||
0, /* additional PERMANENT pools */
|
||||
5000 /* additional IMAGE pools */
|
||||
static const size_t extra_pool_slop[JPOOL_NUMPOOLS] = {
|
||||
0, /* additional PERMANENT pools */
|
||||
5000 /* additional IMAGE pools */
|
||||
};
|
||||
|
||||
#define MIN_SLOP 50 /* greater than 0 to avoid futile looping */
|
||||
|
||||
|
||||
METHODDEF(void *)
|
||||
alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
alloc_small(j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
/* Allocate a "small" object */
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
small_pool_ptr hdr_ptr, prev_hdr_ptr;
|
||||
char *data_ptr;
|
||||
size_t min_request, slop;
|
||||
|
|
@ -311,11 +305,11 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
|||
else
|
||||
slop = extra_pool_slop[pool_id];
|
||||
/* Don't ask for more than MAX_ALLOC_CHUNK */
|
||||
if (slop > (size_t) (MAX_ALLOC_CHUNK-min_request))
|
||||
slop = (size_t) (MAX_ALLOC_CHUNK-min_request);
|
||||
if (slop > (size_t)(MAX_ALLOC_CHUNK - min_request))
|
||||
slop = (size_t)(MAX_ALLOC_CHUNK - min_request);
|
||||
/* Try to get space, if fail reduce slop and try again */
|
||||
for (;;) {
|
||||
hdr_ptr = (small_pool_ptr) jpeg_get_small(cinfo, min_request + slop);
|
||||
hdr_ptr = (small_pool_ptr)jpeg_get_small(cinfo, min_request + slop);
|
||||
if (hdr_ptr != NULL)
|
||||
break;
|
||||
slop /= 2;
|
||||
|
|
@ -334,7 +328,7 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
|||
}
|
||||
|
||||
/* OK, allocate the object from the current pool */
|
||||
data_ptr = (char *) hdr_ptr; /* point to first data byte in pool... */
|
||||
data_ptr = (char *)hdr_ptr; /* point to first data byte in pool... */
|
||||
data_ptr += sizeof(small_pool_hdr); /* ...by skipping the header... */
|
||||
if ((size_t)data_ptr % ALIGN_SIZE) /* ...and adjust for alignment */
|
||||
data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE;
|
||||
|
|
@ -342,7 +336,7 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
|||
hdr_ptr->bytes_used += sizeofobject;
|
||||
hdr_ptr->bytes_left -= sizeofobject;
|
||||
|
||||
return (void *) data_ptr;
|
||||
return (void *)data_ptr;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -360,10 +354,10 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
|||
*/
|
||||
|
||||
METHODDEF(void *)
|
||||
alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
alloc_large(j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
/* Allocate a "large" object */
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
large_pool_ptr hdr_ptr;
|
||||
char *data_ptr;
|
||||
|
||||
|
|
@ -388,9 +382,9 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
|||
if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS)
|
||||
ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */
|
||||
|
||||
hdr_ptr = (large_pool_ptr) jpeg_get_large(cinfo, sizeofobject +
|
||||
sizeof(large_pool_hdr) +
|
||||
ALIGN_SIZE - 1);
|
||||
hdr_ptr = (large_pool_ptr)jpeg_get_large(cinfo, sizeofobject +
|
||||
sizeof(large_pool_hdr) +
|
||||
ALIGN_SIZE - 1);
|
||||
if (hdr_ptr == NULL)
|
||||
out_of_memory(cinfo, 4); /* jpeg_get_large failed */
|
||||
mem->total_space_allocated += sizeofobject + sizeof(large_pool_hdr) +
|
||||
|
|
@ -405,12 +399,12 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
|||
hdr_ptr->bytes_left = 0;
|
||||
mem->large_list[pool_id] = hdr_ptr;
|
||||
|
||||
data_ptr = (char *) hdr_ptr; /* point to first data byte in pool... */
|
||||
data_ptr = (char *)hdr_ptr; /* point to first data byte in pool... */
|
||||
data_ptr += sizeof(small_pool_hdr); /* ...by skipping the header... */
|
||||
if ((size_t)data_ptr % ALIGN_SIZE) /* ...and adjust for alignment */
|
||||
data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE;
|
||||
|
||||
return (void *) data_ptr;
|
||||
return (void *)data_ptr;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -431,11 +425,11 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
|||
*/
|
||||
|
||||
METHODDEF(JSAMPARRAY)
|
||||
alloc_sarray (j_common_ptr cinfo, int pool_id,
|
||||
JDIMENSION samplesperrow, JDIMENSION numrows)
|
||||
alloc_sarray(j_common_ptr cinfo, int pool_id, JDIMENSION samplesperrow,
|
||||
JDIMENSION numrows)
|
||||
/* Allocate a 2-D sample array */
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
JSAMPARRAY result;
|
||||
JSAMPROW workspace;
|
||||
JDIMENSION rowsperchunk, currow, i;
|
||||
|
|
@ -454,27 +448,27 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
|
|||
sizeof(JSAMPLE));
|
||||
|
||||
/* Calculate max # of rows allowed in one allocation chunk */
|
||||
ltemp = (MAX_ALLOC_CHUNK-sizeof(large_pool_hdr)) /
|
||||
((long) samplesperrow * sizeof(JSAMPLE));
|
||||
ltemp = (MAX_ALLOC_CHUNK - sizeof(large_pool_hdr)) /
|
||||
((long)samplesperrow * sizeof(JSAMPLE));
|
||||
if (ltemp <= 0)
|
||||
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
|
||||
if (ltemp < (long) numrows)
|
||||
rowsperchunk = (JDIMENSION) ltemp;
|
||||
if (ltemp < (long)numrows)
|
||||
rowsperchunk = (JDIMENSION)ltemp;
|
||||
else
|
||||
rowsperchunk = numrows;
|
||||
mem->last_rowsperchunk = rowsperchunk;
|
||||
|
||||
/* Get space for row pointers (small object) */
|
||||
result = (JSAMPARRAY) alloc_small(cinfo, pool_id,
|
||||
(size_t) (numrows * sizeof(JSAMPROW)));
|
||||
result = (JSAMPARRAY)alloc_small(cinfo, pool_id,
|
||||
(size_t)(numrows * sizeof(JSAMPROW)));
|
||||
|
||||
/* Get the rows themselves (large objects) */
|
||||
currow = 0;
|
||||
while (currow < numrows) {
|
||||
rowsperchunk = MIN(rowsperchunk, numrows - currow);
|
||||
workspace = (JSAMPROW) alloc_large(cinfo, pool_id,
|
||||
(size_t) ((size_t) rowsperchunk * (size_t) samplesperrow
|
||||
* sizeof(JSAMPLE)));
|
||||
workspace = (JSAMPROW)alloc_large(cinfo, pool_id,
|
||||
(size_t)((size_t)rowsperchunk * (size_t)samplesperrow *
|
||||
sizeof(JSAMPLE)));
|
||||
for (i = rowsperchunk; i > 0; i--) {
|
||||
result[currow++] = workspace;
|
||||
workspace += samplesperrow;
|
||||
|
|
@ -491,11 +485,11 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
|
|||
*/
|
||||
|
||||
METHODDEF(JBLOCKARRAY)
|
||||
alloc_barray (j_common_ptr cinfo, int pool_id,
|
||||
JDIMENSION blocksperrow, JDIMENSION numrows)
|
||||
alloc_barray(j_common_ptr cinfo, int pool_id, JDIMENSION blocksperrow,
|
||||
JDIMENSION numrows)
|
||||
/* Allocate a 2-D coefficient-block array */
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
JBLOCKARRAY result;
|
||||
JBLOCKROW workspace;
|
||||
JDIMENSION rowsperchunk, currow, i;
|
||||
|
|
@ -506,27 +500,27 @@ alloc_barray (j_common_ptr cinfo, int pool_id,
|
|||
out_of_memory(cinfo, 6); /* safety check */
|
||||
|
||||
/* Calculate max # of rows allowed in one allocation chunk */
|
||||
ltemp = (MAX_ALLOC_CHUNK-sizeof(large_pool_hdr)) /
|
||||
((long) blocksperrow * sizeof(JBLOCK));
|
||||
ltemp = (MAX_ALLOC_CHUNK - sizeof(large_pool_hdr)) /
|
||||
((long)blocksperrow * sizeof(JBLOCK));
|
||||
if (ltemp <= 0)
|
||||
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
|
||||
if (ltemp < (long) numrows)
|
||||
rowsperchunk = (JDIMENSION) ltemp;
|
||||
if (ltemp < (long)numrows)
|
||||
rowsperchunk = (JDIMENSION)ltemp;
|
||||
else
|
||||
rowsperchunk = numrows;
|
||||
mem->last_rowsperchunk = rowsperchunk;
|
||||
|
||||
/* Get space for row pointers (small object) */
|
||||
result = (JBLOCKARRAY) alloc_small(cinfo, pool_id,
|
||||
(size_t) (numrows * sizeof(JBLOCKROW)));
|
||||
result = (JBLOCKARRAY)alloc_small(cinfo, pool_id,
|
||||
(size_t)(numrows * sizeof(JBLOCKROW)));
|
||||
|
||||
/* Get the rows themselves (large objects) */
|
||||
currow = 0;
|
||||
while (currow < numrows) {
|
||||
rowsperchunk = MIN(rowsperchunk, numrows - currow);
|
||||
workspace = (JBLOCKROW) alloc_large(cinfo, pool_id,
|
||||
(size_t) ((size_t) rowsperchunk * (size_t) blocksperrow
|
||||
* sizeof(JBLOCK)));
|
||||
workspace = (JBLOCKROW)alloc_large(cinfo, pool_id,
|
||||
(size_t)((size_t)rowsperchunk * (size_t)blocksperrow *
|
||||
sizeof(JBLOCK)));
|
||||
for (i = rowsperchunk; i > 0; i--) {
|
||||
result[currow++] = workspace;
|
||||
workspace += blocksperrow;
|
||||
|
|
@ -575,12 +569,12 @@ alloc_barray (j_common_ptr cinfo, int pool_id,
|
|||
|
||||
|
||||
METHODDEF(jvirt_sarray_ptr)
|
||||
request_virt_sarray (j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
||||
JDIMENSION samplesperrow, JDIMENSION numrows,
|
||||
JDIMENSION maxaccess)
|
||||
request_virt_sarray(j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
||||
JDIMENSION samplesperrow, JDIMENSION numrows,
|
||||
JDIMENSION maxaccess)
|
||||
/* Request a virtual 2-D sample array */
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
jvirt_sarray_ptr result;
|
||||
|
||||
/* Only IMAGE-lifetime virtual arrays are currently supported */
|
||||
|
|
@ -588,8 +582,8 @@ request_virt_sarray (j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
|||
ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */
|
||||
|
||||
/* get control block */
|
||||
result = (jvirt_sarray_ptr) alloc_small(cinfo, pool_id,
|
||||
sizeof(struct jvirt_sarray_control));
|
||||
result = (jvirt_sarray_ptr)alloc_small(cinfo, pool_id,
|
||||
sizeof(struct jvirt_sarray_control));
|
||||
|
||||
result->mem_buffer = NULL; /* marks array not yet realized */
|
||||
result->rows_in_array = numrows;
|
||||
|
|
@ -605,12 +599,12 @@ request_virt_sarray (j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
|||
|
||||
|
||||
METHODDEF(jvirt_barray_ptr)
|
||||
request_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
||||
JDIMENSION blocksperrow, JDIMENSION numrows,
|
||||
JDIMENSION maxaccess)
|
||||
request_virt_barray(j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
||||
JDIMENSION blocksperrow, JDIMENSION numrows,
|
||||
JDIMENSION maxaccess)
|
||||
/* Request a virtual 2-D coefficient-block array */
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
jvirt_barray_ptr result;
|
||||
|
||||
/* Only IMAGE-lifetime virtual arrays are currently supported */
|
||||
|
|
@ -618,8 +612,8 @@ request_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
|||
ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */
|
||||
|
||||
/* get control block */
|
||||
result = (jvirt_barray_ptr) alloc_small(cinfo, pool_id,
|
||||
sizeof(struct jvirt_barray_control));
|
||||
result = (jvirt_barray_ptr)alloc_small(cinfo, pool_id,
|
||||
sizeof(struct jvirt_barray_control));
|
||||
|
||||
result->mem_buffer = NULL; /* marks array not yet realized */
|
||||
result->rows_in_array = numrows;
|
||||
|
|
@ -635,10 +629,10 @@ request_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
|||
|
||||
|
||||
METHODDEF(void)
|
||||
realize_virt_arrays (j_common_ptr cinfo)
|
||||
realize_virt_arrays(j_common_ptr cinfo)
|
||||
/* Allocate the in-memory buffers for any unrealized virtual arrays */
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
size_t space_per_minheight, maximum_space, avail_mem;
|
||||
size_t minheights, max_minheights;
|
||||
jvirt_sarray_ptr sptr;
|
||||
|
|
@ -652,11 +646,11 @@ realize_virt_arrays (j_common_ptr cinfo)
|
|||
maximum_space = 0;
|
||||
for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
|
||||
if (sptr->mem_buffer == NULL) { /* if not realized yet */
|
||||
size_t new_space = (long) sptr->rows_in_array *
|
||||
(long) sptr->samplesperrow * sizeof(JSAMPLE);
|
||||
size_t new_space = (long)sptr->rows_in_array *
|
||||
(long)sptr->samplesperrow * sizeof(JSAMPLE);
|
||||
|
||||
space_per_minheight += (long) sptr->maxaccess *
|
||||
(long) sptr->samplesperrow * sizeof(JSAMPLE);
|
||||
space_per_minheight += (long)sptr->maxaccess *
|
||||
(long)sptr->samplesperrow * sizeof(JSAMPLE);
|
||||
if (SIZE_MAX - maximum_space < new_space)
|
||||
out_of_memory(cinfo, 10);
|
||||
maximum_space += new_space;
|
||||
|
|
@ -664,11 +658,11 @@ realize_virt_arrays (j_common_ptr cinfo)
|
|||
}
|
||||
for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
|
||||
if (bptr->mem_buffer == NULL) { /* if not realized yet */
|
||||
size_t new_space = (long) bptr->rows_in_array *
|
||||
(long) bptr->blocksperrow * sizeof(JBLOCK);
|
||||
size_t new_space = (long)bptr->rows_in_array *
|
||||
(long)bptr->blocksperrow * sizeof(JBLOCK);
|
||||
|
||||
space_per_minheight += (long) bptr->maxaccess *
|
||||
(long) bptr->blocksperrow * sizeof(JBLOCK);
|
||||
space_per_minheight += (long)bptr->maxaccess *
|
||||
(long)bptr->blocksperrow * sizeof(JBLOCK);
|
||||
if (SIZE_MAX - maximum_space < new_space)
|
||||
out_of_memory(cinfo, 11);
|
||||
maximum_space += new_space;
|
||||
|
|
@ -701,17 +695,17 @@ realize_virt_arrays (j_common_ptr cinfo)
|
|||
|
||||
for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
|
||||
if (sptr->mem_buffer == NULL) { /* if not realized yet */
|
||||
minheights = ((long) sptr->rows_in_array - 1L) / sptr->maxaccess + 1L;
|
||||
minheights = ((long)sptr->rows_in_array - 1L) / sptr->maxaccess + 1L;
|
||||
if (minheights <= max_minheights) {
|
||||
/* This buffer fits in memory */
|
||||
sptr->rows_in_mem = sptr->rows_in_array;
|
||||
} else {
|
||||
/* It doesn't fit in memory, create backing store. */
|
||||
sptr->rows_in_mem = (JDIMENSION) (max_minheights * sptr->maxaccess);
|
||||
jpeg_open_backing_store(cinfo, & sptr->b_s_info,
|
||||
(long) sptr->rows_in_array *
|
||||
(long) sptr->samplesperrow *
|
||||
(long) sizeof(JSAMPLE));
|
||||
sptr->rows_in_mem = (JDIMENSION)(max_minheights * sptr->maxaccess);
|
||||
jpeg_open_backing_store(cinfo, &sptr->b_s_info,
|
||||
(long)sptr->rows_in_array *
|
||||
(long)sptr->samplesperrow *
|
||||
(long)sizeof(JSAMPLE));
|
||||
sptr->b_s_open = TRUE;
|
||||
}
|
||||
sptr->mem_buffer = alloc_sarray(cinfo, JPOOL_IMAGE,
|
||||
|
|
@ -725,17 +719,17 @@ realize_virt_arrays (j_common_ptr cinfo)
|
|||
|
||||
for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
|
||||
if (bptr->mem_buffer == NULL) { /* if not realized yet */
|
||||
minheights = ((long) bptr->rows_in_array - 1L) / bptr->maxaccess + 1L;
|
||||
minheights = ((long)bptr->rows_in_array - 1L) / bptr->maxaccess + 1L;
|
||||
if (minheights <= max_minheights) {
|
||||
/* This buffer fits in memory */
|
||||
bptr->rows_in_mem = bptr->rows_in_array;
|
||||
} else {
|
||||
/* It doesn't fit in memory, create backing store. */
|
||||
bptr->rows_in_mem = (JDIMENSION) (max_minheights * bptr->maxaccess);
|
||||
jpeg_open_backing_store(cinfo, & bptr->b_s_info,
|
||||
(long) bptr->rows_in_array *
|
||||
(long) bptr->blocksperrow *
|
||||
(long) sizeof(JBLOCK));
|
||||
bptr->rows_in_mem = (JDIMENSION)(max_minheights * bptr->maxaccess);
|
||||
jpeg_open_backing_store(cinfo, &bptr->b_s_info,
|
||||
(long)bptr->rows_in_array *
|
||||
(long)bptr->blocksperrow *
|
||||
(long)sizeof(JBLOCK));
|
||||
bptr->b_s_open = TRUE;
|
||||
}
|
||||
bptr->mem_buffer = alloc_barray(cinfo, JPOOL_IMAGE,
|
||||
|
|
@ -750,32 +744,32 @@ realize_virt_arrays (j_common_ptr cinfo)
|
|||
|
||||
|
||||
LOCAL(void)
|
||||
do_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
|
||||
do_sarray_io(j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
|
||||
/* Do backing store read or write of a virtual sample array */
|
||||
{
|
||||
long bytesperrow, file_offset, byte_count, rows, thisrow, i;
|
||||
|
||||
bytesperrow = (long) ptr->samplesperrow * sizeof(JSAMPLE);
|
||||
bytesperrow = (long)ptr->samplesperrow * sizeof(JSAMPLE);
|
||||
file_offset = ptr->cur_start_row * bytesperrow;
|
||||
/* Loop to read or write each allocation chunk in mem_buffer */
|
||||
for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) {
|
||||
for (i = 0; i < (long)ptr->rows_in_mem; i += ptr->rowsperchunk) {
|
||||
/* One chunk, but check for short chunk at end of buffer */
|
||||
rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i);
|
||||
rows = MIN((long)ptr->rowsperchunk, (long)ptr->rows_in_mem - i);
|
||||
/* Transfer no more than is currently defined */
|
||||
thisrow = (long) ptr->cur_start_row + i;
|
||||
rows = MIN(rows, (long) ptr->first_undef_row - thisrow);
|
||||
thisrow = (long)ptr->cur_start_row + i;
|
||||
rows = MIN(rows, (long)ptr->first_undef_row - thisrow);
|
||||
/* Transfer no more than fits in file */
|
||||
rows = MIN(rows, (long) ptr->rows_in_array - thisrow);
|
||||
rows = MIN(rows, (long)ptr->rows_in_array - thisrow);
|
||||
if (rows <= 0) /* this chunk might be past end of file! */
|
||||
break;
|
||||
byte_count = rows * bytesperrow;
|
||||
if (writing)
|
||||
(*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info,
|
||||
(void *) ptr->mem_buffer[i],
|
||||
(*ptr->b_s_info.write_backing_store) (cinfo, &ptr->b_s_info,
|
||||
(void *)ptr->mem_buffer[i],
|
||||
file_offset, byte_count);
|
||||
else
|
||||
(*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info,
|
||||
(void *) ptr->mem_buffer[i],
|
||||
(*ptr->b_s_info.read_backing_store) (cinfo, &ptr->b_s_info,
|
||||
(void *)ptr->mem_buffer[i],
|
||||
file_offset, byte_count);
|
||||
file_offset += byte_count;
|
||||
}
|
||||
|
|
@ -783,32 +777,32 @@ do_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
|
|||
|
||||
|
||||
LOCAL(void)
|
||||
do_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing)
|
||||
do_barray_io(j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing)
|
||||
/* Do backing store read or write of a virtual coefficient-block array */
|
||||
{
|
||||
long bytesperrow, file_offset, byte_count, rows, thisrow, i;
|
||||
|
||||
bytesperrow = (long) ptr->blocksperrow * sizeof(JBLOCK);
|
||||
bytesperrow = (long)ptr->blocksperrow * sizeof(JBLOCK);
|
||||
file_offset = ptr->cur_start_row * bytesperrow;
|
||||
/* Loop to read or write each allocation chunk in mem_buffer */
|
||||
for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) {
|
||||
for (i = 0; i < (long)ptr->rows_in_mem; i += ptr->rowsperchunk) {
|
||||
/* One chunk, but check for short chunk at end of buffer */
|
||||
rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i);
|
||||
rows = MIN((long)ptr->rowsperchunk, (long)ptr->rows_in_mem - i);
|
||||
/* Transfer no more than is currently defined */
|
||||
thisrow = (long) ptr->cur_start_row + i;
|
||||
rows = MIN(rows, (long) ptr->first_undef_row - thisrow);
|
||||
thisrow = (long)ptr->cur_start_row + i;
|
||||
rows = MIN(rows, (long)ptr->first_undef_row - thisrow);
|
||||
/* Transfer no more than fits in file */
|
||||
rows = MIN(rows, (long) ptr->rows_in_array - thisrow);
|
||||
rows = MIN(rows, (long)ptr->rows_in_array - thisrow);
|
||||
if (rows <= 0) /* this chunk might be past end of file! */
|
||||
break;
|
||||
byte_count = rows * bytesperrow;
|
||||
if (writing)
|
||||
(*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info,
|
||||
(void *) ptr->mem_buffer[i],
|
||||
(*ptr->b_s_info.write_backing_store) (cinfo, &ptr->b_s_info,
|
||||
(void *)ptr->mem_buffer[i],
|
||||
file_offset, byte_count);
|
||||
else
|
||||
(*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info,
|
||||
(void *) ptr->mem_buffer[i],
|
||||
(*ptr->b_s_info.read_backing_store) (cinfo, &ptr->b_s_info,
|
||||
(void *)ptr->mem_buffer[i],
|
||||
file_offset, byte_count);
|
||||
file_offset += byte_count;
|
||||
}
|
||||
|
|
@ -816,9 +810,8 @@ do_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing)
|
|||
|
||||
|
||||
METHODDEF(JSAMPARRAY)
|
||||
access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
||||
JDIMENSION start_row, JDIMENSION num_rows,
|
||||
boolean writable)
|
||||
access_virt_sarray(j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
||||
JDIMENSION start_row, JDIMENSION num_rows, boolean writable)
|
||||
/* Access the part of a virtual sample array starting at start_row */
|
||||
/* and extending for num_rows rows. writable is true if */
|
||||
/* caller intends to modify the accessed area. */
|
||||
|
|
@ -833,8 +826,8 @@ access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
|||
|
||||
/* Make the desired part of the virtual array accessible */
|
||||
if (start_row < ptr->cur_start_row ||
|
||||
end_row > ptr->cur_start_row+ptr->rows_in_mem) {
|
||||
if (! ptr->b_s_open)
|
||||
end_row > ptr->cur_start_row + ptr->rows_in_mem) {
|
||||
if (!ptr->b_s_open)
|
||||
ERREXIT(cinfo, JERR_VIRTUAL_BUG);
|
||||
/* Flush old buffer contents if necessary */
|
||||
if (ptr->dirty) {
|
||||
|
|
@ -854,10 +847,10 @@ access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
|||
/* use long arithmetic here to avoid overflow & unsigned problems */
|
||||
long ltemp;
|
||||
|
||||
ltemp = (long) end_row - (long) ptr->rows_in_mem;
|
||||
ltemp = (long)end_row - (long)ptr->rows_in_mem;
|
||||
if (ltemp < 0)
|
||||
ltemp = 0; /* don't fall off front end of file */
|
||||
ptr->cur_start_row = (JDIMENSION) ltemp;
|
||||
ptr->cur_start_row = (JDIMENSION)ltemp;
|
||||
}
|
||||
/* Read in the selected part of the array.
|
||||
* During the initial write pass, we will do no actual read
|
||||
|
|
@ -880,15 +873,15 @@ access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
|||
if (writable)
|
||||
ptr->first_undef_row = end_row;
|
||||
if (ptr->pre_zero) {
|
||||
size_t bytesperrow = (size_t) ptr->samplesperrow * sizeof(JSAMPLE);
|
||||
size_t bytesperrow = (size_t)ptr->samplesperrow * sizeof(JSAMPLE);
|
||||
undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */
|
||||
end_row -= ptr->cur_start_row;
|
||||
while (undef_row < end_row) {
|
||||
jzero_far((void *) ptr->mem_buffer[undef_row], bytesperrow);
|
||||
jzero_far((void *)ptr->mem_buffer[undef_row], bytesperrow);
|
||||
undef_row++;
|
||||
}
|
||||
} else {
|
||||
if (! writable) /* reader looking at undefined data */
|
||||
if (!writable) /* reader looking at undefined data */
|
||||
ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);
|
||||
}
|
||||
}
|
||||
|
|
@ -901,9 +894,8 @@ access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
|||
|
||||
|
||||
METHODDEF(JBLOCKARRAY)
|
||||
access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,
|
||||
JDIMENSION start_row, JDIMENSION num_rows,
|
||||
boolean writable)
|
||||
access_virt_barray(j_common_ptr cinfo, jvirt_barray_ptr ptr,
|
||||
JDIMENSION start_row, JDIMENSION num_rows, boolean writable)
|
||||
/* Access the part of a virtual block array starting at start_row */
|
||||
/* and extending for num_rows rows. writable is true if */
|
||||
/* caller intends to modify the accessed area. */
|
||||
|
|
@ -918,8 +910,8 @@ access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,
|
|||
|
||||
/* Make the desired part of the virtual array accessible */
|
||||
if (start_row < ptr->cur_start_row ||
|
||||
end_row > ptr->cur_start_row+ptr->rows_in_mem) {
|
||||
if (! ptr->b_s_open)
|
||||
end_row > ptr->cur_start_row + ptr->rows_in_mem) {
|
||||
if (!ptr->b_s_open)
|
||||
ERREXIT(cinfo, JERR_VIRTUAL_BUG);
|
||||
/* Flush old buffer contents if necessary */
|
||||
if (ptr->dirty) {
|
||||
|
|
@ -939,10 +931,10 @@ access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,
|
|||
/* use long arithmetic here to avoid overflow & unsigned problems */
|
||||
long ltemp;
|
||||
|
||||
ltemp = (long) end_row - (long) ptr->rows_in_mem;
|
||||
ltemp = (long)end_row - (long)ptr->rows_in_mem;
|
||||
if (ltemp < 0)
|
||||
ltemp = 0; /* don't fall off front end of file */
|
||||
ptr->cur_start_row = (JDIMENSION) ltemp;
|
||||
ptr->cur_start_row = (JDIMENSION)ltemp;
|
||||
}
|
||||
/* Read in the selected part of the array.
|
||||
* During the initial write pass, we will do no actual read
|
||||
|
|
@ -965,15 +957,15 @@ access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,
|
|||
if (writable)
|
||||
ptr->first_undef_row = end_row;
|
||||
if (ptr->pre_zero) {
|
||||
size_t bytesperrow = (size_t) ptr->blocksperrow * sizeof(JBLOCK);
|
||||
size_t bytesperrow = (size_t)ptr->blocksperrow * sizeof(JBLOCK);
|
||||
undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */
|
||||
end_row -= ptr->cur_start_row;
|
||||
while (undef_row < end_row) {
|
||||
jzero_far((void *) ptr->mem_buffer[undef_row], bytesperrow);
|
||||
jzero_far((void *)ptr->mem_buffer[undef_row], bytesperrow);
|
||||
undef_row++;
|
||||
}
|
||||
} else {
|
||||
if (! writable) /* reader looking at undefined data */
|
||||
if (!writable) /* reader looking at undefined data */
|
||||
ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);
|
||||
}
|
||||
}
|
||||
|
|
@ -990,9 +982,9 @@ access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,
|
|||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
free_pool (j_common_ptr cinfo, int pool_id)
|
||||
free_pool(j_common_ptr cinfo, int pool_id)
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
small_pool_ptr shdr_ptr;
|
||||
large_pool_ptr lhdr_ptr;
|
||||
size_t space_freed;
|
||||
|
|
@ -1013,14 +1005,14 @@ free_pool (j_common_ptr cinfo, int pool_id)
|
|||
for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
|
||||
if (sptr->b_s_open) { /* there may be no backing store */
|
||||
sptr->b_s_open = FALSE; /* prevent recursive close if error */
|
||||
(*sptr->b_s_info.close_backing_store) (cinfo, & sptr->b_s_info);
|
||||
(*sptr->b_s_info.close_backing_store) (cinfo, &sptr->b_s_info);
|
||||
}
|
||||
}
|
||||
mem->virt_sarray_list = NULL;
|
||||
for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
|
||||
if (bptr->b_s_open) { /* there may be no backing store */
|
||||
bptr->b_s_open = FALSE; /* prevent recursive close if error */
|
||||
(*bptr->b_s_info.close_backing_store) (cinfo, & bptr->b_s_info);
|
||||
(*bptr->b_s_info.close_backing_store) (cinfo, &bptr->b_s_info);
|
||||
}
|
||||
}
|
||||
mem->virt_barray_list = NULL;
|
||||
|
|
@ -1034,8 +1026,8 @@ free_pool (j_common_ptr cinfo, int pool_id)
|
|||
large_pool_ptr next_lhdr_ptr = lhdr_ptr->next;
|
||||
space_freed = lhdr_ptr->bytes_used +
|
||||
lhdr_ptr->bytes_left +
|
||||
sizeof(large_pool_hdr);
|
||||
jpeg_free_large(cinfo, (void *) lhdr_ptr, space_freed);
|
||||
sizeof(large_pool_hdr) + ALIGN_SIZE - 1;
|
||||
jpeg_free_large(cinfo, (void *)lhdr_ptr, space_freed);
|
||||
mem->total_space_allocated -= space_freed;
|
||||
lhdr_ptr = next_lhdr_ptr;
|
||||
}
|
||||
|
|
@ -1046,10 +1038,9 @@ free_pool (j_common_ptr cinfo, int pool_id)
|
|||
|
||||
while (shdr_ptr != NULL) {
|
||||
small_pool_ptr next_shdr_ptr = shdr_ptr->next;
|
||||
space_freed = shdr_ptr->bytes_used +
|
||||
shdr_ptr->bytes_left +
|
||||
sizeof(small_pool_hdr);
|
||||
jpeg_free_small(cinfo, (void *) shdr_ptr, space_freed);
|
||||
space_freed = shdr_ptr->bytes_used + shdr_ptr->bytes_left +
|
||||
sizeof(small_pool_hdr) + ALIGN_SIZE - 1;
|
||||
jpeg_free_small(cinfo, (void *)shdr_ptr, space_freed);
|
||||
mem->total_space_allocated -= space_freed;
|
||||
shdr_ptr = next_shdr_ptr;
|
||||
}
|
||||
|
|
@ -1062,7 +1053,7 @@ free_pool (j_common_ptr cinfo, int pool_id)
|
|||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
self_destruct (j_common_ptr cinfo)
|
||||
self_destruct(j_common_ptr cinfo)
|
||||
{
|
||||
int pool;
|
||||
|
||||
|
|
@ -1070,12 +1061,12 @@ self_destruct (j_common_ptr cinfo)
|
|||
* Releasing pools in reverse order might help avoid fragmentation
|
||||
* with some (brain-damaged) malloc libraries.
|
||||
*/
|
||||
for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) {
|
||||
for (pool = JPOOL_NUMPOOLS - 1; pool >= JPOOL_PERMANENT; pool--) {
|
||||
free_pool(cinfo, pool);
|
||||
}
|
||||
|
||||
/* Release the memory manager control block too. */
|
||||
jpeg_free_small(cinfo, (void *) cinfo->mem, sizeof(my_memory_mgr));
|
||||
jpeg_free_small(cinfo, (void *)cinfo->mem, sizeof(my_memory_mgr));
|
||||
cinfo->mem = NULL; /* ensures I will be called only once */
|
||||
|
||||
jpeg_mem_term(cinfo); /* system-dependent cleanup */
|
||||
|
|
@ -1088,7 +1079,7 @@ self_destruct (j_common_ptr cinfo)
|
|||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_memory_mgr (j_common_ptr cinfo)
|
||||
jinit_memory_mgr(j_common_ptr cinfo)
|
||||
{
|
||||
my_mem_ptr mem;
|
||||
long max_to_use;
|
||||
|
|
@ -1104,22 +1095,22 @@ jinit_memory_mgr (j_common_ptr cinfo)
|
|||
* in common if and only if X is a power of 2, ie has only one one-bit.
|
||||
* Some compilers may give an "unreachable code" warning here; ignore it.
|
||||
*/
|
||||
if ((ALIGN_SIZE & (ALIGN_SIZE-1)) != 0)
|
||||
if ((ALIGN_SIZE & (ALIGN_SIZE - 1)) != 0)
|
||||
ERREXIT(cinfo, JERR_BAD_ALIGN_TYPE);
|
||||
/* MAX_ALLOC_CHUNK must be representable as type size_t, and must be
|
||||
* a multiple of ALIGN_SIZE.
|
||||
* Again, an "unreachable code" warning may be ignored here.
|
||||
* But a "constant too large" warning means you need to fix MAX_ALLOC_CHUNK.
|
||||
*/
|
||||
test_mac = (size_t) MAX_ALLOC_CHUNK;
|
||||
if ((long) test_mac != MAX_ALLOC_CHUNK ||
|
||||
test_mac = (size_t)MAX_ALLOC_CHUNK;
|
||||
if ((long)test_mac != MAX_ALLOC_CHUNK ||
|
||||
(MAX_ALLOC_CHUNK % ALIGN_SIZE) != 0)
|
||||
ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK);
|
||||
|
||||
max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */
|
||||
|
||||
/* Attempt to allocate memory manager's control block */
|
||||
mem = (my_mem_ptr) jpeg_get_small(cinfo, sizeof(my_memory_mgr));
|
||||
mem = (my_mem_ptr)jpeg_get_small(cinfo, sizeof(my_memory_mgr));
|
||||
|
||||
if (mem == NULL) {
|
||||
jpeg_mem_term(cinfo); /* system-dependent cleanup */
|
||||
|
|
@ -1145,7 +1136,7 @@ jinit_memory_mgr (j_common_ptr cinfo)
|
|||
/* Initialize working state */
|
||||
mem->pub.max_memory_to_use = max_to_use;
|
||||
|
||||
for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) {
|
||||
for (pool = JPOOL_NUMPOOLS - 1; pool >= JPOOL_PERMANENT; pool--) {
|
||||
mem->small_list[pool] = NULL;
|
||||
mem->large_list[pool] = NULL;
|
||||
}
|
||||
|
|
@ -1155,7 +1146,7 @@ jinit_memory_mgr (j_common_ptr cinfo)
|
|||
mem->total_space_allocated = sizeof(my_memory_mgr);
|
||||
|
||||
/* Declare ourselves open for business */
|
||||
cinfo->mem = & mem->pub;
|
||||
cinfo->mem = &mem->pub;
|
||||
|
||||
/* Check for an environment variable JPEGMEM; if found, override the
|
||||
* default max_memory setting from jpeg_mem_init. Note that the
|
||||
|
|
@ -1164,12 +1155,17 @@ jinit_memory_mgr (j_common_ptr cinfo)
|
|||
* this feature.
|
||||
*/
|
||||
#ifndef NO_GETENV
|
||||
{ char *memenv;
|
||||
{
|
||||
char memenv[30] = { 0 };
|
||||
|
||||
if ((memenv = getenv("JPEGMEM")) != NULL) {
|
||||
if (!GETENV_S(memenv, 30, "JPEGMEM") && strlen(memenv) > 0) {
|
||||
char ch = 'x';
|
||||
|
||||
#ifdef _MSC_VER
|
||||
if (sscanf_s(memenv, "%ld%c", &max_to_use, &ch, 1) > 0) {
|
||||
#else
|
||||
if (sscanf(memenv, "%ld%c", &max_to_use, &ch) > 0) {
|
||||
#endif
|
||||
if (ch == 'm' || ch == 'M')
|
||||
max_to_use *= 1000L;
|
||||
mem->pub.max_memory_to_use = max_to_use * 1000L;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue