整理代码
This commit is contained in:
commit
c7b4e178ec
364 changed files with 59691 additions and 0 deletions
61
video/core/CodecCapabilityManager.cpp
Normal file
61
video/core/CodecCapabilityManager.cpp
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* INCLUDE
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "CodecCapabilityManager.h"
|
||||
|
||||
namespace Video
|
||||
{
|
||||
namespace Core
|
||||
{
|
||||
/*
|
||||
*******************************************************************************
|
||||
* CLASS DEFINE
|
||||
*******************************************************************************
|
||||
*/
|
||||
const int CodecCapabilityManager::INVALID_HANDLE = -1;
|
||||
|
||||
CodecCapabilityManager::CodecCapabilityManager(uint64_t total): _total(total), _handles(1024)
|
||||
{
|
||||
}
|
||||
|
||||
CodecCapabilityManager::Handle CodecCapabilityManager::alloc(uint32_t width, uint32_t height, uint32_t frameRate)
|
||||
{
|
||||
uint64_t v = width * height * frameRate;
|
||||
Poco::FastMutex::ScopedLock lock(_lock);
|
||||
if (v <= _total)
|
||||
{
|
||||
try
|
||||
{
|
||||
Handle h = _handles.allocHandle();
|
||||
_allocRecord[h] = v;
|
||||
_total -= v;
|
||||
return h;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
return INVALID_HANDLE;
|
||||
}
|
||||
|
||||
void CodecCapabilityManager::free(Handle handle)
|
||||
{
|
||||
if (handle != INVALID_HANDLE)
|
||||
{
|
||||
Poco::FastMutex::ScopedLock lock(_lock);
|
||||
try
|
||||
{
|
||||
_handles.freeHandle(handle);
|
||||
_total += _allocRecord[handle];
|
||||
_allocRecord.erase(handle);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue