source: 3DVCSoftware/trunk/source/App/TAppRenderer/TAppRendererCfg.cpp @ 699

Last change on this file since 699 was 608, checked in by tech, 11 years ago

Merged DEV-2.0-dev0@604.

  • Property svn:eol-style set to native
File size: 24.0 KB
RevLine 
[5]1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license.
5 *
6 * Copyright (c) 2010-2011, ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
[2]33
34
[5]35
[608]36
[2]37#include <stdlib.h>
38#include <math.h>
39#include <cassert>
40#include <cstring>
41#include <string>
42
43#include "TAppRendererCfg.h"
[56]44#include "../../Lib/TAppCommon/program_options_lite.h"
[2]45
[608]46#if H_3D
[2]47
48using namespace std;
49namespace po = df::program_options_lite;
50
51// ====================================================================================================================
52// Local constants
53// ====================================================================================================================
54
[100]55#define MAX_INPUT_VIEW_NUM          10
[2]56#define MAX_OUTPUT_VIEW_NUM         64
57
58// ====================================================================================================================
59// Constructor / destructor / initialization / destroy
60// ====================================================================================================================
[608]61
62
[2]63TAppRendererCfg::TAppRendererCfg()
64{
[608]65 
[2]66}
67
68TAppRendererCfg::~TAppRendererCfg()
69{
70  for(Int i = 0; i< m_pchVideoInputFileList.size(); i++ )
71  {
72    if ( m_pchVideoInputFileList[i] != NULL )
73      free (m_pchVideoInputFileList[i]);
74  }
75
76  for(Int i = 0; i< m_pchDepthInputFileList.size(); i++ )
77  {
78    if ( m_pchDepthInputFileList[i] != NULL )
79      free (m_pchDepthInputFileList[i]);
80  }
81
82  for(Int i = 0; i< m_pchSynthOutputFileList.size(); i++ )
83  {
84    if ( m_pchSynthOutputFileList[i] != NULL )
85      free (m_pchSynthOutputFileList[i]);
86  }
87
88  if ( m_pchVideoInputFileBaseName  ) free( m_pchVideoInputFileBaseName );
89  if ( m_pchDepthInputFileBaseName  ) free( m_pchDepthInputFileBaseName );
90  if ( m_pchSynthOutputFileBaseName ) free( m_pchSynthOutputFileBaseName);
91  if ( m_pchCameraParameterFile     ) free( m_pchCameraParameterFile    );
92  if ( m_pchBaseViewCameraNumbers   ) free( m_pchBaseViewCameraNumbers  );
93  if ( m_pchSynthViewCameraNumbers  ) free( m_pchSynthViewCameraNumbers );
94  if ( m_pchViewConfig              ) free( m_pchViewConfig         );
95}
96
97Void TAppRendererCfg::create()
98{
99}
100
101Void TAppRendererCfg::destroy()
102{
103}
104
105// ====================================================================================================================
106// Public member functions
107// ====================================================================================================================
108
109/** \param  argc        number of arguments
110\param  argv        array of arguments
111\retval             true when success
112*/
113Bool TAppRendererCfg::parseCfg( Int argc, Char* argv[] )
114{
115  bool do_help = false;
116
117  po::Options opts;
118  opts.addOptions()
119    ("help", do_help, false, "this help text")
120    ("c", po::parseConfigFile, "configuration file name")
121
122    /* File I/O */
[189]123    ("VideoInputFileBaseName,v",  m_pchVideoInputFileBaseName,  (Char*) 0, "Basename to generate video input file names")
124    ("DepthInputFileBaseName,d",  m_pchDepthInputFileBaseName,  (Char*) 0, "Basename to generate depth input file names")
125    ("SynthOutputFileBaseName,s", m_pchSynthOutputFileBaseName, (Char*) 0, "Basename to generate synthesized output file names")
[2]126    ("ContOutputFileNumbering", m_bContOutputFileNumbering  ,  false   , "Continuous Output File Numbering")
127    ("Sweep"                  , m_bSweep                    ,  false   , "Store all views in first Output File")
128
129    ("VideoInputFile_%d,v_%d",  m_pchVideoInputFileList ,    (Char *) 0, MAX_INPUT_VIEW_NUM , "Original Yuv video input file name %d")
130    ("DepthInputFile_%d,d_%d",  m_pchDepthInputFileList ,    (Char *) 0, MAX_INPUT_VIEW_NUM , "Original Yuv depth input file name %d")
131    ("SynthOutputFile_%d,s_%d", m_pchSynthOutputFileList,    (Char *) 0, MAX_OUTPUT_VIEW_NUM, "Synthesized Yuv output file name %d")
132
[608]133    ("InputBitDepth",           m_inputBitDepthY,                     8, "Bit-depth of input file")
134    ("OutputBitDepth",          m_outputBitDepthY,                    0, "Bit-depth of output file (default:InternalBitDepth)")
135    ("InternalBitDepth",        m_internalBitDepthY,                  0, "Bit-depth the renderer operates at. (default:InputBitDepth)"                                                                          "If different to InputBitDepth, source data will be converted")
136
137    ("InputBitDepthC",        m_inputBitDepthC,    0, "As per InputBitDepth but for chroma component. (default:InputBitDepth)")
138    ("OutputBitDepthC",       m_outputBitDepthC,   0, "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)")
139    ("InternalBitDepthC",     m_internalBitDepthC, 0, "As per InternalBitDepth but for chroma component. (default:IntrenalBitDepth)")
140
[2]141    /* Source Specification */
142    ("SourceWidth,-wdt",        m_iSourceWidth,                       0, "Source picture width")
143    ("SourceHeight,-hgt",       m_iSourceHeight,                      0, "Source picture height")
144    ("FrameSkip,-fs",           m_iFrameSkip,                         0, "Number of frames to skip at start of input YUV")
145    ("FramesToBeRendered,f",    m_iFramesToBeRendered,                0, "Number of frames to be rendered (default=all)")
146
147    /* Camera Specification */
[189]148    ("CameraParameterFile,-cpf", m_pchCameraParameterFile,          (Char *) 0, "Camera Parameter File Name")
[2]149    ("BaseViewCameraNumbers"  , m_pchBaseViewCameraNumbers,        (Char *) 0, "Numbers of base views")
150    ("SynthViewCameraNumbers" , m_pchSynthViewCameraNumbers,       (Char *) 0, "Numbers of views to synthesis")
151    ("ViewConfig"             , m_pchViewConfig,                   (Char *) 0, "View Configuration"               )
152
153    /* Renderer Modes */
154    ("Log2SamplingFactor",      m_iLog2SamplingFactor,                0, "Factor for horizontal up sampling before processing"     )
155    ("UVup"              ,      m_bUVUp               ,            true, "Up sampling of chroma planes before processing"          )
156    ("PreProcMode"       ,      m_iPreProcMode        ,               0, "Depth preprocessing: 0 = None, 1 = Binomial filtering"   )
157    ("PreFilterSize"     ,      m_iPreFilterSize      ,               0, "For PreProcMode 1: Half Size of filter kernel"           )
[5]158    ("SimEnhance"        ,      m_bSimEnhance         ,           true, "Similarity enhancement of video" )
[2]159    ("BlendMode"         ,      m_iBlendMode          ,               0, "Blending of left and right image: 0: average, 1: only holes from right, 2: only holes from left, 3: first view in BaseViewOrder as main view" )
[5]160    ("BlendZThresPerc"   ,      m_iBlendZThresPerc    ,              30, "Z-difference threshold for blending in percent of total Z-range"   )
[2]161    ("BlendUseDistWeight",      m_bBlendUseDistWeight ,            true, "0: blend using average; 1: blend factor depends on view distance"  )
[5]162    ("BlendHoleMargin"   ,      m_iBlendHoleMargin    ,               6, "Margin around holes to fill with other view"                       )
163    ("InterpolationMode" ,      m_iInterpolationMode  ,               4, "0: NN, 1:linear (int), 2:linear (double) , 3:cubic Hermite spline (double), 4: 8-tap (int)" )
[2]164    ("HoleFillingMode"   ,      m_iHoleFillingMode    ,               1, "0: None, 1: line wise background extension"              )
165    ("PostProcMode"      ,      m_iPostProcMode       ,               0, "0: None, 1: horizontal 3-tap median"                     )
166    ("RenderMode"        ,      m_iRenderMode         ,               0, "0: Use renderer, 1: use model renderer, 10: create used pels map")
[5]167    ("ShiftPrecision"    ,      m_iShiftPrecision     ,               2, "Shift Precision for Interpolation Mode 4"                )
[2]168    ("TemporalDepthFilter",     m_bTempDepthFilter    ,           false, "Temporal depth filtering"                                )
169    ("RenderDirection"   ,      m_iRenderDirection    ,               0, "0: Interpolate, 1: Extrapolate from left, 2: Extrapolate from right")
170    ("UsedPelMapMarExt"  ,      m_iUsedPelMapMarExt   ,               0, "Margin Extension in Pels for used pels map generation"   );
171
172  po::setDefaults(opts);
173  po::scanArgv(opts, argc, (const char**) argv);
174
175  if (argc == 1 || do_help)
176  {
177    /* argc == 1: no options have been specified */
178    po::doHelp(cout, opts);
179    xPrintUsage();
180    return false;
181  }
182
183  /*
184  * Set any derived parameters before checking
185  */
186
[608]187  /* rules for input, output and internal bitdepths as per help text */
188  if (!m_internalBitDepthY) { m_internalBitDepthY = m_inputBitDepthY; }
189  if (!m_internalBitDepthC) { m_internalBitDepthC = m_internalBitDepthY; }
190  if (!m_inputBitDepthC)    { m_inputBitDepthC    = m_inputBitDepthY; }
191  if (!m_outputBitDepthY)   { m_outputBitDepthY   = m_internalBitDepthY; }
192  if (!m_outputBitDepthC)   { m_outputBitDepthC   = m_internalBitDepthC; }
193
[2]194  xSetGlobal();
195
196  UInt  uiInputBitDepth   = 8;
197  UInt  uiCamParPrecision = 5;
198
199  m_bUseSetupString = ( m_pchViewConfig != NULL ) && ( m_iRenderMode != 0);
200
201  if ( m_iRenderMode == 10 )
202  {
203    m_cCameraData.init( MAX_INPUT_VIEW_NUM, uiInputBitDepth, uiCamParPrecision, (UInt)m_iFrameSkip, (UInt)m_iFramesToBeRendered,
204      m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, NULL, NULL, m_iLog2SamplingFactor+m_iShiftPrecision );
205    m_iNumberOfInputViews  = (Int) m_cCameraData.getBaseViewNumbers() .size();
206    m_iNumberOfOutputViews = m_iNumberOfInputViews - 1;
207    m_iRenderDirection     = 1;
208  }
209  else
210  {
211  if ( m_bUseSetupString )
212  {
213    std::vector<Int>  iaTempViews;
214    std::vector<Int>* piaTempViews;
215    m_cCameraData     .convertNumberString( m_pchBaseViewCameraNumbers, iaTempViews, VIEW_NUM_PREC );
216    m_cRenModStrParser.setString( (Int) iaTempViews.size(), m_pchViewConfig );
217    piaTempViews               = m_cRenModStrParser.getSynthViews();
218    m_iNumberOfOutputViews     = (Int) m_cRenModStrParser.getNumOfModels();
219    m_iNumberOfInputViews      = (Int) m_cRenModStrParser.getNumOfBaseViews();
220    m_bContOutputFileNumbering = true;
221
222  m_cCameraData.init( MAX_INPUT_VIEW_NUM, uiInputBitDepth, uiCamParPrecision, (UInt)m_iFrameSkip, (UInt)m_iFramesToBeRendered,
223      m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, NULL, piaTempViews, m_iLog2SamplingFactor+m_iShiftPrecision );
224  }
225  else
226  {
227  m_cCameraData.init( MAX_INPUT_VIEW_NUM, uiInputBitDepth, uiCamParPrecision, (UInt)m_iFrameSkip, (UInt)m_iFramesToBeRendered,
228      m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, m_pchSynthViewCameraNumbers, NULL, m_iLog2SamplingFactor+m_iShiftPrecision );
229  m_iNumberOfOutputViews = (Int) m_cCameraData.getSynthViewNumbers().size();
230  m_iNumberOfInputViews  = (Int) m_cCameraData.getBaseViewNumbers() .size();
231  }
232  }
233
234  if (m_pchSynthOutputFileBaseName != NULL)
235    xConfirmParameter( strrchr(m_pchSynthOutputFileBaseName,'$')  == 0, "'$' must be a character in SynthOutputFileBaseName");
236
237  if (m_pchDepthInputFileBaseName != NULL)
238    xConfirmParameter( strrchr(m_pchDepthInputFileBaseName, '$')  == 0, "'$' must be a character in DepthInputFileBaseName" );
239
240  if (m_pchVideoInputFileBaseName != NULL)
241    xConfirmParameter( strrchr(m_pchVideoInputFileBaseName, '$')  == 0, "'$' must be a character in VideoInputFileBaseName" );
242
243  xCreateFileNames();
244
245  /*
246  * check validity of input parameters
247  */
248  xCheckParameter();
249  m_cCameraData.check( m_iRenderDirection == 0, m_iFramesToBeRendered != 0 );
250
251  // print-out parameters
252  xPrintParameter();
253
254  return true;
255}
256
257
258// ====================================================================================================================
259// Private member functions
260// ====================================================================================================================
261
262Void TAppRendererCfg::xCheckParameter()
263{
264  bool check_failed = false; /* abort if there is a fatal configuration problem */
265#define xConfirmPara(a,b) check_failed |= xConfirmParameter(a,b)
266  // check range of parameters
267
268  /// File I/O
269
270  // source specification
271  xConfirmPara( m_iSourceWidth        <= 0,                   "Source width  must be greater than 0" );
272  xConfirmPara( m_iSourceHeight       <= 0,                   "Source height must be greater than 0" );
273  xConfirmPara( m_iFrameSkip          <  0,                   "Frame Skipping must be more than or equal to 0" );
274  xConfirmPara( m_iFramesToBeRendered <  0,                   "Total Number Of Frames rendered must be more than 1" );
275
[608]276  // bit depth
277  xConfirmPara( m_internalBitDepthC != m_internalBitDepthY,  "InternalBitDepth for luma and chroma must be equal. "); 
278  xConfirmPara( m_inputBitDepthY < 8,                        "InputBitDepth must be at least 8" );
279  xConfirmPara( m_inputBitDepthC < 8,                        "InputBitDepthC must be at least 8" );
[2]280
281  // camera specification
282  xConfirmPara( m_iNumberOfInputViews  > MAX_INPUT_VIEW_NUM , "NumberOfInputViews must be less than of equal to MAX_INPUT_VIEW_NUM");
283  xConfirmPara( m_iNumberOfOutputViews > MAX_OUTPUT_VIEW_NUM, "NumberOfOutputViews must be less than of equal to MAX_OUTPUT_VIEW_NUM");
284
285
286  xConfirmPara( m_iRenderDirection < 0 || m_iRenderDirection > 2  , "RenderDirection must be greater than or equal to 0 and less than 3");
287  xConfirmPara(m_iNumberOfOutputViews < 1,                    "Number of OutputViews must be greater or equal to 1");
288  if ( m_iRenderDirection == 0 )
289  {
290    xConfirmPara( m_iNumberOfInputViews < 2,                  "Number of InputViews must be more than or equal to 2");
291  }
292  else
293  {
294    xConfirmPara( m_iNumberOfInputViews < 1,                  "Number of InputViews must be more than or equal to 1");
295  }
296
297  xConfirmPara( m_iLog2SamplingFactor < 0 || m_iLog2SamplingFactor >  4, "Log2SamplingFactor must be more than or equal to 0 and less than 5"  );
298  xConfirmPara( m_iPreProcMode        < 0 || m_iPreProcMode        >  1, "PreProcMode        must be more than or equal to 0 and less than 2"  );
299
300
301  xConfirmPara( m_iPreFilterSize      < 0 || m_iPreFilterSize      >  3, "PreFilterSize      must be more than or equal to 0 and less than 4" );
302  xConfirmPara( m_iBlendMode          < 0 || m_iBlendMode          >  3, "BlendMode          must be more than or equal to 0 and less than 4"  );
303  xConfirmPara( m_iBlendZThresPerc    < 0 || m_iBlendZThresPerc    > 100,"BlendZThresPerc    must be more than or equal to 0 and less than 101"  );
304  xConfirmPara( m_iBlendHoleMargin    < 0 || m_iBlendHoleMargin    >  20,"BlendHoleMargin    must be more than or equal to 0 and less than 19"  );
305  xConfirmPara( m_iInterpolationMode  < 0 || m_iInterpolationMode  >  4, "InterpolationMode  must be more than or equal to 0 and less than 5"  );
306  xConfirmPara( m_iHoleFillingMode    < 0 || m_iHoleFillingMode    >  1, "HoleFillingMode    must be more than or equal to 0 and less than 2"  );
307  xConfirmPara( m_iPostProcMode       < 0 || m_iPostProcMode       >  2, "PostProcMode       must be more than or equal to 0 and less than 3"  );
308
309  Int iNumNonNULL;
310  for (iNumNonNULL = 0; (iNumNonNULL < m_iNumberOfInputViews)  && m_pchDepthInputFileList[iNumNonNULL]; iNumNonNULL++);  xConfirmPara( iNumNonNULL < m_iNumberOfInputViews,  "Number of DepthInputFiles  must be greater than or equal to number of BaseViewNumbers" );
311  for (iNumNonNULL = 0; (iNumNonNULL < m_iNumberOfInputViews)  && m_pchVideoInputFileList[iNumNonNULL]; iNumNonNULL++);  xConfirmPara( iNumNonNULL < m_iNumberOfInputViews,  "Number of DepthInputFiles  must be greater than or equal to number of BaseViewNumbers" );
312
313
314  if ( !m_bSweep )
315  {
316  for (iNumNonNULL = 0; (iNumNonNULL < m_iNumberOfOutputViews) && m_pchSynthOutputFileList[iNumNonNULL]; iNumNonNULL++); xConfirmPara( iNumNonNULL < m_iNumberOfOutputViews, "Number of SynthOutputFiles must be greater than or equal to number of SynthViewNumbers" );
317  }
318  else
319  {
320      xConfirmPara( iNumNonNULL < 1, "Number of SynthOutputFiles must be equal to or more than 1" );
321  }
322
323#undef xConfirmPara
324  if ( check_failed )
325  {
326    exit(EXIT_FAILURE);
327  }
328
329}
330
331
332
333Void TAppRendererCfg::xPrintParameter()
334{
335  printf("\n");
336  for( Int iCounter = 0; iCounter < m_iNumberOfInputViews; iCounter++)
337  {
338    printf("InputVideoFile_%i        : %s\n", iCounter, m_pchVideoInputFileList[iCounter]);
339  }
340  for( Int iCounter = 0; iCounter < m_iNumberOfInputViews; iCounter++)
341  {
342    printf("InputDepthFile_%i        : %s\n", iCounter, m_pchDepthInputFileList[iCounter]);
343  }
344
345  for( Int iCounter = 0; iCounter < m_iNumberOfOutputViews; iCounter++)
346  {
347    printf("SynthOutputFile_%i       : %s\n", iCounter, m_pchSynthOutputFileList[iCounter]);
348  }
349
350  printf("Format                  : %dx%d \n", m_iSourceWidth, m_iSourceHeight );
351  printf("Frame index             : %d - %d (%d frames)\n", m_iFrameSkip, m_iFrameSkip+m_iFramesToBeRendered-1, m_iFramesToBeRendered);
352  printf("CameraParameterFile     : %s\n", m_pchCameraParameterFile );
353  printf("BaseViewNumbers         : %s  (%d views) \n", m_pchBaseViewCameraNumbers , m_iNumberOfInputViews  );
354  printf("Sweep                   : %d\n", m_bSweep               );
355
356  if ( m_bUseSetupString )
357  {
358    printf("ViewConfig              : %s\n", m_pchViewConfig );
359  }
360  else
361  {
362  printf("SynthViewNumbers        : %s  (%d views) \n", m_pchSynthViewCameraNumbers, m_iNumberOfOutputViews );
363  }
364
365  printf("Log2SamplingFactor      : %d\n", m_iLog2SamplingFactor );
366  printf("UVUp                    : %d\n", m_bUVUp               );
367  printf("PreProcMode             : %d\n", m_iPreProcMode        );
368  printf("PreFilterSize           : %d\n", m_iPreFilterSize      );
369  printf("SimEnhance              : %d\n", m_bSimEnhance         );
370  printf("BlendMode               : %d\n", m_iBlendMode          );
371  printf("BlendZThresPerc         : %d\n", m_iBlendZThresPerc    );
372  printf("BlendUseDistWeight      : %d\n", m_bBlendUseDistWeight );
373  printf("BlendHoleMargin         : %d\n", m_iBlendHoleMargin    );
374  printf("InterpolationMode       : %d\n", m_iInterpolationMode  );
375  printf("HoleFillingMode         : %d\n", m_iHoleFillingMode    );
376  printf("PostProcMode            : %d\n", m_iPostProcMode       );
377  printf("ShiftPrecision          : %d\n", m_iShiftPrecision     );
378  printf("TemporalDepthFilter     : %d\n", m_bTempDepthFilter    );
379  printf("RenderMode              : %d\n", m_iRenderMode         );
380  printf("RendererDirection       : %d\n", m_iRenderDirection       );
381
382  if (m_iRenderMode == 10 )
383  {
384    printf("UsedPelMapMarExt        : %d\n", m_iUsedPelMapMarExt );
385  }
386
387  printf("\n");
388
389  //  printf("TOOL CFG: ");
390  //  printf("ALF:%d ", m_bUseALF             );
391  //  printf("\n");
392
393  fflush(stdout);
394}
395
396Void TAppRendererCfg::xPrintUsage()
397{
398  printf( "\n" );
399  printf( "  Example: TAppRenderer.exe -c test.cfg\n\n");
400}
401
402Bool TAppRendererCfg::xConfirmParameter(Bool bflag, const char* message)
403{
404  if (!bflag)
405    return false;
406
407  printf("Error: %s\n",message);
408  return true;
409}
410
411
412Void TAppRendererCfg::xCreateFileNames()
413{
414  if ( m_iRenderMode == 10 )
415    return;
416
417  Int iPrecBefore;
418  Int iPrecAfter;
419
420  xGetMaxPrecision( m_cCameraData.getSynthViewNumbers(), iPrecBefore, iPrecAfter );
421
422
423  if (iPrecBefore > LOG10_VIEW_NUM_PREC )
424  {
425    std::cerr << "Error: View Numbers with more than " << LOG10_VIEW_NUM_PREC << " digits are not supported" << std::endl;
426    exit(EXIT_FAILURE);
427  }
428
429  AOT( !m_bContOutputFileNumbering && (m_cCameraData.getSynthViewNumbers().size() != m_iNumberOfOutputViews ));
430  for(Int iIdx = 0; iIdx < m_iNumberOfOutputViews; iIdx++)
431  {
432    //GT; Create ReconFileNames
433    if (m_pchSynthOutputFileList[iIdx] == NULL )
434    {
435      if ( m_bContOutputFileNumbering )
436      {
437        xAddNumberToFileName( m_pchSynthOutputFileBaseName, m_pchSynthOutputFileList[iIdx], (Int) ((iIdx+1) * VIEW_NUM_PREC) , 2, 0  );
438      }
439      else
440      {
441        xAddNumberToFileName( m_pchSynthOutputFileBaseName, m_pchSynthOutputFileList[iIdx], m_cCameraData.getSynthViewNumbers()[iIdx], iPrecBefore, iPrecAfter  );
442      }
443    }
444  }
445
446  xGetMaxPrecision( m_cCameraData.getBaseViewNumbers(), iPrecBefore, iPrecAfter );
447  for(Int iIdx = 0; iIdx < m_cCameraData.getBaseViewNumbers().size() ; iIdx++)
448  {
449    //GT; Create ReconFileNames
450    if (m_pchVideoInputFileList[iIdx] == NULL )
451    {
452      xAddNumberToFileName( m_pchVideoInputFileBaseName, m_pchVideoInputFileList[iIdx], m_cCameraData.getBaseViewNumbers()[iIdx], iPrecBefore, iPrecAfter  );
453    }
454
455    if (m_pchDepthInputFileList[iIdx] == NULL )
456    {
457      xAddNumberToFileName( m_pchDepthInputFileBaseName, m_pchDepthInputFileList[iIdx], m_cCameraData.getBaseViewNumbers()[iIdx], iPrecBefore, iPrecAfter  );
458    }
459  }
460}
461
462Void TAppRendererCfg::xAddNumberToFileName( Char* pchSourceFileName, Char*& rpchTargetFileName, Int iNumberToAdd, UInt uiPrecBefore, UInt uiPrecAfter )
463{
464
465  if ( pchSourceFileName == NULL )
466  {
467    std::cerr << "No BaseName for file name generation given." << std::endl;
468    AOT(true);
469    exit(EXIT_FAILURE);
470  }
471
472  Char pchNumberBuffer[2* LOG10_VIEW_NUM_PREC + 2];
473  Char pchPrintBuffer[10];
474
475  Double dNumberToAdd = ( (Double) iNumberToAdd ) / VIEW_NUM_PREC;
476
477  UInt uiWidth = uiPrecBefore;
478
479  if (uiPrecAfter != 0)
480  {
481    uiWidth += uiPrecAfter + 1;
482  }
483
484  sprintf( pchPrintBuffer, "%%0%d.%df", uiWidth, uiPrecAfter );
485  sprintf( pchNumberBuffer, pchPrintBuffer, dNumberToAdd );
486
487  if ( uiPrecAfter > 0 ) pchNumberBuffer[ uiPrecBefore ] = '_';
488
489  size_t iInLength  = strlen(pchSourceFileName);
490  size_t iAddLength = strlen(pchNumberBuffer);
491
492  rpchTargetFileName = (Char*) malloc(iInLength+iAddLength+1);
493
494  Char* pchPlaceHolder = strrchr(pchSourceFileName,'$');
495  assert( pchPlaceHolder );
496
497  size_t iCharsToPlaceHolder = pchPlaceHolder - pchSourceFileName;
498  size_t iCharsToEnd         = iInLength      - iCharsToPlaceHolder;
499
500  strncpy(rpchTargetFileName                               , pchSourceFileName                      , iCharsToPlaceHolder);
501  strncpy(rpchTargetFileName+iCharsToPlaceHolder           , pchNumberBuffer                        , iAddLength         );
502  strncpy(rpchTargetFileName+iCharsToPlaceHolder+iAddLength, pchSourceFileName+iCharsToPlaceHolder+1, iCharsToEnd-1      );
503  rpchTargetFileName[iInLength+iAddLength-1] = '\0';
504}
505
506Void TAppRendererCfg::xGetMaxPrecision( std::vector< Int > aiIn, Int& iPrecBefore, Int& iPrecAfter )
507{
508  iPrecBefore = 0;
509  iPrecAfter  = 0;
510
511  for (UInt uiK = 0; uiK < aiIn.size(); uiK ++ )
512  {
513    if ( aiIn[uiK] == 0 ) continue;
514
515    Int iCurPrec;
516    iCurPrec = 0;
517    for ( Int iCur = aiIn[uiK]; iCur != 0; iCur /= 10, iCurPrec++ );
[56]518    iPrecBefore = max(iPrecBefore, iCurPrec - LOG10_VIEW_NUM_PREC );
[2]519
520    iCurPrec = 0;
521    for ( Int iCur = 1;  aiIn[uiK] % iCur == 0; iCur *= 10, iCurPrec++);
[608]522    iCurPrec = LOG10_VIEW_NUM_PREC - std::min((Int) LOG10_VIEW_NUM_PREC, iCurPrec-1 );
[56]523    iPrecAfter = max(iPrecAfter, iCurPrec );
[2]524  }
525}
526
527Void TAppRendererCfg::xSetGlobal()
528{
[608]529  // set max CU width & height 
[2]530  g_uiMaxCUWidth   = 0;
[608]531  g_uiMaxCUHeight  = 0; 
[2]532}
[608]533
[210]534#endif
Note: See TracBrowser for help on using the repository browser.