/* Copyright 2008-2014 Research Foundation State University of New York */
/* This file is part of QUB Express. */
/* QUB Express is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation, either version 3 of the License, or */
/* (at your option) any later version. */
/* QUB Express is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* You should have received a copy of the GNU General Public License, */
/* named LICENSE.txt, in the QUB Express program directory. If not, see */
/* . */
#include "decode_acquirefile_samples.h"
// begin_html
// *.acquire files store sampled data in a special compressed format.
// This decodes it into 16-bit shorts. Assumes little-endian architecture (flips big-endian literals).
//
decode_acquirefile_samples.h
//
Up: Index
// end_html
extern "C" QUBFAST_API void decode_acquirefile_samples(char *src, short *dest, int size, int count)
{
short val = 0;
char *val_bytes = (char *) &val;
char *src_end = src + size;
short *dest_end = dest + count;
while ( (src != src_end) && (dest != dest_end) ) {
char c = *src;
if ( c == -128 ) {
++src;
val_bytes[1] = *src;
++src;
val_bytes[0] = *src;
++src;
} else {
val = (short) (val + c);
++src;
}
*dest = val;
++dest;
}
}