1 2 /*! 3 ************************************************************************ 4 * \file nalucommon.c 5 * 6 * \brief 7 * Common NALU support functions 8 * 9 * \author 10 * Main contributors (see contributors.h for copyright, address and affiliation details) 11 * - Stephan Wenger <stewe@cs.tu-berlin.de> 12 ************************************************************************ 13 */ 14 15 #include "global.h" 16 #include "nalucommon.h" 17 #include "memalloc.h" 18 19 /*! 20 ************************************************************************************* 21 * \brief 22 * Allocates memory for a NALU 23 * 24 * \param buffersize 25 * size of NALU buffer 26 * 27 * \return 28 * pointer to a NALU 29 ************************************************************************************* 30 */ AllocNALU(int buffersize)31NALU_t *AllocNALU(int buffersize) 32 { 33 NALU_t *n; 34 35 if ((n = (NALU_t*)calloc (1, sizeof (NALU_t))) == NULL) 36 no_mem_exit ("AllocNALU: n"); 37 38 n->max_size=buffersize; 39 if ((n->buf = (byte*)calloc (buffersize, sizeof (byte))) == NULL) 40 { 41 free (n); 42 no_mem_exit ("AllocNALU: n->buf"); 43 } 44 45 return n; 46 } 47 48 49 /*! 50 ************************************************************************************* 51 * \brief 52 * Frees a NALU 53 * 54 * \param n 55 * NALU to be freed 56 * 57 ************************************************************************************* 58 */ FreeNALU(NALU_t * n)59void FreeNALU(NALU_t *n) 60 { 61 if (n != NULL) 62 { 63 if (n->buf != NULL) 64 { 65 free(n->buf); 66 n->buf=NULL; 67 } 68 free (n); 69 } 70 } 71