00001 00002 /*! 00003 ************************************************************************ 00004 * \file nalucommon.c 00005 * 00006 * \brief 00007 * Common NALU support functions 00008 * 00009 * \author 00010 * Main contributors (see contributors.h for copyright, address and affiliation details) 00011 * - Stephan Wenger <stewe@cs.tu-berlin.de> 00012 ************************************************************************ 00013 */ 00014 00015 #include "global.h" 00016 #include "nalu.h" 00017 00018 00019 /*! 00020 ************************************************************************************* 00021 * \brief 00022 * Allocates memory for a NALU 00023 * 00024 * \param buffersize 00025 * size of NALU buffer 00026 * 00027 * \return 00028 * pointer to a NALU 00029 ************************************************************************************* 00030 */ 00031 NALU_t *AllocNALU(int buffersize) 00032 { 00033 NALU_t *n; 00034 00035 if ((n = (NALU_t*)calloc (1, sizeof (NALU_t))) == NULL) 00036 no_mem_exit ("AllocNALU: n"); 00037 00038 n->max_size=buffersize; 00039 00040 if ((n->buf = (byte*)calloc (buffersize, sizeof (byte))) == NULL) 00041 { 00042 free (n); 00043 no_mem_exit ("AllocNALU: n->buf"); 00044 } 00045 00046 return n; 00047 } 00048 00049 00050 /*! 00051 ************************************************************************************* 00052 * \brief 00053 * Frees a NALU 00054 * 00055 * \param n 00056 * NALU to be freed 00057 * 00058 ************************************************************************************* 00059 */ 00060 void FreeNALU(NALU_t *n) 00061 { 00062 if (n != NULL) 00063 { 00064 if (n->buf != NULL) 00065 { 00066 free(n->buf); 00067 n->buf=NULL; 00068 } 00069 free (n); 00070 } 00071 }