From 4ca8ad2612aa7f5227c360cc2025d3873b12295a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 26 Jan 2015 12:50:03 +0200 Subject: [PATCH 1/4] Initialize pCodecInstance in the constructor This avoids using uninitialized memory if SetCodecInstance isn't ever called (as in DecUT_ParseSyntax). --- codec/common/src/welsCodecTrace.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/codec/common/src/welsCodecTrace.cpp b/codec/common/src/welsCodecTrace.cpp index 8676d683..baac560c 100644 --- a/codec/common/src/welsCodecTrace.cpp +++ b/codec/common/src/welsCodecTrace.cpp @@ -58,6 +58,7 @@ welsCodecTrace::welsCodecTrace() { m_sLogCtx.pLogCtx = this; m_sLogCtx.pfLog = StaticCodecTrace; + m_sLogCtx.pCodecInstance = NULL; } welsCodecTrace::~welsCodecTrace() { From faf62464a898be554421e9fccab75275a9c3360f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 26 Jan 2015 12:22:39 +0200 Subject: [PATCH 2/4] Make DecUT_ParseSyntax.cpp actually build and run successfully --- test/decoder/DecUT_ParseSyntax.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/decoder/DecUT_ParseSyntax.cpp b/test/decoder/DecUT_ParseSyntax.cpp index 2353c2ab..59df62fa 100644 --- a/test/decoder/DecUT_ParseSyntax.cpp +++ b/test/decoder/DecUT_ParseSyntax.cpp @@ -250,19 +250,19 @@ void DecoderParseSyntaxTest::TestScalingList() { DecodeBs ("res/BA_MW_D.264"); ASSERT_TRUE (m_pCtx->sSpsBuffer[0].bSeqScalingMatrixPresentFlag == false); EXPECT_EQ (0, memcmp (iScalingListPPS, m_pCtx->sSpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t)));; - ASSERT_TRUE (m_pCtx->sPpsBuffer[0].bSeqScalingMatrixPresentFlag == false); + ASSERT_TRUE (m_pCtx->sPpsBuffer[0].bPicScalingMatrixPresentFlag == false); EXPECT_EQ (0, memcmp (iScalingListPPS, m_pCtx->sPpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t)));; Uninit(); //Scalinglist value just written into sps and pps Init(); - DecodeBs ("test_scalinglist_jm.264"); + DecodeBs ("res/test_scalinglist_jm.264"); ASSERT_TRUE (m_pCtx->sSpsBuffer[0].bSeqScalingMatrixPresentFlag); for (int i = 0; i < 6; i++) { EXPECT_EQ (0, memcmp (iScalingList[i], m_pCtx->sSpsBuffer[0].iScalingList4x4[i], 16 * sizeof (uint8_t))); } - ASSERT_TRUE (m_pCtx->sPpsBuffer[0].bSeqScalingMatrixPresentFlag); - EXPECT_EQ (0, memcmp (iScalingList, m_pCtx->sPpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t))); + ASSERT_TRUE (m_pCtx->sPpsBuffer[0].bPicScalingMatrixPresentFlag == false); + EXPECT_EQ (0, memcmp (iScalingListPPS, m_pCtx->sPpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t))); Uninit(); From 4192165ec9ab95bd512d6ca8e33196259c7c79ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 26 Jan 2015 12:05:10 +0200 Subject: [PATCH 3/4] Add DecUT_ParseSyntax to the build system This test seems to have been added to the git tree in commit 9a602cac (which does much more than what the commit message tells), and finally merged into git master in 2c99f581. --- .../win32/codec_ut/codec_unittest.vcproj | 36 +++++++++++++++++++ test/decoder/targets.mk | 1 + 2 files changed, 37 insertions(+) diff --git a/test/build/win32/codec_ut/codec_unittest.vcproj b/test/build/win32/codec_ut/codec_unittest.vcproj index b5e888a8..37c8f29b 100644 --- a/test/build/win32/codec_ut/codec_unittest.vcproj +++ b/test/build/win32/codec_ut/codec_unittest.vcproj @@ -654,6 +654,42 @@ /> + + + + + + + + + + + + + + diff --git a/test/decoder/targets.mk b/test/decoder/targets.mk index 0b9fec47..2613453b 100644 --- a/test/decoder/targets.mk +++ b/test/decoder/targets.mk @@ -7,6 +7,7 @@ DECODER_UNITTEST_CPP_SRCS=\ $(DECODER_UNITTEST_SRCDIR)/DecUT_IdctResAddPred.cpp\ $(DECODER_UNITTEST_SRCDIR)/DecUT_IntraPrediction.cpp\ $(DECODER_UNITTEST_SRCDIR)/DecUT_MotionCompensation.cpp\ + $(DECODER_UNITTEST_SRCDIR)/DecUT_ParseSyntax.cpp\ $(DECODER_UNITTEST_SRCDIR)/DecUT_PredMv.cpp\ DECODER_UNITTEST_OBJS += $(DECODER_UNITTEST_CPP_SRCS:.cpp=.$(OBJ)) From e64e2bb620be87a4933b14d16460b61e32c89177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 26 Jan 2015 15:21:07 +0200 Subject: [PATCH 4/4] Avoid warnings in DecUT_ParseSyntax --- test/decoder/DecUT_ParseSyntax.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/decoder/DecUT_ParseSyntax.cpp b/test/decoder/DecUT_ParseSyntax.cpp index 59df62fa..01c039e6 100644 --- a/test/decoder/DecUT_ParseSyntax.cpp +++ b/test/decoder/DecUT_ParseSyntax.cpp @@ -165,6 +165,7 @@ void DecoderParseSyntaxTest::Init() { m_pWelsTrace->SetTraceLevel (WELS_LOG_ERROR); } CM_RETURN eRet = (CM_RETURN)Initialize (&m_sDecParam, m_pCtx, &m_pWelsTrace->m_sLogCtx); + (void) eRet; } void DecoderParseSyntaxTest::Uninit() { @@ -195,9 +196,9 @@ void DecoderParseSyntaxTest::DecodeBs (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);