📄 umc_vc1_enc_planes.h
字号:
/* /////////////////////////////////////////////////////////////////////////////
//
// INTEL CORPORATION PROPRIETARY INFORMATION
// This software is supplied under the terms of a license agreement or
// nondisclosure agreement with Intel Corporation and may not be copied
// or disclosed except in accordance with the terms of that agreement.
// Copyright(c) 2007 Intel Corporation. All Rights Reserved.
//
//
// VC-1 (VC1) encoder, work with planes
//
*/
#include "umc_defs.h"
#if defined (UMC_ENABLE_VC1_VIDEO_ENCODER)
#ifndef _ENCODER_VC1_PLANES_H_
#define _ENCODER_VC1_PLANES_H_
#include "ippvc.h"
#include "umc_vc1_enc_def.h"
#include "umc_structures.h"
#include "umc_memory_allocator.h"
namespace UMC_VC1_ENCODER
{
//|--------------|//
//|frame |//
//| |-------| |//
//| | plane | |//
//| | | |//
//| |-------| |//
//|--------------|//
class Frame
{
public:
Frame ():
m_pYFrame(0),
m_pUFrame(0),
m_pVFrame(0),
m_pYPlane(0),
m_pUPlane(0),
m_pVPlane(0),
m_stepY (0),
m_stepUV (0),
m_widthYPlane (0),
m_widthUVPlane (0),
m_heightYPlane(0),
m_heightUVPlane(0),
m_paddingSize(0),
m_pictureType(VC1_ENC_I_FRAME),
m_bTaken(false),
m_pMemoryAllocator(NULL),
m_bOwnAllocator(false),
m_YFrameMemID((UMC::MemID)-1),
m_UFrameMemID((UMC::MemID)-1),
m_VFrameMemID((UMC::MemID)-1)
{};
virtual ~Frame ()
{
Close ();
}
UMC::Status Init(Ipp32u w, Ipp32u h, Ipp32u paddingSize);
void Close();
UMC::Status PadFrameProgressive();
UMC::Status PadPlaneProgressive();
UMC::Status CopyPlane ( Ipp8u* pYPlane, Ipp32u stepY,
Ipp8u* pUPlane, Ipp32u stepU,
Ipp8u* pVPlane, Ipp32u stepV,
ePType pictureType=VC1_ENC_I_FRAME);
void SetMemoryAllocator(UMC::MemoryAllocator* pMemoryAllocator, bool bOwnAllocator);
inline Ipp8u* GetYPlane() {return m_pYPlane;}
inline Ipp8u* GetUPlane() {return m_pUPlane;}
inline Ipp8u* GetVPlane() {return m_pVPlane;}
inline Ipp32u GetYStep() {return m_stepY;}
inline Ipp32u GetUStep() {return m_stepUV;}
inline Ipp32u GetVStep() {return m_stepUV;}
inline ePType GetPictureType()
{
return m_pictureType;
}
inline bool isTaken()
{
return m_bTaken;
}
inline void ReleasePlane ()
{
m_bTaken = false;
}
inline void SetReferenceFrameType()
{
m_pictureType = VC1_ENC_I_FRAME;
}
inline bool isReferenceFrame()
{
return (m_pictureType == VC1_ENC_I_FRAME ||m_pictureType == VC1_ENC_P_FRAME);
}
private:
Ipp8u* m_pYFrame;
Ipp8u* m_pUFrame;
Ipp8u* m_pVFrame;
Ipp32u m_stepY;
Ipp32u m_stepUV;
Ipp8u* m_pYPlane;
Ipp8u* m_pUPlane;
Ipp8u* m_pVPlane;
Ipp32u m_widthYPlane;
Ipp32u m_widthUVPlane;
Ipp32u m_heightYPlane;
Ipp32u m_heightUVPlane;
Ipp32u m_paddingSize;
ePType m_pictureType;
bool m_bTaken;
//MEMORY ALLOCATOR
UMC::MemoryAllocator *m_pMemoryAllocator;
bool m_bOwnAllocator;
UMC::MemID m_YFrameMemID;
UMC::MemID m_UFrameMemID;
UMC::MemID m_VFrameMemID;
};
class StoredFrames
{
public:
StoredFrames():
m_nFrames(0),
m_pFrames(0),
m_pMemoryAllocator(NULL),
m_bOwnAllocator(false)
{};
UMC::Status Init(Ipp8u nBframes, Ipp32u w, Ipp32u h, Ipp32u paddingSize)
{
Ipp32u i;
UMC::Status ret = UMC::UMC_OK;
if(!m_pMemoryAllocator)
return UMC::UMC_ERR_INIT;
Close();
m_nFrames = nBframes+2; // two reference frames
m_pFrames = new Frame[m_nFrames];
if (!m_pFrames)
return UMC::UMC_ERR_ALLOC;
for (i=0;i<m_nFrames;i++)
{
m_pFrames[i].SetMemoryAllocator(m_pMemoryAllocator, m_bOwnAllocator);
ret = m_pFrames[i].Init(w,h,paddingSize);
if (ret != UMC::UMC_OK)
return ret;
}
return ret;
}
void Close()
{
UMC::Status ret = UMC::UMC_OK;
if (m_pFrames)
{
delete [] m_pFrames;
m_pFrames = 0;
}
m_nFrames = 0;
}
~StoredFrames()
{
Close();
}
void Reset()
{
Ipp32u i;
if (m_pFrames)
for (i = 0; i < m_nFrames; i++)
{
m_pFrames[i].ReleasePlane();
}
}
inline Frame* GetFreeFramePointer ()
{
Ipp32u i;
for (i = 0; i < m_nFrames; i++)
{
if (!m_pFrames[i].isTaken())
{
return &m_pFrames[i];
}
}
return 0;
}
inline Ipp32u GetYStep()
{
return m_pFrames[0].GetYStep();
}
void SetMemoryAllocator(UMC::MemoryAllocator *pMemoryAllocator, bool bOwnAllocator)
{
m_pMemoryAllocator = pMemoryAllocator;
m_bOwnAllocator = bOwnAllocator;
};
private:
Ipp32u m_nFrames;
Frame *m_pFrames;
bool *m_pTaken;
//MEMORY ALLOCATOR
UMC::MemoryAllocator *m_pMemoryAllocator;
bool m_bOwnAllocator;
};
class GOP
{
public:
GOP():
m_maxB(0),
m_pFrames(0),
m_numBuffB(0),
m_iCurr(0)
{};
virtual ~GOP()
{
Close();
}
protected:
Ipp32u m_maxB;
Frame** m_pFrames; /* 0 - forward reference frame,
1 - backward reference frame
other - B frames*/
Ipp32u m_numBuffB;
Ipp32u m_iCurr;
protected:
void Close()
{
if (m_pFrames)
{
delete [] m_pFrames;
m_pFrames = 0;
}
m_iCurr = 0;
m_numBuffB = 0;
m_maxB = 0;
}
inline bool NewGOP ()
{
m_pFrames[0]->ReleasePlane();
m_pFrames[0] = m_pFrames[1];
m_pFrames[1] = 0;
m_iCurr = 1;
m_numBuffB = 0;
return true;
}
inline virtual bool AddBFrame(Frame* frame)
{
if (m_numBuffB < m_maxB && m_pFrames[0] != 0 && m_pFrames[1]==0)
{
m_pFrames[m_numBuffB+2] = frame;
m_numBuffB ++;
return true;
}
return false;
}
inline virtual bool AddReferenceFrame(Frame* frame)
{
if (m_pFrames[0] == 0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -