libbpg-0.9.6

This commit is contained in:
King_DuckZ 2015-10-27 11:46:00 +01:00
parent 3035b41edf
commit 35a8402710
248 changed files with 232891 additions and 100 deletions

View file

@ -0,0 +1 @@
add_library(PPA ppa.h ppaApi.h ppa.cpp ../cpuEvents.h)

View file

@ -0,0 +1,147 @@
/*****************************************************************************
* Copyright (C) 2013 x265 project
*
* Authors: Steve Borho <steve@borho.org>
*
* 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 02111, USA.
*
* This program is also available under a commercial proprietary license.
* For more information, contact us at license @ x265.com.
*****************************************************************************/
#if defined(ENABLE_PPA)
#include "ppa.h"
#include <stdlib.h>
#define PPA_REGISTER_CPU_EVENT2GROUP(x, y) # x, # y,
#define CPU_EVENT(x) PPA_REGISTER_CPU_EVENT2GROUP(x, NoGroup)
const char *PPACpuAndGroup[] =
{
#include "../cpuEvents.h"
""
};
#undef CPU_EVENT
#undef PPA_REGISTER_CPU_EVENT2GROUP
extern "C" {
typedef ppa::Base *(FUNC_PPALibInit)(const char **, int);
typedef void (FUNC_PPALibRelease)(ppa::Base* &);
}
using namespace ppa;
static FUNC_PPALibRelease *_pfuncPpaRelease;
ppa::Base *ppa::ppabase;
static void _ppaReleaseAtExit()
{
_pfuncPpaRelease(ppabase);
}
#ifdef _WIN32
#include <windows.h>
#if defined(_M_X64) || defined(__x86_64__) || defined(__amd64__)
# ifdef UNICODE
# define PPA_DLL_NAME L"ppa64.dll"
# else
# define PPA_DLL_NAME "ppa64.dll"
# endif
#else
# ifdef UNICODE
# define PPA_DLL_NAME L"ppa.dll"
# else
# define PPA_DLL_NAME "ppa.dll"
# endif
#endif // if defined(_M_X64) || defined(__x86_64__) || defined(__amd64__)
void initializePPA(void)
{
if (ppabase)
return;
HMODULE _ppaLibHandle = LoadLibrary(PPA_DLL_NAME);
if (!_ppaLibHandle)
return;
FUNC_PPALibInit *_pfuncPpaInit = (FUNC_PPALibInit*)GetProcAddress(_ppaLibHandle, "InitPpaUtil");
_pfuncPpaRelease = (FUNC_PPALibRelease*)GetProcAddress(_ppaLibHandle, "DeletePpa");
if (!_pfuncPpaInit || !_pfuncPpaRelease)
{
FreeLibrary(_ppaLibHandle);
return;
}
ppabase = _pfuncPpaInit(PPACpuAndGroup, PPACpuGroupNums);
if (!ppabase)
{
FreeLibrary(_ppaLibHandle);
return;
}
atexit(_ppaReleaseAtExit);
}
#else /* linux & unix & cygwin */
#include <dlfcn.h>
#include <stdio.h>
#if defined(_M_X64) || defined(__x86_64__) || defined(__amd64__)
# define PPA_LIB_NAME "libppa64.so"
#else
# define PPA_LIB_NAME "libppa.so"
#endif
void initializePPA(void)
{
if (ppabase)
{
printf("PPA: already initialized\n");
return;
}
void *_ppaDllHandle = dlopen(PPA_LIB_NAME, RTLD_LAZY);
if (!_ppaDllHandle)
{
printf("PPA: Unable to load %s\n", PPA_LIB_NAME);
return;
}
FUNC_PPALibInit *_pfuncPpaInit = (FUNC_PPALibInit*)dlsym(_ppaDllHandle, "InitPpaUtil");
_pfuncPpaRelease = (FUNC_PPALibRelease*)dlsym(_ppaDllHandle, "DeletePpa");
if (!_pfuncPpaInit || !_pfuncPpaRelease)
{
printf("PPA: Function bindings failed\n");
dlclose(_ppaDllHandle);
return;
}
ppabase = _pfuncPpaInit(PPACpuAndGroup, PPACpuGroupNums);
if (!ppabase)
{
printf("PPA: Init failed\n");
dlclose(_ppaDllHandle);
return;
}
atexit(_ppaReleaseAtExit);
}
#endif /* !_WIN32 */
#endif /* defined(ENABLE_PPA) */

View file

@ -0,0 +1,43 @@
/*****************************************************************************
* Copyright (C) 2013 x265 project
*
* Authors: Steve Borho <steve@borho.org>
*
* 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 02111, USA.
*
* This program is also available under a commercial proprietary license.
* For more information, contact us at license @ x265.com.
*****************************************************************************/
#ifndef PPA_H
#define PPA_H
/* declare enum list of users CPU events */
#define CPU_EVENT(x) x,
enum PPACpuEventEnum
{
#include "../cpuEvents.h"
PPACpuGroupNums
};
#undef CPU_EVENT
#include "ppaApi.h"
void initializePPA();
#define PPA_INIT() initializePPA()
#define PPAScopeEvent(e) ppa::ProfileScope ppaScope_(e)
#endif /* PPA_H */

View file

@ -0,0 +1,70 @@
/*****************************************************************************
* Copyright (C) 2013 x265 project
*
* Authors: Steve Borho <steve@borho.org>
*
* 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 02111, USA.
*
* This program is also available under a commercial proprietary license.
* For more information, contact us at license @ x265.com.
*****************************************************************************/
#ifndef _PPA_API_H_
#define _PPA_API_H_
namespace ppa {
// PPA private namespace
typedef unsigned short EventID;
typedef unsigned char GroupID;
class Base
{
public:
virtual ~Base() {}
virtual bool isEventFiltered(EventID eventId) const = 0;
virtual bool configEventById(EventID eventId, bool filtered) const = 0;
virtual int configGroupById(GroupID groupId, bool filtered) const = 0;
virtual void configAllEvents(bool filtered) const = 0;
virtual EventID registerEventByName(const char *pEventName) = 0;
virtual GroupID registerGroupByName(const char *pGroupName) = 0;
virtual EventID registerEventInGroup(const char *pEventName, GroupID groupId) = 0;
virtual void triggerStartEvent(EventID eventId) = 0;
virtual void triggerEndEvent(EventID eventId) = 0;
virtual void triggerTidEvent(EventID eventId, unsigned int data) = 0;
virtual void triggerDebugEvent(EventID eventId, unsigned int data0, unsigned int data1) = 0;
virtual EventID getEventId(int index) const = 0;
protected:
virtual void init(const char **pNames, int eventCount) = 0;
};
extern ppa::Base *ppabase;
struct ProfileScope
{
ppa::EventID id;
ProfileScope(int e) { if (ppabase) { id = ppabase->getEventId(e); ppabase->triggerStartEvent(id); } else id = 0; }
~ProfileScope() { if (ppabase) ppabase->triggerEndEvent(id); }
};
}
#endif //_PPA_API_H_