Merge pull request #1735 from mstorsjo/msvc-test-warnings

Fix build warnings with MSVC
This commit is contained in:
dongzha 2015-01-19 09:37:39 +08:00
commit 7d1d2d658f
14 changed files with 52 additions and 51 deletions

View File

@ -127,6 +127,12 @@ API_TEST_INCLUDES += $(CODEC_UNITTEST_INCLUDES) -I$(SRC_PATH)test -I$(SRC_PATH)t
COMMON_UNITTEST_INCLUDES += $(CODEC_UNITTEST_INCLUDES) $(DECODER_INCLUDES) -I$(SRC_PATH)test -I$(SRC_PATH)test/common
MODULE_INCLUDES += -I$(SRC_PATH)gmp-api
DECODER_UNITTEST_CFLAGS += $(CODEC_UNITTEST_CFLAGS)
ENCODER_UNITTEST_CFLAGS += $(CODEC_UNITTEST_CFLAGS)
PROCESSING_UNITTEST_CFLAGS += $(CODEC_UNITTEST_CFLAGS)
API_TEST_CFLAGS += $(CODEC_UNITTEST_CFLAGS)
COMMON_UNITTEST_CFLAGS += $(CODEC_UNITTEST_CFLAGS)
.PHONY: test gtest-bootstrap clean $(PROJECT_NAME).pc $(PROJECT_NAME)-static.pc
all: libraries binaries

View File

@ -10,7 +10,7 @@ else
endif
ifeq ($(ASM_ARCH), arm)
CCAS = gas-preprocessor.pl -as-type armasm -force-thumb -- armasm
CCASFLAGS = -nologo -DHAVE_NEON
CCASFLAGS = -nologo -DHAVE_NEON -ignore 4509
endif
CC=cl
@ -42,3 +42,4 @@ SHARED=-LD
EXTRA_LIBRARY=$(PROJECT_NAME)_dll.lib
SHLDFLAGS=-Fd$(PROJECT_NAME).pdb -link -def:openh264.def -implib:$(EXTRA_LIBRARY)
STATIC_LDFLAGS=
CODEC_UNITTEST_CFLAGS=-D_CRT_SECURE_NO_WARNINGS

View File

@ -605,23 +605,17 @@ int CUtils::CheckOS() {
OSVERSIONINFOEX osvi;
ZeroMemory (&osvi, sizeof (OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
osvi.dwPlatformId = VER_PLATFORM_WIN32_NT;
osvi.dwMajorVersion = 6; // Vista
DWORDLONG condmask = VerSetConditionMask (VerSetConditionMask (0, VER_MAJORVERSION, VER_GREATER_EQUAL),
VER_PLATFORMID, VER_EQUAL);
if (!GetVersionEx ((OSVERSIONINFO*) &osvi)) {
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (! GetVersionEx ((OSVERSIONINFO*) &osvi))
return iType;
}
switch (osvi.dwPlatformId) {
case VER_PLATFORM_WIN32_NT:
if (osvi.dwMajorVersion >= 6)
iType = OS_VISTA_UPPER;
else if (osvi.dwMajorVersion == 5)
if (VerifyVersionInfo (&osvi, VER_MAJORVERSION | VER_PLATFORMID, condmask)) {
iType = OS_VISTA_UPPER;
} else {
osvi.dwMajorVersion = 5; // XP/2000
if (VerifyVersionInfo (&osvi, VER_MAJORVERSION | VER_PLATFORMID, condmask))
iType = OS_XP;
break;
default:
break;
}
#endif

View File

@ -993,8 +993,8 @@ void UpdateDecStatNoFreezingInfo (PWelsDecoderContext pCtx) {
ResetDecStatNums (pDecStat);
pDecStat->iAvgLumaQp = iTotalQp;
} else
pDecStat->iAvgLumaQp = (uint64_t) (pDecStat->iAvgLumaQp * pDecStat->uiDecodedFrameCount + iTotalQp) /
(pDecStat->uiDecodedFrameCount + 1);
pDecStat->iAvgLumaQp = (int) ((uint64_t) (pDecStat->iAvgLumaQp * pDecStat->uiDecodedFrameCount + iTotalQp) /
(pDecStat->uiDecodedFrameCount + 1));
//update IDR number
if (pCurDq->sLayerInfo.sNalHeaderExt.bIdrFlag) {

View File

@ -37,7 +37,7 @@ class BaseDecoderTest {
ISVCDecoder* decoder_;
private:
void DecodeFrame (const uint8_t* src, int sliceSize, Callback* cbk);
void DecodeFrame (const uint8_t* src, size_t sliceSize, Callback* cbk);
std::ifstream file_;
BufferedData buf_;

View File

@ -70,13 +70,13 @@ void BaseDecoderTest::TearDown() {
}
void BaseDecoderTest::DecodeFrame (const uint8_t* src, int sliceSize, Callback* cbk) {
void BaseDecoderTest::DecodeFrame (const uint8_t* src, size_t sliceSize, Callback* cbk) {
uint8_t* data[3];
SBufferInfo bufInfo;
memset (data, 0, sizeof (data));
memset (&bufInfo, 0, sizeof (SBufferInfo));
DECODING_STATE rv = decoder_->DecodeFrame2 (src, sliceSize, data, &bufInfo);
DECODING_STATE rv = decoder_->DecodeFrame2 (src, (int) sliceSize, data, &bufInfo);
ASSERT_TRUE (rv == dsErrorFree);
if (bufInfo.iBufferStatus == 1 && cbk != NULL) {

View File

@ -83,7 +83,7 @@ class DecodeEncodeTest : public ::testing::TestWithParam<DecodeEncodeFileParam>,
break;
}
}
return buf_.PopFront (static_cast<uint8_t*> (ptr), len);
return (int) buf_.PopFront (static_cast<uint8_t*> (ptr), len);
}
protected:

View File

@ -29,7 +29,7 @@ TEST_F (DecoderCapabilityTest, JustInit) {
EXPECT_EQ (sDecCap.iMaxCpb, 20000);
EXPECT_EQ (sDecCap.iMaxDpb, 20480);
EXPECT_EQ (sDecCap.iMaxBr, 20000);
EXPECT_EQ (sDecCap.bRedPicCap, 0);
EXPECT_EQ (sDecCap.bRedPicCap, false);
}

View File

@ -726,7 +726,7 @@ void ExtractDidNal (SFrameBSInfo* pBsInfo, int& iSrcLen, std::vector<SLostSim>*
int SimulateNALLoss (const unsigned char* pSrc, int& iSrcLen, std::vector<SLostSim>* p_SLostSim,
const char* pLossChars, bool bLossPara, int& iLossIdx, bool& bVCLLoss) {
unsigned char* pDst = new unsigned char[iSrcLen];
int iLossCharLen = strlen (pLossChars);
int iLossCharLen = (int) strlen (pLossChars);
int iSkipedBytes = 0;
int iDstLen = 0;
int iBufPos = 0;
@ -815,7 +815,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionLTR_ALLIDR) {
decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);
int32_t iSpsPpsIdAddition = 1;
encoder_->SetOption (ENCODER_OPTION_ENABLE_SPS_PPS_ID_ADDITION, &iSpsPpsIdAddition);
int32_t iIDRPeriod = pow (2.0f, (param_.iTemporalLayerNum - 1)) * ((rand() % 5) + 1);
int32_t iIDRPeriod = (int32_t) pow (2.0f, (param_.iTemporalLayerNum - 1)) * ((rand() % 5) + 1);
encoder_->SetOption (ENCODER_OPTION_IDR_INTERVAL, &iIDRPeriod);
SLTRConfig sLtrConfigVal;
sLtrConfigVal.bEnableLongTermReference = 1;
@ -1594,7 +1594,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificFrameChange) {
EXPECT_EQ (dstBufInfo_.iBufferStatus, 0); //no output
rv = decoder_->DecodeFrame2 (NULL, 0, pData, &dstBufInfo_); //reconstruction
//Ref picture is ECed, so current status is ECed, when EC disable, NO output
EXPECT_TRUE (rv & 32);
EXPECT_TRUE ((rv & 32) != 0);
EXPECT_EQ (dstBufInfo_.iBufferStatus, 0);
iIdx++;
@ -1689,10 +1689,10 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRLoss) {
decoder_->GetOption (DECODER_OPTION_ERROR_CON_IDC, &uiGet);
EXPECT_EQ (uiGet, (uint32_t) ERROR_CON_SLICE_COPY);
rv = decoder_->DecodeFrame2 (info.sLayerInfo[0].pBsBuf, len, pData, &dstBufInfo_);
EXPECT_TRUE (rv & 32); //parse correct, but reconstruct ECed
EXPECT_TRUE ((rv & 32) != 0); //parse correct, but reconstruct ECed
EXPECT_EQ (dstBufInfo_.iBufferStatus, 1); //ECed output for frame 0
rv = decoder_->DecodeFrame2 (NULL, 0, pData, &dstBufInfo_); //ECed status, reconstruction current frame 1
EXPECT_TRUE (rv & 32); //decoder ECed status
EXPECT_TRUE ((rv & 32) != 0); //decoder ECed status
EXPECT_EQ (dstBufInfo_.iBufferStatus, 1); //ECed output for frame 1
iIdx++;
@ -1713,7 +1713,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRLoss) {
EXPECT_EQ (rv, 0); //parse correct
rv = decoder_->DecodeFrame2 (NULL, 0, pData, &dstBufInfo_); //reconstruction
// Ref picture is ECed, so reconstructed picture is ECed
EXPECT_TRUE (rv & 32);
EXPECT_TRUE ((rv & 32) != 0);
EXPECT_EQ (dstBufInfo_.iBufferStatus, 0);
iIdx++;
@ -1734,7 +1734,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRLoss) {
EXPECT_EQ (rv, 0); //parse correct
EXPECT_EQ (dstBufInfo_.iBufferStatus, 0);
rv = decoder_->DecodeFrame2 (NULL, 0, pData, &dstBufInfo_); //reconstruction
EXPECT_TRUE (rv & 32);
EXPECT_TRUE ((rv & 32) != 0);
EXPECT_EQ (dstBufInfo_.iBufferStatus, 0); //slice loss
iIdx++;
@ -1858,10 +1858,10 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRNoLoss) {
decoder_->GetOption (DECODER_OPTION_ERROR_CON_IDC, &uiGet);
EXPECT_EQ (uiGet, (uint32_t) ERROR_CON_SLICE_COPY);
rv = decoder_->DecodeFrame2 (info.sLayerInfo[0].pBsBuf, len, pData, &dstBufInfo_);
EXPECT_TRUE (rv & 32); //parse OK but frame 2 ECed
EXPECT_TRUE ((rv & 32) != 0); //parse OK but frame 2 ECed
EXPECT_EQ (dstBufInfo_.iBufferStatus, 1); //slice loss but ECed output Frame 2
rv = decoder_->DecodeFrame2 (NULL, 0, pData, &dstBufInfo_); //reconstruction
EXPECT_TRUE (rv & 32);
EXPECT_TRUE ((rv & 32) != 0);
EXPECT_EQ (dstBufInfo_.iBufferStatus, 0); //slice loss
iIdx++;
@ -1955,7 +1955,7 @@ TEST_F (EncodeDecodeTestAPI, Engine_SVC_Switch_I) {
decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);
int32_t iSpsPpsIdAddition = 1;
encoder_->SetOption (ENCODER_OPTION_ENABLE_SPS_PPS_ID_ADDITION, &iSpsPpsIdAddition);
int32_t iIDRPeriod = pow (2.0f, (param_.iTemporalLayerNum - 1)) * ((rand() % 5) + 1);
int32_t iIDRPeriod = (int32_t) pow (2.0f, (param_.iTemporalLayerNum - 1)) * ((rand() % 5) + 1);
encoder_->SetOption (ENCODER_OPTION_IDR_INTERVAL, &iIDRPeriod);
SLTRConfig sLtrConfigVal;
sLtrConfigVal.bEnableLongTermReference = 1;
@ -2400,10 +2400,10 @@ class DecodeParseAPI : public EncodeDecodeTestBase {
void EncodeOneFrame (int iIdx) {
int iFrameSize = iWidth_ * iHeight_ * 3 / 2;
int iSize = fread (buf_.data(), sizeof (char), iFrameSize, fYuv_);
int iSize = (int) fread (buf_.data(), sizeof (char), iFrameSize, fYuv_);
if (feof (fYuv_) || iSize != iFrameSize) {
rewind (fYuv_);
iSize = fread (buf_.data(), sizeof (char), iFrameSize, fYuv_);
iSize = (int) fread (buf_.data(), sizeof (char), iFrameSize, fYuv_);
ASSERT_TRUE (iSize == iFrameSize);
}
int rv = encoder_->EncodeFrame (&EncPic, &info);

View File

@ -45,7 +45,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\;..\..\..\..\codec\encoder\plus\inc;..\..\..\..\codec\encoder\core\inc;..\..\..\..\codec\common\inc;..\..\..\..\codec\api\svc;..\..\..\..\gtest\include;..\..\..\codec\processing\src\common;..\..\..\..\codec\processing\interface"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;X86_ASM"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;X86_ASM;_CRT_SECURE_NO_WARNINGS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@ -119,7 +119,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\;..\..\..\..\codec\encoder\plus\inc;..\..\..\..\codec\encoder\core\inc;..\..\..\..\codec\common\inc;..\..\..\..\codec\api\svc;..\..\..\..\gtest\include;..\..\..\codec\processing\src\common;..\..\..\..\codec\processing\interface"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@ -194,7 +194,7 @@
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\..\..\;..\..\..\..\codec\encoder\plus\inc;..\..\..\..\codec\encoder\core\inc;..\..\..\..\codec\common\inc;..\..\..\..\codec\api\svc;..\..\..\..\gtest\include;..\..\..\codec\processing\src\common;..\..\..\..\codec\processing\interface"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;X86_ASM"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;X86_ASM;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
@ -270,7 +270,7 @@
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\..\..\;..\..\..\..\codec\encoder\plus\inc;..\..\..\..\codec\encoder\core\inc;..\..\..\..\codec\common\inc;..\..\..\..\codec\api\svc;..\..\..\..\gtest\include;..\..\..\codec\processing\src\common;..\..\..\..\codec\processing\interface"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"

View File

@ -122,9 +122,9 @@ void DecoderInterfaceTest::DecoderBs (const char* sFileName) {
#if defined(ANDROID_NDK)
std::string filename = std::string ("/sdcard/") + sFileName;
ASSERT_TRUE (pH264File = fopen (filename.c_str(), "rb"));
ASSERT_TRUE ((pH264File = fopen (filename.c_str(), "rb")) != NULL);
#else
ASSERT_TRUE (pH264File = fopen (sFileName, "rb"));
ASSERT_TRUE ((pH264File = fopen (sFileName, "rb")) != NULL);
#endif
fseek (pH264File, 0L, SEEK_END);
iFileSize = (int32_t) ftell (pH264File);
@ -271,7 +271,7 @@ void DecoderInterfaceTest::TestEndOfStream() {
EXPECT_EQ (eRet, cmResultSuccess);
eRet = (CM_RETURN) m_pDec->GetOption (DECODER_OPTION_END_OF_STREAM, &iOut);
EXPECT_EQ (eRet, cmResultSuccess);
EXPECT_EQ (iOut, iTmp != 0);
EXPECT_EQ (iOut, iTmp != 0 ? 1 : 0);
}
//set false as input
@ -281,7 +281,7 @@ void DecoderInterfaceTest::TestEndOfStream() {
eRet = (CM_RETURN) m_pDec->GetOption (DECODER_OPTION_END_OF_STREAM, &iOut);
EXPECT_EQ (eRet, cmResultSuccess);
EXPECT_EQ (iOut, false);
EXPECT_EQ (iOut, 0);
//set true as input
iTmp = true;
@ -290,24 +290,24 @@ void DecoderInterfaceTest::TestEndOfStream() {
eRet = (CM_RETURN) m_pDec->GetOption (DECODER_OPTION_END_OF_STREAM, &iOut);
EXPECT_EQ (eRet, cmResultSuccess);
EXPECT_EQ (iOut, true);
EXPECT_EQ (iOut, 1);
//Mock data packet in
//Test NULL data input for decoder, should be true for EOS
eRet = (CM_RETURN) m_pDec->DecodeFrame2 (NULL, 0, m_pData, &m_sBufferInfo);
EXPECT_EQ (eRet, 0); //decode should return OK
eRet = (CM_RETURN) m_pDec->GetOption (DECODER_OPTION_END_OF_STREAM, &iOut);
EXPECT_EQ (iOut, true); //decoder should have EOS == true
EXPECT_EQ (iOut, 1); //decoder should have EOS == true
//Test valid data input for decoder, should be false for EOS
MockPacketType (NAL_UNIT_UNSPEC_0, 50);
eRet = (CM_RETURN) m_pDec->DecodeFrame2 (m_szBuffer, m_iBufLength, m_pData, &m_sBufferInfo);
eRet = (CM_RETURN) m_pDec->GetOption (DECODER_OPTION_END_OF_STREAM, &iOut);
EXPECT_EQ (iOut, false); //decoder should have EOS == false
EXPECT_EQ (iOut, 0); //decoder should have EOS == false
//Test NULL data input for decoder, should be true for EOS
eRet = (CM_RETURN) m_pDec->DecodeFrame2 (NULL, 0, m_pData, &m_sBufferInfo);
eRet = (CM_RETURN) m_pDec->GetOption (DECODER_OPTION_END_OF_STREAM, &iOut);
EXPECT_EQ (iOut, true); //decoder should have EOS == true
EXPECT_EQ (iOut, 1); //decoder should have EOS == true
Uninit();
}

View File

@ -191,7 +191,7 @@ TEST_F (EncoderInterfaceTest, EncoderOptionSetTest) {
pSrcPic->uiTimeStamp += 30;
eOptionId = ENCODER_OPTION_FRAME_RATE;
fValue = static_cast<int> (rand() % 60 - 5);
fValue = static_cast<float> (rand() % 60 - 5);
iResult = pPtrEnc->SetOption (eOptionId, &fValue);
if (fValue <= 0)

View File

@ -250,14 +250,14 @@ TEST_F (MotionEstimateRangeTest, TestWelsMotionCrossSearch) {
SWelsFuncPtrList sFuncList;
SWelsME sMe;
SSlice sSlice;
int32_t iUsageType = 1;
bool bUsageType = true;
uint8_t* pRef = m_pRefStart + PADDING_LENGTH * m_iWidthExt + PADDING_LENGTH;
const int32_t kiMaxBlock16Sad = 72000;//a rough number
memset (&sSlice, 0, sizeof (sSlice));
memset (&sMe, 0, sizeof (sMe));
WelsInitSampleSadFunc (&sFuncList, 0); //test c functions
WelsInitMeFunc (&sFuncList, 0, iUsageType);
WelsInitMeFunc (&sFuncList, 0, bUsageType);
RandomPixelDataGenerator (m_pSrc, m_iWidth, m_iHeight, m_iWidth);
RandomPixelDataGenerator (m_pRefStart, m_iWidthExt, m_iHeightExt, m_iWidthExt);

View File

@ -15,7 +15,7 @@ class FileInputStream : public InputStream {
return -1;
}
file_.read (static_cast<char*> (ptr), len);
return file_.gcount();
return (int) file_.gcount();
}
private:
std::ifstream file_;