Ignore:
Timestamp:
13 Aug 2015, 17:38:13 (9 years ago)
Author:
tech
Message:

Merged 14.1-update-dev1@1312.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/App/utils/convert_NtoMbit_YCbCr.cpp

    r872 r1313  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
     4 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2014, ITU/ISO/IEC
     6 * Copyright (c) 2010-2015, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    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   frame.create( width, height, 1, 1, 0 );
     107  frame.create( width, height, chromaFormatIDC, width, height, 0, false);
    85108
    86   int pad[2] = {0, 0};
     109  Int pad[2] = {0, 0};
    87110
    88   unsigned int num_frames_processed = 0;
    89   while (!input.isEof())
     111  TComPicYuv cPicYuvTrueOrg;
     112  cPicYuvTrueOrg.create( width, height, chromaFormatIDC, width, height, 0, false );
     113
     114  UInt num_frames_processed = 0;
     115  while (!input.isEof())
    90116  {
    91     if (! input.read(&frame, pad))
     117    if (! input.read(&frame, &cPicYuvTrueOrg, IPCOLOURSPACE_UNCHANGED, pad))
    92118    {
    93119      break;
    94120    }
    95121#if 0
    96     Pel* img = frame.getLumaAddr();
    97     for (int y = 0; y < height; y++)
     122    Pel* img = frame.getAddr(COMPONENT_Y);
     123    for (Int y = 0; y < height; y++)
    98124    {
    99       for (int x = 0; x < height; x++)
     125      for (Int x = 0; x < height; x++)
     126      {
    100127        img[x] = 0;
     128      }
    101129      img += frame.getStride();
    102130    }
    103     img = frame.getLumaAddr();
     131    img = frame.getAddr(COMPONENT_Y);
    104132    img[0] = 1;
    105133#endif
    106134
    107     output.write(&frame);
     135    output.write(&frame, IPCOLOURSPACE_UNCHANGED);
    108136    num_frames_processed++;
    109137    if (num_frames_processed == num_frames)
     138    {
    110139      break;
     140    }
    111141  }
    112142
    113143  input.close();
    114144  output.close();
     145  cPicYuvTrueOrg.destroy();
    115146
    116147  return EXIT_SUCCESS;
Note: See TracChangeset for help on using the changeset viewer.