📄 h264decoder.cpp
字号:
/*
* Multimedia Multipoint Conferencing Unit(MMCU), ver 1.0
* Copyright (c) KCC-Eoun Information Center
*
* File: H264VideoDecoder.cpp
* Description: Base Class for h264 video decoder.
*
* The Initial Writer of Original Code is Yong Su.Han
*
* $Log: H264VideoDecoder.cpp, v $
* Revision 1.0 2006-06-06 Yong Su.Han
* Initial version
*/
#include "H264Decoder.h"
#include "Log.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
/*
Function: CH264Decoder
Description :
Constructor.
Return :
Parameter(s) :
Author : HYS
Final update date : 2006-06-06
*/
//##ModelId=4753B7EA035C
CH264Decoder::CH264Decoder()
{
//Parameter initialize
m_decParam.flags = DECODE_FLAG_COMPLETE;
m_decParam.nLogLevel = 0;
m_decParam.szLogFileName[0] = 0;
m_nCodecIdx = -1;
memset(&m_picYuv, 0, sizeof(DEC_YUV));
memset(&m_picCSP, 0, sizeof(DEC_CSP));
}
/*
Function: ~CH264Decoder
Description :
Destructor.
Return :
Parameter(s) :
Author : HYS
Final update date : 2006-06-06
*/
//##ModelId=4753B7EA035D
CH264Decoder::~CH264Decoder()
{
}
/*
Function: CodecInit
Description :
init the H264 Decoder.
Return :
H263 decoder ID
Parameter(s) :
Author : HYS
Final update date : 2006-06-06
*/
//##ModelId=4753B7EA035F
int CH264Decoder::CodecInit()
{
if( (m_nCodecIdx = H264_DEC_AllocVideo(&m_decParam, 0)) < 0 )
{
LogMsg(LOG_ERR, HCLN, "ERR: H.264 Codec Overflow VideoHandle!");
return -1;
}
LogMsg(LOG_INFO, HCLN, "Alloc H.264 Decoder VideoHandle = %d", m_nCodecIdx);
return m_nCodecIdx;
}
/*
Function: CodecFree
Description :
Free the H264 Decoder.
Return :
0: success
otherwise: fail code
Parameter(s) :
nVidIndex: H264 decoder ID
Author : HYS
Final update date : 2006-06-06
*/
//##ModelId=4753B7EA0360
int CH264Decoder::CodecFree()
{
if( m_nCodecIdx >= 0)
{
H264_DEC_FreeVideo(m_nCodecIdx, 0);
LogMsg(LOG_INFO, HCLN, "Free H.264 Decoder VideoHandle for VideoIndex = %d!", m_nCodecIdx);
}
else
return -1;
return 0;
}
//##ModelId=4753B7EA0361
int CH264Decoder::CodecReset()
{
CodecFree();
CodecInit();
return 0;
}
//##ModelId=4753B7EA036B
void CH264Decoder::SetColorSpace(int nCSP, int nStride)
{
m_nCSP = nCSP;
m_nStride = nStride;
}
//##ModelId=4753B7EA036E
int CH264Decoder::Decode(BYTE *lpEncoded, int nEncLen, BYTE *lpCSP)
{
int ret = 0;
if( m_nCodecIdx < 0 )
{
LogMsg(LOG_WARNING, HCLN, "Invalid VideoIndex =%d", m_nCodecIdx);
return 0;
}
m_picCSP.data = lpCSP;
if( lpEncoded[0] == 0 && lpEncoded[1] == 0 && lpEncoded[2] == 0 && lpEncoded[3] == 0x01 )
ret = H264_DEC_DecodeToCSP(m_nCodecIdx, &m_picCSP, lpEncoded, &nEncLen, m_nStride, m_nCSP, 1);
else
LogMsg(LOG_ERR, HCLN, "Invalid data");
if( ret > 0 )
{
return ret;
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -