source: 3DVCSoftware/branches/0.3-nokia/source/App/TAppDecoder/TAppDecCfg.cpp @ 1417

Last change on this file since 1417 was 5, checked in by hhi, 13 years ago

Clean version with cfg-files

  • Property svn:eol-style set to native
File size: 5.2 KB
Line 
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 */
33
34
35
36/** \file     TAppDecCfg.cpp
37    \brief    Decoder configuration class
38*/
39
40#include <cstdio>
41#include <cstring>
42#include <string>
43#include "TAppDecCfg.h"
44#include "../../App/TAppCommon/program_options_lite.h"
45
46#ifdef WIN32
47#define strdup _strdup
48#endif
49
50using namespace std;
51namespace po = df::program_options_lite;
52
53// ====================================================================================================================
54// Public member functions
55// ====================================================================================================================
56
57/** \param argc number of arguments
58    \param argv array of arguments
59 */
60Bool TAppDecCfg::parseCfg( Int argc, Char* argv[] )
61{
62  bool do_help = false;
63  string cfg_BitstreamFile;
64  string cfg_ReconFile;
65  string cfg_ScaleOffsetFile;
66
67  po::Options opts;
68  opts.addOptions()
69  ("help", do_help, false, "this help text")
70  ("BitstreamFile,b", cfg_BitstreamFile, string(""), "bitstream input file name")
71  ("ReconFile,o",     cfg_ReconFile,     string(""), "reconstructed YUV output file name\n"
72                                                     "YUV writing is skipped if omitted")
73  ("ScaleOffsetFile,p", cfg_ScaleOffsetFile, string(""), "file with coded scales and offsets")
74#if DCM_SKIP_DECODING_FRAMES
75  ("SkipFrames,s", m_iSkipFrame, 0, "number of frames to skip before random access")
76#endif
77  ("OutputBitDepth,d", m_outputBitDepth, 0u, "bit depth of YUV output file (use 0 for native depth)")
78  ("SEIpictureDigest", m_pictureDigestEnabled, false, "Control handling of picture_digest SEI messages\n"
79                                              "\t1: check\n"
80                                              "\t0: ignore")
81  ;
82
83  po::setDefaults(opts);
84  const list<const char*>& argv_unhandled = po::scanArgv(opts, argc, (const char**) argv);
85
86  for (list<const char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
87  {
88    fprintf(stderr, "Unhandled argument ignored: `%s'\n", *it);
89  }
90
91  if (argc == 1 || do_help)
92  {
93    po::doHelp(cout, opts);
94    return false;
95  }
96
97  /* convert std::string to c string for compatability */
98  m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
99  m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
100  m_pchScaleOffsetFile = cfg_ScaleOffsetFile.empty() ? NULL : strdup(cfg_ScaleOffsetFile.c_str());
101
102  if (!m_pchBitstreamFile)
103  {
104    fprintf(stderr, "No input file specifed, aborting\n");
105    return false;
106  }
107
108  return true;
109}
110
111Void TAppDecCfg::xAppendToFileNameEnd( Char* pchInputFileName, const Char* pchStringToAppend, Char*& rpchOutputFileName)
112{
113  size_t iInLength     = strlen(pchInputFileName);
114  size_t iAppendLength = strlen(pchStringToAppend); 
115
116  rpchOutputFileName = (Char*) malloc(iInLength+iAppendLength+1);                                                                                               
117  Char* pCDot = strrchr(pchInputFileName,'.');                         
118  pCDot = pCDot ? pCDot : pchInputFileName + iInLength;                         
119  size_t iCharsToDot = pCDot - pchInputFileName ; 
120  size_t iCharsToEnd = iInLength - iCharsToDot;                                 
121  strncpy(rpchOutputFileName                            ,  pchInputFileName            , iCharsToDot  );
122  strncpy(rpchOutputFileName+ iCharsToDot               ,  pchStringToAppend           , iAppendLength); 
123  strncpy(rpchOutputFileName+ iCharsToDot+iAppendLength ,  pchInputFileName+iCharsToDot, iCharsToEnd  );                               
124  rpchOutputFileName[iInLength+iAppendLength] = '\0';                           
125}
Note: See TracBrowser for help on using the repository browser.