int main(int argc, char **argv) { if (argc < 2) { usage(); } get_args(&argc, &argv); translator.set_callsite_mode(true); // translate callsites, not raw addrs. for (int i=0; i < argc; i++) { ifstream comp_file(argv[i]); if (comp_file.fail()) { cerr << "Unable to open file: '" << argv[i] << "'" << endl; exit(1); } // try to find frame info database based on location of first effort file // fail if it's not found and we can't look up the symbols with SymtabAPI if (translate) { string dir(dirname(argv[i])); ostringstream path; path << dir << "/viewer-data/symtab"; frames.reset(FrameDB::load_from_file(path.str())); } effort_key key; ezw_header header; effort_key::read_in(comp_file, key); ezw_header::read_in(comp_file, header); if (stage == none) { // no parameters write_metadata(cout, key, header); continue; } string metric; int type, number; if (!parse_filename(argv[i], &metric, &type, &number)) { cerr << "Invalid effort file: " << argv[i] << endl; exit(1); } ostringstream sufstr; sufstr << "-" << metric << "-" << type << "-" << number; string suffix = sufstr.str(); if (stage & metadata) { // output metadata to a file. ostringstream mdname; mdname << "md" << suffix; ofstream mdfile(mdname.str().c_str()); write_metadata(mdfile, key, header); } if (stage < wt_coeff) return 0; // Do EZW decoding to get wavelet coefficients wavelet::wt_matrix reconstruction; ezw_decoder decoder; // Use the decode level in the header by default for both ezw and iwt. if (iwt_level < 0) iwt_level = header.level; if (reduce) { // if we're reducing the size of the output, we need to tell the decoder // to create a matrix to hold only the inverse-transformed levels. iwt_level = decoder.decode(comp_file, reconstruction, iwt_level, &header); } else { // if not, then we do a full ezw decode with the level of the forward transform // Don't set the IWT level, though. The user may still want fewer inverse // transforms but full size data. decoder.decode(comp_file, reconstruction, header.level, &header); } if (stage & wt_coeff) { ostringstream matname; matname << "wt" << suffix; ofstream wtfile(matname.str().c_str()); output(reconstruction, wtfile); } if (stage < reconstruct) return 0; // Do iwt for full reconstruction. wt_direct dwt; dwt.iwt_2d(reconstruction, iwt_level); if (stage & reconstruct) { ostringstream matname; matname << "recon" << suffix; ofstream reconfile(matname.str().c_str()); output(reconstruction, reconfile); } } return 0; }