Index: branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 1332)
+++ branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 1333)
@@ -1199,4 +1199,6 @@
   ("ClipInputVideoToRec709Range",                     m_bClipInputVideoToRec709Range,                   false, "If true then clip input video to the Rec. 709 Range on loading when InternalBitDepth is less than MSBExtendedBitDepth")
   ("ClipOutputVideoToRec709Range",                    m_bClipOutputVideoToRec709Range,                  false, "If true then clip output video to the Rec. 709 Range on saving when OutputBitDepth is less than InternalBitDepth")
+  ("SummaryOutFilename",                              m_summaryOutFilename,                          string(), "Filename to use for producing summary output file. If empty, do not produce a file.")
+  ("SummaryPicFilenameBase",                          m_summaryPicFilenameBase,                      string(), "Base filename to use for producing summary picture output files. The actual filenames used will have I.txt, P.txt and B.txt appended. If empty, do not produce a file.")
 
   //Field coding parameters
Index: branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 1332)
+++ branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 1333)
@@ -441,4 +441,7 @@
   Int       m_log2MaxMvLengthVertical;                        ///< Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units
 
+  std::string m_summaryOutFilename;                           ///< filename to use for producing summary output file.
+  std::string m_summaryPicFilenameBase;                       ///< Base filename to use for producing summary picture output files. The actual filenames used will have I.txt, P.txt and B.txt appended.
+
 #if LAYERS_NOT_PRESENT_SEI
   Int       m_layersNotPresentSEIEnabled;
Index: branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 1332)
+++ branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 1333)
@@ -726,4 +726,7 @@
     m_acTEncTop[layer].setHarmonizeGopFirstFieldCoupleEnabled   ( m_bHarmonizeGopFirstFieldCoupleEnabled );
 
+    m_acTEncTop[layer].setSummaryOutFilename                    ( m_summaryOutFilename );
+    m_acTEncTop[layer].setSummaryPicFilenameBase                ( m_summaryPicFilenameBase );
+
     if( layer > 0 )
     {
@@ -1105,4 +1108,7 @@
   m_cTEncTop.setEfficientFieldIRAPEnabled                         ( m_bEfficientFieldIRAPEnabled );
   m_cTEncTop.setHarmonizeGopFirstFieldCoupleEnabled               ( m_bHarmonizeGopFirstFieldCoupleEnabled );
+
+  m_cTEncTop.setSummaryOutFilename                                ( m_summaryOutFilename );
+  m_cTEncTop.setSummaryPicFilenameBase                            ( m_summaryPicFilenameBase );
 }
 #endif //SVC_EXTENSION
@@ -1967,18 +1973,29 @@
   }
 
-#if _SUMMARY_OUT_
   for( layer = 0; layer < m_numLayers; layer++ )
   {
-    m_apcTEncTop[vps->getLayerIdInNuh(layer)]->getAnalyzeAll()->printSummary(chFmt, printSequenceMSE, bitDepths);
-  }
-#endif
-#if _SUMMARY_PIC_
+    const UInt layerId = vps->getLayerIdInNuh(layer);
+
+    if (!m_apcTEncTop[layerId]->getSummaryOutFilename().empty())
+    {
+      const BitDepths bitDepths(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
+
+      m_apcTEncTop[layerId]->getAnalyzeAll()->printSummary(m_acLayerCfg[layer].getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layerId]->getSummaryOutFilename());
+    }
+  }
+
   for( layer = 0; layer < m_numLayers; layer++ )
   {
-    m_apcTEncTop[vps->getLayerIdInNuh(layer)]->getAnalyzeI()->printSummary(chFmt, printSequenceMSE, bitDepths, 'I');
-    m_apcTEncTop[vps->getLayerIdInNuh(layer)]->getAnalyzeP()->printSummary(chFmt, printSequenceMSE, bitDepths, 'P');
-    m_apcTEncTop[vps->getLayerIdInNuh(layer)]->getAnalyzeB()->printSummary(chFmt, printSequenceMSE, bitDepths, 'B');
-  }
-#endif
+    const UInt layerId = vps->getLayerIdInNuh(layer);
+
+    if (!m_apcTEncTop[layerId]->getSummaryPicFilenameBase().empty())
+    {
+      const BitDepths bitDepths(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
+
+      m_apcTEncTop[layerId]->getAnalyzeI()->printSummary(m_acLayerCfg[layer].getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layerId]->getSummaryPicFilenameBase()+"I.txt");
+      m_apcTEncTop[layerId]->getAnalyzeP()->printSummary(m_acLayerCfg[layer].getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layerId]->getSummaryPicFilenameBase()+"P.txt");
+      m_apcTEncTop[layerId]->getAnalyzeB()->printSummary(m_acLayerCfg[layer].getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layerId]->getSummaryPicFilenameBase()+"B.txt");
+    }
+  }
 
   if(isField)
@@ -1986,10 +2003,12 @@
     for(layer = 0; layer < m_numLayers; layer++)
     {
+      const UInt layerId = vps->getLayerIdInNuh(layer);
+
       const BitDepths bitDepths(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
-      TEncAnalyze *analyze = m_apcTEncTop[vps->getLayerIdInNuh(layer)]->getAnalyzeAllin();
+      TEncAnalyze *analyze = m_apcTEncTop[layerId]->getAnalyzeAllin();
 
       //-- interlaced summary
       analyze->setFrmRate( m_acLayerCfg[layer].getFrameRate());
-      analyze->setBits(m_apcTEncTop[vps->getLayerIdInNuh(layer)]->getAnalyzeB()->getBits());
+      analyze->setBits(m_apcTEncTop[layerId]->getAnalyzeB()->getBits());
       // prior to the above statement, the interlace analyser does not contain the correct total number of bits.
 
@@ -1997,7 +2016,8 @@
       analyze->printOut('a', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer);
 
-#if _SUMMARY_OUT_
-      analyze->printSummary(chFmt, printSequenceMSE, bitDepths);
-#endif
+      if (!m_apcTEncTop[layerId]->getSummaryOutFilename().empty())
+      {
+        analyze->printSummary(m_acLayerCfg[layer].getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layerId]->getSummaryOutFilename());
+      }
     }
   }   
Index: branches/SHM-dev/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibCommon/CommonDef.h	(revision 1332)
+++ branches/SHM-dev/source/Lib/TLibCommon/CommonDef.h	(revision 1333)
@@ -116,7 +116,4 @@
 // ====================================================================================================================
 
-#define _SUMMARY_OUT_               0           ///< print-out PSNR results of all slices to summary.txt
-#define _SUMMARY_PIC_               0           ///< print-out PSNR results for each slice type to summary.txt
-
 #define MAX_GOP                     64          ///< max. value of hierarchical GOP size
 
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncAnalyze.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncAnalyze.h	(revision 1332)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncAnalyze.h	(revision 1333)
@@ -376,27 +376,7 @@
 
 
-  Void    printSummary(const ChromaFormat chFmt, const Bool printSequenceMSE, const BitDepths &bitDepths, Char ch='T')
+  Void    printSummary(const ChromaFormat chFmt, const Bool printSequenceMSE, const BitDepths &bitDepths, const std::string &sFilename)
   {
-    FILE* pFile = NULL;
-
-    switch( ch )
-    {
-      case 'T':
-        pFile = fopen ("summaryTotal.txt", "at");
-        break;
-      case 'I':
-        pFile = fopen ("summary_I.txt", "at");
-        break;
-      case 'P':
-        pFile = fopen ("summary_P.txt", "at");
-        break;
-      case 'B':
-        pFile = fopen ("summary_B.txt", "at");
-        break;
-      default:
-        assert(0);
-        return;
-        break;
-    }
+    FILE* pFile = fopen (sFilename.c_str(), "at");
 
     Double dFps     =   m_dFrmRate; //--CFG_KDY
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h	(revision 1332)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h	(revision 1333)
@@ -379,4 +379,7 @@
   Bool      m_bEfficientFieldIRAPEnabled;                     ///< enable to code fields in a specific, potentially more efficient, order.
   Bool      m_bHarmonizeGopFirstFieldCoupleEnabled;
+
+  std::string m_summaryOutFilename;                           ///< filename to use for producing summary output file.
+  std::string m_summaryPicFilenameBase;                       ///< Base filename to use for producing summary picture output files. The actual filenames used will have I.txt, P.txt and B.txt appended.
 
 #if SVC_EXTENSION
@@ -1021,4 +1024,9 @@
   Void      setChromaSamplingVerFilterIdc(Int i)                     { m_chromaSamplingVerFilterIdc = i;}
 
+  Void      setSummaryOutFilename(const std::string &s)              { m_summaryOutFilename = s; }
+  const std::string& getSummaryOutFilename() const                   { return m_summaryOutFilename; }
+  Void      setSummaryPicFilenameBase(const std::string &s)          { m_summaryPicFilenameBase = s; }
+  const std::string& getSummaryPicFilenameBase() const               { return m_summaryPicFilenameBase; }
+
 #if Q0189_TMVP_CONSTRAINTS
   Void  setTMVPConstraintsSEIEnabled(Int b)                  { m_TMVPConstraintsSEIEnabled = b; }
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1332)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1333)
@@ -2933,12 +2933,15 @@
   m_gcAnalyzeB.printOut('b', chFmt, printMSEBasedSNR, printSequenceMSE, bitDepths);
 
-#if _SUMMARY_OUT_
-  m_gcAnalyzeAll.printSummary(chFmt, printSequenceMSE, bitDepths);
-#endif
-#if _SUMMARY_PIC_
-  m_gcAnalyzeI.printSummary(chFmt, printSequenceMSE, bitDepths, 'I');
-  m_gcAnalyzeP.printSummary(chFmt, printSequenceMSE, bitDepths, 'P');
-  m_gcAnalyzeB.printSummary(chFmt, printSequenceMSE, bitDepths, 'B');
-#endif
+  if (!m_pcCfg->getSummaryOutFilename().empty())
+  {
+    m_gcAnalyzeAll.printSummary(chFmt, printSequenceMSE, bitDepths, m_pcCfg->getSummaryOutFilename());
+  }
+
+  if (!m_pcCfg->getSummaryPicFilenameBase().empty())
+  {
+    m_gcAnalyzeI.printSummary(chFmt, printSequenceMSE, bitDepths, m_pcCfg->getSummaryPicFilenameBase()+"I.txt");
+    m_gcAnalyzeP.printSummary(chFmt, printSequenceMSE, bitDepths, m_pcCfg->getSummaryPicFilenameBase()+"P.txt");
+    m_gcAnalyzeB.printSummary(chFmt, printSequenceMSE, bitDepths, m_pcCfg->getSummaryPicFilenameBase()+"B.txt");
+  }
 
   if(isField)
@@ -2952,7 +2955,8 @@
     m_gcAnalyzeAll_in.printOut('a', chFmt, printMSEBasedSNR, printSequenceMSE, bitDepths);
 
-#if _SUMMARY_OUT_
-    m_gcAnalyzeAll_in.printSummary(chFmt, printSequenceMSE, bitDepths);
-#endif
+    if (!m_pcCfg->getSummaryOutFilename().empty())
+    {
+      m_gcAnalyzeAll_in.printSummary(chFmt, printSequenceMSE, bitDepths, m_pcCfg->getSummaryOutFilename());
+    }
   }
 
