mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-13 03:31:45 +08:00
统一成员变量命名风格
This commit is contained in:
@@ -48,17 +48,17 @@ AACEncoder::AACEncoder() {
|
||||
}
|
||||
|
||||
AACEncoder::~AACEncoder() {
|
||||
if (m_hEncoder != nullptr) {
|
||||
faacEncClose(m_hEncoder);
|
||||
m_hEncoder = nullptr;
|
||||
if (_hEncoder != nullptr) {
|
||||
faacEncClose(_hEncoder);
|
||||
_hEncoder = nullptr;
|
||||
}
|
||||
if (m_pucAacBuf != nullptr) {
|
||||
delete[] m_pucAacBuf;
|
||||
m_pucAacBuf = nullptr;
|
||||
if (_pucAacBuf != nullptr) {
|
||||
delete[] _pucAacBuf;
|
||||
_pucAacBuf = nullptr;
|
||||
}
|
||||
if (m_pucPcmBuf != nullptr) {
|
||||
delete[] m_pucPcmBuf;
|
||||
m_pucPcmBuf = nullptr;
|
||||
if (_pucPcmBuf != nullptr) {
|
||||
delete[] _pucPcmBuf;
|
||||
_pucPcmBuf = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,19 +67,19 @@ bool AACEncoder::init(int iSampleRate, int iChannels, int iSampleBit) {
|
||||
return false;
|
||||
}
|
||||
// (1) Open FAAC engine
|
||||
m_hEncoder = faacEncOpen(iSampleRate, iChannels, &m_ulInputSamples,
|
||||
&m_ulMaxOutputBytes);
|
||||
if (m_hEncoder == NULL) {
|
||||
_hEncoder = faacEncOpen(iSampleRate, iChannels, &_ulInputSamples,
|
||||
&_ulMaxOutputBytes);
|
||||
if (_hEncoder == NULL) {
|
||||
return false;
|
||||
}
|
||||
m_pucAacBuf = new unsigned char[m_ulMaxOutputBytes];
|
||||
m_ulMaxInputBytes = m_ulInputSamples * iSampleBit / 8;
|
||||
m_pucPcmBuf = new unsigned char[m_ulMaxInputBytes * 4];
|
||||
_pucAacBuf = new unsigned char[_ulMaxOutputBytes];
|
||||
_ulMaxInputBytes = _ulInputSamples * iSampleBit / 8;
|
||||
_pucPcmBuf = new unsigned char[_ulMaxInputBytes * 4];
|
||||
|
||||
// (2.1) Get current encoding configuration
|
||||
faacEncConfigurationPtr pConfiguration = faacEncGetCurrentConfiguration(m_hEncoder);
|
||||
faacEncConfigurationPtr pConfiguration = faacEncGetCurrentConfiguration(_hEncoder);
|
||||
if (pConfiguration == NULL) {
|
||||
faacEncClose(m_hEncoder);
|
||||
faacEncClose(_hEncoder);
|
||||
return false;
|
||||
}
|
||||
pConfiguration->aacObjectType =LOW;
|
||||
@@ -95,25 +95,25 @@ bool AACEncoder::init(int iSampleRate, int iChannels, int iSampleBit) {
|
||||
pConfiguration->inputFormat = FAAC_INPUT_16BIT;
|
||||
|
||||
// (2.2) Set encoding configuration
|
||||
if(!faacEncSetConfiguration(m_hEncoder, pConfiguration)){
|
||||
if(!faacEncSetConfiguration(_hEncoder, pConfiguration)){
|
||||
ErrorL << "faacEncSetConfiguration failed";
|
||||
faacEncClose(m_hEncoder);
|
||||
faacEncClose(_hEncoder);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int AACEncoder::inputData(char *pcPcmBufr, int iLen, unsigned char **ppucOutBuffer) {
|
||||
memcpy(m_pucPcmBuf + m_uiPcmLen, pcPcmBufr, iLen);
|
||||
m_uiPcmLen += iLen;
|
||||
if (m_uiPcmLen < m_ulMaxInputBytes) {
|
||||
memcpy(_pucPcmBuf + _uiPcmLen, pcPcmBufr, iLen);
|
||||
_uiPcmLen += iLen;
|
||||
if (_uiPcmLen < _ulMaxInputBytes) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nRet = faacEncEncode(m_hEncoder, (int32_t *) (m_pucPcmBuf), m_ulInputSamples, m_pucAacBuf, m_ulMaxOutputBytes);
|
||||
m_uiPcmLen -= m_ulMaxInputBytes;
|
||||
memmove(m_pucPcmBuf, m_pucPcmBuf + m_ulMaxInputBytes, m_uiPcmLen);
|
||||
*ppucOutBuffer = m_pucAacBuf;
|
||||
int nRet = faacEncEncode(_hEncoder, (int32_t *) (_pucPcmBuf), _ulInputSamples, _pucAacBuf, _ulMaxOutputBytes);
|
||||
_uiPcmLen -= _ulMaxInputBytes;
|
||||
memmove(_pucPcmBuf, _pucPcmBuf + _ulMaxInputBytes, _uiPcmLen);
|
||||
*ppucOutBuffer = _pucAacBuf;
|
||||
return nRet;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,15 +39,15 @@ public:
|
||||
int inputData(char *pcData, int iLen, unsigned char **ppucOutBuffer);
|
||||
|
||||
private:
|
||||
unsigned char *m_pucPcmBuf = nullptr;
|
||||
unsigned int m_uiPcmLen = 0;
|
||||
unsigned char *_pucPcmBuf = nullptr;
|
||||
unsigned int _uiPcmLen = 0;
|
||||
|
||||
unsigned char *m_pucAacBuf = nullptr;
|
||||
void *m_hEncoder = nullptr;
|
||||
unsigned char *_pucAacBuf = nullptr;
|
||||
void *_hEncoder = nullptr;
|
||||
|
||||
unsigned long m_ulInputSamples = 0;
|
||||
unsigned long m_ulMaxInputBytes = 0;
|
||||
unsigned long m_ulMaxOutputBytes = 0;
|
||||
unsigned long _ulInputSamples = 0;
|
||||
unsigned long _ulMaxInputBytes = 0;
|
||||
unsigned long _ulMaxOutputBytes = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -39,19 +39,19 @@ H264Encoder::H264Encoder() {
|
||||
|
||||
H264Encoder::~H264Encoder() {
|
||||
//* 清除图像区域
|
||||
if (m_pPicIn) {
|
||||
delete m_pPicIn;
|
||||
m_pPicIn = nullptr;
|
||||
if (_pPicIn) {
|
||||
delete _pPicIn;
|
||||
_pPicIn = nullptr;
|
||||
}
|
||||
if (m_pPicOut) {
|
||||
delete m_pPicOut;
|
||||
m_pPicOut = nullptr;
|
||||
if (_pPicOut) {
|
||||
delete _pPicOut;
|
||||
_pPicOut = nullptr;
|
||||
}
|
||||
|
||||
//* 关闭编码器句柄
|
||||
if (m_pX264Handle) {
|
||||
x264_encoder_close(m_pX264Handle);
|
||||
m_pX264Handle = nullptr;
|
||||
if (_pX264Handle) {
|
||||
x264_encoder_close(_pX264Handle);
|
||||
_pX264Handle = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ Value的值就是fps。
|
||||
} x264_param_t;*/
|
||||
|
||||
bool H264Encoder::init(int iWidth, int iHeight, int iFps) {
|
||||
if (m_pX264Handle) {
|
||||
if (_pX264Handle) {
|
||||
return true;
|
||||
}
|
||||
x264_param_t X264Param, *pX264Param = &X264Param;
|
||||
@@ -307,43 +307,43 @@ bool H264Encoder::init(int iWidth, int iHeight, int iFps) {
|
||||
|
||||
//* 打开编码器句柄,通过x264_encoder_parameters得到设置给X264
|
||||
//* 的参数.通过x264_encoder_reconfig更新X264的参数
|
||||
m_pX264Handle = x264_encoder_open(pX264Param);
|
||||
if (!m_pX264Handle) {
|
||||
_pX264Handle = x264_encoder_open(pX264Param);
|
||||
if (!_pX264Handle) {
|
||||
return false;
|
||||
}
|
||||
m_pPicIn = new x264_picture_t;
|
||||
m_pPicOut = new x264_picture_t;
|
||||
x264_picture_init(m_pPicIn);
|
||||
x264_picture_init(m_pPicOut);
|
||||
m_pPicIn->img.i_csp = X264_CSP_I420;
|
||||
m_pPicIn->img.i_plane = 3;
|
||||
_pPicIn = new x264_picture_t;
|
||||
_pPicOut = new x264_picture_t;
|
||||
x264_picture_init(_pPicIn);
|
||||
x264_picture_init(_pPicOut);
|
||||
_pPicIn->img.i_csp = X264_CSP_I420;
|
||||
_pPicIn->img.i_plane = 3;
|
||||
return true;
|
||||
}
|
||||
|
||||
int H264Encoder::inputData(char* apcYuv[3], int aiYuvLen[3], int64_t i64Pts, H264Frame** ppFrame) {
|
||||
//TimeTicker1(5);
|
||||
m_pPicIn->img.i_stride[0] = aiYuvLen[0];
|
||||
m_pPicIn->img.i_stride[1] = aiYuvLen[1];
|
||||
m_pPicIn->img.i_stride[2] = aiYuvLen[2];
|
||||
m_pPicIn->img.plane[0] = (uint8_t *) apcYuv[0];
|
||||
m_pPicIn->img.plane[1] = (uint8_t *) apcYuv[1];
|
||||
m_pPicIn->img.plane[2] = (uint8_t *) apcYuv[2];
|
||||
m_pPicIn->i_pts = i64Pts;
|
||||
_pPicIn->img.i_stride[0] = aiYuvLen[0];
|
||||
_pPicIn->img.i_stride[1] = aiYuvLen[1];
|
||||
_pPicIn->img.i_stride[2] = aiYuvLen[2];
|
||||
_pPicIn->img.plane[0] = (uint8_t *) apcYuv[0];
|
||||
_pPicIn->img.plane[1] = (uint8_t *) apcYuv[1];
|
||||
_pPicIn->img.plane[2] = (uint8_t *) apcYuv[2];
|
||||
_pPicIn->i_pts = i64Pts;
|
||||
int iNal;
|
||||
x264_nal_t* pNals;
|
||||
|
||||
int iResult = x264_encoder_encode(m_pX264Handle, &pNals, &iNal, m_pPicIn,
|
||||
m_pPicOut);
|
||||
int iResult = x264_encoder_encode(_pX264Handle, &pNals, &iNal, _pPicIn,
|
||||
_pPicOut);
|
||||
if (iResult <= 0) {
|
||||
return 0;
|
||||
}
|
||||
for (int i = 0; i < iNal; i++) {
|
||||
x264_nal_t pNal = pNals[i];
|
||||
m_aFrames[i].iType = pNal.i_type;
|
||||
m_aFrames[i].iLength = pNal.i_payload;
|
||||
m_aFrames[i].pucData = pNal.p_payload;
|
||||
_aFrames[i].iType = pNal.i_type;
|
||||
_aFrames[i].iLength = pNal.i_payload;
|
||||
_aFrames[i].pucData = pNal.p_payload;
|
||||
}
|
||||
*ppFrame = m_aFrames;
|
||||
*ppFrame = _aFrames;
|
||||
return iNal;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,10 +54,10 @@ public:
|
||||
bool init(int iWidth, int iHeight, int iFps);
|
||||
int inputData(char *apcYuv[3], int aiYuvLen[3], int64_t i64Pts, H264Frame **ppFrame);
|
||||
private:
|
||||
x264_t* m_pX264Handle = nullptr;
|
||||
x264_picture_t* m_pPicIn = nullptr;
|
||||
x264_picture_t* m_pPicOut = nullptr;
|
||||
H264Frame m_aFrames[10];
|
||||
x264_t* _pX264Handle = nullptr;
|
||||
x264_picture_t* _pPicIn = nullptr;
|
||||
x264_picture_t* _pPicOut = nullptr;
|
||||
H264Frame _aFrames[10];
|
||||
};
|
||||
|
||||
} /* namespace Codec */
|
||||
|
||||
Reference in New Issue
Block a user