Changeset 1029 in SHVCSoftware for branches/SHM-dev/source/App/utils/convert_NtoMbit_YCbCr.cpp
- Timestamp:
- 26 Feb 2015, 00:21:54 (10 years ago)
- Location:
- branches/SHM-dev
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-dev
- Property svn:mergeinfo changed
-
branches/SHM-dev/source
- Property svn:mergeinfo changed
-
branches/SHM-dev/source/App/utils/convert_NtoMbit_YCbCr.cpp
r595 r1029 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 #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 ); 89 108 90 int pad[2] = {0, 0};109 Int pad[2] = {0, 0}; 91 110 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; 93 115 while (!input.isEof()) 94 116 { 95 if (! input.read(&frame, pad))117 if (! input.read(&frame, &cPicYuvTrueOrg, IPCOLOURSPACE_UNCHANGED, pad)) 96 118 { 97 119 break; 98 120 } 99 121 #if 0 100 Pel* img = frame.get LumaAddr();101 for ( int y = 0; y < height; y++)122 Pel* img = frame.getAddr(COMPONENT_Y); 123 for (Int y = 0; y < height; y++) 102 124 { 103 for ( int x = 0; x < height; x++)125 for (Int x = 0; x < height; x++) 104 126 img[x] = 0; 105 127 img += frame.getStride(); 106 128 } 107 img = frame.get LumaAddr();129 img = frame.getAddr(COMPONENT_Y); 108 130 img[0] = 1; 109 131 #endif 110 132 111 output.write(&frame );133 output.write(&frame, IPCOLOURSPACE_UNCHANGED); 112 134 num_frames_processed++; 113 135 if (num_frames_processed == num_frames) … … 117 139 input.close(); 118 140 output.close(); 141 cPicYuvTrueOrg.destroy(); 119 142 120 143 return EXIT_SUCCESS;
Note: See TracChangeset for help on using the changeset viewer.