revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / jpeg / jmemamiga.c
blob3cd35aa5183b5aa110b92f7e5b5674e910c339c9
1 /*
2 * jmemamiga.c
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;
25 #if defined(__AROS__)
26 #undef GLOBAL
27 #endif
29 #define JPEG_INTERNALS
30 #include "jinclude.h"
31 #include "jpeglib.h"
32 #include "jmemsys.h" /* import the system-dependent declarations */
34 #include <aros/symbolsets.h>
36 GLOBAL(void *)
37 jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)
39 return (void *) AllocPooled(_mempool, sizeofobject);
42 GLOBAL(void)
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.
56 GLOBAL(void FAR *)
57 jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)
59 return (void FAR *) AllocPooled(_mempool, sizeofobject);
62 GLOBAL(void)
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!"
74 GLOBAL(long)
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.
90 GLOBAL(void)
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
100 * cleanup required.
103 GLOBAL(long)
104 jpeg_mem_init (j_common_ptr cinfo)
106 return AvailMem(MEMF_LARGEST);
109 GLOBAL(void)
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);
118 return 1;
121 static void JPEG_Expunge(struct Library * base)
123 DeletePool(_mempool);
124 _mempool = NULL;
127 ADD2INITLIB(JPEG_Init, 0);
128 ADD2EXPUNGELIB(JPEG_Expunge, 0)