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());
+      }
     }
   }   
