ref: 6b08aeff9c012b169b90e51ba0fba922c67986bc
parent: c12edefcd371fcd64d6985d17404ac600e4f2d39
parent: df6813063f3236c5601d7890a34c79fb7e76f339
author: ruil2 <ruil2@cisco.com>
date: Wed Apr 2 11:05:18 EDT 2014
Merge pull request #620 from JuannyWang/expNew [Encoder UT] add expGolom UT and encoder trace modification
--- a/codec/encoder/plus/src/welsEncoderExt.cpp
+++ b/codec/encoder/plus/src/welsEncoderExt.cpp
@@ -225,7 +225,7 @@
int CWelsH264SVCEncoder::InitializeExt (const SEncParamExt* argv) {
if (NULL == argv) {
- WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), invalid argv= 0x%p\n",
+ WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::InitializeExt(), invalid argv= 0x%p\n",
argv);
return cmInitParaError;
}
@@ -233,7 +233,7 @@
SWelsSvcCodingParam sConfig (true);
// Convert SEncParamExt into WelsSVCParamConfig here..
if (sConfig.ParamTranscode (*argv)) {
- WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), parameter_translation failed.\n");
+ WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::InitializeExt(), parameter_translation failed.\n");
Uninitialize();
return cmInitParaError;
}
--- /dev/null
+++ b/test/encoder/EncUT_ExpGolomb.cpp
@@ -1,0 +1,41 @@
+#include <gtest/gtest.h>
+#include <math.h>
+#include "svc_enc_golomb.h"
+#include "macros.h"
+
+using namespace WelsSVCEnc;
+
+const double g_kdLog2Factor = 1.0 / log(2.0);
+
+TEST(UeExpGolombTest, TestBsSizeUeLt256) {
+ uint32_t uiInVal = 0;
+ for (; uiInVal < 256; ++ uiInVal) {
+ const uint32_t uiActVal = BsSizeUE( uiInVal );
+ const int32_t m = static_cast<int32_t>(log( (uiInVal+1) * 1.0 ) * g_kdLog2Factor + 1e-6);
+ const uint32_t uiExpVal = (m<<1)+1;
+ EXPECT_EQ(uiActVal, uiExpVal);
+ }
+}
+
+TEST(UeExpGolombTest, TestBsSizeUeRangeFrom256To65534) {
+ uint32_t uiInVal = 0x100;
+ for (; uiInVal < 0xFFFF; ++ uiInVal) {
+ const uint32_t uiActVal = BsSizeUE( uiInVal );
+ const int32_t m = static_cast<int32_t>(log( (uiInVal+1) * 1.0 ) * g_kdLog2Factor + 1e-6);
+ const uint32_t uiExpVal = (m<<1)+1;
+ EXPECT_EQ(uiActVal, uiExpVal);
+ }
+}
+
+TEST(UeExpGolombTest, TestBsSizeUeRangeFrom65535ToPlus256) {
+ uint32_t uiInVal = 0xFFFF;
+ const uint32_t uiCountBase = 256;
+ const uint32_t uiInValEnd = uiInVal + uiCountBase;
+ for (; uiInVal < uiInValEnd; ++ uiInVal) {
+ const uint32_t uiActVal = BsSizeUE( uiInVal );
+ // float precision issue in case use math::log
+ const int32_t m = WELS_LOG2(1+uiInVal);
+ const uint32_t uiExpVal = (m<<1)+1;
+ EXPECT_EQ(uiActVal, uiExpVal);
+ }
+}
--- a/test/encoder/targets.mk
+++ b/test/encoder/targets.mk
@@ -2,6 +2,7 @@
ENCODER_UNITTEST_CPP_SRCS=\
$(ENCODER_UNITTEST_SRCDIR)/EncUT_EncoderMbTest.cpp\
$(ENCODER_UNITTEST_SRCDIR)/EncUT_ExpandPic.cpp\
+ $(ENCODER_UNITTEST_SRCDIR)/EncUT_ExpGolomb.cpp\
$(ENCODER_UNITTEST_SRCDIR)/EncUT_MemoryAlloc.cpp\
$(ENCODER_UNITTEST_SRCDIR)/EncUT_MotionEstimate.cpp\