4 * Copyright (C) 1992-1996, Thomas G. Lane.
5 * This file is part of the Independent JPEG Group's software.
6 * For conditions of distribution and use, see the accompanying README file.
8 * Copyright (C) 2009-2011, The AROS development team.
10 * This file provides a simple implementation of the system-dependent portion
11 * of the JPEG memory manager using the Amiga API. This implementation
12 * assumes that no backing-store files are needed: all required space
13 * can be obtained from the system.
14 * You'll need to have lots of main memory (or virtual memory) if you want
15 * to process big images.
16 * Note that the max_memory_to_use option is ignored by this implementation.
19 #include <proto/exec.h>
20 #include <exec/memory.h>
21 #include <exec/types.h>
23 static APTR _mempool
= NULL
;
29 #define JPEG_INTERNALS
32 #include "jmemsys.h" /* import the system-dependent declarations */
34 #include <aros/symbolsets.h>
37 jpeg_get_small (j_common_ptr cinfo
, size_t sizeofobject
)
39 return (void *) AllocPooled(_mempool
, sizeofobject
);
43 jpeg_free_small (j_common_ptr cinfo
, void * object
, size_t sizeofobject
)
45 FreePooled(_mempool
, object
, sizeofobject
);
50 * "Large" objects are treated the same as "small" ones.
51 * NB: although we include FAR keywords in the routine declarations,
52 * this file won't actually work in 80x86 small/medium model; at least,
53 * you probably won't be able to process useful-size images in only 64KB.
57 jpeg_get_large (j_common_ptr cinfo
, size_t sizeofobject
)
59 return (void FAR
*) AllocPooled(_mempool
, sizeofobject
);
63 jpeg_free_large (j_common_ptr cinfo
, void FAR
* object
, size_t sizeofobject
)
65 FreePooled(_mempool
, object
, sizeofobject
);
70 * This routine computes the total memory space available for allocation.
71 * Here we always say, "we got all you want bud!"
75 jpeg_mem_available (j_common_ptr cinfo
, long min_bytes_needed
,
76 long max_bytes_needed
, long already_allocated
)
78 long avail
= (long)AvailMem(MEMF_LARGEST
);
80 return max_bytes_needed
> avail
? avail
: max_bytes_needed
;
85 * Backing store (temporary file) management.
86 * Since jpeg_mem_available always promised the moon,
87 * this should never be called and we can just error out.
91 jpeg_open_backing_store (j_common_ptr cinfo
, backing_store_ptr info
,
92 long total_bytes_needed
)
94 ERREXIT(cinfo
, JERR_NO_BACKING_STORE
);
99 * These routines take care of any system-dependent initialization and
104 jpeg_mem_init (j_common_ptr cinfo
)
106 return AvailMem(MEMF_LARGEST
);
110 jpeg_mem_term (j_common_ptr cinfo
)
114 static int JPEG_Init(struct Library
* base
)
116 _mempool
= CreatePool(MEMF_ANY
| MEMF_SEM_PROTECTED
, 65536L, 4096L);
121 static void JPEG_Expunge(struct Library
* base
)
123 DeletePool(_mempool
);
127 ADD2INITLIB(JPEG_Init
, 0);
128 ADD2EXPUNGELIB(JPEG_Expunge
, 0)