Ejemplo n.º 1
0
static int compress( arguments_t * args, cgt_nc * nc ) {
 
  int err = 0;
  int frame;

  struct imgImage * srcImage = NULL;
  struct imgImage * dstImage = NULL;

  int w = -1;
  int h = -1;
  
  {
    
    PrevFrames prevFrames;
    
    SwinkFileWriter swinkFileWriter( *args );
    
    PPPlanar ppPlanar;
    
    printf("compressing %s [%d ... %d] ( %d frames )\n", nc->ident, nc->first, nc->last, nc->file_count );
    
    for(frame = nc->first; frame <= nc->last; frame++) {

      if( imgAllocAndReadF( &srcImage, nc->nc, frame ) == 0 ) {
	
	if(!dstImage) {

	  if( ( err = imgAllocImage( &dstImage ) ) != 0)
	    goto err0;

	  dstImage->format = (imgFormat)(args->format);
	  dstImage->width =  ((srcImage->width+31)/32)*32; // 32 byte aligned width - so that CbCr will be 16 byte aligned.
	  dstImage->height = srcImage->height;

	  if( ( err = imgAllocPixelBuffers( dstImage) ) != 0 )
	    goto err0;
	  
	  zero_buffers( dstImage );
	}

	printf("compressing frame %d.\n\tphase 1...\n", frame);
	if( ( err = imguCopyImage( dstImage, srcImage ) ) != 0 )
	  goto err0;

#if(1)
	{
	  printf("\tphase 2...\n");
	  imgImage * diffed = ppPlanar.Add( dstImage );
	  printf("\tphase 3...\n");
	  swinkFileWriter.WriteFrame( diffed );
	  imgFreeAll( diffed );
	}
#else
	{
	    BC_ADD_LZ4<uint64_t,16,16> BC(prevFrames, dstImage);
	    
	    swinkFileWriter.WriteLZ4BlockArray(
	      BC.GetNumberOfBlocks(),
	      BC.GetCompressedBuffer(), 
	      BC.GetCompressedBufferLength(),
	      BC.GetUncompressedBufferLength(),
	      dstImage);
	}
#endif	
	
	
	
	
	printf("\tdone.\n");

	imgFreeAll( srcImage );
	srcImage = NULL;
      }
    }
  }
  
err0:
  if(err)
    printf("ERROR\n");
//  imgFreeAll(dstImage);
  imgFreeAll(srcImage);

  return err;
}
Ejemplo n.º 2
0
uint32_t test_value(int where, int what) {
  zero_buffers();
  buf1[where] = what;
  return ecc_generate(buf1);
}