source: 3DVCSoftware/branches/0.1-poznan-univ/source/App/utils/convert_NtoMbit_YCbCr.cpp @ 96

Last change on this file since 96 was 2, checked in by hhi, 13 years ago

inital import

  • Property svn:eol-style set to native
File size: 2.1 KB
Line 
1
2
3#include <cstdlib>
4
5#include "TLibCommon/TComPicYuv.h"
6#include "TLibVideoIO/TVideoIOYuv.h"
7#include "../../App/TAppCommon/program_options_lite.h"
8
9using namespace std;
10namespace po = df::program_options_lite;
11
12int main(int argc, const char** argv)
13{
14  bool do_help;
15  string filename_in, filename_out;
16  unsigned int width, height;
17  unsigned int bitdepth_in, bitdepth_out;
18  unsigned int num_frames;
19  unsigned int num_frames_skip;
20
21  po::Options opts;
22  opts.addOptions()
23  ("help", do_help, false, "this help text")
24  ("InputFile,i", filename_in, string(""), "input file to convert")
25  ("OutputFile,o", filename_out, string(""), "output file")
26  ("SourceWidth", width, 0u, "source picture width")
27  ("SourceHeight", height, 0u, "source picture height")
28  ("InputBitDepth", bitdepth_in, 8u, "bit-depth of input file")
29  ("OutputBitDepth", bitdepth_out, 8u, "bit-depth of output file")
30  ("NumFrames", num_frames, 0xffffffffu, "number of frames to process")
31  ("FrameSkip,-fs", num_frames_skip, 0u, "Number of frames to skip at start of input YUV")
32  ;
33
34  po::setDefaults(opts);
35  po::scanArgv(opts, argc, argv);
36
37  if (argc == 1 || do_help)
38  {
39    /* argc == 1: no options have been specified */
40    po::doHelp(cout, opts);
41    return EXIT_FAILURE;
42  }
43
44  TVideoIOYuv input;
45  TVideoIOYuv output;
46
47  input.open((char*)filename_in.c_str(), false, bitdepth_in, bitdepth_out);
48  output.open((char*)filename_out.c_str(), true, bitdepth_out, bitdepth_out);
49
50  input.skipFrames(num_frames_skip, width, height);
51
52  TComPicYuv frame;
53  frame.create( width, height, 1, 1, 0 );
54
55  int pad[2] = {0, 0};
56
57  unsigned int num_frames_processed = 0;
58  while (!input.isEof()) {
59    TComPicYuv *stupid = &frame;
60    input.read(stupid, pad);
61
62#if 0
63    Pel* img = frame.getLumaAddr();
64    for (int y = 0; y < height; y++) {
65      for (int x = 0; x < height; x++)
66        img[x] = 0;
67      img += frame.getStride();
68    }
69    img = frame.getLumaAddr();
70    img[0] = 1;
71#endif
72
73    output.write(&frame, pad);
74    num_frames_processed++;
75    if (num_frames_processed == num_frames)
76      break;
77  }
78
79  input.close();
80  output.close();
81
82  return EXIT_SUCCESS;
83}
Note: See TracBrowser for help on using the repository browser.