Merge "vp8 encoder: remove vp8_yv12_copy_partial_frame_neon"
[aom.git] / vpx_mem / vpx_mem.h
blobe2391f49629dedb06326ef00094ae16afdb082e4
1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
12 #ifndef VPX_MEM_VPX_MEM_H_
13 #define VPX_MEM_VPX_MEM_H_
15 #include "vpx_config.h"
16 #if defined(__uClinux__)
17 # include <lddk.h>
18 #endif
20 /* vpx_mem version info */
21 #define vpx_mem_version "2.2.1.5"
23 #define VPX_MEM_VERSION_CHIEF 2
24 #define VPX_MEM_VERSION_MAJOR 2
25 #define VPX_MEM_VERSION_MINOR 1
26 #define VPX_MEM_VERSION_PATCH 5
27 /* end - vpx_mem version info */
29 #ifndef VPX_TRACK_MEM_USAGE
30 # define VPX_TRACK_MEM_USAGE 0 /* enable memory tracking/integrity checks */
31 #endif
32 #ifndef VPX_CHECK_MEM_FUNCTIONS
33 # define VPX_CHECK_MEM_FUNCTIONS 0 /* enable basic safety checks in _memcpy,
34 _memset, and _memmove */
35 #endif
36 #ifndef REPLACE_BUILTIN_FUNCTIONS
37 # define REPLACE_BUILTIN_FUNCTIONS 0 /* replace builtin functions with their
38 vpx_ equivalents */
39 #endif
41 #include <stdlib.h>
42 #include <stddef.h>
44 #if defined(__cplusplus)
45 extern "C" {
46 #endif
49 vpx_mem_get_version()
50 provided for runtime version checking. Returns an unsigned int of the form
51 CHIEF | MAJOR | MINOR | PATCH, where the chief version number is the high
52 order byte.
54 unsigned int vpx_mem_get_version(void);
57 vpx_mem_set_heap_size(size_t size)
58 size - size in bytes for the memory manager to allocate for its heap
59 Sets the memory manager's initial heap size
60 Return:
61 0: on success
62 -1: if memory manager calls have not been included in the vpx_mem lib
63 -2: if the memory manager has been compiled to use static memory
64 -3: if the memory manager has already allocated its heap
66 int vpx_mem_set_heap_size(size_t size);
68 void *vpx_memalign(size_t align, size_t size);
69 void *vpx_malloc(size_t size);
70 void *vpx_calloc(size_t num, size_t size);
71 void *vpx_realloc(void *memblk, size_t size);
72 void vpx_free(void *memblk);
74 void *vpx_memcpy(void *dest, const void *src, size_t length);
75 void *vpx_memset(void *dest, int val, size_t length);
76 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH
77 void *vpx_memset16(void *dest, int val, size_t length);
78 #endif
79 void *vpx_memmove(void *dest, const void *src, size_t count);
81 /* special memory functions */
82 void *vpx_mem_alloc(int id, size_t size, size_t align);
83 void vpx_mem_free(int id, void *mem, size_t size);
85 /* Wrappers to standard library functions. */
86 typedef void *(* g_malloc_func)(size_t);
87 typedef void *(* g_calloc_func)(size_t, size_t);
88 typedef void *(* g_realloc_func)(void *, size_t);
89 typedef void (* g_free_func)(void *);
90 typedef void *(* g_memcpy_func)(void *, const void *, size_t);
91 typedef void *(* g_memset_func)(void *, int, size_t);
92 typedef void *(* g_memmove_func)(void *, const void *, size_t);
94 int vpx_mem_set_functions(g_malloc_func g_malloc_l
95 , g_calloc_func g_calloc_l
96 , g_realloc_func g_realloc_l
97 , g_free_func g_free_l
98 , g_memcpy_func g_memcpy_l
99 , g_memset_func g_memset_l
100 , g_memmove_func g_memmove_l);
101 int vpx_mem_unset_functions(void);
104 /* some defines for backward compatibility */
105 #define DMEM_GENERAL 0
107 // (*)<
109 #if REPLACE_BUILTIN_FUNCTIONS
110 # ifndef __VPX_MEM_C__
111 # define memalign vpx_memalign
112 # define malloc vpx_malloc
113 # define calloc vpx_calloc
114 # define realloc vpx_realloc
115 # define free vpx_free
116 # define memcpy vpx_memcpy
117 # define memmove vpx_memmove
118 # define memset vpx_memset
119 # endif
120 #endif
122 #if CONFIG_MEM_TRACKER
123 #include <stdarg.h>
124 /*from vpx_mem/vpx_mem_tracker.c*/
125 extern void vpx_memory_tracker_dump();
126 extern void vpx_memory_tracker_check_integrity(char *file, unsigned int line);
127 extern int vpx_memory_tracker_set_log_type(int type, char *option);
128 extern int vpx_memory_tracker_set_log_func(void *userdata,
129 void(*logfunc)(void *userdata,
130 const char *fmt, va_list args));
131 # ifndef __VPX_MEM_C__
132 # define vpx_memalign(align, size) xvpx_memalign((align), (size), __FILE__, __LINE__)
133 # define vpx_malloc(size) xvpx_malloc((size), __FILE__, __LINE__)
134 # define vpx_calloc(num, size) xvpx_calloc(num, size, __FILE__, __LINE__)
135 # define vpx_realloc(addr, size) xvpx_realloc(addr, size, __FILE__, __LINE__)
136 # define vpx_free(addr) xvpx_free(addr, __FILE__, __LINE__)
137 # define vpx_memory_tracker_check_integrity() vpx_memory_tracker_check_integrity(__FILE__, __LINE__)
138 # define vpx_mem_alloc(id,size,align) xvpx_mem_alloc(id, size, align, __FILE__, __LINE__)
139 # define vpx_mem_free(id,mem,size) xvpx_mem_free(id, mem, size, __FILE__, __LINE__)
140 # endif
142 void *xvpx_memalign(size_t align, size_t size, char *file, int line);
143 void *xvpx_malloc(size_t size, char *file, int line);
144 void *xvpx_calloc(size_t num, size_t size, char *file, int line);
145 void *xvpx_realloc(void *memblk, size_t size, char *file, int line);
146 void xvpx_free(void *memblk, char *file, int line);
147 void *xvpx_mem_alloc(int id, size_t size, size_t align, char *file, int line);
148 void xvpx_mem_free(int id, void *mem, size_t size, char *file, int line);
150 #else
151 # ifndef __VPX_MEM_C__
152 # define vpx_memory_tracker_dump()
153 # define vpx_memory_tracker_check_integrity()
154 # define vpx_memory_tracker_set_log_type(t,o) 0
155 # define vpx_memory_tracker_set_log_func(u,f) 0
156 # endif
157 #endif
159 #if !VPX_CHECK_MEM_FUNCTIONS
160 # ifndef __VPX_MEM_C__
161 # include <string.h>
162 # define vpx_memcpy memcpy
163 # define vpx_memset memset
164 # define vpx_memmove memmove
165 # endif
166 #endif
168 #ifdef VPX_MEM_PLTFRM
169 # include VPX_MEM_PLTFRM
170 #endif
172 #if defined(__cplusplus)
174 #endif
176 #endif // VPX_MEM_VPX_MEM_H_