ref: e8fdd4cf7553a9bb05078fec2a583cd1f5ed230d
parent: d0d6842f73dbbd3a7f2a6284a2efa3257dac8251
author: huili2 <[email protected]>
date: Mon Jul 28 13:57:28 EDT 2014
setget_dataformat_ut
--- a/codec/api/svc/codec_app_def.h
+++ b/codec/api/svc/codec_app_def.h
@@ -355,7 +355,7 @@
typedef struct TagSVCDecodingParam {
char* pFileNameRestructed; // File name of restructed frame used for PSNR calculation based debug
- int iOutputColorFormat; // color space format to be outputed, EVideoFormatType specified in codec_def.h
+ EVideoFormatType eOutputColorFormat; // color space format to be outputed, EVideoFormatType specified in codec_def.h
unsigned int uiCpuLoad; // CPU load
unsigned char uiTargetDqLayer; // Setting target dq layer id
--- a/codec/console/dec/src/h264dec.cpp
+++ b/codec/console/dec/src/h264dec.cpp
@@ -349,7 +349,7 @@
} else if (strTag[0].compare ("TargetDQID") == 0) {
sDecParam.uiTargetDqLayer = (uint8_t)atol (strTag[1].c_str());
} else if (strTag[0].compare ("OutColorFormat") == 0) {
- sDecParam.iOutputColorFormat = atoi (strTag[1].c_str());
+ sDecParam.eOutputColorFormat = (EVideoFormatType) atoi (strTag[1].c_str());
} else if (strTag[0].compare ("ErrorConcealmentIdc") == 0) {
sDecParam.eEcActiveIdc = (ERROR_CON_IDC)atol (strTag[1].c_str());
} else if (strTag[0].compare ("CPULoad") == 0) {
@@ -366,7 +366,7 @@
} else if (strstr (pArgV[1],
".264")) { // no output dump yuv file, just try to render the decoded pictures //confirmed_safe_unsafe_usage
strInputFile = pArgV[1];
- sDecParam.iOutputColorFormat = videoFormatI420;
+ sDecParam.eOutputColorFormat = videoFormatI420;
sDecParam.uiTargetDqLayer = (uint8_t) - 1;
sDecParam.eEcActiveIdc = ERROR_CON_SLICE_COPY;
sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
@@ -374,7 +374,7 @@
} else { //iArgC > 2
strInputFile = pArgV[1];
strOutputFile = pArgV[2];
- sDecParam.iOutputColorFormat = videoFormatI420;
+ sDecParam.eOutputColorFormat = videoFormatI420;
sDecParam.uiTargetDqLayer = (uint8_t) - 1;
sDecParam.eEcActiveIdc = ERROR_CON_SLICE_COPY;
sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
--- a/codec/decoder/core/inc/decoder_context.h
+++ b/codec/decoder/core/inc/decoder_context.h
@@ -168,13 +168,13 @@
// Input
void* pArgDec; // structured arguments for decoder, reserved here for extension in the future
-SDataBuffer sRawData;
+SDataBuffer sRawData;
// Configuration
-SDecodingParam* pParam;
+SDecodingParam* pParam;
uint32_t uiCpuFlag; // CPU compatibility detected
-int32_t iOutputColorFormat; // color space format to be outputed
+EVideoFormatType eOutputColorFormat; // color space format to be outputed
VIDEO_BITSTREAM_TYPE eVideoType; //indicate the type of video to decide whether or not to do qp_delta error detection.
bool bHaveGotMemory; // global memory for decoder context related ever requested?
--- a/codec/decoder/core/src/decoder.cpp
+++ b/codec/decoder/core/src/decoder.cpp
@@ -134,7 +134,7 @@
pCtx->pArgDec = NULL;
- pCtx->iOutputColorFormat = videoFormatI420; // yuv in default
+ pCtx->eOutputColorFormat = videoFormatI420; // yuv in default
pCtx->bHaveGotMemory = false; // not ever request memory blocks for decoder context related
pCtx->uiCpuFlag = 0;
@@ -331,7 +331,7 @@
return 1;
memcpy (pCtx->pParam, kpParam, sizeof (SDecodingParam));
- pCtx->iOutputColorFormat = pCtx->pParam->iOutputColorFormat;
+ pCtx->eOutputColorFormat = pCtx->pParam->eOutputColorFormat;
pCtx->eErrorConMethod = pCtx->pParam->eEcActiveIdc;
if (VIDEO_BITSTREAM_SVC == pCtx->pParam->sVideoProperty.eVideoBsType ||
@@ -589,9 +589,15 @@
int32_t DecoderSetCsp (PWelsDecoderContext pCtx, const int32_t kiColorFormat) {
WELS_VERIFY_RETURN_IF (1, (NULL == pCtx));
- pCtx->iOutputColorFormat = kiColorFormat;
+ pCtx->eOutputColorFormat = (EVideoFormatType) kiColorFormat;
if (pCtx->pParam != NULL) {
- pCtx->pParam->iOutputColorFormat = kiColorFormat;
+ pCtx->pParam->eOutputColorFormat = (EVideoFormatType) kiColorFormat;
+ }
+
+ //For now, support only videoFormatI420!
+ if (kiColorFormat != (int32_t) videoFormatI420) {
+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "Support I420 output only for now! Change to I420...\n");
+ pCtx->pParam->eOutputColorFormat = pCtx->eOutputColorFormat = videoFormatI420;
}
return 0;
--- a/codec/decoder/plus/src/welsDecoderExt.cpp
+++ b/codec/decoder/plus/src/welsDecoderExt.cpp
@@ -304,7 +304,7 @@
return cmInitParaError;
if (DECODER_OPTION_DATAFORMAT == eOptID) {
- iVal = m_pDecContext->iOutputColorFormat;
+ iVal = (int32_t) m_pDecContext->eOutputColorFormat;
* ((int*)pOption) = iVal;
return cmResultSuccess;
} else if (DECODER_OPTION_END_OF_STREAM == eOptID) {
--- a/module/gmp-openh264.cpp
+++ b/module/gmp-openh264.cpp
@@ -572,7 +572,7 @@
SDecodingParam param;
memset (¶m, 0, sizeof (param));
- param.iOutputColorFormat = videoFormatI420;
+ param.eOutputColorFormat = videoFormatI420;
param.uiTargetDqLayer = UCHAR_MAX; // Default value
param.eEcActiveIdc = ERROR_CON_SLICE_COPY; // Error concealment on.
param.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
--- a/test/api/BaseDecoderTest.cpp
+++ b/test/api/BaseDecoderTest.cpp
@@ -53,7 +53,7 @@
SDecodingParam decParam;
memset (&decParam, 0, sizeof (SDecodingParam));
- decParam.iOutputColorFormat = videoFormatI420;
+ decParam.eOutputColorFormat = videoFormatI420;
decParam.uiTargetDqLayer = UCHAR_MAX;
decParam.eEcActiveIdc = ERROR_CON_SLICE_COPY;
decParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
--- a/test/decoder/DecUT_DecExt.cpp
+++ b/test/decoder/DecUT_DecExt.cpp
@@ -24,8 +24,8 @@
}
//Init members
void Init();
- //Uninit
- void Uninit() {}
+ //Uninit members
+ void Uninit();
//Mock input data for test
void MockPacketType (const EWelsNalUnitType eNalUnitType);
//Test Initialize/Uninitialize
@@ -72,7 +72,7 @@
memset (&m_sBufferInfo, 0, sizeof (SBufferInfo));
memset (&m_sDecParam, 0, sizeof (SDecodingParam));
m_sDecParam.pFileNameRestructed = NULL;
- m_sDecParam.iOutputColorFormat = rand() % 100;
+ m_sDecParam.eOutputColorFormat = (EVideoFormatType) (rand() % 100);
m_sDecParam.uiCpuLoad = rand() % 100;
m_sDecParam.uiTargetDqLayer = rand() % 100;
m_sDecParam.eEcActiveIdc = (ERROR_CON_IDC) (rand() & 3);
@@ -83,8 +83,21 @@
m_szBuffer[0] = m_szBuffer[1] = m_szBuffer[2] = 0;
m_szBuffer[3] = 1;
m_iBufLength = 4;
+ CM_RETURN eRet = (CM_RETURN) m_pDec->Initialize (&m_sDecParam);
+ ASSERT_EQ (eRet, cmResultSuccess);
}
+void DecoderInterfaceTest::Uninit() {
+ if (m_pDec) {
+ CM_RETURN eRet = (CM_RETURN) m_pDec->Uninitialize();
+ ASSERT_EQ (eRet, cmResultSuccess);
+ }
+ memset (&m_sDecParam, 0, sizeof (SDecodingParam));
+ memset (&m_sBufferInfo, 0, sizeof (SBufferInfo));
+ m_pData[0] = m_pData[1] = m_pData[2] = NULL;
+ m_iBufLength = 0;
+}
+
//Mock input data for test
void DecoderInterfaceTest::MockPacketType (const EWelsNalUnitType eNalUnitType) {
switch (eNalUnitType) {
@@ -128,7 +141,7 @@
eRet = (CM_RETURN) m_pDec->GetOption (DECODER_OPTION_DATAFORMAT, &iOutput);
EXPECT_EQ (eRet, cmInitExpected);
//Initialize first, can get input color format
- m_sDecParam.iOutputColorFormat = 20; //just for test
+ m_sDecParam.eOutputColorFormat = (EVideoFormatType) 20; //just for test
m_pDec->Initialize (&m_sDecParam);
eRet = (CM_RETURN) m_pDec->GetOption (DECODER_OPTION_DATAFORMAT, &iOutput);
EXPECT_EQ (eRet, cmResultSuccess);
@@ -144,7 +157,21 @@
//DECODER_OPTION_DATAFORMAT
void DecoderInterfaceTest::TestDataFormat() {
- //TODO
+ int iTmp = rand();
+ int iOut;
+ CM_RETURN eRet;
+
+ //invalid input
+ eRet = (CM_RETURN) m_pDec->SetOption (DECODER_OPTION_DATAFORMAT, NULL);
+ EXPECT_EQ (eRet, cmInitParaError);
+
+ //valid input
+ eRet = (CM_RETURN) m_pDec->SetOption (DECODER_OPTION_DATAFORMAT, &iTmp);
+ EXPECT_EQ (eRet, cmResultSuccess);
+ eRet = (CM_RETURN) m_pDec->GetOption (DECODER_OPTION_DATAFORMAT, &iOut);
+ EXPECT_EQ (eRet, cmResultSuccess);
+
+ EXPECT_EQ (iOut, (int32_t) videoFormatI420);
}
//DECODER_OPTION_END_OF_STREAM
@@ -204,10 +231,12 @@
//TEST here for whole tests
TEST_F (DecoderInterfaceTest, DecoderInterfaceAll) {
- Init();
//Initialize Uninitialize
TestInitUninit();
+
+ //AfterInitialize is OK, do the following tests
+ Init();
//DECODER_OPTION_DATAFORMAT
TestDataFormat();
//DECODER_OPTION_END_OF_STREAM
@@ -233,6 +262,8 @@
//DECODER_OPTION_TRACE_CALLBACK_CONTEXT
TestTraceCallbackContext();
+ //uninitialize
+ Uninit();
}