From cae151981b4b34250070a7ee14b22d77c67f6c5c Mon Sep 17 00:00:00 2001 From: huili2 Date: Wed, 21 May 2014 17:54:17 -0700 Subject: [PATCH] modify dec API from void to explicit type, and some comments --- codec/api/svc/codec_api.h | 4 ++-- codec/console/dec/src/h264dec.cpp | 14 +++++++------- codec/decoder/plus/inc/welsDecoderExt.h | 4 ++-- codec/decoder/plus/src/welsDecoderExt.cpp | 6 +++--- test/api/BaseDecoderTest.cpp | 8 ++++---- test/api/cpp_interface_test.cpp | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/codec/api/svc/codec_api.h b/codec/api/svc/codec_api.h index 8268aebf..7faa1f7f 100644 --- a/codec/api/svc/codec_api.h +++ b/codec/api/svc/codec_api.h @@ -109,7 +109,7 @@ class ISVCDecoder { */ virtual DECODING_STATE EXTAPI DecodeFrame2 (const unsigned char* pSrc, const int iSrcLen, - void** ppDst, + unsigned char** ppDst, SBufferInfo* pDstInfo) = 0; /* @@ -174,7 +174,7 @@ DECODING_STATE (*DecodeFrame) (ISVCDecoder*, const unsigned char* pSrc, DECODING_STATE (*DecodeFrame2) (ISVCDecoder*, const unsigned char* pSrc, const int iSrcLen, - void** ppDst, + unsigned char** ppDst, SBufferInfo* pDstInfo); DECODING_STATE (*DecodeFrameEx) (ISVCDecoder*, const unsigned char* pSrc, diff --git a/codec/console/dec/src/h264dec.cpp b/codec/console/dec/src/h264dec.cpp index dec09e9c..e156a873 100644 --- a/codec/console/dec/src/h264dec.cpp +++ b/codec/console/dec/src/h264dec.cpp @@ -76,7 +76,7 @@ void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, cons uint8_t* pBuf = NULL; uint8_t uiStartCode[4] = {0, 0, 0, 1}; - void* pData[3] = {NULL}; + uint8_t* pData[3] = {NULL}; uint8_t* pDst[3] = {NULL}; SBufferInfo sDstBufInfo; @@ -212,9 +212,9 @@ void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, cons pDecoder->DecodeFrame2 (pBuf + iBufPos, iSliceSize, pData, &sDstBufInfo); if (sDstBufInfo.iBufferStatus == 1) { - pDst[0] = (uint8_t*)pData[0]; - pDst[1] = (uint8_t*)pData[1]; - pDst[2] = (uint8_t*)pData[2]; + pDst[0] = pData[0]; + pDst[1] = pData[1]; + pDst[2] = pData[2]; } iEnd = WelsTime(); iTotal += iEnd - iStart; @@ -247,9 +247,9 @@ void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, cons pDecoder->DecodeFrame2 (NULL, 0, pData, &sDstBufInfo); if (sDstBufInfo.iBufferStatus == 1) { - pDst[0] = (uint8_t*)pData[0]; - pDst[1] = (uint8_t*)pData[1]; - pDst[2] = (uint8_t*)pData[2]; + pDst[0] = pData[0]; + pDst[1] = pData[1]; + pDst[2] = pData[2]; } if (sDstBufInfo.iBufferStatus == 1) { diff --git a/codec/decoder/plus/inc/welsDecoderExt.h b/codec/decoder/plus/inc/welsDecoderExt.h index 443fbcca..ef5a2ccf 100644 --- a/codec/decoder/plus/inc/welsDecoderExt.h +++ b/codec/decoder/plus/inc/welsDecoderExt.h @@ -64,7 +64,7 @@ class CWelsDecoder : public ISVCDecoder { /*************************************************************************** * Description: - * Decompress one frame, and output RGB24 or YV12 decoded stream and its length. + * Decompress one frame, and output I420 or RGB24(in the future) decoded stream and its length. * Input parameters: * Parameter TYPE Description * pSrc unsigned char* the h264 stream to decode @@ -83,7 +83,7 @@ class CWelsDecoder : public ISVCDecoder { virtual DECODING_STATE EXTAPI DecodeFrame2 (const unsigned char* kpSrc, const int kiSrcLen, - void** ppDst, + unsigned char** ppDst, SBufferInfo* pDstInfo); virtual DECODING_STATE EXTAPI DecodeFrameEx (const unsigned char* kpSrc, const int kiSrcLen, diff --git a/codec/decoder/plus/src/welsDecoderExt.cpp b/codec/decoder/plus/src/welsDecoderExt.cpp index bcec72c8..6c296143 100644 --- a/codec/decoder/plus/src/welsDecoderExt.cpp +++ b/codec/decoder/plus/src/welsDecoderExt.cpp @@ -320,7 +320,7 @@ long CWelsDecoder::GetOption (DECODER_OPTION eOptID, void* pOption) { DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, const int kiSrcLen, - void** ppDst, + unsigned char** ppDst, SBufferInfo* pDstInfo) { if (kiSrcLen > MAX_ACCESS_UNIT_CAPACITY - MAX_MACROBLOCK_CAPACITY) {//prevent from residual reading overflow m_pDecContext->iErrorCode |= dsOutOfMemory; @@ -361,7 +361,7 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, m_pDecContext->iFeedbackTidInAu = -1; //initialize - WelsDecodeBs (m_pDecContext, kpSrc, kiSrcLen, (unsigned char**)ppDst, + WelsDecodeBs (m_pDecContext, kpSrc, kiSrcLen, ppDst, pDstInfo); //iErrorCode has been modified in this function if (m_pDecContext->iErrorCode) { @@ -406,7 +406,7 @@ DECODING_STATE CWelsDecoder::DecodeFrame (const unsigned char* kpSrc, DstInfo.UsrData.sSystemBuffer.iWidth = iWidth; DstInfo.UsrData.sSystemBuffer.iHeight = iHeight; - eDecState = DecodeFrame2 (kpSrc, kiSrcLen, (void**)ppDst, &DstInfo); + eDecState = DecodeFrame2 (kpSrc, kiSrcLen, ppDst, &DstInfo); if (eDecState == dsErrorFree) { pStride[0] = DstInfo.UsrData.sSystemBuffer.iStride[0]; pStride[1] = DstInfo.UsrData.sSystemBuffer.iStride[1]; diff --git a/test/api/BaseDecoderTest.cpp b/test/api/BaseDecoderTest.cpp index 7e970036..bf7f036e 100644 --- a/test/api/BaseDecoderTest.cpp +++ b/test/api/BaseDecoderTest.cpp @@ -71,7 +71,7 @@ void BaseDecoderTest::TearDown() { void BaseDecoderTest::DecodeFrame(const uint8_t* src, int sliceSize, Callback* cbk) { - void* data[3]; + uint8_t* data[3]; SBufferInfo bufInfo; memset(data, 0, sizeof(data)); memset(&bufInfo, 0, sizeof(SBufferInfo)); @@ -82,19 +82,19 @@ void BaseDecoderTest::DecodeFrame(const uint8_t* src, int sliceSize, Callback* c if (bufInfo.iBufferStatus == 1 && cbk != NULL) { const Frame frame = { { // y plane - static_cast(data[0]), + data[0], bufInfo.UsrData.sSystemBuffer.iWidth, bufInfo.UsrData.sSystemBuffer.iHeight, bufInfo.UsrData.sSystemBuffer.iStride[0] }, { // u plane - static_cast(data[1]), + data[1], bufInfo.UsrData.sSystemBuffer.iWidth / 2, bufInfo.UsrData.sSystemBuffer.iHeight / 2, bufInfo.UsrData.sSystemBuffer.iStride[1] }, { // v plane - static_cast(data[2]), + data[2], bufInfo.UsrData.sSystemBuffer.iWidth / 2, bufInfo.UsrData.sSystemBuffer.iHeight / 2, bufInfo.UsrData.sSystemBuffer.iStride[1] diff --git a/test/api/cpp_interface_test.cpp b/test/api/cpp_interface_test.cpp index f9bee979..b717df58 100644 --- a/test/api/cpp_interface_test.cpp +++ b/test/api/cpp_interface_test.cpp @@ -83,7 +83,7 @@ struct SVCDecoderImpl : public ISVCDecoder { return static_cast(3); } virtual DECODING_STATE EXTAPI DecodeFrame2(const unsigned char* pSrc, - const int iSrcLen, void** ppDst, SBufferInfo* pDstInfo) { + const int iSrcLen, unsigned char** ppDst, SBufferInfo* pDstInfo) { EXPECT_TRUE(gThis == this); return static_cast(4); }