source: SHVCSoftware/branches/SHM-4.0-dev/source/App/utils/convert_NtoMbit_YCbCr.cpp @ 824

Last change on this file since 824 was 476, checked in by seregin, 11 years ago

fix compile warnings

  • Property svn:eol-style set to native
File size: 4.0 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-2012, ITU/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 ITU/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#include <cstdlib>
35
36#include "TLibCommon/TComPicYuv.h"
37#include "TLibVideoIO/TVideoIOYuv.h"
38#include "TAppCommon/program_options_lite.h"
39
40using namespace std;
41namespace po = df::program_options_lite;
42
43int main(int argc, const char** argv)
44{
45  bool do_help;
46  string filename_in, filename_out;
47  unsigned int width, height;
48  unsigned int bitdepth_in, bitdepth_out;
49  unsigned int num_frames;
50  unsigned int num_frames_skip;
51
52  po::Options opts;
53  opts.addOptions()
54  ("help", do_help, false, "this help text")
55  ("InputFile,i", filename_in, string(""), "input file to convert")
56  ("OutputFile,o", filename_out, string(""), "output file")
57  ("SourceWidth", width, 0u, "source picture width")
58  ("SourceHeight", height, 0u, "source picture height")
59  ("InputBitDepth", bitdepth_in, 8u, "bit-depth of input file")
60  ("OutputBitDepth", bitdepth_out, 8u, "bit-depth of output file")
61  ("NumFrames", num_frames, 0xffffffffu, "number of frames to process")
62  ("FrameSkip,-fs", num_frames_skip, 0u, "Number of frames to skip at start of input YUV")
63  ;
64
65  po::setDefaults(opts);
66  po::scanArgv(opts, argc, argv);
67
68  if (argc == 1 || do_help)
69  {
70    /* argc == 1: no options have been specified */
71    po::doHelp(cout, opts);
72    return EXIT_FAILURE;
73  }
74
75  TVideoIOYuv input;
76  TVideoIOYuv output;
77
78  input.open((char*)filename_in.c_str(), false, bitdepth_in, bitdepth_in, bitdepth_out, bitdepth_out);
79  output.open((char*)filename_out.c_str(), true, bitdepth_out, bitdepth_out, bitdepth_out, bitdepth_out);
80
81  input.skipFrames(num_frames_skip, width, height);
82
83  TComPicYuv frame;
84#if AUXILIARY_PICTURES
85frame.create( width, height, CHROMA_420, 1, 1, 0 );
86#else
87  frame.create( width, height, 1, 1, 0 );
88#endif
89
90  int pad[2] = {0, 0};
91
92  unsigned int num_frames_processed = 0;
93  while (!input.isEof()) 
94  {
95    if (! input.read(&frame, pad))
96    {
97      break;
98    }
99#if 0
100    Pel* img = frame.getLumaAddr();
101    for (int y = 0; y < height; y++)
102    {
103      for (int x = 0; x < height; x++)
104        img[x] = 0;
105      img += frame.getStride();
106    }
107    img = frame.getLumaAddr();
108    img[0] = 1;
109#endif
110
111    output.write(&frame);
112    num_frames_processed++;
113    if (num_frames_processed == num_frames)
114      break;
115  }
116
117  input.close();
118  output.close();
119
120  return EXIT_SUCCESS;
121}
Note: See TracBrowser for help on using the repository browser.