Ignore:
Timestamp:
26 Feb 2015, 00:21:54 (10 years ago)
Author:
seregin
Message:

merge with SHM-upgrade branch

Location:
branches/SHM-dev
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-dev

  • branches/SHM-dev/source

  • branches/SHM-dev/source/App/utils/convert_NtoMbit_YCbCr.cpp

    r595 r1029  
    4141namespace po = df::program_options_lite;
    4242
    43 int main(int argc, const char** argv)
     43Int main(Int argc, const char** argv)
    4444{
    45   bool do_help;
     45  Bool do_help;
    4646  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;
     47  UInt width, height;
     48  UInt bitdepth_in, bitdepth_out, chromaFormatRaw;
     49  UInt num_frames;
     50  UInt num_frames_skip;
    5151
    5252  po::Options opts;
     
    5959  ("InputBitDepth", bitdepth_in, 8u, "bit-depth of input file")
    6060  ("OutputBitDepth", bitdepth_out, 8u, "bit-depth of output file")
     61  ("ChromaFormat", chromaFormatRaw, 420u, "chroma format. 400, 420, 422 or 444 only")
    6162  ("NumFrames", num_frames, 0xffffffffu, "number of frames to process")
    6263  ("FrameSkip,-fs", num_frames_skip, 0u, "Number of frames to skip at start of input YUV")
     
    6566  po::setDefaults(opts);
    6667  po::scanArgv(opts, argc, argv);
     68
    6769
    6870  if (argc == 1 || do_help)
     
    7375  }
    7476
     77  ChromaFormat chromaFormatIDC=CHROMA_420;
     78  switch (chromaFormatRaw)
     79  {
     80    case 400: chromaFormatIDC=CHROMA_400; break;
     81    case 420: chromaFormatIDC=CHROMA_420; break;
     82    case 422: chromaFormatIDC=CHROMA_422; break;
     83    case 444: chromaFormatIDC=CHROMA_444; break;
     84    default:
     85      fprintf(stderr, "Bad chroma format string\n");
     86      return EXIT_FAILURE;
     87  }
     88
    7589  TVideoIOYuv input;
    7690  TVideoIOYuv output;
    7791
    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);
     92  Int inputBitDepths [MAX_NUM_CHANNEL_TYPE];
     93  Int outputBitDepths[MAX_NUM_CHANNEL_TYPE];
    8094
    81   input.skipFrames(num_frames_skip, width, height);
     95  for (UInt channelTypeIndex = 0; channelTypeIndex < MAX_NUM_CHANNEL_TYPE; channelTypeIndex++)
     96  {
     97    inputBitDepths [channelTypeIndex] = bitdepth_in;
     98    outputBitDepths[channelTypeIndex] = bitdepth_out;
     99  }
     100
     101  input.open((char*)filename_in.c_str(), false, inputBitDepths, inputBitDepths, outputBitDepths);
     102  output.open((char*)filename_out.c_str(), true, outputBitDepths, outputBitDepths, outputBitDepths);
     103
     104  input.skipFrames(num_frames_skip, width, height, chromaFormatIDC);
    82105
    83106  TComPicYuv frame;
    84 #if AUXILIARY_PICTURES
    85 frame.create( width, height, CHROMA_420, 1, 1, 0 );
    86 #else
    87   frame.create( width, height, 1, 1, 0 );
    88 #endif
     107  frame.create( width, height, chromaFormatIDC, 1, 1, 0 );
    89108
    90   int pad[2] = {0, 0};
     109  Int pad[2] = {0, 0};
    91110
    92   unsigned int num_frames_processed = 0;
     111  TComPicYuv cPicYuvTrueOrg;
     112  cPicYuvTrueOrg.create( width, height, chromaFormatIDC, 1, 1, 0 );
     113
     114  UInt num_frames_processed = 0;
    93115  while (!input.isEof())
    94116  {
    95     if (! input.read(&frame, pad))
     117    if (! input.read(&frame, &cPicYuvTrueOrg, IPCOLOURSPACE_UNCHANGED, pad))
    96118    {
    97119      break;
    98120    }
    99121#if 0
    100     Pel* img = frame.getLumaAddr();
    101     for (int y = 0; y < height; y++)
     122    Pel* img = frame.getAddr(COMPONENT_Y);
     123    for (Int y = 0; y < height; y++)
    102124    {
    103       for (int x = 0; x < height; x++)
     125      for (Int x = 0; x < height; x++)
    104126        img[x] = 0;
    105127      img += frame.getStride();
    106128    }
    107     img = frame.getLumaAddr();
     129    img = frame.getAddr(COMPONENT_Y);
    108130    img[0] = 1;
    109131#endif
    110132
    111     output.write(&frame);
     133    output.write(&frame, IPCOLOURSPACE_UNCHANGED);
    112134    num_frames_processed++;
    113135    if (num_frames_processed == num_frames)
     
    117139  input.close();
    118140  output.close();
     141  cPicYuvTrueOrg.destroy();
    119142
    120143  return EXIT_SUCCESS;
Note: See TracChangeset for help on using the changeset viewer.