24#define LARGE_NUMBER 1073741824
30#if defined(__GNUC__) && !(defined(__INTEL_COMPILER))
31#pragma GCC diagnostic ignored "-Wconversion"
33#pragma warning(disable : 4100)
36int byte_rel_comp(
const int *data_in,
int n_in,
char *data_out,
int max_out,
int &n_out) {
37 int i, icurrent, irel;
43 throw std::runtime_error(
"byte rel comp error: nin <= 0");
45 if (max_out <= n_in) {
46 throw std::runtime_error(
"byte rel comp error: nin <= 0");
50 for (i = 0; i < n_in; i++) {
59 irel = data_in[i] - icurrent;
62 if ((irel <= 127) && (irel >= -127)) {
63 if (n_out > max_out) {
64 throw std::runtime_error(
"byte rel comp error: nin <= 0");
66 data_out[n_out] = irel;
70 if (n_out + 4 >= max_out) {
71 throw std::runtime_error(
"byte rel comp error: nin <= 0");
73 data_out[n_out] = -128;
74 byte_pack.i = data_in[i];
75 data_out[n_out + 1] = byte_pack.c[0];
76 data_out[n_out + 2] = byte_pack.c[1];
77 data_out[n_out + 3] = byte_pack.c[2];
78 data_out[n_out + 4] = byte_pack.c[3];
81 icurrent = data_in[i];
119int byte_rel_expn(
const char *data_in,
int n_in,
int n_from,
int *data_out,
int n_out) {
127 throw std::runtime_error(
"byte rel comp error: nin <= 0");
129 if (n_out + n_from > n_in) {
130 throw std::runtime_error(
"byte rel comp error: nin <= 0");
136 for (i = 0; i < n_from + n_out; i++) {
138 throw std::runtime_error(
"byte rel comp error: nin <= 0");
141 if (data_in[j] != -128) {
143 byte_pack.i += data_in[j];
149 throw std::runtime_error(
"byte rel comp error: nin <= 0");
152 byte_pack.c[0] = data_in[j + 1];
153 byte_pack.c[1] = data_in[j + 2];
154 byte_pack.c[2] = data_in[j + 3];
155 byte_pack.c[3] = data_in[j + 4];
161 data_out[i - n_from] = byte_pack.i;
166 if (n_out < n_in / 5) {
167 std::cerr <<
"byte rel expn: excessive bytes\n";
int byte_rel_expn(const char *data_in, int n_in, int n_from, int *data_out, int n_out)
int byte_rel_comp(const int *data_in, int n_in, char *data_out, int max_out, int &n_out)