/* This code is part of the tng compression routines. * * Written by Daniel Spangberg * Copyright (c) 2010, 2013, The GROMACS development team. * * * This program is free software; you can redistribute it and/or * modify it under the terms of the Revised BSD License. */ #include "../../include/compression/rle.h" static void add_rle(unsigned int *rle, int v,int nsim, int *j,int min_rle) { if (nsim>min_rle) { /* Insert run-length */ unsigned int run=((unsigned int)nsim); while (run>1) { if (run&0x1U) rle[(*j)++]=1; else rle[(*j)++]=0; run>>=1; } nsim=1; } while (nsim--) rle[(*j)++]=v+2; } /* Run length encoding. Acceptable inputs are about 16 bits (0-0xFFFF) If input is 0-N output will be be values of 0-(N+2) */ void Ptngc_comp_conv_to_rle(unsigned int *vals, int nvals, unsigned int *rle, int *nrle, int min_rle) { int i; int j=0; int nsim=0; int v=-1; for (i=0; i