shithub: openh264

Download patch

ref: 7ae3fbcfbfbfd059d51f3bba19596a7b211d7b16
parent: b4b1d1df8c0f9bd71aeb44724826228643185660
author: Martin Storsjö <martin@martin.st>
date: Sun Jun 29 15:20:12 EDT 2014

Share one implementation of the CReadConfig class between the decoder and encoder console apps

diff: cannot open b/codec/console/common/inc//null: file does not exist: 'b/codec/console/common/inc//null' diff: cannot open b/codec/console/common/src//null: file does not exist: 'b/codec/console/common/src//null' diff: cannot open b/codec/console/common//null: file does not exist: 'b/codec/console/common//null' diff: cannot open a/codec/console/enc/inc//null: file does not exist: 'a/codec/console/enc/inc//null'
--- a/Makefile
+++ b/Makefile
@@ -90,14 +90,17 @@
     -Igtest/include \
     -Icodec/common/inc \
 
-H264DEC_INCLUDES = $(DECODER_INCLUDES) -Icodec/console/dec/inc
-H264DEC_LDFLAGS = -L. $(call LINK_LIB,decoder) $(call LINK_LIB,common)
-H264DEC_DEPS = $(LIBPREFIX)decoder.$(LIBSUFFIX) $(LIBPREFIX)common.$(LIBSUFFIX)
+CONSOLE_COMMON_INCLUDES = \
+    -Icodec/console/common/inc
 
-H264ENC_INCLUDES = $(ENCODER_INCLUDES) -Icodec/console/enc/inc
-H264ENC_LDFLAGS = -L. $(call LINK_LIB,encoder) $(call LINK_LIB,processing) $(call LINK_LIB,common)
-H264ENC_DEPS = $(LIBPREFIX)encoder.$(LIBSUFFIX) $(LIBPREFIX)processing.$(LIBSUFFIX) $(LIBPREFIX)common.$(LIBSUFFIX)
+H264DEC_INCLUDES = $(DECODER_INCLUDES) $(CONSOLE_COMMON_INCLUDES) -Icodec/console/dec/inc
+H264DEC_LDFLAGS = -L. $(call LINK_LIB,decoder) $(call LINK_LIB,common) $(call LINK_LIB,console_common)
+H264DEC_DEPS = $(LIBPREFIX)decoder.$(LIBSUFFIX) $(LIBPREFIX)common.$(LIBSUFFIX) $(LIBPREFIX)console_common.$(LIBSUFFIX)
 
+H264ENC_INCLUDES = $(ENCODER_INCLUDES) $(CONSOLE_COMMON_INCLUDES) -Icodec/console/enc/inc
+H264ENC_LDFLAGS = -L. $(call LINK_LIB,encoder) $(call LINK_LIB,processing) $(call LINK_LIB,common) $(call LINK_LIB,console_common)
+H264ENC_DEPS = $(LIBPREFIX)encoder.$(LIBSUFFIX) $(LIBPREFIX)processing.$(LIBSUFFIX) $(LIBPREFIX)common.$(LIBSUFFIX) $(LIBPREFIX)console_common.$(LIBSUFFIX)
+
 CODEC_UNITTEST_LDFLAGS = -L. $(call LINK_LIB,gtest) $(call LINK_LIB,decoder) $(call LINK_LIB,encoder) $(call LINK_LIB,processing) $(call LINK_LIB,common) $(CODEC_UNITTEST_LDFLAGS_SUFFIX)
 CODEC_UNITTEST_DEPS = $(LIBPREFIX)gtest.$(LIBSUFFIX) $(LIBPREFIX)decoder.$(LIBSUFFIX) $(LIBPREFIX)encoder.$(LIBSUFFIX) $(LIBPREFIX)processing.$(LIBSUFFIX) $(LIBPREFIX)common.$(LIBSUFFIX)
 DECODER_UNITTEST_INCLUDES = $(CODEC_UNITTEST_INCLUDES) $(DECODER_INCLUDES) -Itest -Itest/decoder
@@ -151,6 +154,7 @@
 ifneq (ios, $(OS))
 include codec/console/dec/targets.mk
 include codec/console/enc/targets.mk
+include codec/console/common/targets.mk
 endif
 endif
 
--- a/build/mktargets.sh
+++ b/build/mktargets.sh
@@ -7,6 +7,7 @@
 
 python build/mktargets.py --directory codec/console/dec --binary h264dec
 python build/mktargets.py --directory codec/console/enc --binary h264enc
+python build/mktargets.py --directory codec/console/common --library console_common
 python build/mktargets.py --directory test/encoder --prefix encoder_unittest
 python build/mktargets.py --directory test/decoder --prefix decoder_unittest
 python build/mktargets.py --directory test/processing --prefix processing_unittest
--- a/codec/build/android/dec/jni/welsdecdemo.mk
+++ b/codec/build/android/dec/jni/welsdecdemo.mk
@@ -22,9 +22,10 @@
 #
 CODEC_PATH := ../../../../
 CONSOLE_DEC_PATH := ../../../../console/dec
+CONSOLE_COMMON_PATH := ../../../../console/common
 LOCAL_SRC_FILES := \
             $(CONSOLE_DEC_PATH)/src/h264dec.cpp \
-            $(CONSOLE_DEC_PATH)/src/read_config.cpp \
+            $(CONSOLE_COMMON_PATH)/src/read_config.cpp \
             $(CONSOLE_DEC_PATH)/src/d3d9_utils.cpp \
             myjni.cpp
 #
@@ -33,6 +34,7 @@
 LOCAL_C_INCLUDES := \
             $(LOCAL_PATH)/../../../../api/svc \
             $(LOCAL_PATH)/../../../../console/dec/inc \
+            $(LOCAL_PATH)/../../../../console/common/inc \
             $(LOCAL_PATH)/../../../../common/inc
 #
 # Compile Flags and Link Libraries
--- a/codec/build/android/enc/jni/welsencdemo.mk
+++ b/codec/build/android/enc/jni/welsencdemo.mk
@@ -22,9 +22,10 @@
 #
 CODEC_PATH := ../../../../
 CONSOLE_ENC_PATH := ../../../../console/enc
+CONSOLE_COMMON_PATH := ../../../../console/common
 LOCAL_SRC_FILES := \
             $(CONSOLE_ENC_PATH)/src/welsenc.cpp \
-            $(CONSOLE_ENC_PATH)/src/read_config.cpp \
+            $(CONSOLE_COMMON_PATH)/src/read_config.cpp \
             myjni.cpp
 
 #
@@ -33,6 +34,7 @@
 LOCAL_C_INCLUDES := \
             $(LOCAL_PATH)/../../../../api/svc \
             $(LOCAL_PATH)/../../../../console/enc/inc \
+            $(LOCAL_PATH)/../../../../console/common/inc \
             $(LOCAL_PATH)/../../../../encoder/core/inc \
             $(LOCAL_PATH)/../../../../processing/interface \
             $(LOCAL_PATH)/../../../../common/inc
--- a/codec/build/iOS/dec/demo/demo.xcodeproj/project.pbxproj
+++ b/codec/build/iOS/dec/demo/demo.xcodeproj/project.pbxproj
@@ -64,10 +64,10 @@
 		F0E663671810EFA5000C888E /* DEMOViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DEMOViewController.h; sourceTree = "<group>"; };
 		F0E663681810EFA5000C888E /* DEMOViewController.m */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; path = DEMOViewController.m; sourceTree = "<group>"; };
 		F0E663721810EFF7000C888E /* d3d9_utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = d3d9_utils.h; sourceTree = "<group>"; };
-		F0E663741810EFF7000C888E /* read_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = read_config.h; sourceTree = "<group>"; };
+		F0E663741810EFF7000C888E /* read_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = read_config.h; path = ../../common/inc/read_config.h; sourceTree = "<group>"; };
 		F0E663761810EFF7000C888E /* d3d9_utils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = d3d9_utils.cpp; sourceTree = "<group>"; };
 		F0E663771810EFF7000C888E /* h264dec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = h264dec.cpp; sourceTree = "<group>"; };
-		F0E663791810EFF7000C888E /* read_config.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = read_config.cpp; sourceTree = "<group>"; };
+		F0E663791810EFF7000C888E /* read_config.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = read_config.cpp; path = ../../common/src/read_config.cpp; sourceTree = "<group>"; };
 		F0E663B3181117B9000C888E /* DEMOViewControllerShowResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DEMOViewControllerShowResource.h; sourceTree = "<group>"; };
 		F0E663B4181117B9000C888E /* DEMOViewControllerShowResource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DEMOViewControllerShowResource.m; sourceTree = "<group>"; };
 /* End PBXFileReference section */
--- a/codec/build/iOS/enc/encDemo/encDemo.xcodeproj/project.pbxproj
+++ b/codec/build/iOS/enc/encDemo/encDemo.xcodeproj/project.pbxproj
@@ -96,7 +96,7 @@
 		FAFB4FF418BC8E9A00315438 /* processing.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = processing.xcodeproj; path = ../../../../processing/build/iOS/processing.xcodeproj; sourceTree = "<group>"; };
 		FAFB500918BC8F6600315438 /* read_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = read_config.h; sourceTree = "<group>"; };
 		FAFB500A18BC8F6C00315438 /* welsenc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = welsenc.cpp; sourceTree = "<group>"; };
-		FAFB502E18BCA50900315438 /* read_config.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = read_config.cpp; sourceTree = "<group>"; };
+		FAFB502E18BCA50900315438 /* read_config.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = read_config.cpp; path = ../../common/src/read_config.cpp; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -224,7 +224,8 @@
 			children = (
 				FAFB500918BC8F6600315438 /* read_config.h */,
 			);
-			path = inc;
+			name = inc;
+			path = ../common/inc;
 			sourceTree = "<group>";
 		};
 /* End PBXGroup section */
--- a/codec/build/win32/dec/decConsole.vcproj
+++ b/codec/build/win32/dec/decConsole.vcproj
@@ -49,7 +49,7 @@
 				Name="VCCLCompilerTool"
 				Optimization="2"
 				InlineFunctionExpansion="1"
-				AdditionalIncludeDirectories="..\..\..\console\dec\inc,..\..\..\api\svc,..\..\..\common\inc"
+				AdditionalIncludeDirectories="..\..\..\console\dec\inc,..\..\..\console\common\inc,..\..\..\api\svc,..\..\..\common\inc"
 				PreprocessorDefinitions="NDEBUG;_CONSOLE"
 				StringPooling="true"
 				RuntimeLibrary="0"
@@ -139,7 +139,7 @@
 				Name="VCCLCompilerTool"
 				Optimization="2"
 				InlineFunctionExpansion="1"
-				AdditionalIncludeDirectories="..\..\..\console\dec\inc,..\..\..\api\svc,..\..\..\common\inc"
+				AdditionalIncludeDirectories="..\..\..\console\dec\inc,..\..\..\console\common\inc,..\..\..\api\svc,..\..\..\common\inc"
 				PreprocessorDefinitions="NDEBUG;_CONSOLE"
 				StringPooling="true"
 				RuntimeLibrary="0"
@@ -227,7 +227,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="..\..\..\console\dec\inc,..\..\..\api\svc,..\..\..\common\inc"
+				AdditionalIncludeDirectories="..\..\..\console\dec\inc,..\..\..\console\common\inc,..\..\..\api\svc,..\..\..\common\inc"
 				PreprocessorDefinitions="_DEBUG;_CONSOLE"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -318,7 +318,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="..\..\..\console\dec\inc,..\..\..\api\svc,..\..\..\common\inc"
+				AdditionalIncludeDirectories="..\..\..\console\dec\inc,..\..\..\console\common\inc,..\..\..\api\svc,..\..\..\common\inc"
 				PreprocessorDefinitions="_DEBUG;_CONSOLE"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -395,7 +395,7 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\console\dec\src\read_config.cpp"
+				RelativePath="..\..\..\console\common\src\read_config.cpp"
 				>
 			</File>
 		</Filter>
@@ -408,7 +408,7 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\console\dec\inc\read_config.h"
+				RelativePath="..\..\..\console\common\inc\read_config.h"
 				>
 			</File>
 		</Filter>
--- a/codec/build/win32/enc/encConsole.vcproj
+++ b/codec/build/win32/enc/encConsole.vcproj
@@ -48,7 +48,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="..\..\..\console\enc\inc,..\..\..\api\svc,..\..\..\encoder\core\inc,..\..\..\common\inc,..\..\..\processing\interface"
+				AdditionalIncludeDirectories="..\..\..\console\enc\inc,..\..\..\console\common\inc,..\..\..\api\svc,..\..\..\encoder\core\inc,..\..\..\common\inc,..\..\..\processing\interface"
 				PreprocessorDefinitions="_DEBUG;_CONSOLE;"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -140,7 +140,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="..\..\..\console\enc\inc,..\..\..\api\svc,..\..\..\encoder\core\inc,..\..\..\common\inc,..\..\..\processing\interface"
+				AdditionalIncludeDirectories="..\..\..\console\enc\inc,..\..\..\console\common\inc,..\..\..\api\svc,..\..\..\encoder\core\inc,..\..\..\common\inc,..\..\..\processing\interface"
 				PreprocessorDefinitions="_DEBUG;_CONSOLE"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -232,7 +232,7 @@
 				Name="VCCLCompilerTool"
 				Optimization="2"
 				InlineFunctionExpansion="1"
-				AdditionalIncludeDirectories="..\..\..\console\enc\inc,..\..\..\api\svc,..\..\..\encoder\core\inc,..\..\..\common\inc,..\..\..\processing\interface"
+				AdditionalIncludeDirectories="..\..\..\console\enc\inc,..\..\..\console\common\inc,..\..\..\api\svc,..\..\..\encoder\core\inc,..\..\..\common\inc,..\..\..\processing\interface"
 				PreprocessorDefinitions="NDEBUG;_CONSOLE;X86_ASM;"
 				StringPooling="true"
 				RuntimeLibrary="0"
@@ -325,7 +325,7 @@
 				Name="VCCLCompilerTool"
 				Optimization="2"
 				InlineFunctionExpansion="1"
-				AdditionalIncludeDirectories="..\..\..\console\enc\inc,..\..\..\api\svc,..\..\..\encoder\core\inc,..\..\..\common\inc,..\..\..\processing\interface"
+				AdditionalIncludeDirectories="..\..\..\console\enc\inc,..\..\..\console\common\inc,..\..\..\api\svc,..\..\..\encoder\core\inc,..\..\..\common\inc,..\..\..\processing\interface"
 				PreprocessorDefinitions="NDEBUG;_CONSOLE"
 				StringPooling="true"
 				RuntimeLibrary="0"
@@ -395,7 +395,7 @@
 			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
 			>
 			<File
-				RelativePath="..\..\..\console\enc\src\read_config.cpp"
+				RelativePath="..\..\..\console\common\src\read_config.cpp"
 				>
 			</File>
 			<File
@@ -408,7 +408,7 @@
 			Filter="h;hpp;hxx;hm;inl"
 			>
 			<File
-				RelativePath="..\..\..\console\enc\inc\read_config.h"
+				RelativePath="..\..\..\console\common\inc\read_config.h"
 				>
 			</File>
 		</Filter>
