[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 | |
---|
[2] | 36 | #include <stdlib.h> |
---|
| 37 | #include <math.h> |
---|
| 38 | #include <cassert> |
---|
| 39 | #include <cstring> |
---|
| 40 | #include <string> |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | #include "TAppRendererCfg.h" |
---|
[56] | 45 | #include "../../Lib/TAppCommon/program_options_lite.h" |
---|
[2] | 46 | |
---|
| 47 | |
---|
| 48 | using namespace std; |
---|
| 49 | namespace 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 | // ==================================================================================================================== |
---|
| 61 | |
---|
| 62 | TAppRendererCfg::TAppRendererCfg() |
---|
| 63 | { |
---|
| 64 | |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | TAppRendererCfg::~TAppRendererCfg() |
---|
| 68 | { |
---|
| 69 | for(Int i = 0; i< m_pchVideoInputFileList.size(); i++ ) |
---|
| 70 | { |
---|
| 71 | if ( m_pchVideoInputFileList[i] != NULL ) |
---|
| 72 | free (m_pchVideoInputFileList[i]); |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | for(Int i = 0; i< m_pchDepthInputFileList.size(); i++ ) |
---|
| 76 | { |
---|
| 77 | if ( m_pchDepthInputFileList[i] != NULL ) |
---|
| 78 | free (m_pchDepthInputFileList[i]); |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | for(Int i = 0; i< m_pchSynthOutputFileList.size(); i++ ) |
---|
| 82 | { |
---|
| 83 | if ( m_pchSynthOutputFileList[i] != NULL ) |
---|
| 84 | free (m_pchSynthOutputFileList[i]); |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | if ( m_pchVideoInputFileBaseName ) free( m_pchVideoInputFileBaseName ); |
---|
| 88 | if ( m_pchDepthInputFileBaseName ) free( m_pchDepthInputFileBaseName ); |
---|
| 89 | if ( m_pchSynthOutputFileBaseName ) free( m_pchSynthOutputFileBaseName); |
---|
| 90 | if ( m_pchCameraParameterFile ) free( m_pchCameraParameterFile ); |
---|
| 91 | if ( m_pchBaseViewCameraNumbers ) free( m_pchBaseViewCameraNumbers ); |
---|
| 92 | if ( m_pchSynthViewCameraNumbers ) free( m_pchSynthViewCameraNumbers ); |
---|
| 93 | if ( m_pchViewConfig ) free( m_pchViewConfig ); |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | Void TAppRendererCfg::create() |
---|
| 97 | { |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | Void TAppRendererCfg::destroy() |
---|
| 101 | { |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | // ==================================================================================================================== |
---|
| 105 | // Public member functions |
---|
| 106 | // ==================================================================================================================== |
---|
| 107 | |
---|
| 108 | /** \param argc number of arguments |
---|
| 109 | \param argv array of arguments |
---|
| 110 | \retval true when success |
---|
| 111 | */ |
---|
| 112 | Bool TAppRendererCfg::parseCfg( Int argc, Char* argv[] ) |
---|
| 113 | { |
---|
| 114 | bool do_help = false; |
---|
| 115 | |
---|
| 116 | po::Options opts; |
---|
| 117 | opts.addOptions() |
---|
| 118 | ("help", do_help, false, "this help text") |
---|
| 119 | ("c", po::parseConfigFile, "configuration file name") |
---|
| 120 | |
---|
| 121 | /* File I/O */ |
---|
| 122 | ("VideoInputFileBaseName", m_pchVideoInputFileBaseName, (Char*) 0, "Basename to generate video input file names") |
---|
| 123 | ("DepthInputFileBaseName", m_pchDepthInputFileBaseName, (Char*) 0, "Basename to generate depth input file names") |
---|
| 124 | ("SynthOutputFileBaseName", m_pchSynthOutputFileBaseName, (Char*) 0, "Basename to generate synthesized output file names") |
---|
| 125 | ("ContOutputFileNumbering", m_bContOutputFileNumbering , false , "Continuous Output File Numbering") |
---|
| 126 | ("Sweep" , m_bSweep , false , "Store all views in first Output File") |
---|
| 127 | |
---|
| 128 | ("VideoInputFile_%d,v_%d", m_pchVideoInputFileList , (Char *) 0, MAX_INPUT_VIEW_NUM , "Original Yuv video input file name %d") |
---|
| 129 | ("DepthInputFile_%d,d_%d", m_pchDepthInputFileList , (Char *) 0, MAX_INPUT_VIEW_NUM , "Original Yuv depth input file name %d") |
---|
| 130 | ("SynthOutputFile_%d,s_%d", m_pchSynthOutputFileList, (Char *) 0, MAX_OUTPUT_VIEW_NUM, "Synthesized Yuv output file name %d") |
---|
| 131 | |
---|
| 132 | /* Source Specification */ |
---|
| 133 | ("SourceWidth,-wdt", m_iSourceWidth, 0, "Source picture width") |
---|
| 134 | ("SourceHeight,-hgt", m_iSourceHeight, 0, "Source picture height") |
---|
| 135 | ("FrameSkip,-fs", m_iFrameSkip, 0, "Number of frames to skip at start of input YUV") |
---|
| 136 | ("FramesToBeRendered,f", m_iFramesToBeRendered, 0, "Number of frames to be rendered (default=all)") |
---|
| 137 | |
---|
| 138 | /* Camera Specification */ |
---|
| 139 | ("CameraParameterFile,cpf", m_pchCameraParameterFile, (Char *) 0, "Camera Parameter File Name") |
---|
| 140 | ("BaseViewCameraNumbers" , m_pchBaseViewCameraNumbers, (Char *) 0, "Numbers of base views") |
---|
| 141 | ("SynthViewCameraNumbers" , m_pchSynthViewCameraNumbers, (Char *) 0, "Numbers of views to synthesis") |
---|
| 142 | ("ViewConfig" , m_pchViewConfig, (Char *) 0, "View Configuration" ) |
---|
| 143 | |
---|
| 144 | /* Renderer Modes */ |
---|
| 145 | ("Log2SamplingFactor", m_iLog2SamplingFactor, 0, "Factor for horizontal up sampling before processing" ) |
---|
| 146 | ("UVup" , m_bUVUp , true, "Up sampling of chroma planes before processing" ) |
---|
| 147 | ("PreProcMode" , m_iPreProcMode , 0, "Depth preprocessing: 0 = None, 1 = Binomial filtering" ) |
---|
| 148 | ("PreFilterSize" , m_iPreFilterSize , 0, "For PreProcMode 1: Half Size of filter kernel" ) |
---|
[5] | 149 | ("SimEnhance" , m_bSimEnhance , true, "Similarity enhancement of video" ) |
---|
[2] | 150 | ("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] | 151 | ("BlendZThresPerc" , m_iBlendZThresPerc , 30, "Z-difference threshold for blending in percent of total Z-range" ) |
---|
[2] | 152 | ("BlendUseDistWeight", m_bBlendUseDistWeight , true, "0: blend using average; 1: blend factor depends on view distance" ) |
---|
[5] | 153 | ("BlendHoleMargin" , m_iBlendHoleMargin , 6, "Margin around holes to fill with other view" ) |
---|
| 154 | ("InterpolationMode" , m_iInterpolationMode , 4, "0: NN, 1:linear (int), 2:linear (double) , 3:cubic Hermite spline (double), 4: 8-tap (int)" ) |
---|
[2] | 155 | ("HoleFillingMode" , m_iHoleFillingMode , 1, "0: None, 1: line wise background extension" ) |
---|
| 156 | ("PostProcMode" , m_iPostProcMode , 0, "0: None, 1: horizontal 3-tap median" ) |
---|
| 157 | ("RenderMode" , m_iRenderMode , 0, "0: Use renderer, 1: use model renderer, 10: create used pels map") |
---|
[5] | 158 | ("ShiftPrecision" , m_iShiftPrecision , 2, "Shift Precision for Interpolation Mode 4" ) |
---|
[2] | 159 | ("TemporalDepthFilter", m_bTempDepthFilter , false, "Temporal depth filtering" ) |
---|
| 160 | ("RenderDirection" , m_iRenderDirection , 0, "0: Interpolate, 1: Extrapolate from left, 2: Extrapolate from right") |
---|
| 161 | ("UsedPelMapMarExt" , m_iUsedPelMapMarExt , 0, "Margin Extension in Pels for used pels map generation" ); |
---|
| 162 | |
---|
| 163 | po::setDefaults(opts); |
---|
| 164 | po::scanArgv(opts, argc, (const char**) argv); |
---|
| 165 | |
---|
| 166 | if (argc == 1 || do_help) |
---|
| 167 | { |
---|
| 168 | /* argc == 1: no options have been specified */ |
---|
| 169 | po::doHelp(cout, opts); |
---|
| 170 | xPrintUsage(); |
---|
| 171 | return false; |
---|
| 172 | } |
---|
| 173 | |
---|
| 174 | /* |
---|
| 175 | * Set any derived parameters before checking |
---|
| 176 | */ |
---|
| 177 | |
---|
| 178 | xSetGlobal(); |
---|
| 179 | |
---|
| 180 | UInt uiInputBitDepth = 8; |
---|
| 181 | UInt uiCamParPrecision = 5; |
---|
| 182 | |
---|
| 183 | m_bUseSetupString = ( m_pchViewConfig != NULL ) && ( m_iRenderMode != 0); |
---|
| 184 | |
---|
| 185 | if ( m_iRenderMode == 10 ) |
---|
| 186 | { |
---|
| 187 | m_cCameraData.init( MAX_INPUT_VIEW_NUM, uiInputBitDepth, uiCamParPrecision, (UInt)m_iFrameSkip, (UInt)m_iFramesToBeRendered, |
---|
| 188 | m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, NULL, NULL, m_iLog2SamplingFactor+m_iShiftPrecision ); |
---|
| 189 | m_iNumberOfInputViews = (Int) m_cCameraData.getBaseViewNumbers() .size(); |
---|
| 190 | m_iNumberOfOutputViews = m_iNumberOfInputViews - 1; |
---|
| 191 | m_iRenderDirection = 1; |
---|
| 192 | } |
---|
| 193 | else |
---|
| 194 | { |
---|
| 195 | if ( m_bUseSetupString ) |
---|
| 196 | { |
---|
| 197 | std::vector<Int> iaTempViews; |
---|
| 198 | std::vector<Int>* piaTempViews; |
---|
| 199 | m_cCameraData .convertNumberString( m_pchBaseViewCameraNumbers, iaTempViews, VIEW_NUM_PREC ); |
---|
| 200 | m_cRenModStrParser.setString( (Int) iaTempViews.size(), m_pchViewConfig ); |
---|
| 201 | piaTempViews = m_cRenModStrParser.getSynthViews(); |
---|
| 202 | m_iNumberOfOutputViews = (Int) m_cRenModStrParser.getNumOfModels(); |
---|
| 203 | m_iNumberOfInputViews = (Int) m_cRenModStrParser.getNumOfBaseViews(); |
---|
| 204 | m_bContOutputFileNumbering = true; |
---|
| 205 | |
---|
| 206 | m_cCameraData.init( MAX_INPUT_VIEW_NUM, uiInputBitDepth, uiCamParPrecision, (UInt)m_iFrameSkip, (UInt)m_iFramesToBeRendered, |
---|
| 207 | m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, NULL, piaTempViews, m_iLog2SamplingFactor+m_iShiftPrecision ); |
---|
| 208 | } |
---|
| 209 | else |
---|
| 210 | { |
---|
| 211 | m_cCameraData.init( MAX_INPUT_VIEW_NUM, uiInputBitDepth, uiCamParPrecision, (UInt)m_iFrameSkip, (UInt)m_iFramesToBeRendered, |
---|
| 212 | m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, m_pchSynthViewCameraNumbers, NULL, m_iLog2SamplingFactor+m_iShiftPrecision ); |
---|
| 213 | m_iNumberOfOutputViews = (Int) m_cCameraData.getSynthViewNumbers().size(); |
---|
| 214 | m_iNumberOfInputViews = (Int) m_cCameraData.getBaseViewNumbers() .size(); |
---|
| 215 | } |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | if (m_pchSynthOutputFileBaseName != NULL) |
---|
| 219 | xConfirmParameter( strrchr(m_pchSynthOutputFileBaseName,'$') == 0, "'$' must be a character in SynthOutputFileBaseName"); |
---|
| 220 | |
---|
| 221 | if (m_pchDepthInputFileBaseName != NULL) |
---|
| 222 | xConfirmParameter( strrchr(m_pchDepthInputFileBaseName, '$') == 0, "'$' must be a character in DepthInputFileBaseName" ); |
---|
| 223 | |
---|
| 224 | if (m_pchVideoInputFileBaseName != NULL) |
---|
| 225 | xConfirmParameter( strrchr(m_pchVideoInputFileBaseName, '$') == 0, "'$' must be a character in VideoInputFileBaseName" ); |
---|
| 226 | |
---|
| 227 | xCreateFileNames(); |
---|
| 228 | |
---|
| 229 | /* |
---|
| 230 | * check validity of input parameters |
---|
| 231 | */ |
---|
| 232 | xCheckParameter(); |
---|
| 233 | m_cCameraData.check( m_iRenderDirection == 0, m_iFramesToBeRendered != 0 ); |
---|
| 234 | |
---|
| 235 | // print-out parameters |
---|
| 236 | xPrintParameter(); |
---|
| 237 | |
---|
| 238 | return true; |
---|
| 239 | } |
---|
| 240 | |
---|
| 241 | |
---|
| 242 | // ==================================================================================================================== |
---|
| 243 | // Private member functions |
---|
| 244 | // ==================================================================================================================== |
---|
| 245 | |
---|
| 246 | Void TAppRendererCfg::xCheckParameter() |
---|
| 247 | { |
---|
| 248 | bool check_failed = false; /* abort if there is a fatal configuration problem */ |
---|
| 249 | #define xConfirmPara(a,b) check_failed |= xConfirmParameter(a,b) |
---|
| 250 | // check range of parameters |
---|
| 251 | |
---|
| 252 | /// File I/O |
---|
| 253 | |
---|
| 254 | // source specification |
---|
| 255 | xConfirmPara( m_iSourceWidth <= 0, "Source width must be greater than 0" ); |
---|
| 256 | xConfirmPara( m_iSourceHeight <= 0, "Source height must be greater than 0" ); |
---|
| 257 | xConfirmPara( m_iFrameSkip < 0, "Frame Skipping must be more than or equal to 0" ); |
---|
| 258 | xConfirmPara( m_iFramesToBeRendered < 0, "Total Number Of Frames rendered must be more than 1" ); |
---|
| 259 | |
---|
| 260 | |
---|
| 261 | // camera specification |
---|
| 262 | xConfirmPara( m_iNumberOfInputViews > MAX_INPUT_VIEW_NUM , "NumberOfInputViews must be less than of equal to MAX_INPUT_VIEW_NUM"); |
---|
| 263 | xConfirmPara( m_iNumberOfOutputViews > MAX_OUTPUT_VIEW_NUM, "NumberOfOutputViews must be less than of equal to MAX_OUTPUT_VIEW_NUM"); |
---|
| 264 | |
---|
| 265 | |
---|
| 266 | xConfirmPara( m_iRenderDirection < 0 || m_iRenderDirection > 2 , "RenderDirection must be greater than or equal to 0 and less than 3"); |
---|
| 267 | xConfirmPara(m_iNumberOfOutputViews < 1, "Number of OutputViews must be greater or equal to 1"); |
---|
| 268 | if ( m_iRenderDirection == 0 ) |
---|
| 269 | { |
---|
| 270 | xConfirmPara( m_iNumberOfInputViews < 2, "Number of InputViews must be more than or equal to 2"); |
---|
| 271 | } |
---|
| 272 | else |
---|
| 273 | { |
---|
| 274 | xConfirmPara( m_iNumberOfInputViews < 1, "Number of InputViews must be more than or equal to 1"); |
---|
| 275 | } |
---|
| 276 | |
---|
| 277 | xConfirmPara( m_iLog2SamplingFactor < 0 || m_iLog2SamplingFactor > 4, "Log2SamplingFactor must be more than or equal to 0 and less than 5" ); |
---|
| 278 | xConfirmPara( m_iPreProcMode < 0 || m_iPreProcMode > 1, "PreProcMode must be more than or equal to 0 and less than 2" ); |
---|
| 279 | |
---|
| 280 | |
---|
| 281 | xConfirmPara( m_iPreFilterSize < 0 || m_iPreFilterSize > 3, "PreFilterSize must be more than or equal to 0 and less than 4" ); |
---|
| 282 | xConfirmPara( m_iBlendMode < 0 || m_iBlendMode > 3, "BlendMode must be more than or equal to 0 and less than 4" ); |
---|
| 283 | xConfirmPara( m_iBlendZThresPerc < 0 || m_iBlendZThresPerc > 100,"BlendZThresPerc must be more than or equal to 0 and less than 101" ); |
---|
| 284 | xConfirmPara( m_iBlendHoleMargin < 0 || m_iBlendHoleMargin > 20,"BlendHoleMargin must be more than or equal to 0 and less than 19" ); |
---|
| 285 | xConfirmPara( m_iInterpolationMode < 0 || m_iInterpolationMode > 4, "InterpolationMode must be more than or equal to 0 and less than 5" ); |
---|
| 286 | xConfirmPara( m_iHoleFillingMode < 0 || m_iHoleFillingMode > 1, "HoleFillingMode must be more than or equal to 0 and less than 2" ); |
---|
| 287 | xConfirmPara( m_iPostProcMode < 0 || m_iPostProcMode > 2, "PostProcMode must be more than or equal to 0 and less than 3" ); |
---|
| 288 | |
---|
| 289 | Int iNumNonNULL; |
---|
| 290 | 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" ); |
---|
| 291 | 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" ); |
---|
| 292 | |
---|
| 293 | |
---|
| 294 | if ( !m_bSweep ) |
---|
| 295 | { |
---|
| 296 | 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" ); |
---|
| 297 | } |
---|
| 298 | else |
---|
| 299 | { |
---|
| 300 | xConfirmPara( iNumNonNULL < 1, "Number of SynthOutputFiles must be equal to or more than 1" ); |
---|
| 301 | } |
---|
| 302 | |
---|
| 303 | #undef xConfirmPara |
---|
| 304 | if ( check_failed ) |
---|
| 305 | { |
---|
| 306 | exit(EXIT_FAILURE); |
---|
| 307 | } |
---|
| 308 | |
---|
| 309 | } |
---|
| 310 | |
---|
| 311 | |
---|
| 312 | |
---|
| 313 | Void TAppRendererCfg::xPrintParameter() |
---|
| 314 | { |
---|
| 315 | printf("\n"); |
---|
| 316 | for( Int iCounter = 0; iCounter < m_iNumberOfInputViews; iCounter++) |
---|
| 317 | { |
---|
| 318 | printf("InputVideoFile_%i : %s\n", iCounter, m_pchVideoInputFileList[iCounter]); |
---|
| 319 | } |
---|
| 320 | for( Int iCounter = 0; iCounter < m_iNumberOfInputViews; iCounter++) |
---|
| 321 | { |
---|
| 322 | printf("InputDepthFile_%i : %s\n", iCounter, m_pchDepthInputFileList[iCounter]); |
---|
| 323 | } |
---|
| 324 | |
---|
| 325 | for( Int iCounter = 0; iCounter < m_iNumberOfOutputViews; iCounter++) |
---|
| 326 | { |
---|
| 327 | printf("SynthOutputFile_%i : %s\n", iCounter, m_pchSynthOutputFileList[iCounter]); |
---|
| 328 | } |
---|
| 329 | |
---|
| 330 | printf("Format : %dx%d \n", m_iSourceWidth, m_iSourceHeight ); |
---|
| 331 | printf("Frame index : %d - %d (%d frames)\n", m_iFrameSkip, m_iFrameSkip+m_iFramesToBeRendered-1, m_iFramesToBeRendered); |
---|
| 332 | printf("CameraParameterFile : %s\n", m_pchCameraParameterFile ); |
---|
| 333 | printf("BaseViewNumbers : %s (%d views) \n", m_pchBaseViewCameraNumbers , m_iNumberOfInputViews ); |
---|
| 334 | printf("Sweep : %d\n", m_bSweep ); |
---|
| 335 | |
---|
| 336 | if ( m_bUseSetupString ) |
---|
| 337 | { |
---|
| 338 | printf("ViewConfig : %s\n", m_pchViewConfig ); |
---|
| 339 | } |
---|
| 340 | else |
---|
| 341 | { |
---|
| 342 | printf("SynthViewNumbers : %s (%d views) \n", m_pchSynthViewCameraNumbers, m_iNumberOfOutputViews ); |
---|
| 343 | } |
---|
| 344 | |
---|
| 345 | printf("Log2SamplingFactor : %d\n", m_iLog2SamplingFactor ); |
---|
| 346 | printf("UVUp : %d\n", m_bUVUp ); |
---|
| 347 | printf("PreProcMode : %d\n", m_iPreProcMode ); |
---|
| 348 | printf("PreFilterSize : %d\n", m_iPreFilterSize ); |
---|
| 349 | printf("SimEnhance : %d\n", m_bSimEnhance ); |
---|
| 350 | printf("BlendMode : %d\n", m_iBlendMode ); |
---|
| 351 | printf("BlendZThresPerc : %d\n", m_iBlendZThresPerc ); |
---|
| 352 | printf("BlendUseDistWeight : %d\n", m_bBlendUseDistWeight ); |
---|
| 353 | printf("BlendHoleMargin : %d\n", m_iBlendHoleMargin ); |
---|
| 354 | printf("InterpolationMode : %d\n", m_iInterpolationMode ); |
---|
| 355 | printf("HoleFillingMode : %d\n", m_iHoleFillingMode ); |
---|
| 356 | printf("PostProcMode : %d\n", m_iPostProcMode ); |
---|
| 357 | printf("ShiftPrecision : %d\n", m_iShiftPrecision ); |
---|
| 358 | printf("TemporalDepthFilter : %d\n", m_bTempDepthFilter ); |
---|
| 359 | printf("RenderMode : %d\n", m_iRenderMode ); |
---|
| 360 | printf("RendererDirection : %d\n", m_iRenderDirection ); |
---|
| 361 | |
---|
| 362 | if (m_iRenderMode == 10 ) |
---|
| 363 | { |
---|
| 364 | printf("UsedPelMapMarExt : %d\n", m_iUsedPelMapMarExt ); |
---|
| 365 | } |
---|
| 366 | |
---|
| 367 | printf("\n"); |
---|
| 368 | |
---|
| 369 | // printf("TOOL CFG: "); |
---|
| 370 | // printf("ALF:%d ", m_bUseALF ); |
---|
| 371 | // printf("\n"); |
---|
| 372 | |
---|
| 373 | fflush(stdout); |
---|
| 374 | } |
---|
| 375 | |
---|
| 376 | Void TAppRendererCfg::xPrintUsage() |
---|
| 377 | { |
---|
| 378 | printf( "\n" ); |
---|
| 379 | printf( " Example: TAppRenderer.exe -c test.cfg\n\n"); |
---|
| 380 | } |
---|
| 381 | |
---|
| 382 | Bool TAppRendererCfg::xConfirmParameter(Bool bflag, const char* message) |
---|
| 383 | { |
---|
| 384 | if (!bflag) |
---|
| 385 | return false; |
---|
| 386 | |
---|
| 387 | printf("Error: %s\n",message); |
---|
| 388 | return true; |
---|
| 389 | } |
---|
| 390 | |
---|
| 391 | |
---|
| 392 | Void TAppRendererCfg::xCreateFileNames() |
---|
| 393 | { |
---|
| 394 | if ( m_iRenderMode == 10 ) |
---|
| 395 | return; |
---|
| 396 | |
---|
| 397 | Int iPrecBefore; |
---|
| 398 | Int iPrecAfter; |
---|
| 399 | |
---|
| 400 | xGetMaxPrecision( m_cCameraData.getSynthViewNumbers(), iPrecBefore, iPrecAfter ); |
---|
| 401 | |
---|
| 402 | |
---|
| 403 | if (iPrecBefore > LOG10_VIEW_NUM_PREC ) |
---|
| 404 | { |
---|
| 405 | std::cerr << "Error: View Numbers with more than " << LOG10_VIEW_NUM_PREC << " digits are not supported" << std::endl; |
---|
| 406 | exit(EXIT_FAILURE); |
---|
| 407 | } |
---|
| 408 | |
---|
| 409 | AOT( !m_bContOutputFileNumbering && (m_cCameraData.getSynthViewNumbers().size() != m_iNumberOfOutputViews )); |
---|
| 410 | for(Int iIdx = 0; iIdx < m_iNumberOfOutputViews; iIdx++) |
---|
| 411 | { |
---|
| 412 | //GT; Create ReconFileNames |
---|
| 413 | if (m_pchSynthOutputFileList[iIdx] == NULL ) |
---|
| 414 | { |
---|
| 415 | if ( m_bContOutputFileNumbering ) |
---|
| 416 | { |
---|
| 417 | xAddNumberToFileName( m_pchSynthOutputFileBaseName, m_pchSynthOutputFileList[iIdx], (Int) ((iIdx+1) * VIEW_NUM_PREC) , 2, 0 ); |
---|
| 418 | } |
---|
| 419 | else |
---|
| 420 | { |
---|
| 421 | xAddNumberToFileName( m_pchSynthOutputFileBaseName, m_pchSynthOutputFileList[iIdx], m_cCameraData.getSynthViewNumbers()[iIdx], iPrecBefore, iPrecAfter ); |
---|
| 422 | } |
---|
| 423 | } |
---|
| 424 | } |
---|
| 425 | |
---|
| 426 | xGetMaxPrecision( m_cCameraData.getBaseViewNumbers(), iPrecBefore, iPrecAfter ); |
---|
| 427 | for(Int iIdx = 0; iIdx < m_cCameraData.getBaseViewNumbers().size() ; iIdx++) |
---|
| 428 | { |
---|
| 429 | //GT; Create ReconFileNames |
---|
| 430 | if (m_pchVideoInputFileList[iIdx] == NULL ) |
---|
| 431 | { |
---|
| 432 | xAddNumberToFileName( m_pchVideoInputFileBaseName, m_pchVideoInputFileList[iIdx], m_cCameraData.getBaseViewNumbers()[iIdx], iPrecBefore, iPrecAfter ); |
---|
| 433 | } |
---|
| 434 | |
---|
| 435 | if (m_pchDepthInputFileList[iIdx] == NULL ) |
---|
| 436 | { |
---|
| 437 | xAddNumberToFileName( m_pchDepthInputFileBaseName, m_pchDepthInputFileList[iIdx], m_cCameraData.getBaseViewNumbers()[iIdx], iPrecBefore, iPrecAfter ); |
---|
| 438 | } |
---|
| 439 | } |
---|
| 440 | } |
---|
| 441 | |
---|
| 442 | Void TAppRendererCfg::xAddNumberToFileName( Char* pchSourceFileName, Char*& rpchTargetFileName, Int iNumberToAdd, UInt uiPrecBefore, UInt uiPrecAfter ) |
---|
| 443 | { |
---|
| 444 | |
---|
| 445 | if ( pchSourceFileName == NULL ) |
---|
| 446 | { |
---|
| 447 | std::cerr << "No BaseName for file name generation given." << std::endl; |
---|
| 448 | AOT(true); |
---|
| 449 | exit(EXIT_FAILURE); |
---|
| 450 | } |
---|
| 451 | |
---|
| 452 | Char pchNumberBuffer[2* LOG10_VIEW_NUM_PREC + 2]; |
---|
| 453 | Char pchPrintBuffer[10]; |
---|
| 454 | |
---|
| 455 | Double dNumberToAdd = ( (Double) iNumberToAdd ) / VIEW_NUM_PREC; |
---|
| 456 | |
---|
| 457 | UInt uiWidth = uiPrecBefore; |
---|
| 458 | |
---|
| 459 | if (uiPrecAfter != 0) |
---|
| 460 | { |
---|
| 461 | uiWidth += uiPrecAfter + 1; |
---|
| 462 | } |
---|
| 463 | |
---|
| 464 | sprintf( pchPrintBuffer, "%%0%d.%df", uiWidth, uiPrecAfter ); |
---|
| 465 | sprintf( pchNumberBuffer, pchPrintBuffer, dNumberToAdd ); |
---|
| 466 | |
---|
| 467 | if ( uiPrecAfter > 0 ) pchNumberBuffer[ uiPrecBefore ] = '_'; |
---|
| 468 | |
---|
| 469 | size_t iInLength = strlen(pchSourceFileName); |
---|
| 470 | size_t iAddLength = strlen(pchNumberBuffer); |
---|
| 471 | |
---|
| 472 | rpchTargetFileName = (Char*) malloc(iInLength+iAddLength+1); |
---|
| 473 | |
---|
| 474 | Char* pchPlaceHolder = strrchr(pchSourceFileName,'$'); |
---|
| 475 | assert( pchPlaceHolder ); |
---|
| 476 | |
---|
| 477 | size_t iCharsToPlaceHolder = pchPlaceHolder - pchSourceFileName; |
---|
| 478 | size_t iCharsToEnd = iInLength - iCharsToPlaceHolder; |
---|
| 479 | |
---|
| 480 | strncpy(rpchTargetFileName , pchSourceFileName , iCharsToPlaceHolder); |
---|
| 481 | strncpy(rpchTargetFileName+iCharsToPlaceHolder , pchNumberBuffer , iAddLength ); |
---|
| 482 | strncpy(rpchTargetFileName+iCharsToPlaceHolder+iAddLength, pchSourceFileName+iCharsToPlaceHolder+1, iCharsToEnd-1 ); |
---|
| 483 | rpchTargetFileName[iInLength+iAddLength-1] = '\0'; |
---|
| 484 | } |
---|
| 485 | |
---|
| 486 | Void TAppRendererCfg::xGetMaxPrecision( std::vector< Int > aiIn, Int& iPrecBefore, Int& iPrecAfter ) |
---|
| 487 | { |
---|
| 488 | iPrecBefore = 0; |
---|
| 489 | iPrecAfter = 0; |
---|
| 490 | |
---|
| 491 | for (UInt uiK = 0; uiK < aiIn.size(); uiK ++ ) |
---|
| 492 | { |
---|
| 493 | if ( aiIn[uiK] == 0 ) continue; |
---|
| 494 | |
---|
| 495 | Int iCurPrec; |
---|
| 496 | iCurPrec = 0; |
---|
| 497 | for ( Int iCur = aiIn[uiK]; iCur != 0; iCur /= 10, iCurPrec++ ); |
---|
[56] | 498 | iPrecBefore = max(iPrecBefore, iCurPrec - LOG10_VIEW_NUM_PREC ); |
---|
[2] | 499 | |
---|
| 500 | iCurPrec = 0; |
---|
| 501 | for ( Int iCur = 1; aiIn[uiK] % iCur == 0; iCur *= 10, iCurPrec++); |
---|
| 502 | iCurPrec = LOG10_VIEW_NUM_PREC - Min(LOG10_VIEW_NUM_PREC, iCurPrec-1 ); |
---|
[56] | 503 | iPrecAfter = max(iPrecAfter, iCurPrec ); |
---|
[2] | 504 | } |
---|
| 505 | } |
---|
| 506 | |
---|
| 507 | Void TAppRendererCfg::xSetGlobal() |
---|
| 508 | { |
---|
| 509 | // set max CU width & height |
---|
| 510 | Int iInternalBitDepth = 8; |
---|
| 511 | g_uiMaxCUWidth = 0; |
---|
| 512 | g_uiMaxCUHeight = 0; |
---|
| 513 | g_uiBitDepth = 8; |
---|
| 514 | g_uiBitIncrement = iInternalBitDepth - g_uiBitDepth; |
---|
| 515 | g_uiBASE_MAX = ((1<<(g_uiBitDepth))-1); |
---|
| 516 | g_uiIBDI_MAX = ((1<<(g_uiBitDepth+g_uiBitIncrement))-1); |
---|
| 517 | } |
---|