Exemple #1
0
int main(int argc, char **argv) {
	//::testing::InitGoogleTest(&argc, argv);
	//return RUN_ALL_TESTS();
	 if(argc != 3){
					cout << "Uso: " << endl;
					cout << argv[0] << " -c archivoAComprimir"<< endl;
					cout << argv[0] << " -d archivoADescomprimir"<< endl;
					exit(1);
			}

			string path=argv[2];

			if(!strcmp(argv[1],"-c")){
					Compressor * comp = new Compressor();
					comp->compress(path);
					//remove(path.c_str());
					delete comp;
			}

			if(!strcmp(argv[1],"-d")){
					Decompressor * decomp = new Decompressor();
					decomp->decompress(path);
					delete decomp;
			}
	return 0;
}
Exemple #2
0
// Returns a gzip decompressed version of the provided string.
inline Try<std::string> decompress(const std::string& compressed)
{
  Decompressor decompressor;
  Try<std::string> decompressed = decompressor.decompress(compressed);

  // Ensure that the decompression stream does not expect more input.
  if (decompressed.isSome() && !decompressor.finished()) {
    return Error("More input is expected");
  }

  return decompressed;
}
Exemple #3
0
void unpackMatrixPlusV3(ByteUnpacker &src, u16 *dst, size_t L) {
  // extract key numbers: 
  const vector<size_t> header = src.pop<size_t>(5);   
  const size_t nGood = header[0];
  const size_t nBad = header[1];
  const size_t RANK_GOOD = header[2];
  //const size_t rankBad = header[3];
  const bool uses16Bit = header[4];
  const int N = nGood + nBad; 
  //assert(rankBad == L);
  const fmat basisGood( POP_CONSTRUCTOR(float, L, RANK_GOOD) );
  // extract partion:
  const Col<u8> partion( src.popPtr<u8>(N), N, false, true );
  const uvec goodIdx = find(partion == 0);
  const uvec badIdx = find(partion == 1);
  assert( goodIdx.n_elem == nGood && badIdx.n_elem == nBad);
    
  // make a matrix using the memory pointed to by dst:
  Mat<u16> restored(dst, L, N, false, true);

  //decompress the good traces:
  if ( nGood > 0) {
    if ( uses16Bit ) {
      // extract scores:
      const Mat<i16> scoreGood( POP_CONSTRUCTOR(i16, nGood, RANK_GOOD) );
      //restored.cols(goodIdx) = convToValidU16( basisGood * convToFloat(scoreGood).t() );
      restored.cols(goodIdx) = convToValidU16( basisGood * scoreGood.t() );
    }
    else {
      // extract scores:
      const Mat<i32> scoreGood( POP_CONSTRUCTOR(i32, nGood, RANK_GOOD) );
      // fill this matrix with the matrix multiplications:
      //restored.cols(goodIdx) = convToValidU16( basisGood * conv_to<fmat>::from(scoreGood).t() );
      restored.cols(goodIdx) = convToValidU16( basisGood * scoreGood.t() );
    }
  }
  //Decompress the bad data, output the uncompressed to restored.cols(badIdx);
  if ( nBad > 0)
    {
      vector<size_t> sSize = src.pop<size_t>(1);
      const vector<uint8_t> deltaIn = src.pop<uint8_t>(sSize[0]);
      Decompressor dc;
      size_t nCols;
      size_t nRows;
      size_t oL;
      vector<uint16_t> deltaOut;
      dc.decompress(deltaIn,nRows,nCols, oL, deltaOut);
      Mat<uint16_t> dataBadMat(&deltaOut[0], L, nBad, false, true);
      restored.cols(badIdx) = dataBadMat;
    }
}
Exemple #4
0
int main()
{
    Compressor c;
    //cout << "compressing" << endl;
//    c.compress("/auto_home/nlephilippe/Téléchargements/test1.txt", "/auto_home/nlephilippe/Téléchargements/compc");
    c.compress("/home/noe/Téléchargements/test1.txt", "/home/noe/Téléchargements/compc");
  //  cout << endl;
    Decompressor d;
    //cout << "decompressing" << endl;
    //d.decompress("/auto_home/nlephilippe/Téléchargements/compc", "/auto_home/nlephilippe/Téléchargements/outc.bin");
    d.decompress("/home/noe/Téléchargements/compc", "/home/noe/Téléchargements/outc.txt");
    cout << endl;
    return 0;
}
// Uncompress section contents if required. Note that this function
// is called from parallelForEach, so it must be thread-safe.
void InputSectionBase::maybeUncompress() {
  if (UncompressBuf || !Decompressor::isCompressedELFSection(Flags, Name))
    return;

  Decompressor Dec = check(Decompressor::create(Name, toStringRef(Data),
                                                Config->IsLE, Config->Is64));

  size_t Size = Dec.getDecompressedSize();
  UncompressBuf.reset(new char[Size]());
  if (Error E = Dec.decompress({UncompressBuf.get(), Size}))
    fatal(toString(this) +
          ": decompress failed: " + llvm::toString(std::move(E)));

  Data = makeArrayRef((uint8_t *)UncompressBuf.get(), Size);
  Flags &= ~(uint64_t)SHF_COMPRESSED;
}
Exemple #6
0
    void processMsg( const char * msg,
                     const size_t len )
      {
#ifdef HAVE_LIBZ
          if ( M_comp_level >= 0 )
          {
              M_decomp.decompress( msg, len, Z_SYNC_FLUSH );
              char * out;
              int size;
              M_decomp.getOutput( out, size );
              if ( size > 0 )
              {
                  parseMsg( out, size );
              }
          }
          else
#endif
          {
              parseMsg( msg, len );
          }
      }
Exemple #7
0
Graphics::Surface *Animation::getFrame(int frameIndex) {
	if (frameIndex < _frameCount) {
		if (_frameList[frameIndex]._isCompressed) {
			Decompressor dec;
			byte *ddata = (byte *)malloc(_frameList[frameIndex]._dataSize);
			dec.decompress(_frameList[frameIndex]._compressedData, ddata, _frameList[frameIndex]._dataSize);
			int frameHeight = _frameList[frameIndex]._surface->h;
			int frameWidth = _frameList[frameIndex]._surface->w;
			for (uint16 i = 0; i < frameHeight; i++) {
				memcpy(_frameList[frameIndex]._surface->getBasePtr(0, i), ddata + frameWidth * i, frameWidth);
			}
			free(ddata);
			free(_frameList[frameIndex]._compressedData);
			_frameList[frameIndex]._compressedData = nullptr;
			_frameList[frameIndex]._dataSize = 0;
			_frameList[frameIndex]._isCompressed = false;
		}
		return _frameList[frameIndex]._surface;
	} else {
		error("getFrame() frameIndex: %d, frameCount: %d", frameIndex, _frameCount);
	}
}
Exemple #8
0
//--------------------------------------------------------------
bool Decompress(const u8* buffer, int size, io::File* ostream)
{
    Decompressor decompr;
    return decompr.decompress(buffer, size, ostream) && decompr.finish(ostream);
}