1 /* This code is part of the tng compression routines.
3 * Written by Daniel Spangberg
4 * Copyright (c) 2010, 2013, The GROMACS development team.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the Revised BSD License.
12 #include "../../include/compression/rle.h"
14 static void add_rle(unsigned int *rle,
15 const int v, int nsim,
16 int *j, const int min_rle)
20 /* Insert run-length */
21 unsigned int run=((unsigned int)nsim);
36 /* Run length encoding.
37 Acceptable inputs are about 16 bits (0-0xFFFF)
38 If input is 0-N output will be be values of 0-(N+2) */
39 void Ptngc_comp_conv_to_rle(unsigned int *vals, const int nvals,
40 unsigned int *rle, int *nrle,
47 for (i=0; i<nvals; i++)
60 add_rle(rle,v,nsim,&j,min_rle);
67 add_rle(rle,v,nsim,&j,min_rle);
71 void Ptngc_comp_conv_from_rle(unsigned int *rle,
72 unsigned int *vals, const int nvals)
80 unsigned int mask=0x1;
81 unsigned int v=rle[j++];
82 unsigned int hasrle=0;
95 for (k=0; k<(int)len; k++)