Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > VSs > VSs__H264__App
comparison libavcodec/utils.c @ 2:897f711a7157
rearrange to work with autoconf
| author | Nina Engelhardt <nengel@mailbox.tu-berlin.de> |
|---|---|
| date | Tue, 25 Sep 2012 15:55:33 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:4c4d1b714878 |
|---|---|
| 1 /* | |
| 2 * utils for libavcodec | |
| 3 * Copyright (c) 2001 Fabrice Bellard | |
| 4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> | |
| 5 * | |
| 6 * This file is part of FFmpeg. | |
| 7 * | |
| 8 * FFmpeg is free software; you can redistribute it and/or | |
| 9 * modify it under the terms of the GNU Lesser General Public | |
| 10 * License as published by the Free Software Foundation; either | |
| 11 * version 2.1 of the License, or (at your option) any later version. | |
| 12 * | |
| 13 * FFmpeg is distributed in the hope that it will be useful, | |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 16 * Lesser General Public License for more details. | |
| 17 * | |
| 18 * You should have received a copy of the GNU Lesser General Public | |
| 19 * License along with FFmpeg; if not, write to the Free Software | |
| 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 21 */ | |
| 22 | |
| 23 /** | |
| 24 * @file | |
| 25 * utils. | |
| 26 */ | |
| 27 | |
| 28 /* needed for mkstemp() */ | |
| 29 #define _XOPEN_SOURCE 600 | |
| 30 | |
| 31 #include "avcodec.h" | |
| 32 #include "dsputil.h" | |
| 33 | |
| 34 #include <stdlib.h> | |
| 35 #include <stdarg.h> | |
| 36 #include <limits.h> | |
| 37 #include <float.h> | |
| 38 //#undef NDEBUG | |
| 39 #include <assert.h> | |
| 40 | |
| 41 #include <fcntl.h> | |
| 42 | |
| 43 void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size) | |
| 44 { | |
| 45 if(min_size < *size) | |
| 46 return ptr; | |
| 47 | |
| 48 *size= FFMAX(17*min_size/16 + 32, min_size); | |
| 49 | |
| 50 ptr= av_realloc(ptr, *size); | |
| 51 if(!ptr) //we could set this to the unmodified min_size but this is safer if the user lost the ptr and uses NULL now | |
| 52 *size= 0; | |
| 53 | |
| 54 return ptr; | |
| 55 } | |
| 56 | |
| 57 void av_fast_malloc(void *ptr, unsigned int *size, unsigned int min_size) | |
| 58 { | |
| 59 void **p = ptr; | |
| 60 if (min_size < *size) | |
| 61 return; | |
| 62 *size= FFMAX(17*min_size/16 + 32, min_size); | |
| 63 av_free(*p); | |
| 64 *p = av_malloc(*size); | |
| 65 if (!*p) *size = 0; | |
| 66 } | |
| 67 | |
| 68 |