--- /dev/null
+++ b/codec/console/common/inc/read_config.h
@@ -1,0 +1,69 @@
+/*!
+ * \copy
+ *     Copyright (c)  2008-2013, Cisco Systems
+ *     All rights reserved.
+ *
+ *     Redistribution and use in source and binary forms, with or without
+ *     modification, are permitted provided that the following conditions
+ *     are met:
+ *
+ *        * Redistributions of source code must retain the above copyright
+ *          notice, this list of conditions and the following disclaimer.
+ *
+ *        * Redistributions in binary form must reproduce the above copyright
+ *          notice, this list of conditions and the following disclaimer in
+ *          the documentation and/or other materials provided with the
+ *          distribution.
+ *
+ *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ *     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ *     COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ *     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ *     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ *     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ *     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ *     POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  read_config.h
+ *
+ *  Abstract
+ *      Class for reading parameter settings in a configure file.
+ *
+ *  History
+ *      08/18/2008 Created
+ *
+ *****************************************************************************/
+#ifndef READ_CONFIG_H__
+#define READ_CONFIG_H__
+
+#include <stdlib.h>
+#include <string>
+using namespace std;
+
+
+class CReadConfig {
+ public:
+  CReadConfig();
+  CReadConfig (const char* pConfigFileName);
+  CReadConfig (const string& pConfigFileName);
+  virtual ~CReadConfig();
+
+  void Openf (const char* strFile);
+  long ReadLine (string* strVal, const int iValSize = 4);
+  const bool EndOfFile();
+  const int GetLines();
+  const bool ExistFile();
+  const string& GetFileName();
+
+ private:
+  FILE*			m_pCfgFile;
+  string			m_strCfgFileName;
+  unsigned int	m_iLines;
+};
+
+#endif	// READ_CONFIG_H__
+
--- /dev/null
+++ b/codec/console/common/src/read_config.cpp
@@ -1,0 +1,139 @@
+/*!
+ * \copy
+ *     Copyright (c)  2008-2013, Cisco Systems
+ *     All rights reserved.
+ *
+ *     Redistribution and use in source and binary forms, with or without
+ *     modification, are permitted provided that the following conditions
+ *     are met:
+ *
+ *        * Redistributions of source code must retain the above copyright
+ *          notice, this list of conditions and the following disclaimer.
+ *
+ *        * Redistributions in binary form must reproduce the above copyright
+ *          notice, this list of conditions and the following disclaimer in
+ *          the documentation and/or other materials provided with the
+ *          distribution.
+ *
+ *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ *     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ *     COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ *     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ *     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ *     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ *     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ *     POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  read_config.h
+ *
+ *  Abstract
+ *      Class for reading parameter settings in a configure file.
+ *
+ *  History
+ *      08/18/2008 Created
+ *
+ *****************************************************************************/
+
+#define _CRT_SECURE_NO_WARNINGS
+#include <stdio.h>
+#include <string.h>
+#include "read_config.h"
+
+CReadConfig::CReadConfig()
+  : m_pCfgFile (NULL)
+  , m_strCfgFileName ("")
+  , m_iLines (0) {
+}
+
+CReadConfig::CReadConfig (const char* kpConfigFileName)
+  : m_pCfgFile (0)
+  , m_strCfgFileName (kpConfigFileName)
+  , m_iLines (0) {
+  if (strlen (kpConfigFileName) > 0) {	// confirmed_safe_unsafe_usage
+    m_pCfgFile = fopen (kpConfigFileName, "r");
+  }
+}
+
+CReadConfig::CReadConfig (const string& kpConfigFileName)
+  : m_pCfgFile (0)
+  , m_strCfgFileName (kpConfigFileName)
+  , m_iLines (0) {
+  if (kpConfigFileName.length() > 0) {
+    m_pCfgFile = fopen (kpConfigFileName.c_str(), "r");
+  }
+}
+
+CReadConfig::~CReadConfig() {
+  if (m_pCfgFile) {
+    fclose (m_pCfgFile);
+    m_pCfgFile = NULL;
+  }
+}
+
+void CReadConfig::Openf (const char* kpStrFile) {
+  if (kpStrFile != NULL && strlen (kpStrFile) > 0) {	// confirmed_safe_unsafe_usage
+    m_strCfgFileName = kpStrFile;
+    m_pCfgFile = fopen (kpStrFile, "r");
+  }
+}
+
+long CReadConfig::ReadLine (string* pVal, const int kiValSize/* = 4*/) {
+  if (m_pCfgFile == NULL || pVal == NULL || kiValSize <= 1)
+    return 0;
+
+  string* strTags = &pVal[0];
+  int nTagNum = 0, n = 0;
+  bool bCommentFlag = false;
+
+  while (n < kiValSize) {
+    pVal[n]	= "";
+    ++ n;
+  }
+
+  do {
+    const char kCh = (char)fgetc (m_pCfgFile);
+
+    if (kCh == '\n' || feof (m_pCfgFile)) {
+      ++ m_iLines;
+      break;
+    }
+    if (kCh == '#')
+      bCommentFlag = true;
+    if (!bCommentFlag) {
+      if (kCh == '\t' || kCh == ' ') {
+        if (nTagNum >= kiValSize)
+          break;
+        if (! (*strTags).empty()) {
+          ++ nTagNum;
+          strTags	= &pVal[nTagNum];
+        }
+      } else
+        *strTags += kCh;
+    }
+
+  } while (true);
+
+  return 1 + nTagNum;
+}
+
+const bool CReadConfig::EndOfFile() {
+  if (m_pCfgFile == NULL)
+    return true;
+  return feof (m_pCfgFile) ? true : false;
+}
+
+const int CReadConfig::GetLines() {
+  return m_iLines;
+}
+
+const bool CReadConfig::ExistFile() {
+  return (m_pCfgFile != NULL);
+}
+
+const string& CReadConfig::GetFileName() {
+  return m_strCfgFileName;
+}
--- /dev/null
+++ b/codec/console/common/targets.mk
@@ -1,0 +1,16 @@
+CONSOLE_COMMON_SRCDIR=codec/console/common
+CONSOLE_COMMON_CPP_SRCS=\
+	$(CONSOLE_COMMON_SRCDIR)/src/read_config.cpp\
+
+CONSOLE_COMMON_OBJS += $(CONSOLE_COMMON_CPP_SRCS:.cpp=.$(OBJ))
+
+OBJS += $(CONSOLE_COMMON_OBJS)
+$(CONSOLE_COMMON_SRCDIR)/%.$(OBJ): $(CONSOLE_COMMON_SRCDIR)/%.cpp
+	$(QUIET_CXX)$(CXX) $(CFLAGS) $(CXXFLAGS) $(INCLUDES) $(CONSOLE_COMMON_CFLAGS) $(CONSOLE_COMMON_INCLUDES) -c $(CXX_O) $<
+
+$(LIBPREFIX)console_common.$(LIBSUFFIX): $(CONSOLE_COMMON_OBJS)
+	$(QUIET)rm -f $@
+	$(QUIET_AR)$(AR) $(AR_OPTS) $+
+
+libraries: $(LIBPREFIX)console_common.$(LIBSUFFIX)
+LIBRARIES += $(LIBPREFIX)console_common.$(LIBSUFFIX)
--- a/codec/console/dec/inc/read_config.h
+++ /dev/null
@@ -1,65 +1,0 @@
-/*!
- * \copy
- *     Copyright (c)  2008-2013, Cisco Systems
- *     All rights reserved.
- *
- *     Redistribution and use in source and binary forms, with or without
- *     modification, are permitted provided that the following conditions
- *     are met:
- *
- *        * Redistributions of source code must retain the above copyright
- *          notice, this list of conditions and the following disclaimer.
- *
- *        * Redistributions in binary form must reproduce the above copyright
- *          notice, this list of conditions and the following disclaimer in
- *          the documentation and/or other materials provided with the
- *          distribution.
- *
- *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- *     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- *     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- *     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- *     COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- *     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- *     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- *     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- *     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- *     POSSIBILITY OF SUCH DAMAGE.
- *
- *  read_config.h
- *
- *  Abstract
- *      Class for reading parameter settings in a configure file.
- *
- *  History
- *      08/18/2008 Created
- *
- *****************************************************************************/
-#ifndef READ_CONFIG_H__
-#define READ_CONFIG_H__
-
-#include <stdlib.h>
-#include <string>
-using namespace std;
-
-class CReadConfig {
- public:
-  CReadConfig (const char* kpConfigFileName);
-  virtual ~CReadConfig();
-
-  long ReadLine (string* val, const int kiValSize = 4);
-  const bool EndOfFile();
-  const int GetLines();
-  const bool ExistFile();
-  const string& GetFileName();
-
- private:
-  FILE*			m_pCfgFile;
-  string			m_strCfgFileName;
-  unsigned int	m_ulLines;
-};
-
-#endif	// READ_CONFIG_H__
-
--- a/codec/console/dec/src/read_config.cpp
+++ /dev/null
@@ -1,120 +1,0 @@
-/*!
- * \copy
- *     Copyright (c)  2008-2013, Cisco Systems
- *     All rights reserved.
- *
- *     Redistribution and use in source and binary forms, with or without
- *     modification, are permitted provided that the following conditions
- *     are met:
- *
- *        * Redistributions of source code must retain the above copyright
- *          notice, this list of conditions and the following disclaimer.
- *
- *        * Redistributions in binary form must reproduce the above copyright
- *          notice, this list of conditions and the following disclaimer in
- *          the documentation and/or other materials provided with the
- *          distribution.
- *
- *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- *     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- *     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- *     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- *     COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- *     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- *     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- *     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- *     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- *     POSSIBILITY OF SUCH DAMAGE.
- *
- *  read_config.h
- *
- *  Abstract
- *      Class for reading parameter settings in a configure file.
- *
- *  History
- *      08/18/2008 Created
- *
- *****************************************************************************/
-
-#define _CRT_SECURE_NO_WARNINGS
-#include <string.h>
-#include <stdio.h>
-
-
-
-#include "read_config.h"
-
-CReadConfig::CReadConfig (const char* kpConfigFileName)
-  : m_pCfgFile (0)
-  , m_strCfgFileName (kpConfigFileName)
-  , m_ulLines (0) {
-  if (strlen (kpConfigFileName) > 0) {	// FIXME: To check validation in configure file name
-    m_pCfgFile = fopen (kpConfigFileName, "r");
-  }
-}
-
-CReadConfig::~CReadConfig() {
-  if (m_pCfgFile) {
-    fclose (m_pCfgFile);
-    m_pCfgFile = NULL;
-  }
-}
-
-long CReadConfig::ReadLine (string* pStr, const int kiValSize/* = 4*/) {
-  if (m_pCfgFile == NULL || pStr == NULL || kiValSize <= 1)
-    return 0;
-
-  string* strTags = &pStr[0];
-  int iTagNum = 0, iNum = 0;
-  bool bCommentFlag = false;
-
-  while (iNum < kiValSize) {
-    pStr[iNum]	= "";
-    ++ iNum;
-  }
-
-  do {
-    const char kChar = (char)fgetc (m_pCfgFile);
-
-    if (kChar == '\n' || feof (m_pCfgFile)) {
-      ++ m_ulLines;
-      break;
-    }
-    if (kChar == '#')
-      bCommentFlag = true;
-    if (!bCommentFlag) {
-      if (kChar == '\t' || kChar == ' ') {
-        if (iTagNum >= kiValSize)
-          break;
-        if (! (*strTags).empty()) {
-          ++ iTagNum;
-          strTags	= &pStr[iTagNum];
-        }
-      } else
-        *strTags += kChar;
-    }
-
-  } while (true);
-
-  return 1 + iTagNum;
-}
-
-const bool CReadConfig::EndOfFile() {
-  if (m_pCfgFile == NULL)
-    return true;
-  return feof (m_pCfgFile) ? true : false;
-}
-
-const int CReadConfig::GetLines() {
-  return m_ulLines;
-}
-
-const bool CReadConfig::ExistFile() {
-  return (m_pCfgFile != NULL);
-}
-
-const string& CReadConfig::GetFileName() {
-  return m_strCfgFileName;
-}
--- a/codec/console/dec/targets.mk
+++ b/codec/console/dec/targets.mk
@@ -2,7 +2,6 @@
 H264DEC_CPP_SRCS=\
 	$(H264DEC_SRCDIR)/src/d3d9_utils.cpp\
 	$(H264DEC_SRCDIR)/src/h264dec.cpp\
