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