-1

I'm trying to compress a large array of 16 bit integers (acquired through camera) and I want to compress it as fast as possible. However after looking at several options, it seems that most libraries are optimized for 32 bit data. (e.g https://github.com/lemire/FastPFor)

I also tried Oroch library (https://github.com/ademakov/Oroch) but it doesn't seem like it's particularly efficient..

#include <cstdlib>
#include <chrono>
#include <iostream>
#include <vector>
#include "oroch/varint.h"
unsigned long length = 1365ul*1531ul*1265ul;
using namespace std;
static vector<uint8_t> x;
static vector<uint16_t> img(length);
void *read_tiff(string filename,unsigned long length,vector<uint16_t> buffer)
{
  FILE *ptr_file;
  ptr_file = fopen(filename.c_str(),"rb");
  printf("length of array: %lu\n",length);
  rewind(ptr_file);
  printf("ok here?");
  uint16_t temp;
  int k;
  for (k=0;k<length;k++)
    {
      //printf("%d",k);
      fread(&temp,2,1,ptr_file);
      buffer[k] = temp;     
    }  
  fclose(ptr_file);
}
int main(){
  cout<<"this is working!\n";
  string dir;
  dir = "somedir";
  read_tiff(dir,length,img);
  cout<<"reading successful";
  auto start = chrono::high_resolution_clock::now();
  size_t size = oroch::varint_codec<uint16_t>::space(img.begin(),img.end());
  x.resize(size);
  uint8_t *data = x.data();
  oroch::varint_codec<uint16_t>::encode(data,img.begin(),img.end());
  auto finish = chrono::high_resolution_clock::now();
  auto time = chrono::duration_cast<chrono::milliseconds>(finish - start);
  cout << "emcode time : " << time.count() << " ms" << std::endl;
  return EXIT_SUCCESS;
}

Is there a user friendly library for other integer type ?

p.s. Speed more important than efficiency

1 Answers1

0

TurboPFor Integer Compression supports efficient 16/32/64 bits FULL range integer arrays.

powturbo
  • 311
  • 3
  • 3