-	$(H264DEC_SRCDIR)/src/read_config.cpp\
 
 H264DEC_OBJS += $(H264DEC_CPP_SRCS:.cpp=.$(OBJ))
 
--- a/codec/console/enc/inc/read_config.h
+++ /dev/null
@@ -1,69 +1,0 @@
-/*!
- * \copy
- *     Copyright (c)  2008-2013, Cisco Systems
- *     All rights reserved.
- *
- *     Redistribution and use in source and binary forms, with or without
- *     modification, are permitted provided that the following conditions
- *     are met:
- *
- *        * Redistributions of source code must retain the above copyright
- *          notice, this list of conditions and the following disclaimer.
- *
- *        * Redistributions in binary form must reproduce the above copyright
- *          notice, this list of conditions and the following disclaimer in
- *          the documentation and/or other materials provided with the
- *          distribution.
- *
- *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- *     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- *     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- *     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- *     COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- *     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- *     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- *     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- *     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- *     POSSIBILITY OF SUCH DAMAGE.
- *
- *  read_config.h
- *
- *  Abstract
- *      Class for reading parameter settings in a configure file.
- *
- *  History
- *      08/18/2008 Created
- *
- *****************************************************************************/
-#ifndef READ_CONFIG_H__
-#define READ_CONFIG_H__
-
-#include <stdlib.h>
-#include <string>
-using namespace std;
-
-
-class CReadConfig {
- public:
-  CReadConfig();
-  CReadConfig (const char* pConfigFileName);
-  CReadConfig (const string& pConfigFileName);
-  virtual ~CReadConfig();
-
-  void Openf (const char* strFile);
-  long ReadLine (string* strVal, const int iValSize = 4);
-  const bool EndOfFile();
-  const int GetLines();
-  const bool ExistFile();
-  const string& GetFileName();
-
- private:
-  FILE*			m_pCfgFile;
-  string			m_strCfgFileName;
-  unsigned int	m_iLines;
-};
-
-#endif	// READ_CONFIG_H__
-
--- a/codec/console/enc/src/read_config.cpp
+++ /dev/null
@@ -1,139 +1,0 @@
-/*!
- * \copy
- *     Copyright (c)  2008-2013, Cisco Systems
- *     All rights reserved.
- *
- *     Redistribution and use in source and binary forms, with or without
- *     modification, are permitted provided that the following conditions
- *     are met:
- *
- *        * Redistributions of source code must retain the above copyright
- *          notice, this list of conditions and the following disclaimer.
- *
- *        * Redistributions in binary form must reproduce the above copyright
- *          notice, this list of conditions and the following disclaimer in
- *          the documentation and/or other materials provided with the
- *          distribution.
- *
- *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- *     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- *     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- *     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- *     COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- *     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- *     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- *     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- *     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- *     POSSIBILITY OF SUCH DAMAGE.
- *
- *  read_config.h
- *
- *  Abstract
- *      Class for reading parameter settings in a configure file.
- *
- *  History
- *      08/18/2008 Created
- *
- *****************************************************************************/
-
-#define _CRT_SECURE_NO_WARNINGS
-#include <stdio.h>
-#include <string.h>
-#include "read_config.h"
-
-CReadConfig::CReadConfig()
-  : m_pCfgFile (NULL)
-  , m_strCfgFileName ("")
-  , m_iLines (0) {
-}
-
-CReadConfig::CReadConfig (const char* kpConfigFileName)
-  : m_pCfgFile (0)
-  , m_strCfgFileName (kpConfigFileName)
-  , m_iLines (0) {
-  if (strlen (kpConfigFileName) > 0) {	// confirmed_safe_unsafe_usage
-    m_pCfgFile = fopen (kpConfigFileName, "r");
-  }
-}
-
-CReadConfig::CReadConfig (const string& kpConfigFileName)
-  : m_pCfgFile (0)
-  , m_strCfgFileName (kpConfigFileName)
-  , m_iLines (0) {
-  if (kpConfigFileName.length() > 0) {
-    m_pCfgFile = fopen (kpConfigFileName.c_str(), "r");
-  }
-}
-
-CReadConfig::~CReadConfig() {
-  if (m_pCfgFile) {
-    fclose (m_pCfgFile);
-    m_pCfgFile = NULL;
-  }
-}
-
-void CReadConfig::Openf (const char* kpStrFile) {
-  if (kpStrFile != NULL && strlen (kpStrFile) > 0) {	// confirmed_safe_unsafe_usage
-    m_strCfgFileName = kpStrFile;
-    m_pCfgFile = fopen (kpStrFile, "r");
-  }
-}
-
-long CReadConfig::ReadLine (string* pVal, const int kiValSize/* = 4*/) {
-  if (m_pCfgFile == NULL || pVal == NULL || kiValSize <= 1)
-    return 0;
-
-  string* strTags = &pVal[0];
-  int nTagNum = 0, n = 0;
-  bool bCommentFlag = false;
-
-  while (n < kiValSize) {
-    pVal[n]	= "";
-    ++ n;
-  }
-
-  do {
-    const char kCh = (char)fgetc (m_pCfgFile);
-
-    if (kCh == '\n' || feof (m_pCfgFile)) {
-      ++ m_iLines;
-      break;
-    }
-    if (kCh == '#')
-      bCommentFlag = true;
-    if (!bCommentFlag) {
-      if (kCh == '\t' || kCh == ' ') {
-        if (nTagNum >= kiValSize)
-          break;
-        if (! (*strTags).empty()) {
-          ++ nTagNum;
-          strTags	= &pVal[nTagNum];
-        }
-      } else
-        *strTags += kCh;
-    }
-
-  } while (true);
-
-  return 1 + nTagNum;
-}
-
-const bool CReadConfig::EndOfFile() {
-  if (m_pCfgFile == NULL)
-    return true;
-  return feof (m_pCfgFile) ? true : false;
-}
-
-const int CReadConfig::GetLines() {
-  return m_iLines;
-}
-
-const bool CReadConfig::ExistFile() {
-  return (m_pCfgFile != NULL);
-}
-
-const string& CReadConfig::GetFileName() {
-  return m_strCfgFileName;
-}
--- a/codec/console/enc/targets.mk
+++ b/codec/console/enc/targets.mk
@@ -1,6 +1,5 @@
 H264ENC_SRCDIR=codec/console/enc
 H264ENC_CPP_SRCS=\
-	$(H264ENC_SRCDIR)/src/read_config.cpp\
 	$(H264ENC_SRCDIR)/src/welsenc.cpp\
 
 H264ENC_OBJS += $(H264ENC_CPP_SRCS:.cpp=.$(OBJ))