Change file names and add a macro to check when the code is inside the playuver

This commit is contained in:
jfmcarreira committed 2014-06-17 10:41:11 +01:00
1 parent 53fc0381a8
commit dda51b20ff
14 files changed
+31 -911

No files matched your search

-144
View File
@@ -1,144 +0,0 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* \file LibMemAlloc.cpp
* \brief memory allocation functions
*/
#include "LibMemAlloc.h"
namespace plaYUVer
{
/*!
************************************************************************
* \brief
* Allocate 1D memory array -> Pel array1D[dim0
*
* \par Output:
* memory size in bytes
************************************************************************/
int get_mem1Dpel( Pel **array1D, int dim0 )
{
if( ( *array1D = ( Pel* )mem_calloc( dim0, sizeof(Pel) ) ) == NULL )
return 0;
return ( sizeof(Pel*) + dim0 * sizeof(Pel) );
}
/*!
************************************************************************
* \brief
* Allocate 2D memory array -> Pel array2D[dim0][dim1]
*
* \par Output:
* memory size in bytes
************************************************************************/
int get_mem2Dpel( Pel ***array2D, int dim0, int dim1 )
{
int i;
if( ( *array2D = ( Pel** )mem_malloc( dim0 * sizeof(Pel*) ) ) == NULL )
return 0;
if( ( *( *array2D ) = ( Pel* )mem_malloc( dim0 * dim1 * sizeof(Pel) ) ) == NULL )
return 0;
for( i = 1; i < dim0; i++ )
{
( *array2D )[i] = ( *array2D )[i - 1] + dim1;
}
return dim0 * ( sizeof(Pel*) + dim1 * sizeof(Pel) );
}
/*!
************************************************************************
* \brief
* Allocate 3D memory array -> Pel array3D[dim0][dim1][dim2]
*
* \par Output:
* memory size in bytes
************************************************************************
*/
int get_mem3Dpel( Pel ****array3D, int dim0, int dim1, int dim2 )
{
int i, mem_size = dim0 * sizeof(Pel**);
if( ( ( *array3D ) = ( Pel*** )malloc( dim0 * sizeof(Pel**) ) ) == NULL )
return 0;
mem_size += get_mem2Dpel( *array3D, dim0 * dim1, dim2 );
for( i = 1; i < dim0; i++ )
( *array3D )[i] = ( *array3D )[i - 1] + dim1;
return mem_size;
}
/*!
************************************************************************
* \brief
* free 1D memory array
* which was allocated with get_mem1Dpel()
************************************************************************
*/
void free_mem1Dpel( Pel *array1D )
{
if( array1D )
{
mem_free( array1D );
}
}
/*!
************************************************************************
* \brief
* free 2D memory array
* which was allocated with get_mem2Dpel()
************************************************************************
*/
void free_mem2Dpel( Pel **array2D )
{
if( array2D )
{
if( *array2D )
mem_free( *array2D );
mem_free( array2D );
}
}
/*!
************************************************************************
* \brief
* free 3D memory array
* which was allocated with get_mem3Dpel()
************************************************************************
*/
void free_mem3Dpel( Pel ***array3D )
{
if( array3D )
{
free_mem2Dpel( *array3D );
mem_free( array3D );
}
}
} // NAMESPACE
-78
View File
@@ -1,78 +0,0 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* \file LibMemAlloc.h
* \brief memory allocation functions
*/
#ifndef __LIBMEMALLOC_H__
#define __LIBMEMALLOC_H__
#include "config.h"
#include "PlaYUVerDefs.h"
#include <cstdlib>
#include <cstring>
namespace plaYUVer
{
extern int get_mem1Dpel( Pel **array2D, int dim0 );
extern int get_mem2Dpel( Pel ***array2D, int dim0, int dim1 );
extern int get_mem3Dpel( Pel ****array3D, int dim0, int dim1, int dim2 );
extern void free_mem1Dpel( Pel *array1D );
extern void free_mem2Dpel( Pel **array2D );
extern void free_mem3Dpel( Pel ***array3D );
/*!
************************************************************************
* \brief
* allocate and set memory aligned at SSE_MEMORY_ALIGNMENT
*
************************************************************************/
static inline void* mem_malloc( size_t nitems )
{
void *d;
if( ( d = malloc( nitems ) ) == NULL )
{
return NULL;
}
return d;
}
static inline void* mem_calloc( size_t nitems, size_t size )
{
size_t padded_size = nitems * size;
void *d = mem_malloc( padded_size );
memset( d, 0, ( int )padded_size );
return d;
}
static inline void mem_free( void *ptr )
{
if( ptr != NULL )
{
free( ptr );
ptr = NULL;
}
}
} // NAMESPACE
#endif // __LIBMEMALLOC_H__␍
+21
View File
@@ -49,6 +49,27 @@ typedef long long Int64;
typedef unsigned long long UInt64;
#endif
static inline void* mem_malloc( size_t nitems )
{
void *d;
if( ( d = malloc( nitems ) ) == NULL )
{
return NULL;
}
return d;
}
static inline void mem_free( void *ptr )
{
if( ptr != NULL )
{
free( ptr );
ptr = NULL;
}
}
static inline Void* xMallocMem( SizeT nitems )
{
Void *d;
+1 -1
View File
@@ -25,7 +25,7 @@
#ifndef __TYPEDEF_H__
#define __TYPEDEF_H__
#ifndef __MAKE_LIB__
#ifdef PLAYUVER
#include "config.h"
#endif
#include <string>
-1
View File
@@ -24,7 +24,6 @@
#include <cstdio>
#include "PlaYUVerFrame.h"
#include "LibMemAlloc.h"
#include "LibMemory.h"
namespace plaYUVer
+2
View File
@@ -25,7 +25,9 @@
#ifndef __PLAYUVERFRAME_H__
#define __PLAYUVERFRAME_H__
#ifdef PLAYUVER
#include "config.h"
#endif
#include "PlaYUVerDefs.h"
#include <iostream>
#include <cstdio>