media/libvpx/vpx_mem/vpx_mem.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libvpx/vpx_mem/vpx_mem.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,173 @@
     1.4 +/*
     1.5 + *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
     1.6 + *
     1.7 + *  Use of this source code is governed by a BSD-style license
     1.8 + *  that can be found in the LICENSE file in the root of the source
     1.9 + *  tree. An additional intellectual property rights grant can be found
    1.10 + *  in the file PATENTS.  All contributing project authors may
    1.11 + *  be found in the AUTHORS file in the root of the source tree.
    1.12 + */
    1.13 +
    1.14 +
    1.15 +#ifndef __VPX_MEM_H__
    1.16 +#define __VPX_MEM_H__
    1.17 +
    1.18 +#include "vpx_config.h"
    1.19 +#if defined(__uClinux__)
    1.20 +# include <lddk.h>
    1.21 +#endif
    1.22 +
    1.23 +/* vpx_mem version info */
    1.24 +#define vpx_mem_version "2.2.1.5"
    1.25 +
    1.26 +#define VPX_MEM_VERSION_CHIEF 2
    1.27 +#define VPX_MEM_VERSION_MAJOR 2
    1.28 +#define VPX_MEM_VERSION_MINOR 1
    1.29 +#define VPX_MEM_VERSION_PATCH 5
    1.30 +/* end - vpx_mem version info */
    1.31 +
    1.32 +#ifndef VPX_TRACK_MEM_USAGE
    1.33 +# define VPX_TRACK_MEM_USAGE       0  /* enable memory tracking/integrity checks */
    1.34 +#endif
    1.35 +#ifndef VPX_CHECK_MEM_FUNCTIONS
    1.36 +# define VPX_CHECK_MEM_FUNCTIONS   0  /* enable basic safety checks in _memcpy,
    1.37 +_memset, and _memmove */
    1.38 +#endif
    1.39 +#ifndef REPLACE_BUILTIN_FUNCTIONS
    1.40 +# define REPLACE_BUILTIN_FUNCTIONS 0  /* replace builtin functions with their
    1.41 +vpx_ equivalents */
    1.42 +#endif
    1.43 +
    1.44 +#include <stdlib.h>
    1.45 +#include <stddef.h>
    1.46 +
    1.47 +#if defined(__cplusplus)
    1.48 +extern "C" {
    1.49 +#endif
    1.50 +
    1.51 +  /*
    1.52 +      vpx_mem_get_version()
    1.53 +      provided for runtime version checking. Returns an unsigned int of the form
    1.54 +      CHIEF | MAJOR | MINOR | PATCH, where the chief version number is the high
    1.55 +      order byte.
    1.56 +  */
    1.57 +  unsigned int vpx_mem_get_version(void);
    1.58 +
    1.59 +  /*
    1.60 +      vpx_mem_set_heap_size(size_t size)
    1.61 +        size - size in bytes for the memory manager to allocate for its heap
    1.62 +      Sets the memory manager's initial heap size
    1.63 +      Return:
    1.64 +        0: on success
    1.65 +        -1: if memory manager calls have not been included in the vpx_mem lib
    1.66 +        -2: if the memory manager has been compiled to use static memory
    1.67 +        -3: if the memory manager has already allocated its heap
    1.68 +  */
    1.69 +  int vpx_mem_set_heap_size(size_t size);
    1.70 +
    1.71 +  void *vpx_memalign(size_t align, size_t size);
    1.72 +  void *vpx_malloc(size_t size);
    1.73 +  void *vpx_calloc(size_t num, size_t size);
    1.74 +  void *vpx_realloc(void *memblk, size_t size);
    1.75 +  void vpx_free(void *memblk);
    1.76 +
    1.77 +  void *vpx_memcpy(void *dest, const void *src, size_t length);
    1.78 +  void *vpx_memset(void *dest, int val, size_t length);
    1.79 +  void *vpx_memmove(void *dest, const void *src, size_t count);
    1.80 +
    1.81 +  /* special memory functions */
    1.82 +  void *vpx_mem_alloc(int id, size_t size, size_t align);
    1.83 +  void vpx_mem_free(int id, void *mem, size_t size);
    1.84 +
    1.85 +  /* Wrappers to standard library functions. */
    1.86 +  typedef void *(* g_malloc_func)(size_t);
    1.87 +  typedef void *(* g_calloc_func)(size_t, size_t);
    1.88 +  typedef void *(* g_realloc_func)(void *, size_t);
    1.89 +  typedef void (* g_free_func)(void *);
    1.90 +  typedef void *(* g_memcpy_func)(void *, const void *, size_t);
    1.91 +  typedef void *(* g_memset_func)(void *, int, size_t);
    1.92 +  typedef void *(* g_memmove_func)(void *, const void *, size_t);
    1.93 +
    1.94 +  int vpx_mem_set_functions(g_malloc_func g_malloc_l
    1.95 +, g_calloc_func g_calloc_l
    1.96 +, g_realloc_func g_realloc_l
    1.97 +, g_free_func g_free_l
    1.98 +, g_memcpy_func g_memcpy_l
    1.99 +, g_memset_func g_memset_l
   1.100 +, g_memmove_func g_memmove_l);
   1.101 +  int vpx_mem_unset_functions(void);
   1.102 +
   1.103 +
   1.104 +  /* some defines for backward compatibility */
   1.105 +#define DMEM_GENERAL 0
   1.106 +
   1.107 +// (*)<
   1.108 +
   1.109 +#if REPLACE_BUILTIN_FUNCTIONS
   1.110 +# ifndef __VPX_MEM_C__
   1.111 +#  define memalign vpx_memalign
   1.112 +#  define malloc   vpx_malloc
   1.113 +#  define calloc   vpx_calloc
   1.114 +#  define realloc  vpx_realloc
   1.115 +#  define free     vpx_free
   1.116 +#  define memcpy   vpx_memcpy
   1.117 +#  define memmove  vpx_memmove
   1.118 +#  define memset   vpx_memset
   1.119 +# endif
   1.120 +#endif
   1.121 +
   1.122 +#if CONFIG_MEM_TRACKER
   1.123 +#include <stdarg.h>
   1.124 +  /*from vpx_mem/vpx_mem_tracker.c*/
   1.125 +  extern void vpx_memory_tracker_dump();
   1.126 +  extern void vpx_memory_tracker_check_integrity(char *file, unsigned int line);
   1.127 +  extern int vpx_memory_tracker_set_log_type(int type, char *option);
   1.128 +  extern int vpx_memory_tracker_set_log_func(void *userdata,
   1.129 +                                             void(*logfunc)(void *userdata,
   1.130 +                                                            const char *fmt, va_list args));
   1.131 +# ifndef __VPX_MEM_C__
   1.132 +#  define vpx_memalign(align, size) xvpx_memalign((align), (size), __FILE__, __LINE__)
   1.133 +#  define vpx_malloc(size)          xvpx_malloc((size), __FILE__, __LINE__)
   1.134 +#  define vpx_calloc(num, size)     xvpx_calloc(num, size, __FILE__, __LINE__)
   1.135 +#  define vpx_realloc(addr, size)   xvpx_realloc(addr, size, __FILE__, __LINE__)
   1.136 +#  define vpx_free(addr)            xvpx_free(addr, __FILE__, __LINE__)
   1.137 +#  define vpx_memory_tracker_check_integrity() vpx_memory_tracker_check_integrity(__FILE__, __LINE__)
   1.138 +#  define vpx_mem_alloc(id,size,align) xvpx_mem_alloc(id, size, align, __FILE__, __LINE__)
   1.139 +#  define vpx_mem_free(id,mem,size) xvpx_mem_free(id, mem, size, __FILE__, __LINE__)
   1.140 +# endif
   1.141 +
   1.142 +  void *xvpx_memalign(size_t align, size_t size, char *file, int line);
   1.143 +  void *xvpx_malloc(size_t size, char *file, int line);
   1.144 +  void *xvpx_calloc(size_t num, size_t size, char *file, int line);
   1.145 +  void *xvpx_realloc(void *memblk, size_t size, char *file, int line);
   1.146 +  void xvpx_free(void *memblk, char *file, int line);
   1.147 +  void *xvpx_mem_alloc(int id, size_t size, size_t align, char *file, int line);
   1.148 +  void xvpx_mem_free(int id, void *mem, size_t size, char *file, int line);
   1.149 +
   1.150 +#else
   1.151 +# ifndef __VPX_MEM_C__
   1.152 +#  define vpx_memory_tracker_dump()
   1.153 +#  define vpx_memory_tracker_check_integrity()
   1.154 +#  define vpx_memory_tracker_set_log_type(t,o) 0
   1.155 +#  define vpx_memory_tracker_set_log_func(u,f) 0
   1.156 +# endif
   1.157 +#endif
   1.158 +
   1.159 +#if !VPX_CHECK_MEM_FUNCTIONS
   1.160 +# ifndef __VPX_MEM_C__
   1.161 +#  include <string.h>
   1.162 +#  define vpx_memcpy  memcpy
   1.163 +#  define vpx_memset  memset
   1.164 +#  define vpx_memmove memmove
   1.165 +# endif
   1.166 +#endif
   1.167 +
   1.168 +#ifdef VPX_MEM_PLTFRM
   1.169 +# include VPX_MEM_PLTFRM
   1.170 +#endif
   1.171 +
   1.172 +#if defined(__cplusplus)
   1.173 +}
   1.174 +#endif
   1.175 +
   1.176 +#endif /* __VPX_MEM_H__ */

mercurial