Changeset 1313 in 3DVCSoftware for trunk/source/App/utils/convert_NtoMbit_YCbCr.cpp
- Timestamp:
- 13 Aug 2015, 17:38:13 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/App/utils/convert_NtoMbit_YCbCr.cpp
r872 r1313 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 4, ITU/ISO/IEC6 * Copyright (c) 2010-2015, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 41 41 namespace po = df::program_options_lite; 42 42 43 int main(int argc, const char** argv)43 Int main(Int argc, const char** argv) 44 44 { 45 bool do_help;45 Bool do_help; 46 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;47 UInt width, height; 48 UInt bitdepth_in, bitdepth_out, chromaFormatRaw; 49 UInt num_frames; 50 UInt num_frames_skip; 51 51 52 52 po::Options opts; … … 59 59 ("InputBitDepth", bitdepth_in, 8u, "bit-depth of input file") 60 60 ("OutputBitDepth", bitdepth_out, 8u, "bit-depth of output file") 61 ("ChromaFormat", chromaFormatRaw, 420u, "chroma format. 400, 420, 422 or 444 only") 61 62 ("NumFrames", num_frames, 0xffffffffu, "number of frames to process") 62 63 ("FrameSkip,-fs", num_frames_skip, 0u, "Number of frames to skip at start of input YUV") … … 65 66 po::setDefaults(opts); 66 67 po::scanArgv(opts, argc, argv); 68 67 69 68 70 if (argc == 1 || do_help) … … 73 75 } 74 76 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 75 89 TVideoIOYuv input; 76 90 TVideoIOYuv output; 77 91 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]; 80 94 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); 82 105 83 106 TComPicYuv frame; 84 frame.create( width, height, 1, 1, 0);107 frame.create( width, height, chromaFormatIDC, width, height, 0, false); 85 108 86 int pad[2] = {0, 0};109 Int pad[2] = {0, 0}; 87 110 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()) 90 116 { 91 if (! input.read(&frame, pad))117 if (! input.read(&frame, &cPicYuvTrueOrg, IPCOLOURSPACE_UNCHANGED, pad)) 92 118 { 93 119 break; 94 120 } 95 121 #if 0 96 Pel* img = frame.get LumaAddr();97 for ( int y = 0; y < height; y++)122 Pel* img = frame.getAddr(COMPONENT_Y); 123 for (Int y = 0; y < height; y++) 98 124 { 99 for (int x = 0; x < height; x++) 125 for (Int x = 0; x < height; x++) 126 { 100 127 img[x] = 0; 128 } 101 129 img += frame.getStride(); 102 130 } 103 img = frame.get LumaAddr();131 img = frame.getAddr(COMPONENT_Y); 104 132 img[0] = 1; 105 133 #endif 106 134 107 output.write(&frame );135 output.write(&frame, IPCOLOURSPACE_UNCHANGED); 108 136 num_frames_processed++; 109 137 if (num_frames_processed == num_frames) 138 { 110 139 break; 140 } 111 141 } 112 142 113 143 input.close(); 114 144 output.close(); 145 cPicYuvTrueOrg.destroy(); 115 146 116 147 return EXIT_SUCCESS;
Note: See TracChangeset for help on using the changeset viewer.