// AUTOGENERATED FILE. DO NOT MODIFY.

#include <stdlib.h>
#include <stdint.h>

#include "unpack31.h"



static void unpack_1_31bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 1 values into output
	// Values are 31-bit signed
	// Skip 0 bits, read 31 bits of data.
	// Input must be at least 4 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);
}

static void unpack_1_31bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 1 values into output
	// Values are 31-bit unsigned
	// Skip 0 bits, read 31 bits of data.
	// Input must be at least 4 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);
}

static void unpack_1_31bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 1 values into output
	// Values are 31-bit signed
	// Skip 1 bits, read 31 bits of data.
	// Input must be at least 4 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);
}

static void unpack_1_31bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 1 values into output
	// Values are 31-bit unsigned
	// Skip 1 bits, read 31 bits of data.
	// Input must be at least 4 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);
}

static void unpack_1_31bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 1 values into output
	// Values are 31-bit signed
	// Skip 2 bits, read 31 bits of data.
	// Input must be at least 5 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);
}

static void unpack_1_31bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 1 values into output
	// Values are 31-bit unsigned
	// Skip 2 bits, read 31 bits of data.
	// Input must be at least 5 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);
}

static void unpack_1_31bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 1 values into output
	// Values are 31-bit signed
	// Skip 3 bits, read 31 bits of data.
	// Input must be at least 5 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);
}

static void unpack_1_31bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 1 values into output
	// Values are 31-bit unsigned
	// Skip 3 bits, read 31 bits of data.
	// Input must be at least 5 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);
}

static void unpack_1_31bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 1 values into output
	// Values are 31-bit signed
	// Skip 4 bits, read 31 bits of data.
	// Input must be at least 5 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);
}

static void unpack_1_31bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 1 values into output
	// Values are 31-bit unsigned
	// Skip 4 bits, read 31 bits of data.
	// Input must be at least 5 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);
}

static void unpack_1_31bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 1 values into output
	// Values are 31-bit signed
	// Skip 5 bits, read 31 bits of data.
	// Input must be at least 5 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);
}

static void unpack_1_31bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 1 values into output
	// Values are 31-bit unsigned
	// Skip 5 bits, read 31 bits of data.
	// Input must be at least 5 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);
}

static void unpack_1_31bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 1 values into output
	// Values are 31-bit signed
	// Skip 6 bits, read 31 bits of data.
	// Input must be at least 5 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);
}

static void unpack_1_31bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 1 values into output
	// Values are 31-bit unsigned
	// Skip 6 bits, read 31 bits of data.
	// Input must be at least 5 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);
}

static void unpack_1_31bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 1 values into output
	// Values are 31-bit signed
	// Skip 7 bits, read 31 bits of data.
	// Input must be at least 5 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);
}

static void unpack_1_31bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 1 values into output
	// Values are 31-bit unsigned
	// Skip 7 bits, read 31 bits of data.
	// Input must be at least 5 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);
}

static void unpack_2_31bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 2 values into output
	// Values are 31-bit signed
	// Skip 0 bits, read 62 bits of data.
	// Input must be at least 8 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);
}

static void unpack_2_31bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 2 values into output
	// Values are 31-bit unsigned
	// Skip 0 bits, read 62 bits of data.
	// Input must be at least 8 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);
}

static void unpack_2_31bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 2 values into output
	// Values are 31-bit signed
	// Skip 1 bits, read 62 bits of data.
	// Input must be at least 8 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);
}

static void unpack_2_31bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 2 values into output
	// Values are 31-bit unsigned
	// Skip 1 bits, read 62 bits of data.
	// Input must be at least 8 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);
}

static void unpack_2_31bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 2 values into output
	// Values are 31-bit signed
	// Skip 2 bits, read 62 bits of data.
	// Input must be at least 8 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);
}

static void unpack_2_31bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 2 values into output
	// Values are 31-bit unsigned
	// Skip 2 bits, read 62 bits of data.
	// Input must be at least 8 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);
}

static void unpack_2_31bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 2 values into output
	// Values are 31-bit signed
	// Skip 3 bits, read 62 bits of data.
	// Input must be at least 9 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);
}

static void unpack_2_31bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 2 values into output
	// Values are 31-bit unsigned
	// Skip 3 bits, read 62 bits of data.
	// Input must be at least 9 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);
}

static void unpack_2_31bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 2 values into output
	// Values are 31-bit signed
	// Skip 4 bits, read 62 bits of data.
	// Input must be at least 9 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);
}

static void unpack_2_31bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 2 values into output
	// Values are 31-bit unsigned
	// Skip 4 bits, read 62 bits of data.
	// Input must be at least 9 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);
}

static void unpack_2_31bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 2 values into output
	// Values are 31-bit signed
	// Skip 5 bits, read 62 bits of data.
	// Input must be at least 9 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);
}

static void unpack_2_31bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 2 values into output
	// Values are 31-bit unsigned
	// Skip 5 bits, read 62 bits of data.
	// Input must be at least 9 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);
}

static void unpack_2_31bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 2 values into output
	// Values are 31-bit signed
	// Skip 6 bits, read 62 bits of data.
	// Input must be at least 9 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);
}

static void unpack_2_31bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 2 values into output
	// Values are 31-bit unsigned
	// Skip 6 bits, read 62 bits of data.
	// Input must be at least 9 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);
}

static void unpack_2_31bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 2 values into output
	// Values are 31-bit signed
	// Skip 7 bits, read 62 bits of data.
	// Input must be at least 9 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);
}

static void unpack_2_31bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 2 values into output
	// Values are 31-bit unsigned
	// Skip 7 bits, read 62 bits of data.
	// Input must be at least 9 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);
}

static void unpack_3_31bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 3 values into output
	// Values are 31-bit signed
	// Skip 0 bits, read 93 bits of data.
	// Input must be at least 12 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);
}

static void unpack_3_31bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 3 values into output
	// Values are 31-bit unsigned
	// Skip 0 bits, read 93 bits of data.
	// Input must be at least 12 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);
}

static void unpack_3_31bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 3 values into output
	// Values are 31-bit signed
	// Skip 1 bits, read 93 bits of data.
	// Input must be at least 12 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);
}

static void unpack_3_31bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 3 values into output
	// Values are 31-bit unsigned
	// Skip 1 bits, read 93 bits of data.
	// Input must be at least 12 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);
}

static void unpack_3_31bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 3 values into output
	// Values are 31-bit signed
	// Skip 2 bits, read 93 bits of data.
	// Input must be at least 12 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);
}

static void unpack_3_31bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 3 values into output
	// Values are 31-bit unsigned
	// Skip 2 bits, read 93 bits of data.
	// Input must be at least 12 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);
}

static void unpack_3_31bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 3 values into output
	// Values are 31-bit signed
	// Skip 3 bits, read 93 bits of data.
	// Input must be at least 12 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);
}

static void unpack_3_31bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 3 values into output
	// Values are 31-bit unsigned
	// Skip 3 bits, read 93 bits of data.
	// Input must be at least 12 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);
}

static void unpack_3_31bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 3 values into output
	// Values are 31-bit signed
	// Skip 4 bits, read 93 bits of data.
	// Input must be at least 13 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);
}

static void unpack_3_31bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 3 values into output
	// Values are 31-bit unsigned
	// Skip 4 bits, read 93 bits of data.
	// Input must be at least 13 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);
}

static void unpack_3_31bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 3 values into output
	// Values are 31-bit signed
	// Skip 5 bits, read 93 bits of data.
	// Input must be at least 13 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);
}

static void unpack_3_31bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 3 values into output
	// Values are 31-bit unsigned
	// Skip 5 bits, read 93 bits of data.
	// Input must be at least 13 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);
}

static void unpack_3_31bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 3 values into output
	// Values are 31-bit signed
	// Skip 6 bits, read 93 bits of data.
	// Input must be at least 13 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);
}

static void unpack_3_31bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 3 values into output
	// Values are 31-bit unsigned
	// Skip 6 bits, read 93 bits of data.
	// Input must be at least 13 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);
}

static void unpack_3_31bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 3 values into output
	// Values are 31-bit signed
	// Skip 7 bits, read 93 bits of data.
	// Input must be at least 13 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);
}

static void unpack_3_31bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 3 values into output
	// Values are 31-bit unsigned
	// Skip 7 bits, read 93 bits of data.
	// Input must be at least 13 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);
}

static void unpack_4_31bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 4 values into output
	// Values are 31-bit signed
	// Skip 0 bits, read 124 bits of data.
	// Input must be at least 16 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);
}

static void unpack_4_31bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 4 values into output
	// Values are 31-bit unsigned
	// Skip 0 bits, read 124 bits of data.
	// Input must be at least 16 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);
}

static void unpack_4_31bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 4 values into output
	// Values are 31-bit signed
	// Skip 1 bits, read 124 bits of data.
	// Input must be at least 16 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);
}

static void unpack_4_31bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 4 values into output
	// Values are 31-bit unsigned
	// Skip 1 bits, read 124 bits of data.
	// Input must be at least 16 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);
}

static void unpack_4_31bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 4 values into output
	// Values are 31-bit signed
	// Skip 2 bits, read 124 bits of data.
	// Input must be at least 16 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);
}

static void unpack_4_31bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 4 values into output
	// Values are 31-bit unsigned
	// Skip 2 bits, read 124 bits of data.
	// Input must be at least 16 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);
}

static void unpack_4_31bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 4 values into output
	// Values are 31-bit signed
	// Skip 3 bits, read 124 bits of data.
	// Input must be at least 16 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);
}

static void unpack_4_31bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 4 values into output
	// Values are 31-bit unsigned
	// Skip 3 bits, read 124 bits of data.
	// Input must be at least 16 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);
}

static void unpack_4_31bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 4 values into output
	// Values are 31-bit signed
	// Skip 4 bits, read 124 bits of data.
	// Input must be at least 16 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);
}

static void unpack_4_31bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 4 values into output
	// Values are 31-bit unsigned
	// Skip 4 bits, read 124 bits of data.
	// Input must be at least 16 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);
}

static void unpack_4_31bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 4 values into output
	// Values are 31-bit signed
	// Skip 5 bits, read 124 bits of data.
	// Input must be at least 17 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);
}

static void unpack_4_31bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 4 values into output
	// Values are 31-bit unsigned
	// Skip 5 bits, read 124 bits of data.
	// Input must be at least 17 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);
}

static void unpack_4_31bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 4 values into output
	// Values are 31-bit signed
	// Skip 6 bits, read 124 bits of data.
	// Input must be at least 17 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);
}

static void unpack_4_31bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 4 values into output
	// Values are 31-bit unsigned
	// Skip 6 bits, read 124 bits of data.
	// Input must be at least 17 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);
}

static void unpack_4_31bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 4 values into output
	// Values are 31-bit signed
	// Skip 7 bits, read 124 bits of data.
	// Input must be at least 17 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);
}

static void unpack_4_31bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 4 values into output
	// Values are 31-bit unsigned
	// Skip 7 bits, read 124 bits of data.
	// Input must be at least 17 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);
}

static void unpack_5_31bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 5 values into output
	// Values are 31-bit signed
	// Skip 0 bits, read 155 bits of data.
	// Input must be at least 20 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);
}

static void unpack_5_31bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 5 values into output
	// Values are 31-bit unsigned
	// Skip 0 bits, read 155 bits of data.
	// Input must be at least 20 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);
}

static void unpack_5_31bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 5 values into output
	// Values are 31-bit signed
	// Skip 1 bits, read 155 bits of data.
	// Input must be at least 20 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);
}

static void unpack_5_31bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 5 values into output
	// Values are 31-bit unsigned
	// Skip 1 bits, read 155 bits of data.
	// Input must be at least 20 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);
}

static void unpack_5_31bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 5 values into output
	// Values are 31-bit signed
	// Skip 2 bits, read 155 bits of data.
	// Input must be at least 20 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);
}

static void unpack_5_31bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 5 values into output
	// Values are 31-bit unsigned
	// Skip 2 bits, read 155 bits of data.
	// Input must be at least 20 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);
}

static void unpack_5_31bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 5 values into output
	// Values are 31-bit signed
	// Skip 3 bits, read 155 bits of data.
	// Input must be at least 20 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);
}

static void unpack_5_31bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 5 values into output
	// Values are 31-bit unsigned
	// Skip 3 bits, read 155 bits of data.
	// Input must be at least 20 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);
}

static void unpack_5_31bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 5 values into output
	// Values are 31-bit signed
	// Skip 4 bits, read 155 bits of data.
	// Input must be at least 20 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);
}

static void unpack_5_31bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 5 values into output
	// Values are 31-bit unsigned
	// Skip 4 bits, read 155 bits of data.
	// Input must be at least 20 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);
}

static void unpack_5_31bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 5 values into output
	// Values are 31-bit signed
	// Skip 5 bits, read 155 bits of data.
	// Input must be at least 20 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);
}

static void unpack_5_31bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 5 values into output
	// Values are 31-bit unsigned
	// Skip 5 bits, read 155 bits of data.
	// Input must be at least 20 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);
}

static void unpack_5_31bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 5 values into output
	// Values are 31-bit signed
	// Skip 6 bits, read 155 bits of data.
	// Input must be at least 21 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);
}

static void unpack_5_31bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 5 values into output
	// Values are 31-bit unsigned
	// Skip 6 bits, read 155 bits of data.
	// Input must be at least 21 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);
}

static void unpack_5_31bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 5 values into output
	// Values are 31-bit signed
	// Skip 7 bits, read 155 bits of data.
	// Input must be at least 21 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);
}

static void unpack_5_31bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 5 values into output
	// Values are 31-bit unsigned
	// Skip 7 bits, read 155 bits of data.
	// Input must be at least 21 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);
}

static void unpack_6_31bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 6 values into output
	// Values are 31-bit signed
	// Skip 0 bits, read 186 bits of data.
	// Input must be at least 24 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 155 to 185
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)input[21] << 11) |
			((uint32_t)input[22] << 3) |
			((uint32_t)(input[23] & 0xc0) >> 5);
	output[5] = (double)(value >> 1);
}

static void unpack_6_31bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 6 values into output
	// Values are 31-bit unsigned
	// Skip 0 bits, read 186 bits of data.
	// Input must be at least 24 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 155 to 185
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)input[21] << 11) |
			((uint32_t)input[22] << 3) |
			((uint32_t)(input[23] & 0xc0) >> 5);
	output[5] = (double)(value >> 1);
}

static void unpack_6_31bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 6 values into output
	// Values are 31-bit signed
	// Skip 1 bits, read 186 bits of data.
	// Input must be at least 24 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 156 to 186
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)input[21] << 12) |
			((uint32_t)input[22] << 4) |
			((uint32_t)(input[23] & 0xe0) >> 4);
	output[5] = (double)(value >> 1);
}

static void unpack_6_31bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 6 values into output
	// Values are 31-bit unsigned
	// Skip 1 bits, read 186 bits of data.
	// Input must be at least 24 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 156 to 186
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)input[21] << 12) |
			((uint32_t)input[22] << 4) |
			((uint32_t)(input[23] & 0xe0) >> 4);
	output[5] = (double)(value >> 1);
}

static void unpack_6_31bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 6 values into output
	// Values are 31-bit signed
	// Skip 2 bits, read 186 bits of data.
	// Input must be at least 24 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 157 to 187
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13) |
			((uint32_t)input[22] << 5) |
			((uint32_t)(input[23] & 0xf0) >> 3);
	output[5] = (double)(value >> 1);
}

static void unpack_6_31bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 6 values into output
	// Values are 31-bit unsigned
	// Skip 2 bits, read 186 bits of data.
	// Input must be at least 24 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 157 to 187
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13) |
			((uint32_t)input[22] << 5) |
			((uint32_t)(input[23] & 0xf0) >> 3);
	output[5] = (double)(value >> 1);
}

static void unpack_6_31bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 6 values into output
	// Values are 31-bit signed
	// Skip 3 bits, read 186 bits of data.
	// Input must be at least 24 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 158 to 188
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)input[22] << 6) |
			((uint32_t)(input[23] & 0xf8) >> 2);
	output[5] = (double)(value >> 1);
}

static void unpack_6_31bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 6 values into output
	// Values are 31-bit unsigned
	// Skip 3 bits, read 186 bits of data.
	// Input must be at least 24 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 158 to 188
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)input[22] << 6) |
			((uint32_t)(input[23] & 0xf8) >> 2);
	output[5] = (double)(value >> 1);
}

static void unpack_6_31bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 6 values into output
	// Values are 31-bit signed
	// Skip 4 bits, read 186 bits of data.
	// Input must be at least 24 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 159 to 189
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)input[22] << 7) |
			((uint32_t)(input[23] & 0xfc) >> 1);
	output[5] = (double)(value >> 1);
}

static void unpack_6_31bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 6 values into output
	// Values are 31-bit unsigned
	// Skip 4 bits, read 186 bits of data.
	// Input must be at least 24 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 159 to 189
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)input[22] << 7) |
			((uint32_t)(input[23] & 0xfc) >> 1);
	output[5] = (double)(value >> 1);
}

static void unpack_6_31bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 6 values into output
	// Values are 31-bit signed
	// Skip 5 bits, read 186 bits of data.
	// Input must be at least 24 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 160 to 190
	value = ((uint32_t)input[20] << 24) |
			((uint32_t)input[21] << 16) |
			((uint32_t)input[22] << 8) |
			((uint32_t)(input[23] & 0xfe));
	output[5] = (double)(value >> 1);
}

static void unpack_6_31bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 6 values into output
	// Values are 31-bit unsigned
	// Skip 5 bits, read 186 bits of data.
	// Input must be at least 24 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 160 to 190
	value = ((uint32_t)input[20] << 24) |
			((uint32_t)input[21] << 16) |
			((uint32_t)input[22] << 8) |
			((uint32_t)(input[23] & 0xfe));
	output[5] = (double)(value >> 1);
}

static void unpack_6_31bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 6 values into output
	// Values are 31-bit signed
	// Skip 6 bits, read 186 bits of data.
	// Input must be at least 24 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 161 to 191
	value = ((uint32_t)(input[20] & 0x7f) << 25) |
			((uint32_t)input[21] << 17) |
			((uint32_t)input[22] << 9) |
			((uint32_t)input[23] << 1);
	output[5] = (double)(value >> 1);
}

static void unpack_6_31bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 6 values into output
	// Values are 31-bit unsigned
	// Skip 6 bits, read 186 bits of data.
	// Input must be at least 24 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 161 to 191
	value = ((uint32_t)(input[20] & 0x7f) << 25) |
			((uint32_t)input[21] << 17) |
			((uint32_t)input[22] << 9) |
			((uint32_t)input[23] << 1);
	output[5] = (double)(value >> 1);
}

static void unpack_6_31bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 6 values into output
	// Values are 31-bit signed
	// Skip 7 bits, read 186 bits of data.
	// Input must be at least 25 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 162 to 192
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)input[23] << 2) |
			((uint32_t)(input[24] & 0x80) >> 6);
	output[5] = (double)(value >> 1);
}

static void unpack_6_31bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 6 values into output
	// Values are 31-bit unsigned
	// Skip 7 bits, read 186 bits of data.
	// Input must be at least 25 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 162 to 192
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)input[23] << 2) |
			((uint32_t)(input[24] & 0x80) >> 6);
	output[5] = (double)(value >> 1);
}

static void unpack_7_31bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 7 values into output
	// Values are 31-bit signed
	// Skip 0 bits, read 217 bits of data.
	// Input must be at least 28 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 155 to 185
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)input[21] << 11) |
			((uint32_t)input[22] << 3) |
			((uint32_t)(input[23] & 0xc0) >> 5);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 186 to 216
	value = ((uint32_t)(input[23] & 0x3f) << 26) |
			((uint32_t)input[24] << 18) |
			((uint32_t)input[25] << 10) |
			((uint32_t)input[26] << 2) |
			((uint32_t)(input[27] & 0x80) >> 6);
	output[6] = (double)(value >> 1);
}

static void unpack_7_31bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 7 values into output
	// Values are 31-bit unsigned
	// Skip 0 bits, read 217 bits of data.
	// Input must be at least 28 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 155 to 185
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)input[21] << 11) |
			((uint32_t)input[22] << 3) |
			((uint32_t)(input[23] & 0xc0) >> 5);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 186 to 216
	value = ((uint32_t)(input[23] & 0x3f) << 26) |
			((uint32_t)input[24] << 18) |
			((uint32_t)input[25] << 10) |
			((uint32_t)input[26] << 2) |
			((uint32_t)(input[27] & 0x80) >> 6);
	output[6] = (double)(value >> 1);
}

static void unpack_7_31bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 7 values into output
	// Values are 31-bit signed
	// Skip 1 bits, read 217 bits of data.
	// Input must be at least 28 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 156 to 186
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)input[21] << 12) |
			((uint32_t)input[22] << 4) |
			((uint32_t)(input[23] & 0xe0) >> 4);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 187 to 217
	value = ((uint32_t)(input[23] & 0x1f) << 27) |
			((uint32_t)input[24] << 19) |
			((uint32_t)input[25] << 11) |
			((uint32_t)input[26] << 3) |
			((uint32_t)(input[27] & 0xc0) >> 5);
	output[6] = (double)(value >> 1);
}

static void unpack_7_31bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 7 values into output
	// Values are 31-bit unsigned
	// Skip 1 bits, read 217 bits of data.
	// Input must be at least 28 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 156 to 186
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)input[21] << 12) |
			((uint32_t)input[22] << 4) |
			((uint32_t)(input[23] & 0xe0) >> 4);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 187 to 217
	value = ((uint32_t)(input[23] & 0x1f) << 27) |
			((uint32_t)input[24] << 19) |
			((uint32_t)input[25] << 11) |
			((uint32_t)input[26] << 3) |
			((uint32_t)(input[27] & 0xc0) >> 5);
	output[6] = (double)(value >> 1);
}

static void unpack_7_31bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 7 values into output
	// Values are 31-bit signed
	// Skip 2 bits, read 217 bits of data.
	// Input must be at least 28 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 157 to 187
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13) |
			((uint32_t)input[22] << 5) |
			((uint32_t)(input[23] & 0xf0) >> 3);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 188 to 218
	value = ((uint32_t)(input[23] & 0x0f) << 28) |
			((uint32_t)input[24] << 20) |
			((uint32_t)input[25] << 12) |
			((uint32_t)input[26] << 4) |
			((uint32_t)(input[27] & 0xe0) >> 4);
	output[6] = (double)(value >> 1);
}

static void unpack_7_31bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 7 values into output
	// Values are 31-bit unsigned
	// Skip 2 bits, read 217 bits of data.
	// Input must be at least 28 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 157 to 187
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13) |
			((uint32_t)input[22] << 5) |
			((uint32_t)(input[23] & 0xf0) >> 3);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 188 to 218
	value = ((uint32_t)(input[23] & 0x0f) << 28) |
			((uint32_t)input[24] << 20) |
			((uint32_t)input[25] << 12) |
			((uint32_t)input[26] << 4) |
			((uint32_t)(input[27] & 0xe0) >> 4);
	output[6] = (double)(value >> 1);
}

static void unpack_7_31bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 7 values into output
	// Values are 31-bit signed
	// Skip 3 bits, read 217 bits of data.
	// Input must be at least 28 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 158 to 188
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)input[22] << 6) |
			((uint32_t)(input[23] & 0xf8) >> 2);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 189 to 219
	value = ((uint32_t)(input[23] & 0x07) << 29) |
			((uint32_t)input[24] << 21) |
			((uint32_t)input[25] << 13) |
			((uint32_t)input[26] << 5) |
			((uint32_t)(input[27] & 0xf0) >> 3);
	output[6] = (double)(value >> 1);
}

static void unpack_7_31bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 7 values into output
	// Values are 31-bit unsigned
	// Skip 3 bits, read 217 bits of data.
	// Input must be at least 28 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 158 to 188
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)input[22] << 6) |
			((uint32_t)(input[23] & 0xf8) >> 2);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 189 to 219
	value = ((uint32_t)(input[23] & 0x07) << 29) |
			((uint32_t)input[24] << 21) |
			((uint32_t)input[25] << 13) |
			((uint32_t)input[26] << 5) |
			((uint32_t)(input[27] & 0xf0) >> 3);
	output[6] = (double)(value >> 1);
}

static void unpack_7_31bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 7 values into output
	// Values are 31-bit signed
	// Skip 4 bits, read 217 bits of data.
	// Input must be at least 28 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 159 to 189
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)input[22] << 7) |
			((uint32_t)(input[23] & 0xfc) >> 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 190 to 220
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)input[26] << 6) |
			((uint32_t)(input[27] & 0xf8) >> 2);
	output[6] = (double)(value >> 1);
}

static void unpack_7_31bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 7 values into output
	// Values are 31-bit unsigned
	// Skip 4 bits, read 217 bits of data.
	// Input must be at least 28 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 159 to 189
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)input[22] << 7) |
			((uint32_t)(input[23] & 0xfc) >> 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 190 to 220
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)input[26] << 6) |
			((uint32_t)(input[27] & 0xf8) >> 2);
	output[6] = (double)(value >> 1);
}

static void unpack_7_31bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 7 values into output
	// Values are 31-bit signed
	// Skip 5 bits, read 217 bits of data.
	// Input must be at least 28 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 160 to 190
	value = ((uint32_t)input[20] << 24) |
			((uint32_t)input[21] << 16) |
			((uint32_t)input[22] << 8) |
			((uint32_t)(input[23] & 0xfe));
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 191 to 221
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)input[26] << 7) |
			((uint32_t)(input[27] & 0xfc) >> 1);
	output[6] = (double)(value >> 1);
}

static void unpack_7_31bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 7 values into output
	// Values are 31-bit unsigned
	// Skip 5 bits, read 217 bits of data.
	// Input must be at least 28 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 160 to 190
	value = ((uint32_t)input[20] << 24) |
			((uint32_t)input[21] << 16) |
			((uint32_t)input[22] << 8) |
			((uint32_t)(input[23] & 0xfe));
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 191 to 221
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)input[26] << 7) |
			((uint32_t)(input[27] & 0xfc) >> 1);
	output[6] = (double)(value >> 1);
}

static void unpack_7_31bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 7 values into output
	// Values are 31-bit signed
	// Skip 6 bits, read 217 bits of data.
	// Input must be at least 28 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 161 to 191
	value = ((uint32_t)(input[20] & 0x7f) << 25) |
			((uint32_t)input[21] << 17) |
			((uint32_t)input[22] << 9) |
			((uint32_t)input[23] << 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 192 to 222
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xfe));
	output[6] = (double)(value >> 1);
}

static void unpack_7_31bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 7 values into output
	// Values are 31-bit unsigned
	// Skip 6 bits, read 217 bits of data.
	// Input must be at least 28 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 161 to 191
	value = ((uint32_t)(input[20] & 0x7f) << 25) |
			((uint32_t)input[21] << 17) |
			((uint32_t)input[22] << 9) |
			((uint32_t)input[23] << 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 192 to 222
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xfe));
	output[6] = (double)(value >> 1);
}

static void unpack_7_31bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 7 values into output
	// Values are 31-bit signed
	// Skip 7 bits, read 217 bits of data.
	// Input must be at least 28 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 162 to 192
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)input[23] << 2) |
			((uint32_t)(input[24] & 0x80) >> 6);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 193 to 223
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)input[26] << 9) |
			((uint32_t)input[27] << 1);
	output[6] = (double)(value >> 1);
}

static void unpack_7_31bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 7 values into output
	// Values are 31-bit unsigned
	// Skip 7 bits, read 217 bits of data.
	// Input must be at least 28 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 162 to 192
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)input[23] << 2) |
			((uint32_t)(input[24] & 0x80) >> 6);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 193 to 223
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)input[26] << 9) |
			((uint32_t)input[27] << 1);
	output[6] = (double)(value >> 1);
}

static void unpack_8_31bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 8 values into output
	// Values are 31-bit signed
	// Skip 0 bits, read 248 bits of data.
	// Input must be at least 31 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 155 to 185
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)input[21] << 11) |
			((uint32_t)input[22] << 3) |
			((uint32_t)(input[23] & 0xc0) >> 5);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 186 to 216
	value = ((uint32_t)(input[23] & 0x3f) << 26) |
			((uint32_t)input[24] << 18) |
			((uint32_t)input[25] << 10) |
			((uint32_t)input[26] << 2) |
			((uint32_t)(input[27] & 0x80) >> 6);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 217 to 247
	value = ((uint32_t)(input[27] & 0x7f) << 25) |
			((uint32_t)input[28] << 17) |
			((uint32_t)input[29] << 9) |
			((uint32_t)input[30] << 1);
	output[7] = (double)(value >> 1);
}

static void unpack_8_31bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 8 values into output
	// Values are 31-bit unsigned
	// Skip 0 bits, read 248 bits of data.
	// Input must be at least 31 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 155 to 185
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)input[21] << 11) |
			((uint32_t)input[22] << 3) |
			((uint32_t)(input[23] & 0xc0) >> 5);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 186 to 216
	value = ((uint32_t)(input[23] & 0x3f) << 26) |
			((uint32_t)input[24] << 18) |
			((uint32_t)input[25] << 10) |
			((uint32_t)input[26] << 2) |
			((uint32_t)(input[27] & 0x80) >> 6);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 217 to 247
	value = ((uint32_t)(input[27] & 0x7f) << 25) |
			((uint32_t)input[28] << 17) |
			((uint32_t)input[29] << 9) |
			((uint32_t)input[30] << 1);
	output[7] = (double)(value >> 1);
}

static void unpack_8_31bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 8 values into output
	// Values are 31-bit signed
	// Skip 1 bits, read 248 bits of data.
	// Input must be at least 32 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 156 to 186
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)input[21] << 12) |
			((uint32_t)input[22] << 4) |
			((uint32_t)(input[23] & 0xe0) >> 4);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 187 to 217
	value = ((uint32_t)(input[23] & 0x1f) << 27) |
			((uint32_t)input[24] << 19) |
			((uint32_t)input[25] << 11) |
			((uint32_t)input[26] << 3) |
			((uint32_t)(input[27] & 0xc0) >> 5);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 218 to 248
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)input[30] << 2) |
			((uint32_t)(input[31] & 0x80) >> 6);
	output[7] = (double)(value >> 1);
}

static void unpack_8_31bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 8 values into output
	// Values are 31-bit unsigned
	// Skip 1 bits, read 248 bits of data.
	// Input must be at least 32 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 156 to 186
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)input[21] << 12) |
			((uint32_t)input[22] << 4) |
			((uint32_t)(input[23] & 0xe0) >> 4);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 187 to 217
	value = ((uint32_t)(input[23] & 0x1f) << 27) |
			((uint32_t)input[24] << 19) |
			((uint32_t)input[25] << 11) |
			((uint32_t)input[26] << 3) |
			((uint32_t)(input[27] & 0xc0) >> 5);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 218 to 248
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)input[30] << 2) |
			((uint32_t)(input[31] & 0x80) >> 6);
	output[7] = (double)(value >> 1);
}

static void unpack_8_31bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 8 values into output
	// Values are 31-bit signed
	// Skip 2 bits, read 248 bits of data.
	// Input must be at least 32 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 157 to 187
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13) |
			((uint32_t)input[22] << 5) |
			((uint32_t)(input[23] & 0xf0) >> 3);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 188 to 218
	value = ((uint32_t)(input[23] & 0x0f) << 28) |
			((uint32_t)input[24] << 20) |
			((uint32_t)input[25] << 12) |
			((uint32_t)input[26] << 4) |
			((uint32_t)(input[27] & 0xe0) >> 4);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 219 to 249
	value = ((uint32_t)(input[27] & 0x1f) << 27) |
			((uint32_t)input[28] << 19) |
			((uint32_t)input[29] << 11) |
			((uint32_t)input[30] << 3) |
			((uint32_t)(input[31] & 0xc0) >> 5);
	output[7] = (double)(value >> 1);
}

static void unpack_8_31bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 8 values into output
	// Values are 31-bit unsigned
	// Skip 2 bits, read 248 bits of data.
	// Input must be at least 32 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 157 to 187
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13) |
			((uint32_t)input[22] << 5) |
			((uint32_t)(input[23] & 0xf0) >> 3);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 188 to 218
	value = ((uint32_t)(input[23] & 0x0f) << 28) |
			((uint32_t)input[24] << 20) |
			((uint32_t)input[25] << 12) |
			((uint32_t)input[26] << 4) |
			((uint32_t)(input[27] & 0xe0) >> 4);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 219 to 249
	value = ((uint32_t)(input[27] & 0x1f) << 27) |
			((uint32_t)input[28] << 19) |
			((uint32_t)input[29] << 11) |
			((uint32_t)input[30] << 3) |
			((uint32_t)(input[31] & 0xc0) >> 5);
	output[7] = (double)(value >> 1);
}

static void unpack_8_31bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 8 values into output
	// Values are 31-bit signed
	// Skip 3 bits, read 248 bits of data.
	// Input must be at least 32 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 158 to 188
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)input[22] << 6) |
			((uint32_t)(input[23] & 0xf8) >> 2);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 189 to 219
	value = ((uint32_t)(input[23] & 0x07) << 29) |
			((uint32_t)input[24] << 21) |
			((uint32_t)input[25] << 13) |
			((uint32_t)input[26] << 5) |
			((uint32_t)(input[27] & 0xf0) >> 3);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 220 to 250
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)input[30] << 4) |
			((uint32_t)(input[31] & 0xe0) >> 4);
	output[7] = (double)(value >> 1);
}

static void unpack_8_31bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 8 values into output
	// Values are 31-bit unsigned
	// Skip 3 bits, read 248 bits of data.
	// Input must be at least 32 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 158 to 188
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)input[22] << 6) |
			((uint32_t)(input[23] & 0xf8) >> 2);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 189 to 219
	value = ((uint32_t)(input[23] & 0x07) << 29) |
			((uint32_t)input[24] << 21) |
			((uint32_t)input[25] << 13) |
			((uint32_t)input[26] << 5) |
			((uint32_t)(input[27] & 0xf0) >> 3);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 220 to 250
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)input[30] << 4) |
			((uint32_t)(input[31] & 0xe0) >> 4);
	output[7] = (double)(value >> 1);
}

static void unpack_8_31bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 8 values into output
	// Values are 31-bit signed
	// Skip 4 bits, read 248 bits of data.
	// Input must be at least 32 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 159 to 189
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)input[22] << 7) |
			((uint32_t)(input[23] & 0xfc) >> 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 190 to 220
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)input[26] << 6) |
			((uint32_t)(input[27] & 0xf8) >> 2);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 221 to 251
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5) |
			((uint32_t)(input[31] & 0xf0) >> 3);
	output[7] = (double)(value >> 1);
}

static void unpack_8_31bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 8 values into output
	// Values are 31-bit unsigned
	// Skip 4 bits, read 248 bits of data.
	// Input must be at least 32 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 159 to 189
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)input[22] << 7) |
			((uint32_t)(input[23] & 0xfc) >> 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 190 to 220
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)input[26] << 6) |
			((uint32_t)(input[27] & 0xf8) >> 2);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 221 to 251
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5) |
			((uint32_t)(input[31] & 0xf0) >> 3);
	output[7] = (double)(value >> 1);
}

static void unpack_8_31bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 8 values into output
	// Values are 31-bit signed
	// Skip 5 bits, read 248 bits of data.
	// Input must be at least 32 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 160 to 190
	value = ((uint32_t)input[20] << 24) |
			((uint32_t)input[21] << 16) |
			((uint32_t)input[22] << 8) |
			((uint32_t)(input[23] & 0xfe));
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 191 to 221
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)input[26] << 7) |
			((uint32_t)(input[27] & 0xfc) >> 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 222 to 252
	value = ((uint32_t)(input[27] & 0x03) << 30) |
			((uint32_t)input[28] << 22) |
			((uint32_t)input[29] << 14) |
			((uint32_t)input[30] << 6) |
			((uint32_t)(input[31] & 0xf8) >> 2);
	output[7] = (double)(value >> 1);
}

static void unpack_8_31bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 8 values into output
	// Values are 31-bit unsigned
	// Skip 5 bits, read 248 bits of data.
	// Input must be at least 32 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 160 to 190
	value = ((uint32_t)input[20] << 24) |
			((uint32_t)input[21] << 16) |
			((uint32_t)input[22] << 8) |
			((uint32_t)(input[23] & 0xfe));
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 191 to 221
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)input[26] << 7) |
			((uint32_t)(input[27] & 0xfc) >> 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 222 to 252
	value = ((uint32_t)(input[27] & 0x03) << 30) |
			((uint32_t)input[28] << 22) |
			((uint32_t)input[29] << 14) |
			((uint32_t)input[30] << 6) |
			((uint32_t)(input[31] & 0xf8) >> 2);
	output[7] = (double)(value >> 1);
}

static void unpack_8_31bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 8 values into output
	// Values are 31-bit signed
	// Skip 6 bits, read 248 bits of data.
	// Input must be at least 32 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 161 to 191
	value = ((uint32_t)(input[20] & 0x7f) << 25) |
			((uint32_t)input[21] << 17) |
			((uint32_t)input[22] << 9) |
			((uint32_t)input[23] << 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 192 to 222
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xfe));
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 223 to 253
	value = ((uint32_t)(input[27] & 0x01) << 31) |
			((uint32_t)input[28] << 23) |
			((uint32_t)input[29] << 15) |
			((uint32_t)input[30] << 7) |
			((uint32_t)(input[31] & 0xfc) >> 1);
	output[7] = (double)(value >> 1);
}

static void unpack_8_31bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 8 values into output
	// Values are 31-bit unsigned
	// Skip 6 bits, read 248 bits of data.
	// Input must be at least 32 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 161 to 191
	value = ((uint32_t)(input[20] & 0x7f) << 25) |
			((uint32_t)input[21] << 17) |
			((uint32_t)input[22] << 9) |
			((uint32_t)input[23] << 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 192 to 222
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xfe));
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 223 to 253
	value = ((uint32_t)(input[27] & 0x01) << 31) |
			((uint32_t)input[28] << 23) |
			((uint32_t)input[29] << 15) |
			((uint32_t)input[30] << 7) |
			((uint32_t)(input[31] & 0xfc) >> 1);
	output[7] = (double)(value >> 1);
}

static void unpack_8_31bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 8 values into output
	// Values are 31-bit signed
	// Skip 7 bits, read 248 bits of data.
	// Input must be at least 32 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 162 to 192
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)input[23] << 2) |
			((uint32_t)(input[24] & 0x80) >> 6);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 193 to 223
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)input[26] << 9) |
			((uint32_t)input[27] << 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 224 to 254
	value = ((uint32_t)input[28] << 24) |
			((uint32_t)input[29] << 16) |
			((uint32_t)input[30] << 8) |
			((uint32_t)(input[31] & 0xfe));
	output[7] = (double)(value >> 1);
}

static void unpack_8_31bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 8 values into output
	// Values are 31-bit unsigned
	// Skip 7 bits, read 248 bits of data.
	// Input must be at least 32 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 162 to 192
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)input[23] << 2) |
			((uint32_t)(input[24] & 0x80) >> 6);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 193 to 223
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)input[26] << 9) |
			((uint32_t)input[27] << 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 224 to 254
	value = ((uint32_t)input[28] << 24) |
			((uint32_t)input[29] << 16) |
			((uint32_t)input[30] << 8) |
			((uint32_t)(input[31] & 0xfe));
	output[7] = (double)(value >> 1);
}

static void unpack_9_31bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 9 values into output
	// Values are 31-bit signed
	// Skip 0 bits, read 279 bits of data.
	// Input must be at least 35 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 155 to 185
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)input[21] << 11) |
			((uint32_t)input[22] << 3) |
			((uint32_t)(input[23] & 0xc0) >> 5);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 186 to 216
	value = ((uint32_t)(input[23] & 0x3f) << 26) |
			((uint32_t)input[24] << 18) |
			((uint32_t)input[25] << 10) |
			((uint32_t)input[26] << 2) |
			((uint32_t)(input[27] & 0x80) >> 6);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 217 to 247
	value = ((uint32_t)(input[27] & 0x7f) << 25) |
			((uint32_t)input[28] << 17) |
			((uint32_t)input[29] << 9) |
			((uint32_t)input[30] << 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 248 to 278
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xfe));
	output[8] = (double)(value >> 1);
}

static void unpack_9_31bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 9 values into output
	// Values are 31-bit unsigned
	// Skip 0 bits, read 279 bits of data.
	// Input must be at least 35 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 155 to 185
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)input[21] << 11) |
			((uint32_t)input[22] << 3) |
			((uint32_t)(input[23] & 0xc0) >> 5);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 186 to 216
	value = ((uint32_t)(input[23] & 0x3f) << 26) |
			((uint32_t)input[24] << 18) |
			((uint32_t)input[25] << 10) |
			((uint32_t)input[26] << 2) |
			((uint32_t)(input[27] & 0x80) >> 6);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 217 to 247
	value = ((uint32_t)(input[27] & 0x7f) << 25) |
			((uint32_t)input[28] << 17) |
			((uint32_t)input[29] << 9) |
			((uint32_t)input[30] << 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 248 to 278
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xfe));
	output[8] = (double)(value >> 1);
}

static void unpack_9_31bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 9 values into output
	// Values are 31-bit signed
	// Skip 1 bits, read 279 bits of data.
	// Input must be at least 35 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 156 to 186
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)input[21] << 12) |
			((uint32_t)input[22] << 4) |
			((uint32_t)(input[23] & 0xe0) >> 4);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 187 to 217
	value = ((uint32_t)(input[23] & 0x1f) << 27) |
			((uint32_t)input[24] << 19) |
			((uint32_t)input[25] << 11) |
			((uint32_t)input[26] << 3) |
			((uint32_t)(input[27] & 0xc0) >> 5);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 218 to 248
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)input[30] << 2) |
			((uint32_t)(input[31] & 0x80) >> 6);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 249 to 279
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)input[33] << 9) |
			((uint32_t)input[34] << 1);
	output[8] = (double)(value >> 1);
}

static void unpack_9_31bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 9 values into output
	// Values are 31-bit unsigned
	// Skip 1 bits, read 279 bits of data.
	// Input must be at least 35 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 156 to 186
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)input[21] << 12) |
			((uint32_t)input[22] << 4) |
			((uint32_t)(input[23] & 0xe0) >> 4);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 187 to 217
	value = ((uint32_t)(input[23] & 0x1f) << 27) |
			((uint32_t)input[24] << 19) |
			((uint32_t)input[25] << 11) |
			((uint32_t)input[26] << 3) |
			((uint32_t)(input[27] & 0xc0) >> 5);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 218 to 248
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)input[30] << 2) |
			((uint32_t)(input[31] & 0x80) >> 6);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 249 to 279
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)input[33] << 9) |
			((uint32_t)input[34] << 1);
	output[8] = (double)(value >> 1);
}

static void unpack_9_31bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 9 values into output
	// Values are 31-bit signed
	// Skip 2 bits, read 279 bits of data.
	// Input must be at least 36 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 157 to 187
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13) |
			((uint32_t)input[22] << 5) |
			((uint32_t)(input[23] & 0xf0) >> 3);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 188 to 218
	value = ((uint32_t)(input[23] & 0x0f) << 28) |
			((uint32_t)input[24] << 20) |
			((uint32_t)input[25] << 12) |
			((uint32_t)input[26] << 4) |
			((uint32_t)(input[27] & 0xe0) >> 4);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 219 to 249
	value = ((uint32_t)(input[27] & 0x1f) << 27) |
			((uint32_t)input[28] << 19) |
			((uint32_t)input[29] << 11) |
			((uint32_t)input[30] << 3) |
			((uint32_t)(input[31] & 0xc0) >> 5);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 250 to 280
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)input[34] << 2) |
			((uint32_t)(input[35] & 0x80) >> 6);
	output[8] = (double)(value >> 1);
}

static void unpack_9_31bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 9 values into output
	// Values are 31-bit unsigned
	// Skip 2 bits, read 279 bits of data.
	// Input must be at least 36 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 157 to 187
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13) |
			((uint32_t)input[22] << 5) |
			((uint32_t)(input[23] & 0xf0) >> 3);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 188 to 218
	value = ((uint32_t)(input[23] & 0x0f) << 28) |
			((uint32_t)input[24] << 20) |
			((uint32_t)input[25] << 12) |
			((uint32_t)input[26] << 4) |
			((uint32_t)(input[27] & 0xe0) >> 4);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 219 to 249
	value = ((uint32_t)(input[27] & 0x1f) << 27) |
			((uint32_t)input[28] << 19) |
			((uint32_t)input[29] << 11) |
			((uint32_t)input[30] << 3) |
			((uint32_t)(input[31] & 0xc0) >> 5);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 250 to 280
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)input[34] << 2) |
			((uint32_t)(input[35] & 0x80) >> 6);
	output[8] = (double)(value >> 1);
}

static void unpack_9_31bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 9 values into output
	// Values are 31-bit signed
	// Skip 3 bits, read 279 bits of data.
	// Input must be at least 36 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 158 to 188
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)input[22] << 6) |
			((uint32_t)(input[23] & 0xf8) >> 2);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 189 to 219
	value = ((uint32_t)(input[23] & 0x07) << 29) |
			((uint32_t)input[24] << 21) |
			((uint32_t)input[25] << 13) |
			((uint32_t)input[26] << 5) |
			((uint32_t)(input[27] & 0xf0) >> 3);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 220 to 250
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)input[30] << 4) |
			((uint32_t)(input[31] & 0xe0) >> 4);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 251 to 281
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)input[33] << 11) |
			((uint32_t)input[34] << 3) |
			((uint32_t)(input[35] & 0xc0) >> 5);
	output[8] = (double)(value >> 1);
}

static void unpack_9_31bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 9 values into output
	// Values are 31-bit unsigned
	// Skip 3 bits, read 279 bits of data.
	// Input must be at least 36 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 158 to 188
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)input[22] << 6) |
			((uint32_t)(input[23] & 0xf8) >> 2);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 189 to 219
	value = ((uint32_t)(input[23] & 0x07) << 29) |
			((uint32_t)input[24] << 21) |
			((uint32_t)input[25] << 13) |
			((uint32_t)input[26] << 5) |
			((uint32_t)(input[27] & 0xf0) >> 3);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 220 to 250
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)input[30] << 4) |
			((uint32_t)(input[31] & 0xe0) >> 4);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 251 to 281
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)input[33] << 11) |
			((uint32_t)input[34] << 3) |
			((uint32_t)(input[35] & 0xc0) >> 5);
	output[8] = (double)(value >> 1);
}

static void unpack_9_31bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 9 values into output
	// Values are 31-bit signed
	// Skip 4 bits, read 279 bits of data.
	// Input must be at least 36 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 159 to 189
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)input[22] << 7) |
			((uint32_t)(input[23] & 0xfc) >> 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 190 to 220
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)input[26] << 6) |
			((uint32_t)(input[27] & 0xf8) >> 2);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 221 to 251
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5) |
			((uint32_t)(input[31] & 0xf0) >> 3);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 252 to 282
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)input[33] << 12) |
			((uint32_t)input[34] << 4) |
			((uint32_t)(input[35] & 0xe0) >> 4);
	output[8] = (double)(value >> 1);
}

static void unpack_9_31bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 9 values into output
	// Values are 31-bit unsigned
	// Skip 4 bits, read 279 bits of data.
	// Input must be at least 36 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 159 to 189
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)input[22] << 7) |
			((uint32_t)(input[23] & 0xfc) >> 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 190 to 220
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)input[26] << 6) |
			((uint32_t)(input[27] & 0xf8) >> 2);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 221 to 251
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5) |
			((uint32_t)(input[31] & 0xf0) >> 3);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 252 to 282
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)input[33] << 12) |
			((uint32_t)input[34] << 4) |
			((uint32_t)(input[35] & 0xe0) >> 4);
	output[8] = (double)(value >> 1);
}

static void unpack_9_31bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 9 values into output
	// Values are 31-bit signed
	// Skip 5 bits, read 279 bits of data.
	// Input must be at least 36 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 160 to 190
	value = ((uint32_t)input[20] << 24) |
			((uint32_t)input[21] << 16) |
			((uint32_t)input[22] << 8) |
			((uint32_t)(input[23] & 0xfe));
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 191 to 221
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)input[26] << 7) |
			((uint32_t)(input[27] & 0xfc) >> 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 222 to 252
	value = ((uint32_t)(input[27] & 0x03) << 30) |
			((uint32_t)input[28] << 22) |
			((uint32_t)input[29] << 14) |
			((uint32_t)input[30] << 6) |
			((uint32_t)(input[31] & 0xf8) >> 2);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 253 to 283
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13) |
			((uint32_t)input[34] << 5) |
			((uint32_t)(input[35] & 0xf0) >> 3);
	output[8] = (double)(value >> 1);
}

static void unpack_9_31bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 9 values into output
	// Values are 31-bit unsigned
	// Skip 5 bits, read 279 bits of data.
	// Input must be at least 36 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 160 to 190
	value = ((uint32_t)input[20] << 24) |
			((uint32_t)input[21] << 16) |
			((uint32_t)input[22] << 8) |
			((uint32_t)(input[23] & 0xfe));
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 191 to 221
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)input[26] << 7) |
			((uint32_t)(input[27] & 0xfc) >> 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 222 to 252
	value = ((uint32_t)(input[27] & 0x03) << 30) |
			((uint32_t)input[28] << 22) |
			((uint32_t)input[29] << 14) |
			((uint32_t)input[30] << 6) |
			((uint32_t)(input[31] & 0xf8) >> 2);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 253 to 283
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13) |
			((uint32_t)input[34] << 5) |
			((uint32_t)(input[35] & 0xf0) >> 3);
	output[8] = (double)(value >> 1);
}

static void unpack_9_31bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 9 values into output
	// Values are 31-bit signed
	// Skip 6 bits, read 279 bits of data.
	// Input must be at least 36 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 161 to 191
	value = ((uint32_t)(input[20] & 0x7f) << 25) |
			((uint32_t)input[21] << 17) |
			((uint32_t)input[22] << 9) |
			((uint32_t)input[23] << 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 192 to 222
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xfe));
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 223 to 253
	value = ((uint32_t)(input[27] & 0x01) << 31) |
			((uint32_t)input[28] << 23) |
			((uint32_t)input[29] << 15) |
			((uint32_t)input[30] << 7) |
			((uint32_t)(input[31] & 0xfc) >> 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 254 to 284
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)input[34] << 6) |
			((uint32_t)(input[35] & 0xf8) >> 2);
	output[8] = (double)(value >> 1);
}

static void unpack_9_31bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 9 values into output
	// Values are 31-bit unsigned
	// Skip 6 bits, read 279 bits of data.
	// Input must be at least 36 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 161 to 191
	value = ((uint32_t)(input[20] & 0x7f) << 25) |
			((uint32_t)input[21] << 17) |
			((uint32_t)input[22] << 9) |
			((uint32_t)input[23] << 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 192 to 222
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xfe));
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 223 to 253
	value = ((uint32_t)(input[27] & 0x01) << 31) |
			((uint32_t)input[28] << 23) |
			((uint32_t)input[29] << 15) |
			((uint32_t)input[30] << 7) |
			((uint32_t)(input[31] & 0xfc) >> 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 254 to 284
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)input[34] << 6) |
			((uint32_t)(input[35] & 0xf8) >> 2);
	output[8] = (double)(value >> 1);
}

static void unpack_9_31bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 9 values into output
	// Values are 31-bit signed
	// Skip 7 bits, read 279 bits of data.
	// Input must be at least 36 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 162 to 192
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)input[23] << 2) |
			((uint32_t)(input[24] & 0x80) >> 6);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 193 to 223
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)input[26] << 9) |
			((uint32_t)input[27] << 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 224 to 254
	value = ((uint32_t)input[28] << 24) |
			((uint32_t)input[29] << 16) |
			((uint32_t)input[30] << 8) |
			((uint32_t)(input[31] & 0xfe));
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 255 to 285
	value = ((uint32_t)(input[31] & 0x01) << 31) |
			((uint32_t)input[32] << 23) |
			((uint32_t)input[33] << 15) |
			((uint32_t)input[34] << 7) |
			((uint32_t)(input[35] & 0xfc) >> 1);
	output[8] = (double)(value >> 1);
}

static void unpack_9_31bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 9 values into output
	// Values are 31-bit unsigned
	// Skip 7 bits, read 279 bits of data.
	// Input must be at least 36 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 162 to 192
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)input[23] << 2) |
			((uint32_t)(input[24] & 0x80) >> 6);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 193 to 223
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)input[26] << 9) |
			((uint32_t)input[27] << 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 224 to 254
	value = ((uint32_t)input[28] << 24) |
			((uint32_t)input[29] << 16) |
			((uint32_t)input[30] << 8) |
			((uint32_t)(input[31] & 0xfe));
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 255 to 285
	value = ((uint32_t)(input[31] & 0x01) << 31) |
			((uint32_t)input[32] << 23) |
			((uint32_t)input[33] << 15) |
			((uint32_t)input[34] << 7) |
			((uint32_t)(input[35] & 0xfc) >> 1);
	output[8] = (double)(value >> 1);
}

static void unpack_10_31bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 31-bit signed
	// Skip 0 bits, read 310 bits of data.
	// Input must be at least 39 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 155 to 185
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)input[21] << 11) |
			((uint32_t)input[22] << 3) |
			((uint32_t)(input[23] & 0xc0) >> 5);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 186 to 216
	value = ((uint32_t)(input[23] & 0x3f) << 26) |
			((uint32_t)input[24] << 18) |
			((uint32_t)input[25] << 10) |
			((uint32_t)input[26] << 2) |
			((uint32_t)(input[27] & 0x80) >> 6);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 217 to 247
	value = ((uint32_t)(input[27] & 0x7f) << 25) |
			((uint32_t)input[28] << 17) |
			((uint32_t)input[29] << 9) |
			((uint32_t)input[30] << 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 248 to 278
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xfe));
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 279 to 309
	value = ((uint32_t)(input[34] & 0x01) << 31) |
			((uint32_t)input[35] << 23) |
			((uint32_t)input[36] << 15) |
			((uint32_t)input[37] << 7) |
			((uint32_t)(input[38] & 0xfc) >> 1);
	output[9] = (double)(value >> 1);
}

static void unpack_10_31bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 31-bit unsigned
	// Skip 0 bits, read 310 bits of data.
	// Input must be at least 39 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 155 to 185
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)input[21] << 11) |
			((uint32_t)input[22] << 3) |
			((uint32_t)(input[23] & 0xc0) >> 5);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 186 to 216
	value = ((uint32_t)(input[23] & 0x3f) << 26) |
			((uint32_t)input[24] << 18) |
			((uint32_t)input[25] << 10) |
			((uint32_t)input[26] << 2) |
			((uint32_t)(input[27] & 0x80) >> 6);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 217 to 247
	value = ((uint32_t)(input[27] & 0x7f) << 25) |
			((uint32_t)input[28] << 17) |
			((uint32_t)input[29] << 9) |
			((uint32_t)input[30] << 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 248 to 278
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xfe));
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 279 to 309
	value = ((uint32_t)(input[34] & 0x01) << 31) |
			((uint32_t)input[35] << 23) |
			((uint32_t)input[36] << 15) |
			((uint32_t)input[37] << 7) |
			((uint32_t)(input[38] & 0xfc) >> 1);
	output[9] = (double)(value >> 1);
}

static void unpack_10_31bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 31-bit signed
	// Skip 1 bits, read 310 bits of data.
	// Input must be at least 39 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 156 to 186
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)input[21] << 12) |
			((uint32_t)input[22] << 4) |
			((uint32_t)(input[23] & 0xe0) >> 4);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 187 to 217
	value = ((uint32_t)(input[23] & 0x1f) << 27) |
			((uint32_t)input[24] << 19) |
			((uint32_t)input[25] << 11) |
			((uint32_t)input[26] << 3) |
			((uint32_t)(input[27] & 0xc0) >> 5);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 218 to 248
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)input[30] << 2) |
			((uint32_t)(input[31] & 0x80) >> 6);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 249 to 279
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)input[33] << 9) |
			((uint32_t)input[34] << 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 280 to 310
	value = ((uint32_t)input[35] << 24) |
			((uint32_t)input[36] << 16) |
			((uint32_t)input[37] << 8) |
			((uint32_t)(input[38] & 0xfe));
	output[9] = (double)(value >> 1);
}

static void unpack_10_31bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 31-bit unsigned
	// Skip 1 bits, read 310 bits of data.
	// Input must be at least 39 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 156 to 186
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)input[21] << 12) |
			((uint32_t)input[22] << 4) |
			((uint32_t)(input[23] & 0xe0) >> 4);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 187 to 217
	value = ((uint32_t)(input[23] & 0x1f) << 27) |
			((uint32_t)input[24] << 19) |
			((uint32_t)input[25] << 11) |
			((uint32_t)input[26] << 3) |
			((uint32_t)(input[27] & 0xc0) >> 5);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 218 to 248
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)input[30] << 2) |
			((uint32_t)(input[31] & 0x80) >> 6);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 249 to 279
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)input[33] << 9) |
			((uint32_t)input[34] << 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 280 to 310
	value = ((uint32_t)input[35] << 24) |
			((uint32_t)input[36] << 16) |
			((uint32_t)input[37] << 8) |
			((uint32_t)(input[38] & 0xfe));
	output[9] = (double)(value >> 1);
}

static void unpack_10_31bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 31-bit signed
	// Skip 2 bits, read 310 bits of data.
	// Input must be at least 39 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 157 to 187
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13) |
			((uint32_t)input[22] << 5) |
			((uint32_t)(input[23] & 0xf0) >> 3);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 188 to 218
	value = ((uint32_t)(input[23] & 0x0f) << 28) |
			((uint32_t)input[24] << 20) |
			((uint32_t)input[25] << 12) |
			((uint32_t)input[26] << 4) |
			((uint32_t)(input[27] & 0xe0) >> 4);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 219 to 249
	value = ((uint32_t)(input[27] & 0x1f) << 27) |
			((uint32_t)input[28] << 19) |
			((uint32_t)input[29] << 11) |
			((uint32_t)input[30] << 3) |
			((uint32_t)(input[31] & 0xc0) >> 5);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 250 to 280
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)input[34] << 2) |
			((uint32_t)(input[35] & 0x80) >> 6);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 281 to 311
	value = ((uint32_t)(input[35] & 0x7f) << 25) |
			((uint32_t)input[36] << 17) |
			((uint32_t)input[37] << 9) |
			((uint32_t)input[38] << 1);
	output[9] = (double)(value >> 1);
}

static void unpack_10_31bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 31-bit unsigned
	// Skip 2 bits, read 310 bits of data.
	// Input must be at least 39 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 157 to 187
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13) |
			((uint32_t)input[22] << 5) |
			((uint32_t)(input[23] & 0xf0) >> 3);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 188 to 218
	value = ((uint32_t)(input[23] & 0x0f) << 28) |
			((uint32_t)input[24] << 20) |
			((uint32_t)input[25] << 12) |
			((uint32_t)input[26] << 4) |
			((uint32_t)(input[27] & 0xe0) >> 4);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 219 to 249
	value = ((uint32_t)(input[27] & 0x1f) << 27) |
			((uint32_t)input[28] << 19) |
			((uint32_t)input[29] << 11) |
			((uint32_t)input[30] << 3) |
			((uint32_t)(input[31] & 0xc0) >> 5);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 250 to 280
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)input[34] << 2) |
			((uint32_t)(input[35] & 0x80) >> 6);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 281 to 311
	value = ((uint32_t)(input[35] & 0x7f) << 25) |
			((uint32_t)input[36] << 17) |
			((uint32_t)input[37] << 9) |
			((uint32_t)input[38] << 1);
	output[9] = (double)(value >> 1);
}

static void unpack_10_31bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 31-bit signed
	// Skip 3 bits, read 310 bits of data.
	// Input must be at least 40 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 158 to 188
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)input[22] << 6) |
			((uint32_t)(input[23] & 0xf8) >> 2);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 189 to 219
	value = ((uint32_t)(input[23] & 0x07) << 29) |
			((uint32_t)input[24] << 21) |
			((uint32_t)input[25] << 13) |
			((uint32_t)input[26] << 5) |
			((uint32_t)(input[27] & 0xf0) >> 3);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 220 to 250
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)input[30] << 4) |
			((uint32_t)(input[31] & 0xe0) >> 4);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 251 to 281
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)input[33] << 11) |
			((uint32_t)input[34] << 3) |
			((uint32_t)(input[35] & 0xc0) >> 5);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 282 to 312
	value = ((uint32_t)(input[35] & 0x3f) << 26) |
			((uint32_t)input[36] << 18) |
			((uint32_t)input[37] << 10) |
			((uint32_t)input[38] << 2) |
			((uint32_t)(input[39] & 0x80) >> 6);
	output[9] = (double)(value >> 1);
}

static void unpack_10_31bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 31-bit unsigned
	// Skip 3 bits, read 310 bits of data.
	// Input must be at least 40 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 158 to 188
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)input[22] << 6) |
			((uint32_t)(input[23] & 0xf8) >> 2);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 189 to 219
	value = ((uint32_t)(input[23] & 0x07) << 29) |
			((uint32_t)input[24] << 21) |
			((uint32_t)input[25] << 13) |
			((uint32_t)input[26] << 5) |
			((uint32_t)(input[27] & 0xf0) >> 3);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 220 to 250
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)input[30] << 4) |
			((uint32_t)(input[31] & 0xe0) >> 4);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 251 to 281
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)input[33] << 11) |
			((uint32_t)input[34] << 3) |
			((uint32_t)(input[35] & 0xc0) >> 5);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 282 to 312
	value = ((uint32_t)(input[35] & 0x3f) << 26) |
			((uint32_t)input[36] << 18) |
			((uint32_t)input[37] << 10) |
			((uint32_t)input[38] << 2) |
			((uint32_t)(input[39] & 0x80) >> 6);
	output[9] = (double)(value >> 1);
}

static void unpack_10_31bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 31-bit signed
	// Skip 4 bits, read 310 bits of data.
	// Input must be at least 40 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 159 to 189
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)input[22] << 7) |
			((uint32_t)(input[23] & 0xfc) >> 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 190 to 220
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)input[26] << 6) |
			((uint32_t)(input[27] & 0xf8) >> 2);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 221 to 251
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5) |
			((uint32_t)(input[31] & 0xf0) >> 3);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 252 to 282
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)input[33] << 12) |
			((uint32_t)input[34] << 4) |
			((uint32_t)(input[35] & 0xe0) >> 4);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 283 to 313
	value = ((uint32_t)(input[35] & 0x1f) << 27) |
			((uint32_t)input[36] << 19) |
			((uint32_t)input[37] << 11) |
			((uint32_t)input[38] << 3) |
			((uint32_t)(input[39] & 0xc0) >> 5);
	output[9] = (double)(value >> 1);
}

static void unpack_10_31bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 31-bit unsigned
	// Skip 4 bits, read 310 bits of data.
	// Input must be at least 40 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 159 to 189
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)input[22] << 7) |
			((uint32_t)(input[23] & 0xfc) >> 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 190 to 220
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)input[26] << 6) |
			((uint32_t)(input[27] & 0xf8) >> 2);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 221 to 251
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5) |
			((uint32_t)(input[31] & 0xf0) >> 3);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 252 to 282
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)input[33] << 12) |
			((uint32_t)input[34] << 4) |
			((uint32_t)(input[35] & 0xe0) >> 4);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 283 to 313
	value = ((uint32_t)(input[35] & 0x1f) << 27) |
			((uint32_t)input[36] << 19) |
			((uint32_t)input[37] << 11) |
			((uint32_t)input[38] << 3) |
			((uint32_t)(input[39] & 0xc0) >> 5);
	output[9] = (double)(value >> 1);
}

static void unpack_10_31bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 31-bit signed
	// Skip 5 bits, read 310 bits of data.
	// Input must be at least 40 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 160 to 190
	value = ((uint32_t)input[20] << 24) |
			((uint32_t)input[21] << 16) |
			((uint32_t)input[22] << 8) |
			((uint32_t)(input[23] & 0xfe));
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 191 to 221
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)input[26] << 7) |
			((uint32_t)(input[27] & 0xfc) >> 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 222 to 252
	value = ((uint32_t)(input[27] & 0x03) << 30) |
			((uint32_t)input[28] << 22) |
			((uint32_t)input[29] << 14) |
			((uint32_t)input[30] << 6) |
			((uint32_t)(input[31] & 0xf8) >> 2);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 253 to 283
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13) |
			((uint32_t)input[34] << 5) |
			((uint32_t)(input[35] & 0xf0) >> 3);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 284 to 314
	value = ((uint32_t)(input[35] & 0x0f) << 28) |
			((uint32_t)input[36] << 20) |
			((uint32_t)input[37] << 12) |
			((uint32_t)input[38] << 4) |
			((uint32_t)(input[39] & 0xe0) >> 4);
	output[9] = (double)(value >> 1);
}

static void unpack_10_31bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 31-bit unsigned
	// Skip 5 bits, read 310 bits of data.
	// Input must be at least 40 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 160 to 190
	value = ((uint32_t)input[20] << 24) |
			((uint32_t)input[21] << 16) |
			((uint32_t)input[22] << 8) |
			((uint32_t)(input[23] & 0xfe));
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 191 to 221
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)input[26] << 7) |
			((uint32_t)(input[27] & 0xfc) >> 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 222 to 252
	value = ((uint32_t)(input[27] & 0x03) << 30) |
			((uint32_t)input[28] << 22) |
			((uint32_t)input[29] << 14) |
			((uint32_t)input[30] << 6) |
			((uint32_t)(input[31] & 0xf8) >> 2);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 253 to 283
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13) |
			((uint32_t)input[34] << 5) |
			((uint32_t)(input[35] & 0xf0) >> 3);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 284 to 314
	value = ((uint32_t)(input[35] & 0x0f) << 28) |
			((uint32_t)input[36] << 20) |
			((uint32_t)input[37] << 12) |
			((uint32_t)input[38] << 4) |
			((uint32_t)(input[39] & 0xe0) >> 4);
	output[9] = (double)(value >> 1);
}

static void unpack_10_31bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 31-bit signed
	// Skip 6 bits, read 310 bits of data.
	// Input must be at least 40 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 161 to 191
	value = ((uint32_t)(input[20] & 0x7f) << 25) |
			((uint32_t)input[21] << 17) |
			((uint32_t)input[22] << 9) |
			((uint32_t)input[23] << 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 192 to 222
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xfe));
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 223 to 253
	value = ((uint32_t)(input[27] & 0x01) << 31) |
			((uint32_t)input[28] << 23) |
			((uint32_t)input[29] << 15) |
			((uint32_t)input[30] << 7) |
			((uint32_t)(input[31] & 0xfc) >> 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 254 to 284
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)input[34] << 6) |
			((uint32_t)(input[35] & 0xf8) >> 2);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 285 to 315
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13) |
			((uint32_t)input[38] << 5) |
			((uint32_t)(input[39] & 0xf0) >> 3);
	output[9] = (double)(value >> 1);
}

static void unpack_10_31bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 31-bit unsigned
	// Skip 6 bits, read 310 bits of data.
	// Input must be at least 40 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 161 to 191
	value = ((uint32_t)(input[20] & 0x7f) << 25) |
			((uint32_t)input[21] << 17) |
			((uint32_t)input[22] << 9) |
			((uint32_t)input[23] << 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 192 to 222
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xfe));
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 223 to 253
	value = ((uint32_t)(input[27] & 0x01) << 31) |
			((uint32_t)input[28] << 23) |
			((uint32_t)input[29] << 15) |
			((uint32_t)input[30] << 7) |
			((uint32_t)(input[31] & 0xfc) >> 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 254 to 284
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)input[34] << 6) |
			((uint32_t)(input[35] & 0xf8) >> 2);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 285 to 315
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13) |
			((uint32_t)input[38] << 5) |
			((uint32_t)(input[39] & 0xf0) >> 3);
	output[9] = (double)(value >> 1);
}

static void unpack_10_31bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 31-bit signed
	// Skip 7 bits, read 310 bits of data.
	// Input must be at least 40 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 162 to 192
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)input[23] << 2) |
			((uint32_t)(input[24] & 0x80) >> 6);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 193 to 223
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)input[26] << 9) |
			((uint32_t)input[27] << 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 224 to 254
	value = ((uint32_t)input[28] << 24) |
			((uint32_t)input[29] << 16) |
			((uint32_t)input[30] << 8) |
			((uint32_t)(input[31] & 0xfe));
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 255 to 285
	value = ((uint32_t)(input[31] & 0x01) << 31) |
			((uint32_t)input[32] << 23) |
			((uint32_t)input[33] << 15) |
			((uint32_t)input[34] << 7) |
			((uint32_t)(input[35] & 0xfc) >> 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 286 to 316
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)input[38] << 6) |
			((uint32_t)(input[39] & 0xf8) >> 2);
	output[9] = (double)(value >> 1);
}

static void unpack_10_31bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 31-bit unsigned
	// Skip 7 bits, read 310 bits of data.
	// Input must be at least 40 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 162 to 192
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)input[23] << 2) |
			((uint32_t)(input[24] & 0x80) >> 6);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 193 to 223
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)input[26] << 9) |
			((uint32_t)input[27] << 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 224 to 254
	value = ((uint32_t)input[28] << 24) |
			((uint32_t)input[29] << 16) |
			((uint32_t)input[30] << 8) |
			((uint32_t)(input[31] & 0xfe));
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 255 to 285
	value = ((uint32_t)(input[31] & 0x01) << 31) |
			((uint32_t)input[32] << 23) |
			((uint32_t)input[33] << 15) |
			((uint32_t)input[34] << 7) |
			((uint32_t)(input[35] & 0xfc) >> 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 286 to 316
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)input[38] << 6) |
			((uint32_t)(input[39] & 0xf8) >> 2);
	output[9] = (double)(value >> 1);
}

static void unpack_11_31bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 31-bit signed
	// Skip 0 bits, read 341 bits of data.
	// Input must be at least 43 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 155 to 185
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)input[21] << 11) |
			((uint32_t)input[22] << 3) |
			((uint32_t)(input[23] & 0xc0) >> 5);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 186 to 216
	value = ((uint32_t)(input[23] & 0x3f) << 26) |
			((uint32_t)input[24] << 18) |
			((uint32_t)input[25] << 10) |
			((uint32_t)input[26] << 2) |
			((uint32_t)(input[27] & 0x80) >> 6);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 217 to 247
	value = ((uint32_t)(input[27] & 0x7f) << 25) |
			((uint32_t)input[28] << 17) |
			((uint32_t)input[29] << 9) |
			((uint32_t)input[30] << 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 248 to 278
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xfe));
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 279 to 309
	value = ((uint32_t)(input[34] & 0x01) << 31) |
			((uint32_t)input[35] << 23) |
			((uint32_t)input[36] << 15) |
			((uint32_t)input[37] << 7) |
			((uint32_t)(input[38] & 0xfc) >> 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 310 to 340
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)input[41] << 6) |
			((uint32_t)(input[42] & 0xf8) >> 2);
	output[10] = (double)(value >> 1);
}

static void unpack_11_31bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 31-bit unsigned
	// Skip 0 bits, read 341 bits of data.
	// Input must be at least 43 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 155 to 185
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)input[21] << 11) |
			((uint32_t)input[22] << 3) |
			((uint32_t)(input[23] & 0xc0) >> 5);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 186 to 216
	value = ((uint32_t)(input[23] & 0x3f) << 26) |
			((uint32_t)input[24] << 18) |
			((uint32_t)input[25] << 10) |
			((uint32_t)input[26] << 2) |
			((uint32_t)(input[27] & 0x80) >> 6);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 217 to 247
	value = ((uint32_t)(input[27] & 0x7f) << 25) |
			((uint32_t)input[28] << 17) |
			((uint32_t)input[29] << 9) |
			((uint32_t)input[30] << 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 248 to 278
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xfe));
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 279 to 309
	value = ((uint32_t)(input[34] & 0x01) << 31) |
			((uint32_t)input[35] << 23) |
			((uint32_t)input[36] << 15) |
			((uint32_t)input[37] << 7) |
			((uint32_t)(input[38] & 0xfc) >> 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 310 to 340
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)input[41] << 6) |
			((uint32_t)(input[42] & 0xf8) >> 2);
	output[10] = (double)(value >> 1);
}

static void unpack_11_31bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 31-bit signed
	// Skip 1 bits, read 341 bits of data.
	// Input must be at least 43 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 156 to 186
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)input[21] << 12) |
			((uint32_t)input[22] << 4) |
			((uint32_t)(input[23] & 0xe0) >> 4);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 187 to 217
	value = ((uint32_t)(input[23] & 0x1f) << 27) |
			((uint32_t)input[24] << 19) |
			((uint32_t)input[25] << 11) |
			((uint32_t)input[26] << 3) |
			((uint32_t)(input[27] & 0xc0) >> 5);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 218 to 248
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)input[30] << 2) |
			((uint32_t)(input[31] & 0x80) >> 6);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 249 to 279
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)input[33] << 9) |
			((uint32_t)input[34] << 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 280 to 310
	value = ((uint32_t)input[35] << 24) |
			((uint32_t)input[36] << 16) |
			((uint32_t)input[37] << 8) |
			((uint32_t)(input[38] & 0xfe));
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 311 to 341
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)input[41] << 7) |
			((uint32_t)(input[42] & 0xfc) >> 1);
	output[10] = (double)(value >> 1);
}

static void unpack_11_31bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 31-bit unsigned
	// Skip 1 bits, read 341 bits of data.
	// Input must be at least 43 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 156 to 186
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)input[21] << 12) |
			((uint32_t)input[22] << 4) |
			((uint32_t)(input[23] & 0xe0) >> 4);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 187 to 217
	value = ((uint32_t)(input[23] & 0x1f) << 27) |
			((uint32_t)input[24] << 19) |
			((uint32_t)input[25] << 11) |
			((uint32_t)input[26] << 3) |
			((uint32_t)(input[27] & 0xc0) >> 5);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 218 to 248
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)input[30] << 2) |
			((uint32_t)(input[31] & 0x80) >> 6);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 249 to 279
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)input[33] << 9) |
			((uint32_t)input[34] << 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 280 to 310
	value = ((uint32_t)input[35] << 24) |
			((uint32_t)input[36] << 16) |
			((uint32_t)input[37] << 8) |
			((uint32_t)(input[38] & 0xfe));
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 311 to 341
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)input[41] << 7) |
			((uint32_t)(input[42] & 0xfc) >> 1);
	output[10] = (double)(value >> 1);
}

static void unpack_11_31bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 31-bit signed
	// Skip 2 bits, read 341 bits of data.
	// Input must be at least 43 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 157 to 187
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13) |
			((uint32_t)input[22] << 5) |
			((uint32_t)(input[23] & 0xf0) >> 3);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 188 to 218
	value = ((uint32_t)(input[23] & 0x0f) << 28) |
			((uint32_t)input[24] << 20) |
			((uint32_t)input[25] << 12) |
			((uint32_t)input[26] << 4) |
			((uint32_t)(input[27] & 0xe0) >> 4);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 219 to 249
	value = ((uint32_t)(input[27] & 0x1f) << 27) |
			((uint32_t)input[28] << 19) |
			((uint32_t)input[29] << 11) |
			((uint32_t)input[30] << 3) |
			((uint32_t)(input[31] & 0xc0) >> 5);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 250 to 280
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)input[34] << 2) |
			((uint32_t)(input[35] & 0x80) >> 6);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 281 to 311
	value = ((uint32_t)(input[35] & 0x7f) << 25) |
			((uint32_t)input[36] << 17) |
			((uint32_t)input[37] << 9) |
			((uint32_t)input[38] << 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 312 to 342
	value = ((uint32_t)input[39] << 24) |
			((uint32_t)input[40] << 16) |
			((uint32_t)input[41] << 8) |
			((uint32_t)(input[42] & 0xfe));
	output[10] = (double)(value >> 1);
}

static void unpack_11_31bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 31-bit unsigned
	// Skip 2 bits, read 341 bits of data.
	// Input must be at least 43 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 157 to 187
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13) |
			((uint32_t)input[22] << 5) |
			((uint32_t)(input[23] & 0xf0) >> 3);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 188 to 218
	value = ((uint32_t)(input[23] & 0x0f) << 28) |
			((uint32_t)input[24] << 20) |
			((uint32_t)input[25] << 12) |
			((uint32_t)input[26] << 4) |
			((uint32_t)(input[27] & 0xe0) >> 4);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 219 to 249
	value = ((uint32_t)(input[27] & 0x1f) << 27) |
			((uint32_t)input[28] << 19) |
			((uint32_t)input[29] << 11) |
			((uint32_t)input[30] << 3) |
			((uint32_t)(input[31] & 0xc0) >> 5);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 250 to 280
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)input[34] << 2) |
			((uint32_t)(input[35] & 0x80) >> 6);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 281 to 311
	value = ((uint32_t)(input[35] & 0x7f) << 25) |
			((uint32_t)input[36] << 17) |
			((uint32_t)input[37] << 9) |
			((uint32_t)input[38] << 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 312 to 342
	value = ((uint32_t)input[39] << 24) |
			((uint32_t)input[40] << 16) |
			((uint32_t)input[41] << 8) |
			((uint32_t)(input[42] & 0xfe));
	output[10] = (double)(value >> 1);
}

static void unpack_11_31bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 31-bit signed
	// Skip 3 bits, read 341 bits of data.
	// Input must be at least 43 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 158 to 188
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)input[22] << 6) |
			((uint32_t)(input[23] & 0xf8) >> 2);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 189 to 219
	value = ((uint32_t)(input[23] & 0x07) << 29) |
			((uint32_t)input[24] << 21) |
			((uint32_t)input[25] << 13) |
			((uint32_t)input[26] << 5) |
			((uint32_t)(input[27] & 0xf0) >> 3);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 220 to 250
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)input[30] << 4) |
			((uint32_t)(input[31] & 0xe0) >> 4);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 251 to 281
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)input[33] << 11) |
			((uint32_t)input[34] << 3) |
			((uint32_t)(input[35] & 0xc0) >> 5);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 282 to 312
	value = ((uint32_t)(input[35] & 0x3f) << 26) |
			((uint32_t)input[36] << 18) |
			((uint32_t)input[37] << 10) |
			((uint32_t)input[38] << 2) |
			((uint32_t)(input[39] & 0x80) >> 6);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 313 to 343
	value = ((uint32_t)(input[39] & 0x7f) << 25) |
			((uint32_t)input[40] << 17) |
			((uint32_t)input[41] << 9) |
			((uint32_t)input[42] << 1);
	output[10] = (double)(value >> 1);
}

static void unpack_11_31bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 31-bit unsigned
	// Skip 3 bits, read 341 bits of data.
	// Input must be at least 43 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 158 to 188
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)input[22] << 6) |
			((uint32_t)(input[23] & 0xf8) >> 2);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 189 to 219
	value = ((uint32_t)(input[23] & 0x07) << 29) |
			((uint32_t)input[24] << 21) |
			((uint32_t)input[25] << 13) |
			((uint32_t)input[26] << 5) |
			((uint32_t)(input[27] & 0xf0) >> 3);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 220 to 250
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)input[30] << 4) |
			((uint32_t)(input[31] & 0xe0) >> 4);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 251 to 281
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)input[33] << 11) |
			((uint32_t)input[34] << 3) |
			((uint32_t)(input[35] & 0xc0) >> 5);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 282 to 312
	value = ((uint32_t)(input[35] & 0x3f) << 26) |
			((uint32_t)input[36] << 18) |
			((uint32_t)input[37] << 10) |
			((uint32_t)input[38] << 2) |
			((uint32_t)(input[39] & 0x80) >> 6);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 313 to 343
	value = ((uint32_t)(input[39] & 0x7f) << 25) |
			((uint32_t)input[40] << 17) |
			((uint32_t)input[41] << 9) |
			((uint32_t)input[42] << 1);
	output[10] = (double)(value >> 1);
}

static void unpack_11_31bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 31-bit signed
	// Skip 4 bits, read 341 bits of data.
	// Input must be at least 44 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 159 to 189
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)input[22] << 7) |
			((uint32_t)(input[23] & 0xfc) >> 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 190 to 220
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)input[26] << 6) |
			((uint32_t)(input[27] & 0xf8) >> 2);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 221 to 251
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5) |
			((uint32_t)(input[31] & 0xf0) >> 3);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 252 to 282
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)input[33] << 12) |
			((uint32_t)input[34] << 4) |
			((uint32_t)(input[35] & 0xe0) >> 4);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 283 to 313
	value = ((uint32_t)(input[35] & 0x1f) << 27) |
			((uint32_t)input[36] << 19) |
			((uint32_t)input[37] << 11) |
			((uint32_t)input[38] << 3) |
			((uint32_t)(input[39] & 0xc0) >> 5);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 314 to 344
	value = ((uint32_t)(input[39] & 0x3f) << 26) |
			((uint32_t)input[40] << 18) |
			((uint32_t)input[41] << 10) |
			((uint32_t)input[42] << 2) |
			((uint32_t)(input[43] & 0x80) >> 6);
	output[10] = (double)(value >> 1);
}

static void unpack_11_31bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 31-bit unsigned
	// Skip 4 bits, read 341 bits of data.
	// Input must be at least 44 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 159 to 189
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)input[22] << 7) |
			((uint32_t)(input[23] & 0xfc) >> 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 190 to 220
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)input[26] << 6) |
			((uint32_t)(input[27] & 0xf8) >> 2);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 221 to 251
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5) |
			((uint32_t)(input[31] & 0xf0) >> 3);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 252 to 282
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)input[33] << 12) |
			((uint32_t)input[34] << 4) |
			((uint32_t)(input[35] & 0xe0) >> 4);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 283 to 313
	value = ((uint32_t)(input[35] & 0x1f) << 27) |
			((uint32_t)input[36] << 19) |
			((uint32_t)input[37] << 11) |
			((uint32_t)input[38] << 3) |
			((uint32_t)(input[39] & 0xc0) >> 5);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 314 to 344
	value = ((uint32_t)(input[39] & 0x3f) << 26) |
			((uint32_t)input[40] << 18) |
			((uint32_t)input[41] << 10) |
			((uint32_t)input[42] << 2) |
			((uint32_t)(input[43] & 0x80) >> 6);
	output[10] = (double)(value >> 1);
}

static void unpack_11_31bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 31-bit signed
	// Skip 5 bits, read 341 bits of data.
	// Input must be at least 44 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 160 to 190
	value = ((uint32_t)input[20] << 24) |
			((uint32_t)input[21] << 16) |
			((uint32_t)input[22] << 8) |
			((uint32_t)(input[23] & 0xfe));
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 191 to 221
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)input[26] << 7) |
			((uint32_t)(input[27] & 0xfc) >> 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 222 to 252
	value = ((uint32_t)(input[27] & 0x03) << 30) |
			((uint32_t)input[28] << 22) |
			((uint32_t)input[29] << 14) |
			((uint32_t)input[30] << 6) |
			((uint32_t)(input[31] & 0xf8) >> 2);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 253 to 283
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13) |
			((uint32_t)input[34] << 5) |
			((uint32_t)(input[35] & 0xf0) >> 3);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 284 to 314
	value = ((uint32_t)(input[35] & 0x0f) << 28) |
			((uint32_t)input[36] << 20) |
			((uint32_t)input[37] << 12) |
			((uint32_t)input[38] << 4) |
			((uint32_t)(input[39] & 0xe0) >> 4);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 315 to 345
	value = ((uint32_t)(input[39] & 0x1f) << 27) |
			((uint32_t)input[40] << 19) |
			((uint32_t)input[41] << 11) |
			((uint32_t)input[42] << 3) |
			((uint32_t)(input[43] & 0xc0) >> 5);
	output[10] = (double)(value >> 1);
}

static void unpack_11_31bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 31-bit unsigned
	// Skip 5 bits, read 341 bits of data.
	// Input must be at least 44 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 160 to 190
	value = ((uint32_t)input[20] << 24) |
			((uint32_t)input[21] << 16) |
			((uint32_t)input[22] << 8) |
			((uint32_t)(input[23] & 0xfe));
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 191 to 221
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)input[26] << 7) |
			((uint32_t)(input[27] & 0xfc) >> 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 222 to 252
	value = ((uint32_t)(input[27] & 0x03) << 30) |
			((uint32_t)input[28] << 22) |
			((uint32_t)input[29] << 14) |
			((uint32_t)input[30] << 6) |
			((uint32_t)(input[31] & 0xf8) >> 2);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 253 to 283
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13) |
			((uint32_t)input[34] << 5) |
			((uint32_t)(input[35] & 0xf0) >> 3);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 284 to 314
	value = ((uint32_t)(input[35] & 0x0f) << 28) |
			((uint32_t)input[36] << 20) |
			((uint32_t)input[37] << 12) |
			((uint32_t)input[38] << 4) |
			((uint32_t)(input[39] & 0xe0) >> 4);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 315 to 345
	value = ((uint32_t)(input[39] & 0x1f) << 27) |
			((uint32_t)input[40] << 19) |
			((uint32_t)input[41] << 11) |
			((uint32_t)input[42] << 3) |
			((uint32_t)(input[43] & 0xc0) >> 5);
	output[10] = (double)(value >> 1);
}

static void unpack_11_31bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 31-bit signed
	// Skip 6 bits, read 341 bits of data.
	// Input must be at least 44 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 161 to 191
	value = ((uint32_t)(input[20] & 0x7f) << 25) |
			((uint32_t)input[21] << 17) |
			((uint32_t)input[22] << 9) |
			((uint32_t)input[23] << 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 192 to 222
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xfe));
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 223 to 253
	value = ((uint32_t)(input[27] & 0x01) << 31) |
			((uint32_t)input[28] << 23) |
			((uint32_t)input[29] << 15) |
			((uint32_t)input[30] << 7) |
			((uint32_t)(input[31] & 0xfc) >> 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 254 to 284
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)input[34] << 6) |
			((uint32_t)(input[35] & 0xf8) >> 2);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 285 to 315
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13) |
			((uint32_t)input[38] << 5) |
			((uint32_t)(input[39] & 0xf0) >> 3);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 316 to 346
	value = ((uint32_t)(input[39] & 0x0f) << 28) |
			((uint32_t)input[40] << 20) |
			((uint32_t)input[41] << 12) |
			((uint32_t)input[42] << 4) |
			((uint32_t)(input[43] & 0xe0) >> 4);
	output[10] = (double)(value >> 1);
}

static void unpack_11_31bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 31-bit unsigned
	// Skip 6 bits, read 341 bits of data.
	// Input must be at least 44 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 161 to 191
	value = ((uint32_t)(input[20] & 0x7f) << 25) |
			((uint32_t)input[21] << 17) |
			((uint32_t)input[22] << 9) |
			((uint32_t)input[23] << 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 192 to 222
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xfe));
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 223 to 253
	value = ((uint32_t)(input[27] & 0x01) << 31) |
			((uint32_t)input[28] << 23) |
			((uint32_t)input[29] << 15) |
			((uint32_t)input[30] << 7) |
			((uint32_t)(input[31] & 0xfc) >> 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 254 to 284
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)input[34] << 6) |
			((uint32_t)(input[35] & 0xf8) >> 2);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 285 to 315
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13) |
			((uint32_t)input[38] << 5) |
			((uint32_t)(input[39] & 0xf0) >> 3);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 316 to 346
	value = ((uint32_t)(input[39] & 0x0f) << 28) |
			((uint32_t)input[40] << 20) |
			((uint32_t)input[41] << 12) |
			((uint32_t)input[42] << 4) |
			((uint32_t)(input[43] & 0xe0) >> 4);
	output[10] = (double)(value >> 1);
}

static void unpack_11_31bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 31-bit signed
	// Skip 7 bits, read 341 bits of data.
	// Input must be at least 44 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 162 to 192
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)input[23] << 2) |
			((uint32_t)(input[24] & 0x80) >> 6);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 193 to 223
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)input[26] << 9) |
			((uint32_t)input[27] << 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 224 to 254
	value = ((uint32_t)input[28] << 24) |
			((uint32_t)input[29] << 16) |
			((uint32_t)input[30] << 8) |
			((uint32_t)(input[31] & 0xfe));
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 255 to 285
	value = ((uint32_t)(input[31] & 0x01) << 31) |
			((uint32_t)input[32] << 23) |
			((uint32_t)input[33] << 15) |
			((uint32_t)input[34] << 7) |
			((uint32_t)(input[35] & 0xfc) >> 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 286 to 316
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)input[38] << 6) |
			((uint32_t)(input[39] & 0xf8) >> 2);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 317 to 347
	value = ((uint32_t)(input[39] & 0x07) << 29) |
			((uint32_t)input[40] << 21) |
			((uint32_t)input[41] << 13) |
			((uint32_t)input[42] << 5) |
			((uint32_t)(input[43] & 0xf0) >> 3);
	output[10] = (double)(value >> 1);
}

static void unpack_11_31bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 31-bit unsigned
	// Skip 7 bits, read 341 bits of data.
	// Input must be at least 44 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 162 to 192
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)input[23] << 2) |
			((uint32_t)(input[24] & 0x80) >> 6);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 193 to 223
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)input[26] << 9) |
			((uint32_t)input[27] << 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 224 to 254
	value = ((uint32_t)input[28] << 24) |
			((uint32_t)input[29] << 16) |
			((uint32_t)input[30] << 8) |
			((uint32_t)(input[31] & 0xfe));
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 255 to 285
	value = ((uint32_t)(input[31] & 0x01) << 31) |
			((uint32_t)input[32] << 23) |
			((uint32_t)input[33] << 15) |
			((uint32_t)input[34] << 7) |
			((uint32_t)(input[35] & 0xfc) >> 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 286 to 316
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)input[38] << 6) |
			((uint32_t)(input[39] & 0xf8) >> 2);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 317 to 347
	value = ((uint32_t)(input[39] & 0x07) << 29) |
			((uint32_t)input[40] << 21) |
			((uint32_t)input[41] << 13) |
			((uint32_t)input[42] << 5) |
			((uint32_t)(input[43] & 0xf0) >> 3);
	output[10] = (double)(value >> 1);
}

static void unpack_12_31bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 31-bit signed
	// Skip 0 bits, read 372 bits of data.
	// Input must be at least 47 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 155 to 185
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)input[21] << 11) |
			((uint32_t)input[22] << 3) |
			((uint32_t)(input[23] & 0xc0) >> 5);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 186 to 216
	value = ((uint32_t)(input[23] & 0x3f) << 26) |
			((uint32_t)input[24] << 18) |
			((uint32_t)input[25] << 10) |
			((uint32_t)input[26] << 2) |
			((uint32_t)(input[27] & 0x80) >> 6);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 217 to 247
	value = ((uint32_t)(input[27] & 0x7f) << 25) |
			((uint32_t)input[28] << 17) |
			((uint32_t)input[29] << 9) |
			((uint32_t)input[30] << 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 248 to 278
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xfe));
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 279 to 309
	value = ((uint32_t)(input[34] & 0x01) << 31) |
			((uint32_t)input[35] << 23) |
			((uint32_t)input[36] << 15) |
			((uint32_t)input[37] << 7) |
			((uint32_t)(input[38] & 0xfc) >> 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 310 to 340
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)input[41] << 6) |
			((uint32_t)(input[42] & 0xf8) >> 2);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 341 to 371
	value = ((uint32_t)(input[42] & 0x07) << 29) |
			((uint32_t)input[43] << 21) |
			((uint32_t)input[44] << 13) |
			((uint32_t)input[45] << 5) |
			((uint32_t)(input[46] & 0xf0) >> 3);
	output[11] = (double)(value >> 1);
}

static void unpack_12_31bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 31-bit unsigned
	// Skip 0 bits, read 372 bits of data.
	// Input must be at least 47 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 155 to 185
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)input[21] << 11) |
			((uint32_t)input[22] << 3) |
			((uint32_t)(input[23] & 0xc0) >> 5);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 186 to 216
	value = ((uint32_t)(input[23] & 0x3f) << 26) |
			((uint32_t)input[24] << 18) |
			((uint32_t)input[25] << 10) |
			((uint32_t)input[26] << 2) |
			((uint32_t)(input[27] & 0x80) >> 6);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 217 to 247
	value = ((uint32_t)(input[27] & 0x7f) << 25) |
			((uint32_t)input[28] << 17) |
			((uint32_t)input[29] << 9) |
			((uint32_t)input[30] << 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 248 to 278
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xfe));
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 279 to 309
	value = ((uint32_t)(input[34] & 0x01) << 31) |
			((uint32_t)input[35] << 23) |
			((uint32_t)input[36] << 15) |
			((uint32_t)input[37] << 7) |
			((uint32_t)(input[38] & 0xfc) >> 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 310 to 340
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)input[41] << 6) |
			((uint32_t)(input[42] & 0xf8) >> 2);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 341 to 371
	value = ((uint32_t)(input[42] & 0x07) << 29) |
			((uint32_t)input[43] << 21) |
			((uint32_t)input[44] << 13) |
			((uint32_t)input[45] << 5) |
			((uint32_t)(input[46] & 0xf0) >> 3);
	output[11] = (double)(value >> 1);
}

static void unpack_12_31bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 31-bit signed
	// Skip 1 bits, read 372 bits of data.
	// Input must be at least 47 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 156 to 186
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)input[21] << 12) |
			((uint32_t)input[22] << 4) |
			((uint32_t)(input[23] & 0xe0) >> 4);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 187 to 217
	value = ((uint32_t)(input[23] & 0x1f) << 27) |
			((uint32_t)input[24] << 19) |
			((uint32_t)input[25] << 11) |
			((uint32_t)input[26] << 3) |
			((uint32_t)(input[27] & 0xc0) >> 5);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 218 to 248
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)input[30] << 2) |
			((uint32_t)(input[31] & 0x80) >> 6);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 249 to 279
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)input[33] << 9) |
			((uint32_t)input[34] << 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 280 to 310
	value = ((uint32_t)input[35] << 24) |
			((uint32_t)input[36] << 16) |
			((uint32_t)input[37] << 8) |
			((uint32_t)(input[38] & 0xfe));
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 311 to 341
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)input[41] << 7) |
			((uint32_t)(input[42] & 0xfc) >> 1);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 342 to 372
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)input[45] << 6) |
			((uint32_t)(input[46] & 0xf8) >> 2);
	output[11] = (double)(value >> 1);
}

static void unpack_12_31bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 31-bit unsigned
	// Skip 1 bits, read 372 bits of data.
	// Input must be at least 47 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 156 to 186
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)input[21] << 12) |
			((uint32_t)input[22] << 4) |
			((uint32_t)(input[23] & 0xe0) >> 4);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 187 to 217
	value = ((uint32_t)(input[23] & 0x1f) << 27) |
			((uint32_t)input[24] << 19) |
			((uint32_t)input[25] << 11) |
			((uint32_t)input[26] << 3) |
			((uint32_t)(input[27] & 0xc0) >> 5);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 218 to 248
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)input[30] << 2) |
			((uint32_t)(input[31] & 0x80) >> 6);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 249 to 279
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)input[33] << 9) |
			((uint32_t)input[34] << 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 280 to 310
	value = ((uint32_t)input[35] << 24) |
			((uint32_t)input[36] << 16) |
			((uint32_t)input[37] << 8) |
			((uint32_t)(input[38] & 0xfe));
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 311 to 341
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)input[41] << 7) |
			((uint32_t)(input[42] & 0xfc) >> 1);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 342 to 372
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)input[45] << 6) |
			((uint32_t)(input[46] & 0xf8) >> 2);
	output[11] = (double)(value >> 1);
}

static void unpack_12_31bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 31-bit signed
	// Skip 2 bits, read 372 bits of data.
	// Input must be at least 47 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 157 to 187
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13) |
			((uint32_t)input[22] << 5) |
			((uint32_t)(input[23] & 0xf0) >> 3);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 188 to 218
	value = ((uint32_t)(input[23] & 0x0f) << 28) |
			((uint32_t)input[24] << 20) |
			((uint32_t)input[25] << 12) |
			((uint32_t)input[26] << 4) |
			((uint32_t)(input[27] & 0xe0) >> 4);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 219 to 249
	value = ((uint32_t)(input[27] & 0x1f) << 27) |
			((uint32_t)input[28] << 19) |
			((uint32_t)input[29] << 11) |
			((uint32_t)input[30] << 3) |
			((uint32_t)(input[31] & 0xc0) >> 5);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 250 to 280
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)input[34] << 2) |
			((uint32_t)(input[35] & 0x80) >> 6);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 281 to 311
	value = ((uint32_t)(input[35] & 0x7f) << 25) |
			((uint32_t)input[36] << 17) |
			((uint32_t)input[37] << 9) |
			((uint32_t)input[38] << 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 312 to 342
	value = ((uint32_t)input[39] << 24) |
			((uint32_t)input[40] << 16) |
			((uint32_t)input[41] << 8) |
			((uint32_t)(input[42] & 0xfe));
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 343 to 373
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)input[45] << 7) |
			((uint32_t)(input[46] & 0xfc) >> 1);
	output[11] = (double)(value >> 1);
}

static void unpack_12_31bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 31-bit unsigned
	// Skip 2 bits, read 372 bits of data.
	// Input must be at least 47 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 157 to 187
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13) |
			((uint32_t)input[22] << 5) |
			((uint32_t)(input[23] & 0xf0) >> 3);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 188 to 218
	value = ((uint32_t)(input[23] & 0x0f) << 28) |
			((uint32_t)input[24] << 20) |
			((uint32_t)input[25] << 12) |
			((uint32_t)input[26] << 4) |
			((uint32_t)(input[27] & 0xe0) >> 4);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 219 to 249
	value = ((uint32_t)(input[27] & 0x1f) << 27) |
			((uint32_t)input[28] << 19) |
			((uint32_t)input[29] << 11) |
			((uint32_t)input[30] << 3) |
			((uint32_t)(input[31] & 0xc0) >> 5);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 250 to 280
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)input[34] << 2) |
			((uint32_t)(input[35] & 0x80) >> 6);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 281 to 311
	value = ((uint32_t)(input[35] & 0x7f) << 25) |
			((uint32_t)input[36] << 17) |
			((uint32_t)input[37] << 9) |
			((uint32_t)input[38] << 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 312 to 342
	value = ((uint32_t)input[39] << 24) |
			((uint32_t)input[40] << 16) |
			((uint32_t)input[41] << 8) |
			((uint32_t)(input[42] & 0xfe));
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 343 to 373
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)input[45] << 7) |
			((uint32_t)(input[46] & 0xfc) >> 1);
	output[11] = (double)(value >> 1);
}

static void unpack_12_31bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 31-bit signed
	// Skip 3 bits, read 372 bits of data.
	// Input must be at least 47 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 158 to 188
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)input[22] << 6) |
			((uint32_t)(input[23] & 0xf8) >> 2);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 189 to 219
	value = ((uint32_t)(input[23] & 0x07) << 29) |
			((uint32_t)input[24] << 21) |
			((uint32_t)input[25] << 13) |
			((uint32_t)input[26] << 5) |
			((uint32_t)(input[27] & 0xf0) >> 3);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 220 to 250
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)input[30] << 4) |
			((uint32_t)(input[31] & 0xe0) >> 4);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 251 to 281
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)input[33] << 11) |
			((uint32_t)input[34] << 3) |
			((uint32_t)(input[35] & 0xc0) >> 5);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 282 to 312
	value = ((uint32_t)(input[35] & 0x3f) << 26) |
			((uint32_t)input[36] << 18) |
			((uint32_t)input[37] << 10) |
			((uint32_t)input[38] << 2) |
			((uint32_t)(input[39] & 0x80) >> 6);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 313 to 343
	value = ((uint32_t)(input[39] & 0x7f) << 25) |
			((uint32_t)input[40] << 17) |
			((uint32_t)input[41] << 9) |
			((uint32_t)input[42] << 1);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 344 to 374
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)input[45] << 8) |
			((uint32_t)(input[46] & 0xfe));
	output[11] = (double)(value >> 1);
}

static void unpack_12_31bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 31-bit unsigned
	// Skip 3 bits, read 372 bits of data.
	// Input must be at least 47 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 158 to 188
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)input[22] << 6) |
			((uint32_t)(input[23] & 0xf8) >> 2);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 189 to 219
	value = ((uint32_t)(input[23] & 0x07) << 29) |
			((uint32_t)input[24] << 21) |
			((uint32_t)input[25] << 13) |
			((uint32_t)input[26] << 5) |
			((uint32_t)(input[27] & 0xf0) >> 3);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 220 to 250
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)input[30] << 4) |
			((uint32_t)(input[31] & 0xe0) >> 4);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 251 to 281
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)input[33] << 11) |
			((uint32_t)input[34] << 3) |
			((uint32_t)(input[35] & 0xc0) >> 5);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 282 to 312
	value = ((uint32_t)(input[35] & 0x3f) << 26) |
			((uint32_t)input[36] << 18) |
			((uint32_t)input[37] << 10) |
			((uint32_t)input[38] << 2) |
			((uint32_t)(input[39] & 0x80) >> 6);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 313 to 343
	value = ((uint32_t)(input[39] & 0x7f) << 25) |
			((uint32_t)input[40] << 17) |
			((uint32_t)input[41] << 9) |
			((uint32_t)input[42] << 1);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 344 to 374
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)input[45] << 8) |
			((uint32_t)(input[46] & 0xfe));
	output[11] = (double)(value >> 1);
}

static void unpack_12_31bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 31-bit signed
	// Skip 4 bits, read 372 bits of data.
	// Input must be at least 47 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 159 to 189
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)input[22] << 7) |
			((uint32_t)(input[23] & 0xfc) >> 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 190 to 220
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)input[26] << 6) |
			((uint32_t)(input[27] & 0xf8) >> 2);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 221 to 251
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5) |
			((uint32_t)(input[31] & 0xf0) >> 3);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 252 to 282
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)input[33] << 12) |
			((uint32_t)input[34] << 4) |
			((uint32_t)(input[35] & 0xe0) >> 4);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 283 to 313
	value = ((uint32_t)(input[35] & 0x1f) << 27) |
			((uint32_t)input[36] << 19) |
			((uint32_t)input[37] << 11) |
			((uint32_t)input[38] << 3) |
			((uint32_t)(input[39] & 0xc0) >> 5);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 314 to 344
	value = ((uint32_t)(input[39] & 0x3f) << 26) |
			((uint32_t)input[40] << 18) |
			((uint32_t)input[41] << 10) |
			((uint32_t)input[42] << 2) |
			((uint32_t)(input[43] & 0x80) >> 6);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 345 to 375
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)input[45] << 9) |
			((uint32_t)input[46] << 1);
	output[11] = (double)(value >> 1);
}

static void unpack_12_31bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 31-bit unsigned
	// Skip 4 bits, read 372 bits of data.
	// Input must be at least 47 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 159 to 189
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)input[22] << 7) |
			((uint32_t)(input[23] & 0xfc) >> 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 190 to 220
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)input[26] << 6) |
			((uint32_t)(input[27] & 0xf8) >> 2);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 221 to 251
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5) |
			((uint32_t)(input[31] & 0xf0) >> 3);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 252 to 282
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)input[33] << 12) |
			((uint32_t)input[34] << 4) |
			((uint32_t)(input[35] & 0xe0) >> 4);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 283 to 313
	value = ((uint32_t)(input[35] & 0x1f) << 27) |
			((uint32_t)input[36] << 19) |
			((uint32_t)input[37] << 11) |
			((uint32_t)input[38] << 3) |
			((uint32_t)(input[39] & 0xc0) >> 5);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 314 to 344
	value = ((uint32_t)(input[39] & 0x3f) << 26) |
			((uint32_t)input[40] << 18) |
			((uint32_t)input[41] << 10) |
			((uint32_t)input[42] << 2) |
			((uint32_t)(input[43] & 0x80) >> 6);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 345 to 375
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)input[45] << 9) |
			((uint32_t)input[46] << 1);
	output[11] = (double)(value >> 1);
}

static void unpack_12_31bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 31-bit signed
	// Skip 5 bits, read 372 bits of data.
	// Input must be at least 48 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 160 to 190
	value = ((uint32_t)input[20] << 24) |
			((uint32_t)input[21] << 16) |
			((uint32_t)input[22] << 8) |
			((uint32_t)(input[23] & 0xfe));
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 191 to 221
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)input[26] << 7) |
			((uint32_t)(input[27] & 0xfc) >> 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 222 to 252
	value = ((uint32_t)(input[27] & 0x03) << 30) |
			((uint32_t)input[28] << 22) |
			((uint32_t)input[29] << 14) |
			((uint32_t)input[30] << 6) |
			((uint32_t)(input[31] & 0xf8) >> 2);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 253 to 283
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13) |
			((uint32_t)input[34] << 5) |
			((uint32_t)(input[35] & 0xf0) >> 3);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 284 to 314
	value = ((uint32_t)(input[35] & 0x0f) << 28) |
			((uint32_t)input[36] << 20) |
			((uint32_t)input[37] << 12) |
			((uint32_t)input[38] << 4) |
			((uint32_t)(input[39] & 0xe0) >> 4);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 315 to 345
	value = ((uint32_t)(input[39] & 0x1f) << 27) |
			((uint32_t)input[40] << 19) |
			((uint32_t)input[41] << 11) |
			((uint32_t)input[42] << 3) |
			((uint32_t)(input[43] & 0xc0) >> 5);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 346 to 376
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)input[45] << 10) |
			((uint32_t)input[46] << 2) |
			((uint32_t)(input[47] & 0x80) >> 6);
	output[11] = (double)(value >> 1);
}

static void unpack_12_31bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 31-bit unsigned
	// Skip 5 bits, read 372 bits of data.
	// Input must be at least 48 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 160 to 190
	value = ((uint32_t)input[20] << 24) |
			((uint32_t)input[21] << 16) |
			((uint32_t)input[22] << 8) |
			((uint32_t)(input[23] & 0xfe));
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 191 to 221
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)input[26] << 7) |
			((uint32_t)(input[27] & 0xfc) >> 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 222 to 252
	value = ((uint32_t)(input[27] & 0x03) << 30) |
			((uint32_t)input[28] << 22) |
			((uint32_t)input[29] << 14) |
			((uint32_t)input[30] << 6) |
			((uint32_t)(input[31] & 0xf8) >> 2);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 253 to 283
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13) |
			((uint32_t)input[34] << 5) |
			((uint32_t)(input[35] & 0xf0) >> 3);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 284 to 314
	value = ((uint32_t)(input[35] & 0x0f) << 28) |
			((uint32_t)input[36] << 20) |
			((uint32_t)input[37] << 12) |
			((uint32_t)input[38] << 4) |
			((uint32_t)(input[39] & 0xe0) >> 4);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 315 to 345
	value = ((uint32_t)(input[39] & 0x1f) << 27) |
			((uint32_t)input[40] << 19) |
			((uint32_t)input[41] << 11) |
			((uint32_t)input[42] << 3) |
			((uint32_t)(input[43] & 0xc0) >> 5);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 346 to 376
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)input[45] << 10) |
			((uint32_t)input[46] << 2) |
			((uint32_t)(input[47] & 0x80) >> 6);
	output[11] = (double)(value >> 1);
}

static void unpack_12_31bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 31-bit signed
	// Skip 6 bits, read 372 bits of data.
	// Input must be at least 48 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 161 to 191
	value = ((uint32_t)(input[20] & 0x7f) << 25) |
			((uint32_t)input[21] << 17) |
			((uint32_t)input[22] << 9) |
			((uint32_t)input[23] << 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 192 to 222
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xfe));
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 223 to 253
	value = ((uint32_t)(input[27] & 0x01) << 31) |
			((uint32_t)input[28] << 23) |
			((uint32_t)input[29] << 15) |
			((uint32_t)input[30] << 7) |
			((uint32_t)(input[31] & 0xfc) >> 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 254 to 284
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)input[34] << 6) |
			((uint32_t)(input[35] & 0xf8) >> 2);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 285 to 315
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13) |
			((uint32_t)input[38] << 5) |
			((uint32_t)(input[39] & 0xf0) >> 3);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 316 to 346
	value = ((uint32_t)(input[39] & 0x0f) << 28) |
			((uint32_t)input[40] << 20) |
			((uint32_t)input[41] << 12) |
			((uint32_t)input[42] << 4) |
			((uint32_t)(input[43] & 0xe0) >> 4);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 347 to 377
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)input[45] << 11) |
			((uint32_t)input[46] << 3) |
			((uint32_t)(input[47] & 0xc0) >> 5);
	output[11] = (double)(value >> 1);
}

static void unpack_12_31bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 31-bit unsigned
	// Skip 6 bits, read 372 bits of data.
	// Input must be at least 48 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 161 to 191
	value = ((uint32_t)(input[20] & 0x7f) << 25) |
			((uint32_t)input[21] << 17) |
			((uint32_t)input[22] << 9) |
			((uint32_t)input[23] << 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 192 to 222
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xfe));
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 223 to 253
	value = ((uint32_t)(input[27] & 0x01) << 31) |
			((uint32_t)input[28] << 23) |
			((uint32_t)input[29] << 15) |
			((uint32_t)input[30] << 7) |
			((uint32_t)(input[31] & 0xfc) >> 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 254 to 284
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)input[34] << 6) |
			((uint32_t)(input[35] & 0xf8) >> 2);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 285 to 315
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13) |
			((uint32_t)input[38] << 5) |
			((uint32_t)(input[39] & 0xf0) >> 3);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 316 to 346
	value = ((uint32_t)(input[39] & 0x0f) << 28) |
			((uint32_t)input[40] << 20) |
			((uint32_t)input[41] << 12) |
			((uint32_t)input[42] << 4) |
			((uint32_t)(input[43] & 0xe0) >> 4);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 347 to 377
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)input[45] << 11) |
			((uint32_t)input[46] << 3) |
			((uint32_t)(input[47] & 0xc0) >> 5);
	output[11] = (double)(value >> 1);
}

static void unpack_12_31bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 31-bit signed
	// Skip 7 bits, read 372 bits of data.
	// Input must be at least 48 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 162 to 192
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)input[23] << 2) |
			((uint32_t)(input[24] & 0x80) >> 6);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 193 to 223
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)input[26] << 9) |
			((uint32_t)input[27] << 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 224 to 254
	value = ((uint32_t)input[28] << 24) |
			((uint32_t)input[29] << 16) |
			((uint32_t)input[30] << 8) |
			((uint32_t)(input[31] & 0xfe));
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 255 to 285
	value = ((uint32_t)(input[31] & 0x01) << 31) |
			((uint32_t)input[32] << 23) |
			((uint32_t)input[33] << 15) |
			((uint32_t)input[34] << 7) |
			((uint32_t)(input[35] & 0xfc) >> 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 286 to 316
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)input[38] << 6) |
			((uint32_t)(input[39] & 0xf8) >> 2);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 317 to 347
	value = ((uint32_t)(input[39] & 0x07) << 29) |
			((uint32_t)input[40] << 21) |
			((uint32_t)input[41] << 13) |
			((uint32_t)input[42] << 5) |
			((uint32_t)(input[43] & 0xf0) >> 3);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 348 to 378
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)input[45] << 12) |
			((uint32_t)input[46] << 4) |
			((uint32_t)(input[47] & 0xe0) >> 4);
	output[11] = (double)(value >> 1);
}

static void unpack_12_31bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 31-bit unsigned
	// Skip 7 bits, read 372 bits of data.
	// Input must be at least 48 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 162 to 192
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)input[23] << 2) |
			((uint32_t)(input[24] & 0x80) >> 6);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 193 to 223
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)input[26] << 9) |
			((uint32_t)input[27] << 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 224 to 254
	value = ((uint32_t)input[28] << 24) |
			((uint32_t)input[29] << 16) |
			((uint32_t)input[30] << 8) |
			((uint32_t)(input[31] & 0xfe));
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 255 to 285
	value = ((uint32_t)(input[31] & 0x01) << 31) |
			((uint32_t)input[32] << 23) |
			((uint32_t)input[33] << 15) |
			((uint32_t)input[34] << 7) |
			((uint32_t)(input[35] & 0xfc) >> 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 286 to 316
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)input[38] << 6) |
			((uint32_t)(input[39] & 0xf8) >> 2);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 317 to 347
	value = ((uint32_t)(input[39] & 0x07) << 29) |
			((uint32_t)input[40] << 21) |
			((uint32_t)input[41] << 13) |
			((uint32_t)input[42] << 5) |
			((uint32_t)(input[43] & 0xf0) >> 3);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 348 to 378
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)input[45] << 12) |
			((uint32_t)input[46] << 4) |
			((uint32_t)(input[47] & 0xe0) >> 4);
	output[11] = (double)(value >> 1);
}

static void unpack_13_31bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 31-bit signed
	// Skip 0 bits, read 403 bits of data.
	// Input must be at least 51 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 155 to 185
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)input[21] << 11) |
			((uint32_t)input[22] << 3) |
			((uint32_t)(input[23] & 0xc0) >> 5);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 186 to 216
	value = ((uint32_t)(input[23] & 0x3f) << 26) |
			((uint32_t)input[24] << 18) |
			((uint32_t)input[25] << 10) |
			((uint32_t)input[26] << 2) |
			((uint32_t)(input[27] & 0x80) >> 6);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 217 to 247
	value = ((uint32_t)(input[27] & 0x7f) << 25) |
			((uint32_t)input[28] << 17) |
			((uint32_t)input[29] << 9) |
			((uint32_t)input[30] << 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 248 to 278
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xfe));
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 279 to 309
	value = ((uint32_t)(input[34] & 0x01) << 31) |
			((uint32_t)input[35] << 23) |
			((uint32_t)input[36] << 15) |
			((uint32_t)input[37] << 7) |
			((uint32_t)(input[38] & 0xfc) >> 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 310 to 340
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)input[41] << 6) |
			((uint32_t)(input[42] & 0xf8) >> 2);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 341 to 371
	value = ((uint32_t)(input[42] & 0x07) << 29) |
			((uint32_t)input[43] << 21) |
			((uint32_t)input[44] << 13) |
			((uint32_t)input[45] << 5) |
			((uint32_t)(input[46] & 0xf0) >> 3);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 372 to 402
	value = ((uint32_t)(input[46] & 0x0f) << 28) |
			((uint32_t)input[47] << 20) |
			((uint32_t)input[48] << 12) |
			((uint32_t)input[49] << 4) |
			((uint32_t)(input[50] & 0xe0) >> 4);
	output[12] = (double)(value >> 1);
}

static void unpack_13_31bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 31-bit unsigned
	// Skip 0 bits, read 403 bits of data.
	// Input must be at least 51 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 155 to 185
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)input[21] << 11) |
			((uint32_t)input[22] << 3) |
			((uint32_t)(input[23] & 0xc0) >> 5);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 186 to 216
	value = ((uint32_t)(input[23] & 0x3f) << 26) |
			((uint32_t)input[24] << 18) |
			((uint32_t)input[25] << 10) |
			((uint32_t)input[26] << 2) |
			((uint32_t)(input[27] & 0x80) >> 6);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 217 to 247
	value = ((uint32_t)(input[27] & 0x7f) << 25) |
			((uint32_t)input[28] << 17) |
			((uint32_t)input[29] << 9) |
			((uint32_t)input[30] << 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 248 to 278
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xfe));
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 279 to 309
	value = ((uint32_t)(input[34] & 0x01) << 31) |
			((uint32_t)input[35] << 23) |
			((uint32_t)input[36] << 15) |
			((uint32_t)input[37] << 7) |
			((uint32_t)(input[38] & 0xfc) >> 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 310 to 340
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)input[41] << 6) |
			((uint32_t)(input[42] & 0xf8) >> 2);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 341 to 371
	value = ((uint32_t)(input[42] & 0x07) << 29) |
			((uint32_t)input[43] << 21) |
			((uint32_t)input[44] << 13) |
			((uint32_t)input[45] << 5) |
			((uint32_t)(input[46] & 0xf0) >> 3);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 372 to 402
	value = ((uint32_t)(input[46] & 0x0f) << 28) |
			((uint32_t)input[47] << 20) |
			((uint32_t)input[48] << 12) |
			((uint32_t)input[49] << 4) |
			((uint32_t)(input[50] & 0xe0) >> 4);
	output[12] = (double)(value >> 1);
}

static void unpack_13_31bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 31-bit signed
	// Skip 1 bits, read 403 bits of data.
	// Input must be at least 51 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 156 to 186
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)input[21] << 12) |
			((uint32_t)input[22] << 4) |
			((uint32_t)(input[23] & 0xe0) >> 4);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 187 to 217
	value = ((uint32_t)(input[23] & 0x1f) << 27) |
			((uint32_t)input[24] << 19) |
			((uint32_t)input[25] << 11) |
			((uint32_t)input[26] << 3) |
			((uint32_t)(input[27] & 0xc0) >> 5);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 218 to 248
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)input[30] << 2) |
			((uint32_t)(input[31] & 0x80) >> 6);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 249 to 279
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)input[33] << 9) |
			((uint32_t)input[34] << 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 280 to 310
	value = ((uint32_t)input[35] << 24) |
			((uint32_t)input[36] << 16) |
			((uint32_t)input[37] << 8) |
			((uint32_t)(input[38] & 0xfe));
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 311 to 341
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)input[41] << 7) |
			((uint32_t)(input[42] & 0xfc) >> 1);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 342 to 372
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)input[45] << 6) |
			((uint32_t)(input[46] & 0xf8) >> 2);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 373 to 403
	value = ((uint32_t)(input[46] & 0x07) << 29) |
			((uint32_t)input[47] << 21) |
			((uint32_t)input[48] << 13) |
			((uint32_t)input[49] << 5) |
			((uint32_t)(input[50] & 0xf0) >> 3);
	output[12] = (double)(value >> 1);
}

static void unpack_13_31bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 31-bit unsigned
	// Skip 1 bits, read 403 bits of data.
	// Input must be at least 51 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 156 to 186
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)input[21] << 12) |
			((uint32_t)input[22] << 4) |
			((uint32_t)(input[23] & 0xe0) >> 4);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 187 to 217
	value = ((uint32_t)(input[23] & 0x1f) << 27) |
			((uint32_t)input[24] << 19) |
			((uint32_t)input[25] << 11) |
			((uint32_t)input[26] << 3) |
			((uint32_t)(input[27] & 0xc0) >> 5);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 218 to 248
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)input[30] << 2) |
			((uint32_t)(input[31] & 0x80) >> 6);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 249 to 279
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)input[33] << 9) |
			((uint32_t)input[34] << 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 280 to 310
	value = ((uint32_t)input[35] << 24) |
			((uint32_t)input[36] << 16) |
			((uint32_t)input[37] << 8) |
			((uint32_t)(input[38] & 0xfe));
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 311 to 341
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)input[41] << 7) |
			((uint32_t)(input[42] & 0xfc) >> 1);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 342 to 372
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)input[45] << 6) |
			((uint32_t)(input[46] & 0xf8) >> 2);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 373 to 403
	value = ((uint32_t)(input[46] & 0x07) << 29) |
			((uint32_t)input[47] << 21) |
			((uint32_t)input[48] << 13) |
			((uint32_t)input[49] << 5) |
			((uint32_t)(input[50] & 0xf0) >> 3);
	output[12] = (double)(value >> 1);
}

static void unpack_13_31bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 31-bit signed
	// Skip 2 bits, read 403 bits of data.
	// Input must be at least 51 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 157 to 187
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13) |
			((uint32_t)input[22] << 5) |
			((uint32_t)(input[23] & 0xf0) >> 3);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 188 to 218
	value = ((uint32_t)(input[23] & 0x0f) << 28) |
			((uint32_t)input[24] << 20) |
			((uint32_t)input[25] << 12) |
			((uint32_t)input[26] << 4) |
			((uint32_t)(input[27] & 0xe0) >> 4);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 219 to 249
	value = ((uint32_t)(input[27] & 0x1f) << 27) |
			((uint32_t)input[28] << 19) |
			((uint32_t)input[29] << 11) |
			((uint32_t)input[30] << 3) |
			((uint32_t)(input[31] & 0xc0) >> 5);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 250 to 280
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)input[34] << 2) |
			((uint32_t)(input[35] & 0x80) >> 6);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 281 to 311
	value = ((uint32_t)(input[35] & 0x7f) << 25) |
			((uint32_t)input[36] << 17) |
			((uint32_t)input[37] << 9) |
			((uint32_t)input[38] << 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 312 to 342
	value = ((uint32_t)input[39] << 24) |
			((uint32_t)input[40] << 16) |
			((uint32_t)input[41] << 8) |
			((uint32_t)(input[42] & 0xfe));
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 343 to 373
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)input[45] << 7) |
			((uint32_t)(input[46] & 0xfc) >> 1);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 374 to 404
	value = ((uint32_t)(input[46] & 0x03) << 30) |
			((uint32_t)input[47] << 22) |
			((uint32_t)input[48] << 14) |
			((uint32_t)input[49] << 6) |
			((uint32_t)(input[50] & 0xf8) >> 2);
	output[12] = (double)(value >> 1);
}

static void unpack_13_31bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 31-bit unsigned
	// Skip 2 bits, read 403 bits of data.
	// Input must be at least 51 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 157 to 187
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13) |
			((uint32_t)input[22] << 5) |
			((uint32_t)(input[23] & 0xf0) >> 3);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 188 to 218
	value = ((uint32_t)(input[23] & 0x0f) << 28) |
			((uint32_t)input[24] << 20) |
			((uint32_t)input[25] << 12) |
			((uint32_t)input[26] << 4) |
			((uint32_t)(input[27] & 0xe0) >> 4);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 219 to 249
	value = ((uint32_t)(input[27] & 0x1f) << 27) |
			((uint32_t)input[28] << 19) |
			((uint32_t)input[29] << 11) |
			((uint32_t)input[30] << 3) |
			((uint32_t)(input[31] & 0xc0) >> 5);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 250 to 280
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)input[34] << 2) |
			((uint32_t)(input[35] & 0x80) >> 6);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 281 to 311
	value = ((uint32_t)(input[35] & 0x7f) << 25) |
			((uint32_t)input[36] << 17) |
			((uint32_t)input[37] << 9) |
			((uint32_t)input[38] << 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 312 to 342
	value = ((uint32_t)input[39] << 24) |
			((uint32_t)input[40] << 16) |
			((uint32_t)input[41] << 8) |
			((uint32_t)(input[42] & 0xfe));
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 343 to 373
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)input[45] << 7) |
			((uint32_t)(input[46] & 0xfc) >> 1);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 374 to 404
	value = ((uint32_t)(input[46] & 0x03) << 30) |
			((uint32_t)input[47] << 22) |
			((uint32_t)input[48] << 14) |
			((uint32_t)input[49] << 6) |
			((uint32_t)(input[50] & 0xf8) >> 2);
	output[12] = (double)(value >> 1);
}

static void unpack_13_31bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 31-bit signed
	// Skip 3 bits, read 403 bits of data.
	// Input must be at least 51 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 158 to 188
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)input[22] << 6) |
			((uint32_t)(input[23] & 0xf8) >> 2);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 189 to 219
	value = ((uint32_t)(input[23] & 0x07) << 29) |
			((uint32_t)input[24] << 21) |
			((uint32_t)input[25] << 13) |
			((uint32_t)input[26] << 5) |
			((uint32_t)(input[27] & 0xf0) >> 3);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 220 to 250
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)input[30] << 4) |
			((uint32_t)(input[31] & 0xe0) >> 4);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 251 to 281
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)input[33] << 11) |
			((uint32_t)input[34] << 3) |
			((uint32_t)(input[35] & 0xc0) >> 5);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 282 to 312
	value = ((uint32_t)(input[35] & 0x3f) << 26) |
			((uint32_t)input[36] << 18) |
			((uint32_t)input[37] << 10) |
			((uint32_t)input[38] << 2) |
			((uint32_t)(input[39] & 0x80) >> 6);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 313 to 343
	value = ((uint32_t)(input[39] & 0x7f) << 25) |
			((uint32_t)input[40] << 17) |
			((uint32_t)input[41] << 9) |
			((uint32_t)input[42] << 1);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 344 to 374
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)input[45] << 8) |
			((uint32_t)(input[46] & 0xfe));
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 375 to 405
	value = ((uint32_t)(input[46] & 0x01) << 31) |
			((uint32_t)input[47] << 23) |
			((uint32_t)input[48] << 15) |
			((uint32_t)input[49] << 7) |
			((uint32_t)(input[50] & 0xfc) >> 1);
	output[12] = (double)(value >> 1);
}

static void unpack_13_31bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 31-bit unsigned
	// Skip 3 bits, read 403 bits of data.
	// Input must be at least 51 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 158 to 188
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)input[22] << 6) |
			((uint32_t)(input[23] & 0xf8) >> 2);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 189 to 219
	value = ((uint32_t)(input[23] & 0x07) << 29) |
			((uint32_t)input[24] << 21) |
			((uint32_t)input[25] << 13) |
			((uint32_t)input[26] << 5) |
			((uint32_t)(input[27] & 0xf0) >> 3);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 220 to 250
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)input[30] << 4) |
			((uint32_t)(input[31] & 0xe0) >> 4);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 251 to 281
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)input[33] << 11) |
			((uint32_t)input[34] << 3) |
			((uint32_t)(input[35] & 0xc0) >> 5);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 282 to 312
	value = ((uint32_t)(input[35] & 0x3f) << 26) |
			((uint32_t)input[36] << 18) |
			((uint32_t)input[37] << 10) |
			((uint32_t)input[38] << 2) |
			((uint32_t)(input[39] & 0x80) >> 6);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 313 to 343
	value = ((uint32_t)(input[39] & 0x7f) << 25) |
			((uint32_t)input[40] << 17) |
			((uint32_t)input[41] << 9) |
			((uint32_t)input[42] << 1);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 344 to 374
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)input[45] << 8) |
			((uint32_t)(input[46] & 0xfe));
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 375 to 405
	value = ((uint32_t)(input[46] & 0x01) << 31) |
			((uint32_t)input[47] << 23) |
			((uint32_t)input[48] << 15) |
			((uint32_t)input[49] << 7) |
			((uint32_t)(input[50] & 0xfc) >> 1);
	output[12] = (double)(value >> 1);
}

static void unpack_13_31bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 31-bit signed
	// Skip 4 bits, read 403 bits of data.
	// Input must be at least 51 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 159 to 189
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)input[22] << 7) |
			((uint32_t)(input[23] & 0xfc) >> 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 190 to 220
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)input[26] << 6) |
			((uint32_t)(input[27] & 0xf8) >> 2);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 221 to 251
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5) |
			((uint32_t)(input[31] & 0xf0) >> 3);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 252 to 282
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)input[33] << 12) |
			((uint32_t)input[34] << 4) |
			((uint32_t)(input[35] & 0xe0) >> 4);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 283 to 313
	value = ((uint32_t)(input[35] & 0x1f) << 27) |
			((uint32_t)input[36] << 19) |
			((uint32_t)input[37] << 11) |
			((uint32_t)input[38] << 3) |
			((uint32_t)(input[39] & 0xc0) >> 5);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 314 to 344
	value = ((uint32_t)(input[39] & 0x3f) << 26) |
			((uint32_t)input[40] << 18) |
			((uint32_t)input[41] << 10) |
			((uint32_t)input[42] << 2) |
			((uint32_t)(input[43] & 0x80) >> 6);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 345 to 375
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)input[45] << 9) |
			((uint32_t)input[46] << 1);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 376 to 406
	value = ((uint32_t)input[47] << 24) |
			((uint32_t)input[48] << 16) |
			((uint32_t)input[49] << 8) |
			((uint32_t)(input[50] & 0xfe));
	output[12] = (double)(value >> 1);
}

static void unpack_13_31bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 31-bit unsigned
	// Skip 4 bits, read 403 bits of data.
	// Input must be at least 51 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 159 to 189
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)input[22] << 7) |
			((uint32_t)(input[23] & 0xfc) >> 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 190 to 220
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)input[26] << 6) |
			((uint32_t)(input[27] & 0xf8) >> 2);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 221 to 251
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5) |
			((uint32_t)(input[31] & 0xf0) >> 3);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 252 to 282
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)input[33] << 12) |
			((uint32_t)input[34] << 4) |
			((uint32_t)(input[35] & 0xe0) >> 4);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 283 to 313
	value = ((uint32_t)(input[35] & 0x1f) << 27) |
			((uint32_t)input[36] << 19) |
			((uint32_t)input[37] << 11) |
			((uint32_t)input[38] << 3) |
			((uint32_t)(input[39] & 0xc0) >> 5);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 314 to 344
	value = ((uint32_t)(input[39] & 0x3f) << 26) |
			((uint32_t)input[40] << 18) |
			((uint32_t)input[41] << 10) |
			((uint32_t)input[42] << 2) |
			((uint32_t)(input[43] & 0x80) >> 6);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 345 to 375
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)input[45] << 9) |
			((uint32_t)input[46] << 1);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 376 to 406
	value = ((uint32_t)input[47] << 24) |
			((uint32_t)input[48] << 16) |
			((uint32_t)input[49] << 8) |
			((uint32_t)(input[50] & 0xfe));
	output[12] = (double)(value >> 1);
}

static void unpack_13_31bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 31-bit signed
	// Skip 5 bits, read 403 bits of data.
	// Input must be at least 51 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 160 to 190
	value = ((uint32_t)input[20] << 24) |
			((uint32_t)input[21] << 16) |
			((uint32_t)input[22] << 8) |
			((uint32_t)(input[23] & 0xfe));
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 191 to 221
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)input[26] << 7) |
			((uint32_t)(input[27] & 0xfc) >> 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 222 to 252
	value = ((uint32_t)(input[27] & 0x03) << 30) |
			((uint32_t)input[28] << 22) |
			((uint32_t)input[29] << 14) |
			((uint32_t)input[30] << 6) |
			((uint32_t)(input[31] & 0xf8) >> 2);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 253 to 283
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13) |
			((uint32_t)input[34] << 5) |
			((uint32_t)(input[35] & 0xf0) >> 3);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 284 to 314
	value = ((uint32_t)(input[35] & 0x0f) << 28) |
			((uint32_t)input[36] << 20) |
			((uint32_t)input[37] << 12) |
			((uint32_t)input[38] << 4) |
			((uint32_t)(input[39] & 0xe0) >> 4);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 315 to 345
	value = ((uint32_t)(input[39] & 0x1f) << 27) |
			((uint32_t)input[40] << 19) |
			((uint32_t)input[41] << 11) |
			((uint32_t)input[42] << 3) |
			((uint32_t)(input[43] & 0xc0) >> 5);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 346 to 376
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)input[45] << 10) |
			((uint32_t)input[46] << 2) |
			((uint32_t)(input[47] & 0x80) >> 6);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 377 to 407
	value = ((uint32_t)(input[47] & 0x7f) << 25) |
			((uint32_t)input[48] << 17) |
			((uint32_t)input[49] << 9) |
			((uint32_t)input[50] << 1);
	output[12] = (double)(value >> 1);
}

static void unpack_13_31bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 31-bit unsigned
	// Skip 5 bits, read 403 bits of data.
	// Input must be at least 51 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 160 to 190
	value = ((uint32_t)input[20] << 24) |
			((uint32_t)input[21] << 16) |
			((uint32_t)input[22] << 8) |
			((uint32_t)(input[23] & 0xfe));
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 191 to 221
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)input[26] << 7) |
			((uint32_t)(input[27] & 0xfc) >> 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 222 to 252
	value = ((uint32_t)(input[27] & 0x03) << 30) |
			((uint32_t)input[28] << 22) |
			((uint32_t)input[29] << 14) |
			((uint32_t)input[30] << 6) |
			((uint32_t)(input[31] & 0xf8) >> 2);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 253 to 283
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13) |
			((uint32_t)input[34] << 5) |
			((uint32_t)(input[35] & 0xf0) >> 3);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 284 to 314
	value = ((uint32_t)(input[35] & 0x0f) << 28) |
			((uint32_t)input[36] << 20) |
			((uint32_t)input[37] << 12) |
			((uint32_t)input[38] << 4) |
			((uint32_t)(input[39] & 0xe0) >> 4);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 315 to 345
	value = ((uint32_t)(input[39] & 0x1f) << 27) |
			((uint32_t)input[40] << 19) |
			((uint32_t)input[41] << 11) |
			((uint32_t)input[42] << 3) |
			((uint32_t)(input[43] & 0xc0) >> 5);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 346 to 376
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)input[45] << 10) |
			((uint32_t)input[46] << 2) |
			((uint32_t)(input[47] & 0x80) >> 6);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 377 to 407
	value = ((uint32_t)(input[47] & 0x7f) << 25) |
			((uint32_t)input[48] << 17) |
			((uint32_t)input[49] << 9) |
			((uint32_t)input[50] << 1);
	output[12] = (double)(value >> 1);
}

static void unpack_13_31bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 31-bit signed
	// Skip 6 bits, read 403 bits of data.
	// Input must be at least 52 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 161 to 191
	value = ((uint32_t)(input[20] & 0x7f) << 25) |
			((uint32_t)input[21] << 17) |
			((uint32_t)input[22] << 9) |
			((uint32_t)input[23] << 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 192 to 222
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xfe));
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 223 to 253
	value = ((uint32_t)(input[27] & 0x01) << 31) |
			((uint32_t)input[28] << 23) |
			((uint32_t)input[29] << 15) |
			((uint32_t)input[30] << 7) |
			((uint32_t)(input[31] & 0xfc) >> 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 254 to 284
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)input[34] << 6) |
			((uint32_t)(input[35] & 0xf8) >> 2);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 285 to 315
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13) |
			((uint32_t)input[38] << 5) |
			((uint32_t)(input[39] & 0xf0) >> 3);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 316 to 346
	value = ((uint32_t)(input[39] & 0x0f) << 28) |
			((uint32_t)input[40] << 20) |
			((uint32_t)input[41] << 12) |
			((uint32_t)input[42] << 4) |
			((uint32_t)(input[43] & 0xe0) >> 4);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 347 to 377
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)input[45] << 11) |
			((uint32_t)input[46] << 3) |
			((uint32_t)(input[47] & 0xc0) >> 5);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 378 to 408
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)input[50] << 2) |
			((uint32_t)(input[51] & 0x80) >> 6);
	output[12] = (double)(value >> 1);
}

static void unpack_13_31bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 31-bit unsigned
	// Skip 6 bits, read 403 bits of data.
	// Input must be at least 52 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 161 to 191
	value = ((uint32_t)(input[20] & 0x7f) << 25) |
			((uint32_t)input[21] << 17) |
			((uint32_t)input[22] << 9) |
			((uint32_t)input[23] << 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 192 to 222
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xfe));
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 223 to 253
	value = ((uint32_t)(input[27] & 0x01) << 31) |
			((uint32_t)input[28] << 23) |
			((uint32_t)input[29] << 15) |
			((uint32_t)input[30] << 7) |
			((uint32_t)(input[31] & 0xfc) >> 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 254 to 284
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)input[34] << 6) |
			((uint32_t)(input[35] & 0xf8) >> 2);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 285 to 315
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13) |
			((uint32_t)input[38] << 5) |
			((uint32_t)(input[39] & 0xf0) >> 3);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 316 to 346
	value = ((uint32_t)(input[39] & 0x0f) << 28) |
			((uint32_t)input[40] << 20) |
			((uint32_t)input[41] << 12) |
			((uint32_t)input[42] << 4) |
			((uint32_t)(input[43] & 0xe0) >> 4);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 347 to 377
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)input[45] << 11) |
			((uint32_t)input[46] << 3) |
			((uint32_t)(input[47] & 0xc0) >> 5);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 378 to 408
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)input[50] << 2) |
			((uint32_t)(input[51] & 0x80) >> 6);
	output[12] = (double)(value >> 1);
}

static void unpack_13_31bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 31-bit signed
	// Skip 7 bits, read 403 bits of data.
	// Input must be at least 52 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 162 to 192
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)input[23] << 2) |
			((uint32_t)(input[24] & 0x80) >> 6);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 193 to 223
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)input[26] << 9) |
			((uint32_t)input[27] << 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 224 to 254
	value = ((uint32_t)input[28] << 24) |
			((uint32_t)input[29] << 16) |
			((uint32_t)input[30] << 8) |
			((uint32_t)(input[31] & 0xfe));
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 255 to 285
	value = ((uint32_t)(input[31] & 0x01) << 31) |
			((uint32_t)input[32] << 23) |
			((uint32_t)input[33] << 15) |
			((uint32_t)input[34] << 7) |
			((uint32_t)(input[35] & 0xfc) >> 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 286 to 316
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)input[38] << 6) |
			((uint32_t)(input[39] & 0xf8) >> 2);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 317 to 347
	value = ((uint32_t)(input[39] & 0x07) << 29) |
			((uint32_t)input[40] << 21) |
			((uint32_t)input[41] << 13) |
			((uint32_t)input[42] << 5) |
			((uint32_t)(input[43] & 0xf0) >> 3);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 348 to 378
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)input[45] << 12) |
			((uint32_t)input[46] << 4) |
			((uint32_t)(input[47] & 0xe0) >> 4);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 379 to 409
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)input[50] << 3) |
			((uint32_t)(input[51] & 0xc0) >> 5);
	output[12] = (double)(value >> 1);
}

static void unpack_13_31bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 31-bit unsigned
	// Skip 7 bits, read 403 bits of data.
	// Input must be at least 52 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 162 to 192
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)input[23] << 2) |
			((uint32_t)(input[24] & 0x80) >> 6);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 193 to 223
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)input[26] << 9) |
			((uint32_t)input[27] << 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 224 to 254
	value = ((uint32_t)input[28] << 24) |
			((uint32_t)input[29] << 16) |
			((uint32_t)input[30] << 8) |
			((uint32_t)(input[31] & 0xfe));
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 255 to 285
	value = ((uint32_t)(input[31] & 0x01) << 31) |
			((uint32_t)input[32] << 23) |
			((uint32_t)input[33] << 15) |
			((uint32_t)input[34] << 7) |
			((uint32_t)(input[35] & 0xfc) >> 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 286 to 316
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)input[38] << 6) |
			((uint32_t)(input[39] & 0xf8) >> 2);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 317 to 347
	value = ((uint32_t)(input[39] & 0x07) << 29) |
			((uint32_t)input[40] << 21) |
			((uint32_t)input[41] << 13) |
			((uint32_t)input[42] << 5) |
			((uint32_t)(input[43] & 0xf0) >> 3);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 348 to 378
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)input[45] << 12) |
			((uint32_t)input[46] << 4) |
			((uint32_t)(input[47] & 0xe0) >> 4);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 379 to 409
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)input[50] << 3) |
			((uint32_t)(input[51] & 0xc0) >> 5);
	output[12] = (double)(value >> 1);
}

static void unpack_14_31bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 31-bit signed
	// Skip 0 bits, read 434 bits of data.
	// Input must be at least 55 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 155 to 185
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)input[21] << 11) |
			((uint32_t)input[22] << 3) |
			((uint32_t)(input[23] & 0xc0) >> 5);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 186 to 216
	value = ((uint32_t)(input[23] & 0x3f) << 26) |
			((uint32_t)input[24] << 18) |
			((uint32_t)input[25] << 10) |
			((uint32_t)input[26] << 2) |
			((uint32_t)(input[27] & 0x80) >> 6);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 217 to 247
	value = ((uint32_t)(input[27] & 0x7f) << 25) |
			((uint32_t)input[28] << 17) |
			((uint32_t)input[29] << 9) |
			((uint32_t)input[30] << 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 248 to 278
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xfe));
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 279 to 309
	value = ((uint32_t)(input[34] & 0x01) << 31) |
			((uint32_t)input[35] << 23) |
			((uint32_t)input[36] << 15) |
			((uint32_t)input[37] << 7) |
			((uint32_t)(input[38] & 0xfc) >> 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 310 to 340
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)input[41] << 6) |
			((uint32_t)(input[42] & 0xf8) >> 2);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 341 to 371
	value = ((uint32_t)(input[42] & 0x07) << 29) |
			((uint32_t)input[43] << 21) |
			((uint32_t)input[44] << 13) |
			((uint32_t)input[45] << 5) |
			((uint32_t)(input[46] & 0xf0) >> 3);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 372 to 402
	value = ((uint32_t)(input[46] & 0x0f) << 28) |
			((uint32_t)input[47] << 20) |
			((uint32_t)input[48] << 12) |
			((uint32_t)input[49] << 4) |
			((uint32_t)(input[50] & 0xe0) >> 4);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 403 to 433
	value = ((uint32_t)(input[50] & 0x1f) << 27) |
			((uint32_t)input[51] << 19) |
			((uint32_t)input[52] << 11) |
			((uint32_t)input[53] << 3) |
			((uint32_t)(input[54] & 0xc0) >> 5);
	output[13] = (double)(value >> 1);
}

static void unpack_14_31bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 31-bit unsigned
	// Skip 0 bits, read 434 bits of data.
	// Input must be at least 55 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 155 to 185
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)input[21] << 11) |
			((uint32_t)input[22] << 3) |
			((uint32_t)(input[23] & 0xc0) >> 5);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 186 to 216
	value = ((uint32_t)(input[23] & 0x3f) << 26) |
			((uint32_t)input[24] << 18) |
			((uint32_t)input[25] << 10) |
			((uint32_t)input[26] << 2) |
			((uint32_t)(input[27] & 0x80) >> 6);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 217 to 247
	value = ((uint32_t)(input[27] & 0x7f) << 25) |
			((uint32_t)input[28] << 17) |
			((uint32_t)input[29] << 9) |
			((uint32_t)input[30] << 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 248 to 278
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xfe));
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 279 to 309
	value = ((uint32_t)(input[34] & 0x01) << 31) |
			((uint32_t)input[35] << 23) |
			((uint32_t)input[36] << 15) |
			((uint32_t)input[37] << 7) |
			((uint32_t)(input[38] & 0xfc) >> 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 310 to 340
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)input[41] << 6) |
			((uint32_t)(input[42] & 0xf8) >> 2);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 341 to 371
	value = ((uint32_t)(input[42] & 0x07) << 29) |
			((uint32_t)input[43] << 21) |
			((uint32_t)input[44] << 13) |
			((uint32_t)input[45] << 5) |
			((uint32_t)(input[46] & 0xf0) >> 3);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 372 to 402
	value = ((uint32_t)(input[46] & 0x0f) << 28) |
			((uint32_t)input[47] << 20) |
			((uint32_t)input[48] << 12) |
			((uint32_t)input[49] << 4) |
			((uint32_t)(input[50] & 0xe0) >> 4);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 403 to 433
	value = ((uint32_t)(input[50] & 0x1f) << 27) |
			((uint32_t)input[51] << 19) |
			((uint32_t)input[52] << 11) |
			((uint32_t)input[53] << 3) |
			((uint32_t)(input[54] & 0xc0) >> 5);
	output[13] = (double)(value >> 1);
}

static void unpack_14_31bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 31-bit signed
	// Skip 1 bits, read 434 bits of data.
	// Input must be at least 55 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 156 to 186
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)input[21] << 12) |
			((uint32_t)input[22] << 4) |
			((uint32_t)(input[23] & 0xe0) >> 4);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 187 to 217
	value = ((uint32_t)(input[23] & 0x1f) << 27) |
			((uint32_t)input[24] << 19) |
			((uint32_t)input[25] << 11) |
			((uint32_t)input[26] << 3) |
			((uint32_t)(input[27] & 0xc0) >> 5);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 218 to 248
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)input[30] << 2) |
			((uint32_t)(input[31] & 0x80) >> 6);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 249 to 279
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)input[33] << 9) |
			((uint32_t)input[34] << 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 280 to 310
	value = ((uint32_t)input[35] << 24) |
			((uint32_t)input[36] << 16) |
			((uint32_t)input[37] << 8) |
			((uint32_t)(input[38] & 0xfe));
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 311 to 341
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)input[41] << 7) |
			((uint32_t)(input[42] & 0xfc) >> 1);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 342 to 372
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)input[45] << 6) |
			((uint32_t)(input[46] & 0xf8) >> 2);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 373 to 403
	value = ((uint32_t)(input[46] & 0x07) << 29) |
			((uint32_t)input[47] << 21) |
			((uint32_t)input[48] << 13) |
			((uint32_t)input[49] << 5) |
			((uint32_t)(input[50] & 0xf0) >> 3);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 404 to 434
	value = ((uint32_t)(input[50] & 0x0f) << 28) |
			((uint32_t)input[51] << 20) |
			((uint32_t)input[52] << 12) |
			((uint32_t)input[53] << 4) |
			((uint32_t)(input[54] & 0xe0) >> 4);
	output[13] = (double)(value >> 1);
}

static void unpack_14_31bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 31-bit unsigned
	// Skip 1 bits, read 434 bits of data.
	// Input must be at least 55 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 156 to 186
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)input[21] << 12) |
			((uint32_t)input[22] << 4) |
			((uint32_t)(input[23] & 0xe0) >> 4);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 187 to 217
	value = ((uint32_t)(input[23] & 0x1f) << 27) |
			((uint32_t)input[24] << 19) |
			((uint32_t)input[25] << 11) |
			((uint32_t)input[26] << 3) |
			((uint32_t)(input[27] & 0xc0) >> 5);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 218 to 248
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)input[30] << 2) |
			((uint32_t)(input[31] & 0x80) >> 6);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 249 to 279
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)input[33] << 9) |
			((uint32_t)input[34] << 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 280 to 310
	value = ((uint32_t)input[35] << 24) |
			((uint32_t)input[36] << 16) |
			((uint32_t)input[37] << 8) |
			((uint32_t)(input[38] & 0xfe));
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 311 to 341
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)input[41] << 7) |
			((uint32_t)(input[42] & 0xfc) >> 1);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 342 to 372
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)input[45] << 6) |
			((uint32_t)(input[46] & 0xf8) >> 2);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 373 to 403
	value = ((uint32_t)(input[46] & 0x07) << 29) |
			((uint32_t)input[47] << 21) |
			((uint32_t)input[48] << 13) |
			((uint32_t)input[49] << 5) |
			((uint32_t)(input[50] & 0xf0) >> 3);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 404 to 434
	value = ((uint32_t)(input[50] & 0x0f) << 28) |
			((uint32_t)input[51] << 20) |
			((uint32_t)input[52] << 12) |
			((uint32_t)input[53] << 4) |
			((uint32_t)(input[54] & 0xe0) >> 4);
	output[13] = (double)(value >> 1);
}

static void unpack_14_31bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 31-bit signed
	// Skip 2 bits, read 434 bits of data.
	// Input must be at least 55 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 157 to 187
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13) |
			((uint32_t)input[22] << 5) |
			((uint32_t)(input[23] & 0xf0) >> 3);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 188 to 218
	value = ((uint32_t)(input[23] & 0x0f) << 28) |
			((uint32_t)input[24] << 20) |
			((uint32_t)input[25] << 12) |
			((uint32_t)input[26] << 4) |
			((uint32_t)(input[27] & 0xe0) >> 4);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 219 to 249
	value = ((uint32_t)(input[27] & 0x1f) << 27) |
			((uint32_t)input[28] << 19) |
			((uint32_t)input[29] << 11) |
			((uint32_t)input[30] << 3) |
			((uint32_t)(input[31] & 0xc0) >> 5);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 250 to 280
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)input[34] << 2) |
			((uint32_t)(input[35] & 0x80) >> 6);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 281 to 311
	value = ((uint32_t)(input[35] & 0x7f) << 25) |
			((uint32_t)input[36] << 17) |
			((uint32_t)input[37] << 9) |
			((uint32_t)input[38] << 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 312 to 342
	value = ((uint32_t)input[39] << 24) |
			((uint32_t)input[40] << 16) |
			((uint32_t)input[41] << 8) |
			((uint32_t)(input[42] & 0xfe));
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 343 to 373
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)input[45] << 7) |
			((uint32_t)(input[46] & 0xfc) >> 1);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 374 to 404
	value = ((uint32_t)(input[46] & 0x03) << 30) |
			((uint32_t)input[47] << 22) |
			((uint32_t)input[48] << 14) |
			((uint32_t)input[49] << 6) |
			((uint32_t)(input[50] & 0xf8) >> 2);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 405 to 435
	value = ((uint32_t)(input[50] & 0x07) << 29) |
			((uint32_t)input[51] << 21) |
			((uint32_t)input[52] << 13) |
			((uint32_t)input[53] << 5) |
			((uint32_t)(input[54] & 0xf0) >> 3);
	output[13] = (double)(value >> 1);
}

static void unpack_14_31bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 31-bit unsigned
	// Skip 2 bits, read 434 bits of data.
	// Input must be at least 55 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 157 to 187
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13) |
			((uint32_t)input[22] << 5) |
			((uint32_t)(input[23] & 0xf0) >> 3);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 188 to 218
	value = ((uint32_t)(input[23] & 0x0f) << 28) |
			((uint32_t)input[24] << 20) |
			((uint32_t)input[25] << 12) |
			((uint32_t)input[26] << 4) |
			((uint32_t)(input[27] & 0xe0) >> 4);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 219 to 249
	value = ((uint32_t)(input[27] & 0x1f) << 27) |
			((uint32_t)input[28] << 19) |
			((uint32_t)input[29] << 11) |
			((uint32_t)input[30] << 3) |
			((uint32_t)(input[31] & 0xc0) >> 5);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 250 to 280
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)input[34] << 2) |
			((uint32_t)(input[35] & 0x80) >> 6);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 281 to 311
	value = ((uint32_t)(input[35] & 0x7f) << 25) |
			((uint32_t)input[36] << 17) |
			((uint32_t)input[37] << 9) |
			((uint32_t)input[38] << 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 312 to 342
	value = ((uint32_t)input[39] << 24) |
			((uint32_t)input[40] << 16) |
			((uint32_t)input[41] << 8) |
			((uint32_t)(input[42] & 0xfe));
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 343 to 373
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)input[45] << 7) |
			((uint32_t)(input[46] & 0xfc) >> 1);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 374 to 404
	value = ((uint32_t)(input[46] & 0x03) << 30) |
			((uint32_t)input[47] << 22) |
			((uint32_t)input[48] << 14) |
			((uint32_t)input[49] << 6) |
			((uint32_t)(input[50] & 0xf8) >> 2);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 405 to 435
	value = ((uint32_t)(input[50] & 0x07) << 29) |
			((uint32_t)input[51] << 21) |
			((uint32_t)input[52] << 13) |
			((uint32_t)input[53] << 5) |
			((uint32_t)(input[54] & 0xf0) >> 3);
	output[13] = (double)(value >> 1);
}

static void unpack_14_31bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 31-bit signed
	// Skip 3 bits, read 434 bits of data.
	// Input must be at least 55 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 158 to 188
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)input[22] << 6) |
			((uint32_t)(input[23] & 0xf8) >> 2);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 189 to 219
	value = ((uint32_t)(input[23] & 0x07) << 29) |
			((uint32_t)input[24] << 21) |
			((uint32_t)input[25] << 13) |
			((uint32_t)input[26] << 5) |
			((uint32_t)(input[27] & 0xf0) >> 3);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 220 to 250
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)input[30] << 4) |
			((uint32_t)(input[31] & 0xe0) >> 4);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 251 to 281
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)input[33] << 11) |
			((uint32_t)input[34] << 3) |
			((uint32_t)(input[35] & 0xc0) >> 5);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 282 to 312
	value = ((uint32_t)(input[35] & 0x3f) << 26) |
			((uint32_t)input[36] << 18) |
			((uint32_t)input[37] << 10) |
			((uint32_t)input[38] << 2) |
			((uint32_t)(input[39] & 0x80) >> 6);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 313 to 343
	value = ((uint32_t)(input[39] & 0x7f) << 25) |
			((uint32_t)input[40] << 17) |
			((uint32_t)input[41] << 9) |
			((uint32_t)input[42] << 1);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 344 to 374
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)input[45] << 8) |
			((uint32_t)(input[46] & 0xfe));
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 375 to 405
	value = ((uint32_t)(input[46] & 0x01) << 31) |
			((uint32_t)input[47] << 23) |
			((uint32_t)input[48] << 15) |
			((uint32_t)input[49] << 7) |
			((uint32_t)(input[50] & 0xfc) >> 1);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 406 to 436
	value = ((uint32_t)(input[50] & 0x03) << 30) |
			((uint32_t)input[51] << 22) |
			((uint32_t)input[52] << 14) |
			((uint32_t)input[53] << 6) |
			((uint32_t)(input[54] & 0xf8) >> 2);
	output[13] = (double)(value >> 1);
}

static void unpack_14_31bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 31-bit unsigned
	// Skip 3 bits, read 434 bits of data.
	// Input must be at least 55 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 158 to 188
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)input[22] << 6) |
			((uint32_t)(input[23] & 0xf8) >> 2);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 189 to 219
	value = ((uint32_t)(input[23] & 0x07) << 29) |
			((uint32_t)input[24] << 21) |
			((uint32_t)input[25] << 13) |
			((uint32_t)input[26] << 5) |
			((uint32_t)(input[27] & 0xf0) >> 3);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 220 to 250
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)input[30] << 4) |
			((uint32_t)(input[31] & 0xe0) >> 4);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 251 to 281
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)input[33] << 11) |
			((uint32_t)input[34] << 3) |
			((uint32_t)(input[35] & 0xc0) >> 5);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 282 to 312
	value = ((uint32_t)(input[35] & 0x3f) << 26) |
			((uint32_t)input[36] << 18) |
			((uint32_t)input[37] << 10) |
			((uint32_t)input[38] << 2) |
			((uint32_t)(input[39] & 0x80) >> 6);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 313 to 343
	value = ((uint32_t)(input[39] & 0x7f) << 25) |
			((uint32_t)input[40] << 17) |
			((uint32_t)input[41] << 9) |
			((uint32_t)input[42] << 1);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 344 to 374
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)input[45] << 8) |
			((uint32_t)(input[46] & 0xfe));
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 375 to 405
	value = ((uint32_t)(input[46] & 0x01) << 31) |
			((uint32_t)input[47] << 23) |
			((uint32_t)input[48] << 15) |
			((uint32_t)input[49] << 7) |
			((uint32_t)(input[50] & 0xfc) >> 1);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 406 to 436
	value = ((uint32_t)(input[50] & 0x03) << 30) |
			((uint32_t)input[51] << 22) |
			((uint32_t)input[52] << 14) |
			((uint32_t)input[53] << 6) |
			((uint32_t)(input[54] & 0xf8) >> 2);
	output[13] = (double)(value >> 1);
}

static void unpack_14_31bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 31-bit signed
	// Skip 4 bits, read 434 bits of data.
	// Input must be at least 55 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 159 to 189
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)input[22] << 7) |
			((uint32_t)(input[23] & 0xfc) >> 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 190 to 220
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)input[26] << 6) |
			((uint32_t)(input[27] & 0xf8) >> 2);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 221 to 251
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5) |
			((uint32_t)(input[31] & 0xf0) >> 3);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 252 to 282
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)input[33] << 12) |
			((uint32_t)input[34] << 4) |
			((uint32_t)(input[35] & 0xe0) >> 4);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 283 to 313
	value = ((uint32_t)(input[35] & 0x1f) << 27) |
			((uint32_t)input[36] << 19) |
			((uint32_t)input[37] << 11) |
			((uint32_t)input[38] << 3) |
			((uint32_t)(input[39] & 0xc0) >> 5);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 314 to 344
	value = ((uint32_t)(input[39] & 0x3f) << 26) |
			((uint32_t)input[40] << 18) |
			((uint32_t)input[41] << 10) |
			((uint32_t)input[42] << 2) |
			((uint32_t)(input[43] & 0x80) >> 6);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 345 to 375
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)input[45] << 9) |
			((uint32_t)input[46] << 1);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 376 to 406
	value = ((uint32_t)input[47] << 24) |
			((uint32_t)input[48] << 16) |
			((uint32_t)input[49] << 8) |
			((uint32_t)(input[50] & 0xfe));
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 407 to 437
	value = ((uint32_t)(input[50] & 0x01) << 31) |
			((uint32_t)input[51] << 23) |
			((uint32_t)input[52] << 15) |
			((uint32_t)input[53] << 7) |
			((uint32_t)(input[54] & 0xfc) >> 1);
	output[13] = (double)(value >> 1);
}

static void unpack_14_31bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 31-bit unsigned
	// Skip 4 bits, read 434 bits of data.
	// Input must be at least 55 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 159 to 189
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)input[22] << 7) |
			((uint32_t)(input[23] & 0xfc) >> 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 190 to 220
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)input[26] << 6) |
			((uint32_t)(input[27] & 0xf8) >> 2);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 221 to 251
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5) |
			((uint32_t)(input[31] & 0xf0) >> 3);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 252 to 282
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)input[33] << 12) |
			((uint32_t)input[34] << 4) |
			((uint32_t)(input[35] & 0xe0) >> 4);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 283 to 313
	value = ((uint32_t)(input[35] & 0x1f) << 27) |
			((uint32_t)input[36] << 19) |
			((uint32_t)input[37] << 11) |
			((uint32_t)input[38] << 3) |
			((uint32_t)(input[39] & 0xc0) >> 5);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 314 to 344
	value = ((uint32_t)(input[39] & 0x3f) << 26) |
			((uint32_t)input[40] << 18) |
			((uint32_t)input[41] << 10) |
			((uint32_t)input[42] << 2) |
			((uint32_t)(input[43] & 0x80) >> 6);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 345 to 375
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)input[45] << 9) |
			((uint32_t)input[46] << 1);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 376 to 406
	value = ((uint32_t)input[47] << 24) |
			((uint32_t)input[48] << 16) |
			((uint32_t)input[49] << 8) |
			((uint32_t)(input[50] & 0xfe));
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 407 to 437
	value = ((uint32_t)(input[50] & 0x01) << 31) |
			((uint32_t)input[51] << 23) |
			((uint32_t)input[52] << 15) |
			((uint32_t)input[53] << 7) |
			((uint32_t)(input[54] & 0xfc) >> 1);
	output[13] = (double)(value >> 1);
}

static void unpack_14_31bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 31-bit signed
	// Skip 5 bits, read 434 bits of data.
	// Input must be at least 55 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 160 to 190
	value = ((uint32_t)input[20] << 24) |
			((uint32_t)input[21] << 16) |
			((uint32_t)input[22] << 8) |
			((uint32_t)(input[23] & 0xfe));
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 191 to 221
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)input[26] << 7) |
			((uint32_t)(input[27] & 0xfc) >> 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 222 to 252
	value = ((uint32_t)(input[27] & 0x03) << 30) |
			((uint32_t)input[28] << 22) |
			((uint32_t)input[29] << 14) |
			((uint32_t)input[30] << 6) |
			((uint32_t)(input[31] & 0xf8) >> 2);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 253 to 283
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13) |
			((uint32_t)input[34] << 5) |
			((uint32_t)(input[35] & 0xf0) >> 3);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 284 to 314
	value = ((uint32_t)(input[35] & 0x0f) << 28) |
			((uint32_t)input[36] << 20) |
			((uint32_t)input[37] << 12) |
			((uint32_t)input[38] << 4) |
			((uint32_t)(input[39] & 0xe0) >> 4);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 315 to 345
	value = ((uint32_t)(input[39] & 0x1f) << 27) |
			((uint32_t)input[40] << 19) |
			((uint32_t)input[41] << 11) |
			((uint32_t)input[42] << 3) |
			((uint32_t)(input[43] & 0xc0) >> 5);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 346 to 376
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)input[45] << 10) |
			((uint32_t)input[46] << 2) |
			((uint32_t)(input[47] & 0x80) >> 6);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 377 to 407
	value = ((uint32_t)(input[47] & 0x7f) << 25) |
			((uint32_t)input[48] << 17) |
			((uint32_t)input[49] << 9) |
			((uint32_t)input[50] << 1);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 408 to 438
	value = ((uint32_t)input[51] << 24) |
			((uint32_t)input[52] << 16) |
			((uint32_t)input[53] << 8) |
			((uint32_t)(input[54] & 0xfe));
	output[13] = (double)(value >> 1);
}

static void unpack_14_31bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 31-bit unsigned
	// Skip 5 bits, read 434 bits of data.
	// Input must be at least 55 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 160 to 190
	value = ((uint32_t)input[20] << 24) |
			((uint32_t)input[21] << 16) |
			((uint32_t)input[22] << 8) |
			((uint32_t)(input[23] & 0xfe));
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 191 to 221
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)input[26] << 7) |
			((uint32_t)(input[27] & 0xfc) >> 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 222 to 252
	value = ((uint32_t)(input[27] & 0x03) << 30) |
			((uint32_t)input[28] << 22) |
			((uint32_t)input[29] << 14) |
			((uint32_t)input[30] << 6) |
			((uint32_t)(input[31] & 0xf8) >> 2);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 253 to 283
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13) |
			((uint32_t)input[34] << 5) |
			((uint32_t)(input[35] & 0xf0) >> 3);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 284 to 314
	value = ((uint32_t)(input[35] & 0x0f) << 28) |
			((uint32_t)input[36] << 20) |
			((uint32_t)input[37] << 12) |
			((uint32_t)input[38] << 4) |
			((uint32_t)(input[39] & 0xe0) >> 4);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 315 to 345
	value = ((uint32_t)(input[39] & 0x1f) << 27) |
			((uint32_t)input[40] << 19) |
			((uint32_t)input[41] << 11) |
			((uint32_t)input[42] << 3) |
			((uint32_t)(input[43] & 0xc0) >> 5);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 346 to 376
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)input[45] << 10) |
			((uint32_t)input[46] << 2) |
			((uint32_t)(input[47] & 0x80) >> 6);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 377 to 407
	value = ((uint32_t)(input[47] & 0x7f) << 25) |
			((uint32_t)input[48] << 17) |
			((uint32_t)input[49] << 9) |
			((uint32_t)input[50] << 1);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 408 to 438
	value = ((uint32_t)input[51] << 24) |
			((uint32_t)input[52] << 16) |
			((uint32_t)input[53] << 8) |
			((uint32_t)(input[54] & 0xfe));
	output[13] = (double)(value >> 1);
}

static void unpack_14_31bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 31-bit signed
	// Skip 6 bits, read 434 bits of data.
	// Input must be at least 55 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 161 to 191
	value = ((uint32_t)(input[20] & 0x7f) << 25) |
			((uint32_t)input[21] << 17) |
			((uint32_t)input[22] << 9) |
			((uint32_t)input[23] << 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 192 to 222
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xfe));
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 223 to 253
	value = ((uint32_t)(input[27] & 0x01) << 31) |
			((uint32_t)input[28] << 23) |
			((uint32_t)input[29] << 15) |
			((uint32_t)input[30] << 7) |
			((uint32_t)(input[31] & 0xfc) >> 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 254 to 284
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)input[34] << 6) |
			((uint32_t)(input[35] & 0xf8) >> 2);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 285 to 315
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13) |
			((uint32_t)input[38] << 5) |
			((uint32_t)(input[39] & 0xf0) >> 3);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 316 to 346
	value = ((uint32_t)(input[39] & 0x0f) << 28) |
			((uint32_t)input[40] << 20) |
			((uint32_t)input[41] << 12) |
			((uint32_t)input[42] << 4) |
			((uint32_t)(input[43] & 0xe0) >> 4);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 347 to 377
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)input[45] << 11) |
			((uint32_t)input[46] << 3) |
			((uint32_t)(input[47] & 0xc0) >> 5);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 378 to 408
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)input[50] << 2) |
			((uint32_t)(input[51] & 0x80) >> 6);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 409 to 439
	value = ((uint32_t)(input[51] & 0x7f) << 25) |
			((uint32_t)input[52] << 17) |
			((uint32_t)input[53] << 9) |
			((uint32_t)input[54] << 1);
	output[13] = (double)(value >> 1);
}

static void unpack_14_31bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 31-bit unsigned
	// Skip 6 bits, read 434 bits of data.
	// Input must be at least 55 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 161 to 191
	value = ((uint32_t)(input[20] & 0x7f) << 25) |
			((uint32_t)input[21] << 17) |
			((uint32_t)input[22] << 9) |
			((uint32_t)input[23] << 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 192 to 222
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xfe));
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 223 to 253
	value = ((uint32_t)(input[27] & 0x01) << 31) |
			((uint32_t)input[28] << 23) |
			((uint32_t)input[29] << 15) |
			((uint32_t)input[30] << 7) |
			((uint32_t)(input[31] & 0xfc) >> 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 254 to 284
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)input[34] << 6) |
			((uint32_t)(input[35] & 0xf8) >> 2);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 285 to 315
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13) |
			((uint32_t)input[38] << 5) |
			((uint32_t)(input[39] & 0xf0) >> 3);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 316 to 346
	value = ((uint32_t)(input[39] & 0x0f) << 28) |
			((uint32_t)input[40] << 20) |
			((uint32_t)input[41] << 12) |
			((uint32_t)input[42] << 4) |
			((uint32_t)(input[43] & 0xe0) >> 4);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 347 to 377
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)input[45] << 11) |
			((uint32_t)input[46] << 3) |
			((uint32_t)(input[47] & 0xc0) >> 5);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 378 to 408
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)input[50] << 2) |
			((uint32_t)(input[51] & 0x80) >> 6);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 409 to 439
	value = ((uint32_t)(input[51] & 0x7f) << 25) |
			((uint32_t)input[52] << 17) |
			((uint32_t)input[53] << 9) |
			((uint32_t)input[54] << 1);
	output[13] = (double)(value >> 1);
}

static void unpack_14_31bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 31-bit signed
	// Skip 7 bits, read 434 bits of data.
	// Input must be at least 56 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 162 to 192
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)input[23] << 2) |
			((uint32_t)(input[24] & 0x80) >> 6);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 193 to 223
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)input[26] << 9) |
			((uint32_t)input[27] << 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 224 to 254
	value = ((uint32_t)input[28] << 24) |
			((uint32_t)input[29] << 16) |
			((uint32_t)input[30] << 8) |
			((uint32_t)(input[31] & 0xfe));
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 255 to 285
	value = ((uint32_t)(input[31] & 0x01) << 31) |
			((uint32_t)input[32] << 23) |
			((uint32_t)input[33] << 15) |
			((uint32_t)input[34] << 7) |
			((uint32_t)(input[35] & 0xfc) >> 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 286 to 316
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)input[38] << 6) |
			((uint32_t)(input[39] & 0xf8) >> 2);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 317 to 347
	value = ((uint32_t)(input[39] & 0x07) << 29) |
			((uint32_t)input[40] << 21) |
			((uint32_t)input[41] << 13) |
			((uint32_t)input[42] << 5) |
			((uint32_t)(input[43] & 0xf0) >> 3);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 348 to 378
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)input[45] << 12) |
			((uint32_t)input[46] << 4) |
			((uint32_t)(input[47] & 0xe0) >> 4);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 379 to 409
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)input[50] << 3) |
			((uint32_t)(input[51] & 0xc0) >> 5);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 410 to 440
	value = ((uint32_t)(input[51] & 0x3f) << 26) |
			((uint32_t)input[52] << 18) |
			((uint32_t)input[53] << 10) |
			((uint32_t)input[54] << 2) |
			((uint32_t)(input[55] & 0x80) >> 6);
	output[13] = (double)(value >> 1);
}

static void unpack_14_31bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 31-bit unsigned
	// Skip 7 bits, read 434 bits of data.
	// Input must be at least 56 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 162 to 192
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)input[23] << 2) |
			((uint32_t)(input[24] & 0x80) >> 6);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 193 to 223
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)input[26] << 9) |
			((uint32_t)input[27] << 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 224 to 254
	value = ((uint32_t)input[28] << 24) |
			((uint32_t)input[29] << 16) |
			((uint32_t)input[30] << 8) |
			((uint32_t)(input[31] & 0xfe));
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 255 to 285
	value = ((uint32_t)(input[31] & 0x01) << 31) |
			((uint32_t)input[32] << 23) |
			((uint32_t)input[33] << 15) |
			((uint32_t)input[34] << 7) |
			((uint32_t)(input[35] & 0xfc) >> 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 286 to 316
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)input[38] << 6) |
			((uint32_t)(input[39] & 0xf8) >> 2);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 317 to 347
	value = ((uint32_t)(input[39] & 0x07) << 29) |
			((uint32_t)input[40] << 21) |
			((uint32_t)input[41] << 13) |
			((uint32_t)input[42] << 5) |
			((uint32_t)(input[43] & 0xf0) >> 3);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 348 to 378
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)input[45] << 12) |
			((uint32_t)input[46] << 4) |
			((uint32_t)(input[47] & 0xe0) >> 4);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 379 to 409
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)input[50] << 3) |
			((uint32_t)(input[51] & 0xc0) >> 5);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 410 to 440
	value = ((uint32_t)(input[51] & 0x3f) << 26) |
			((uint32_t)input[52] << 18) |
			((uint32_t)input[53] << 10) |
			((uint32_t)input[54] << 2) |
			((uint32_t)(input[55] & 0x80) >> 6);
	output[13] = (double)(value >> 1);
}

static void unpack_15_31bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 31-bit signed
	// Skip 0 bits, read 465 bits of data.
	// Input must be at least 59 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 155 to 185
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)input[21] << 11) |
			((uint32_t)input[22] << 3) |
			((uint32_t)(input[23] & 0xc0) >> 5);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 186 to 216
	value = ((uint32_t)(input[23] & 0x3f) << 26) |
			((uint32_t)input[24] << 18) |
			((uint32_t)input[25] << 10) |
			((uint32_t)input[26] << 2) |
			((uint32_t)(input[27] & 0x80) >> 6);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 217 to 247
	value = ((uint32_t)(input[27] & 0x7f) << 25) |
			((uint32_t)input[28] << 17) |
			((uint32_t)input[29] << 9) |
			((uint32_t)input[30] << 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 248 to 278
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xfe));
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 279 to 309
	value = ((uint32_t)(input[34] & 0x01) << 31) |
			((uint32_t)input[35] << 23) |
			((uint32_t)input[36] << 15) |
			((uint32_t)input[37] << 7) |
			((uint32_t)(input[38] & 0xfc) >> 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 310 to 340
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)input[41] << 6) |
			((uint32_t)(input[42] & 0xf8) >> 2);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 341 to 371
	value = ((uint32_t)(input[42] & 0x07) << 29) |
			((uint32_t)input[43] << 21) |
			((uint32_t)input[44] << 13) |
			((uint32_t)input[45] << 5) |
			((uint32_t)(input[46] & 0xf0) >> 3);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 372 to 402
	value = ((uint32_t)(input[46] & 0x0f) << 28) |
			((uint32_t)input[47] << 20) |
			((uint32_t)input[48] << 12) |
			((uint32_t)input[49] << 4) |
			((uint32_t)(input[50] & 0xe0) >> 4);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 403 to 433
	value = ((uint32_t)(input[50] & 0x1f) << 27) |
			((uint32_t)input[51] << 19) |
			((uint32_t)input[52] << 11) |
			((uint32_t)input[53] << 3) |
			((uint32_t)(input[54] & 0xc0) >> 5);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 434 to 464
	value = ((uint32_t)(input[54] & 0x3f) << 26) |
			((uint32_t)input[55] << 18) |
			((uint32_t)input[56] << 10) |
			((uint32_t)input[57] << 2) |
			((uint32_t)(input[58] & 0x80) >> 6);
	output[14] = (double)(value >> 1);
}

static void unpack_15_31bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 31-bit unsigned
	// Skip 0 bits, read 465 bits of data.
	// Input must be at least 59 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 155 to 185
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)input[21] << 11) |
			((uint32_t)input[22] << 3) |
			((uint32_t)(input[23] & 0xc0) >> 5);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 186 to 216
	value = ((uint32_t)(input[23] & 0x3f) << 26) |
			((uint32_t)input[24] << 18) |
			((uint32_t)input[25] << 10) |
			((uint32_t)input[26] << 2) |
			((uint32_t)(input[27] & 0x80) >> 6);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 217 to 247
	value = ((uint32_t)(input[27] & 0x7f) << 25) |
			((uint32_t)input[28] << 17) |
			((uint32_t)input[29] << 9) |
			((uint32_t)input[30] << 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 248 to 278
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xfe));
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 279 to 309
	value = ((uint32_t)(input[34] & 0x01) << 31) |
			((uint32_t)input[35] << 23) |
			((uint32_t)input[36] << 15) |
			((uint32_t)input[37] << 7) |
			((uint32_t)(input[38] & 0xfc) >> 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 310 to 340
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)input[41] << 6) |
			((uint32_t)(input[42] & 0xf8) >> 2);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 341 to 371
	value = ((uint32_t)(input[42] & 0x07) << 29) |
			((uint32_t)input[43] << 21) |
			((uint32_t)input[44] << 13) |
			((uint32_t)input[45] << 5) |
			((uint32_t)(input[46] & 0xf0) >> 3);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 372 to 402
	value = ((uint32_t)(input[46] & 0x0f) << 28) |
			((uint32_t)input[47] << 20) |
			((uint32_t)input[48] << 12) |
			((uint32_t)input[49] << 4) |
			((uint32_t)(input[50] & 0xe0) >> 4);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 403 to 433
	value = ((uint32_t)(input[50] & 0x1f) << 27) |
			((uint32_t)input[51] << 19) |
			((uint32_t)input[52] << 11) |
			((uint32_t)input[53] << 3) |
			((uint32_t)(input[54] & 0xc0) >> 5);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 434 to 464
	value = ((uint32_t)(input[54] & 0x3f) << 26) |
			((uint32_t)input[55] << 18) |
			((uint32_t)input[56] << 10) |
			((uint32_t)input[57] << 2) |
			((uint32_t)(input[58] & 0x80) >> 6);
	output[14] = (double)(value >> 1);
}

static void unpack_15_31bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 31-bit signed
	// Skip 1 bits, read 465 bits of data.
	// Input must be at least 59 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 156 to 186
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)input[21] << 12) |
			((uint32_t)input[22] << 4) |
			((uint32_t)(input[23] & 0xe0) >> 4);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 187 to 217
	value = ((uint32_t)(input[23] & 0x1f) << 27) |
			((uint32_t)input[24] << 19) |
			((uint32_t)input[25] << 11) |
			((uint32_t)input[26] << 3) |
			((uint32_t)(input[27] & 0xc0) >> 5);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 218 to 248
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)input[30] << 2) |
			((uint32_t)(input[31] & 0x80) >> 6);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 249 to 279
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)input[33] << 9) |
			((uint32_t)input[34] << 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 280 to 310
	value = ((uint32_t)input[35] << 24) |
			((uint32_t)input[36] << 16) |
			((uint32_t)input[37] << 8) |
			((uint32_t)(input[38] & 0xfe));
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 311 to 341
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)input[41] << 7) |
			((uint32_t)(input[42] & 0xfc) >> 1);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 342 to 372
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)input[45] << 6) |
			((uint32_t)(input[46] & 0xf8) >> 2);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 373 to 403
	value = ((uint32_t)(input[46] & 0x07) << 29) |
			((uint32_t)input[47] << 21) |
			((uint32_t)input[48] << 13) |
			((uint32_t)input[49] << 5) |
			((uint32_t)(input[50] & 0xf0) >> 3);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 404 to 434
	value = ((uint32_t)(input[50] & 0x0f) << 28) |
			((uint32_t)input[51] << 20) |
			((uint32_t)input[52] << 12) |
			((uint32_t)input[53] << 4) |
			((uint32_t)(input[54] & 0xe0) >> 4);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 435 to 465
	value = ((uint32_t)(input[54] & 0x1f) << 27) |
			((uint32_t)input[55] << 19) |
			((uint32_t)input[56] << 11) |
			((uint32_t)input[57] << 3) |
			((uint32_t)(input[58] & 0xc0) >> 5);
	output[14] = (double)(value >> 1);
}

static void unpack_15_31bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 31-bit unsigned
	// Skip 1 bits, read 465 bits of data.
	// Input must be at least 59 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 156 to 186
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)input[21] << 12) |
			((uint32_t)input[22] << 4) |
			((uint32_t)(input[23] & 0xe0) >> 4);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 187 to 217
	value = ((uint32_t)(input[23] & 0x1f) << 27) |
			((uint32_t)input[24] << 19) |
			((uint32_t)input[25] << 11) |
			((uint32_t)input[26] << 3) |
			((uint32_t)(input[27] & 0xc0) >> 5);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 218 to 248
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)input[30] << 2) |
			((uint32_t)(input[31] & 0x80) >> 6);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 249 to 279
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)input[33] << 9) |
			((uint32_t)input[34] << 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 280 to 310
	value = ((uint32_t)input[35] << 24) |
			((uint32_t)input[36] << 16) |
			((uint32_t)input[37] << 8) |
			((uint32_t)(input[38] & 0xfe));
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 311 to 341
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)input[41] << 7) |
			((uint32_t)(input[42] & 0xfc) >> 1);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 342 to 372
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)input[45] << 6) |
			((uint32_t)(input[46] & 0xf8) >> 2);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 373 to 403
	value = ((uint32_t)(input[46] & 0x07) << 29) |
			((uint32_t)input[47] << 21) |
			((uint32_t)input[48] << 13) |
			((uint32_t)input[49] << 5) |
			((uint32_t)(input[50] & 0xf0) >> 3);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 404 to 434
	value = ((uint32_t)(input[50] & 0x0f) << 28) |
			((uint32_t)input[51] << 20) |
			((uint32_t)input[52] << 12) |
			((uint32_t)input[53] << 4) |
			((uint32_t)(input[54] & 0xe0) >> 4);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 435 to 465
	value = ((uint32_t)(input[54] & 0x1f) << 27) |
			((uint32_t)input[55] << 19) |
			((uint32_t)input[56] << 11) |
			((uint32_t)input[57] << 3) |
			((uint32_t)(input[58] & 0xc0) >> 5);
	output[14] = (double)(value >> 1);
}

static void unpack_15_31bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 31-bit signed
	// Skip 2 bits, read 465 bits of data.
	// Input must be at least 59 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 157 to 187
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13) |
			((uint32_t)input[22] << 5) |
			((uint32_t)(input[23] & 0xf0) >> 3);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 188 to 218
	value = ((uint32_t)(input[23] & 0x0f) << 28) |
			((uint32_t)input[24] << 20) |
			((uint32_t)input[25] << 12) |
			((uint32_t)input[26] << 4) |
			((uint32_t)(input[27] & 0xe0) >> 4);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 219 to 249
	value = ((uint32_t)(input[27] & 0x1f) << 27) |
			((uint32_t)input[28] << 19) |
			((uint32_t)input[29] << 11) |
			((uint32_t)input[30] << 3) |
			((uint32_t)(input[31] & 0xc0) >> 5);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 250 to 280
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)input[34] << 2) |
			((uint32_t)(input[35] & 0x80) >> 6);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 281 to 311
	value = ((uint32_t)(input[35] & 0x7f) << 25) |
			((uint32_t)input[36] << 17) |
			((uint32_t)input[37] << 9) |
			((uint32_t)input[38] << 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 312 to 342
	value = ((uint32_t)input[39] << 24) |
			((uint32_t)input[40] << 16) |
			((uint32_t)input[41] << 8) |
			((uint32_t)(input[42] & 0xfe));
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 343 to 373
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)input[45] << 7) |
			((uint32_t)(input[46] & 0xfc) >> 1);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 374 to 404
	value = ((uint32_t)(input[46] & 0x03) << 30) |
			((uint32_t)input[47] << 22) |
			((uint32_t)input[48] << 14) |
			((uint32_t)input[49] << 6) |
			((uint32_t)(input[50] & 0xf8) >> 2);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 405 to 435
	value = ((uint32_t)(input[50] & 0x07) << 29) |
			((uint32_t)input[51] << 21) |
			((uint32_t)input[52] << 13) |
			((uint32_t)input[53] << 5) |
			((uint32_t)(input[54] & 0xf0) >> 3);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 436 to 466
	value = ((uint32_t)(input[54] & 0x0f) << 28) |
			((uint32_t)input[55] << 20) |
			((uint32_t)input[56] << 12) |
			((uint32_t)input[57] << 4) |
			((uint32_t)(input[58] & 0xe0) >> 4);
	output[14] = (double)(value >> 1);
}

static void unpack_15_31bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 31-bit unsigned
	// Skip 2 bits, read 465 bits of data.
	// Input must be at least 59 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 157 to 187
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13) |
			((uint32_t)input[22] << 5) |
			((uint32_t)(input[23] & 0xf0) >> 3);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 188 to 218
	value = ((uint32_t)(input[23] & 0x0f) << 28) |
			((uint32_t)input[24] << 20) |
			((uint32_t)input[25] << 12) |
			((uint32_t)input[26] << 4) |
			((uint32_t)(input[27] & 0xe0) >> 4);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 219 to 249
	value = ((uint32_t)(input[27] & 0x1f) << 27) |
			((uint32_t)input[28] << 19) |
			((uint32_t)input[29] << 11) |
			((uint32_t)input[30] << 3) |
			((uint32_t)(input[31] & 0xc0) >> 5);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 250 to 280
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)input[34] << 2) |
			((uint32_t)(input[35] & 0x80) >> 6);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 281 to 311
	value = ((uint32_t)(input[35] & 0x7f) << 25) |
			((uint32_t)input[36] << 17) |
			((uint32_t)input[37] << 9) |
			((uint32_t)input[38] << 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 312 to 342
	value = ((uint32_t)input[39] << 24) |
			((uint32_t)input[40] << 16) |
			((uint32_t)input[41] << 8) |
			((uint32_t)(input[42] & 0xfe));
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 343 to 373
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)input[45] << 7) |
			((uint32_t)(input[46] & 0xfc) >> 1);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 374 to 404
	value = ((uint32_t)(input[46] & 0x03) << 30) |
			((uint32_t)input[47] << 22) |
			((uint32_t)input[48] << 14) |
			((uint32_t)input[49] << 6) |
			((uint32_t)(input[50] & 0xf8) >> 2);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 405 to 435
	value = ((uint32_t)(input[50] & 0x07) << 29) |
			((uint32_t)input[51] << 21) |
			((uint32_t)input[52] << 13) |
			((uint32_t)input[53] << 5) |
			((uint32_t)(input[54] & 0xf0) >> 3);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 436 to 466
	value = ((uint32_t)(input[54] & 0x0f) << 28) |
			((uint32_t)input[55] << 20) |
			((uint32_t)input[56] << 12) |
			((uint32_t)input[57] << 4) |
			((uint32_t)(input[58] & 0xe0) >> 4);
	output[14] = (double)(value >> 1);
}

static void unpack_15_31bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 31-bit signed
	// Skip 3 bits, read 465 bits of data.
	// Input must be at least 59 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 158 to 188
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)input[22] << 6) |
			((uint32_t)(input[23] & 0xf8) >> 2);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 189 to 219
	value = ((uint32_t)(input[23] & 0x07) << 29) |
			((uint32_t)input[24] << 21) |
			((uint32_t)input[25] << 13) |
			((uint32_t)input[26] << 5) |
			((uint32_t)(input[27] & 0xf0) >> 3);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 220 to 250
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)input[30] << 4) |
			((uint32_t)(input[31] & 0xe0) >> 4);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 251 to 281
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)input[33] << 11) |
			((uint32_t)input[34] << 3) |
			((uint32_t)(input[35] & 0xc0) >> 5);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 282 to 312
	value = ((uint32_t)(input[35] & 0x3f) << 26) |
			((uint32_t)input[36] << 18) |
			((uint32_t)input[37] << 10) |
			((uint32_t)input[38] << 2) |
			((uint32_t)(input[39] & 0x80) >> 6);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 313 to 343
	value = ((uint32_t)(input[39] & 0x7f) << 25) |
			((uint32_t)input[40] << 17) |
			((uint32_t)input[41] << 9) |
			((uint32_t)input[42] << 1);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 344 to 374
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)input[45] << 8) |
			((uint32_t)(input[46] & 0xfe));
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 375 to 405
	value = ((uint32_t)(input[46] & 0x01) << 31) |
			((uint32_t)input[47] << 23) |
			((uint32_t)input[48] << 15) |
			((uint32_t)input[49] << 7) |
			((uint32_t)(input[50] & 0xfc) >> 1);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 406 to 436
	value = ((uint32_t)(input[50] & 0x03) << 30) |
			((uint32_t)input[51] << 22) |
			((uint32_t)input[52] << 14) |
			((uint32_t)input[53] << 6) |
			((uint32_t)(input[54] & 0xf8) >> 2);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 437 to 467
	value = ((uint32_t)(input[54] & 0x07) << 29) |
			((uint32_t)input[55] << 21) |
			((uint32_t)input[56] << 13) |
			((uint32_t)input[57] << 5) |
			((uint32_t)(input[58] & 0xf0) >> 3);
	output[14] = (double)(value >> 1);
}

static void unpack_15_31bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 31-bit unsigned
	// Skip 3 bits, read 465 bits of data.
	// Input must be at least 59 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 158 to 188
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)input[22] << 6) |
			((uint32_t)(input[23] & 0xf8) >> 2);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 189 to 219
	value = ((uint32_t)(input[23] & 0x07) << 29) |
			((uint32_t)input[24] << 21) |
			((uint32_t)input[25] << 13) |
			((uint32_t)input[26] << 5) |
			((uint32_t)(input[27] & 0xf0) >> 3);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 220 to 250
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)input[30] << 4) |
			((uint32_t)(input[31] & 0xe0) >> 4);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 251 to 281
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)input[33] << 11) |
			((uint32_t)input[34] << 3) |
			((uint32_t)(input[35] & 0xc0) >> 5);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 282 to 312
	value = ((uint32_t)(input[35] & 0x3f) << 26) |
			((uint32_t)input[36] << 18) |
			((uint32_t)input[37] << 10) |
			((uint32_t)input[38] << 2) |
			((uint32_t)(input[39] & 0x80) >> 6);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 313 to 343
	value = ((uint32_t)(input[39] & 0x7f) << 25) |
			((uint32_t)input[40] << 17) |
			((uint32_t)input[41] << 9) |
			((uint32_t)input[42] << 1);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 344 to 374
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)input[45] << 8) |
			((uint32_t)(input[46] & 0xfe));
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 375 to 405
	value = ((uint32_t)(input[46] & 0x01) << 31) |
			((uint32_t)input[47] << 23) |
			((uint32_t)input[48] << 15) |
			((uint32_t)input[49] << 7) |
			((uint32_t)(input[50] & 0xfc) >> 1);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 406 to 436
	value = ((uint32_t)(input[50] & 0x03) << 30) |
			((uint32_t)input[51] << 22) |
			((uint32_t)input[52] << 14) |
			((uint32_t)input[53] << 6) |
			((uint32_t)(input[54] & 0xf8) >> 2);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 437 to 467
	value = ((uint32_t)(input[54] & 0x07) << 29) |
			((uint32_t)input[55] << 21) |
			((uint32_t)input[56] << 13) |
			((uint32_t)input[57] << 5) |
			((uint32_t)(input[58] & 0xf0) >> 3);
	output[14] = (double)(value >> 1);
}

static void unpack_15_31bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 31-bit signed
	// Skip 4 bits, read 465 bits of data.
	// Input must be at least 59 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 159 to 189
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)input[22] << 7) |
			((uint32_t)(input[23] & 0xfc) >> 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 190 to 220
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)input[26] << 6) |
			((uint32_t)(input[27] & 0xf8) >> 2);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 221 to 251
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5) |
			((uint32_t)(input[31] & 0xf0) >> 3);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 252 to 282
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)input[33] << 12) |
			((uint32_t)input[34] << 4) |
			((uint32_t)(input[35] & 0xe0) >> 4);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 283 to 313
	value = ((uint32_t)(input[35] & 0x1f) << 27) |
			((uint32_t)input[36] << 19) |
			((uint32_t)input[37] << 11) |
			((uint32_t)input[38] << 3) |
			((uint32_t)(input[39] & 0xc0) >> 5);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 314 to 344
	value = ((uint32_t)(input[39] & 0x3f) << 26) |
			((uint32_t)input[40] << 18) |
			((uint32_t)input[41] << 10) |
			((uint32_t)input[42] << 2) |
			((uint32_t)(input[43] & 0x80) >> 6);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 345 to 375
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)input[45] << 9) |
			((uint32_t)input[46] << 1);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 376 to 406
	value = ((uint32_t)input[47] << 24) |
			((uint32_t)input[48] << 16) |
			((uint32_t)input[49] << 8) |
			((uint32_t)(input[50] & 0xfe));
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 407 to 437
	value = ((uint32_t)(input[50] & 0x01) << 31) |
			((uint32_t)input[51] << 23) |
			((uint32_t)input[52] << 15) |
			((uint32_t)input[53] << 7) |
			((uint32_t)(input[54] & 0xfc) >> 1);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 438 to 468
	value = ((uint32_t)(input[54] & 0x03) << 30) |
			((uint32_t)input[55] << 22) |
			((uint32_t)input[56] << 14) |
			((uint32_t)input[57] << 6) |
			((uint32_t)(input[58] & 0xf8) >> 2);
	output[14] = (double)(value >> 1);
}

static void unpack_15_31bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 31-bit unsigned
	// Skip 4 bits, read 465 bits of data.
	// Input must be at least 59 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 159 to 189
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)input[22] << 7) |
			((uint32_t)(input[23] & 0xfc) >> 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 190 to 220
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)input[26] << 6) |
			((uint32_t)(input[27] & 0xf8) >> 2);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 221 to 251
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5) |
			((uint32_t)(input[31] & 0xf0) >> 3);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 252 to 282
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)input[33] << 12) |
			((uint32_t)input[34] << 4) |
			((uint32_t)(input[35] & 0xe0) >> 4);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 283 to 313
	value = ((uint32_t)(input[35] & 0x1f) << 27) |
			((uint32_t)input[36] << 19) |
			((uint32_t)input[37] << 11) |
			((uint32_t)input[38] << 3) |
			((uint32_t)(input[39] & 0xc0) >> 5);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 314 to 344
	value = ((uint32_t)(input[39] & 0x3f) << 26) |
			((uint32_t)input[40] << 18) |
			((uint32_t)input[41] << 10) |
			((uint32_t)input[42] << 2) |
			((uint32_t)(input[43] & 0x80) >> 6);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 345 to 375
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)input[45] << 9) |
			((uint32_t)input[46] << 1);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 376 to 406
	value = ((uint32_t)input[47] << 24) |
			((uint32_t)input[48] << 16) |
			((uint32_t)input[49] << 8) |
			((uint32_t)(input[50] & 0xfe));
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 407 to 437
	value = ((uint32_t)(input[50] & 0x01) << 31) |
			((uint32_t)input[51] << 23) |
			((uint32_t)input[52] << 15) |
			((uint32_t)input[53] << 7) |
			((uint32_t)(input[54] & 0xfc) >> 1);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 438 to 468
	value = ((uint32_t)(input[54] & 0x03) << 30) |
			((uint32_t)input[55] << 22) |
			((uint32_t)input[56] << 14) |
			((uint32_t)input[57] << 6) |
			((uint32_t)(input[58] & 0xf8) >> 2);
	output[14] = (double)(value >> 1);
}

static void unpack_15_31bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 31-bit signed
	// Skip 5 bits, read 465 bits of data.
	// Input must be at least 59 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 160 to 190
	value = ((uint32_t)input[20] << 24) |
			((uint32_t)input[21] << 16) |
			((uint32_t)input[22] << 8) |
			((uint32_t)(input[23] & 0xfe));
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 191 to 221
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)input[26] << 7) |
			((uint32_t)(input[27] & 0xfc) >> 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 222 to 252
	value = ((uint32_t)(input[27] & 0x03) << 30) |
			((uint32_t)input[28] << 22) |
			((uint32_t)input[29] << 14) |
			((uint32_t)input[30] << 6) |
			((uint32_t)(input[31] & 0xf8) >> 2);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 253 to 283
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13) |
			((uint32_t)input[34] << 5) |
			((uint32_t)(input[35] & 0xf0) >> 3);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 284 to 314
	value = ((uint32_t)(input[35] & 0x0f) << 28) |
			((uint32_t)input[36] << 20) |
			((uint32_t)input[37] << 12) |
			((uint32_t)input[38] << 4) |
			((uint32_t)(input[39] & 0xe0) >> 4);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 315 to 345
	value = ((uint32_t)(input[39] & 0x1f) << 27) |
			((uint32_t)input[40] << 19) |
			((uint32_t)input[41] << 11) |
			((uint32_t)input[42] << 3) |
			((uint32_t)(input[43] & 0xc0) >> 5);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 346 to 376
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)input[45] << 10) |
			((uint32_t)input[46] << 2) |
			((uint32_t)(input[47] & 0x80) >> 6);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 377 to 407
	value = ((uint32_t)(input[47] & 0x7f) << 25) |
			((uint32_t)input[48] << 17) |
			((uint32_t)input[49] << 9) |
			((uint32_t)input[50] << 1);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 408 to 438
	value = ((uint32_t)input[51] << 24) |
			((uint32_t)input[52] << 16) |
			((uint32_t)input[53] << 8) |
			((uint32_t)(input[54] & 0xfe));
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 439 to 469
	value = ((uint32_t)(input[54] & 0x01) << 31) |
			((uint32_t)input[55] << 23) |
			((uint32_t)input[56] << 15) |
			((uint32_t)input[57] << 7) |
			((uint32_t)(input[58] & 0xfc) >> 1);
	output[14] = (double)(value >> 1);
}

static void unpack_15_31bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 31-bit unsigned
	// Skip 5 bits, read 465 bits of data.
	// Input must be at least 59 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 160 to 190
	value = ((uint32_t)input[20] << 24) |
			((uint32_t)input[21] << 16) |
			((uint32_t)input[22] << 8) |
			((uint32_t)(input[23] & 0xfe));
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 191 to 221
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)input[26] << 7) |
			((uint32_t)(input[27] & 0xfc) >> 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 222 to 252
	value = ((uint32_t)(input[27] & 0x03) << 30) |
			((uint32_t)input[28] << 22) |
			((uint32_t)input[29] << 14) |
			((uint32_t)input[30] << 6) |
			((uint32_t)(input[31] & 0xf8) >> 2);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 253 to 283
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13) |
			((uint32_t)input[34] << 5) |
			((uint32_t)(input[35] & 0xf0) >> 3);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 284 to 314
	value = ((uint32_t)(input[35] & 0x0f) << 28) |
			((uint32_t)input[36] << 20) |
			((uint32_t)input[37] << 12) |
			((uint32_t)input[38] << 4) |
			((uint32_t)(input[39] & 0xe0) >> 4);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 315 to 345
	value = ((uint32_t)(input[39] & 0x1f) << 27) |
			((uint32_t)input[40] << 19) |
			((uint32_t)input[41] << 11) |
			((uint32_t)input[42] << 3) |
			((uint32_t)(input[43] & 0xc0) >> 5);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 346 to 376
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)input[45] << 10) |
			((uint32_t)input[46] << 2) |
			((uint32_t)(input[47] & 0x80) >> 6);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 377 to 407
	value = ((uint32_t)(input[47] & 0x7f) << 25) |
			((uint32_t)input[48] << 17) |
			((uint32_t)input[49] << 9) |
			((uint32_t)input[50] << 1);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 408 to 438
	value = ((uint32_t)input[51] << 24) |
			((uint32_t)input[52] << 16) |
			((uint32_t)input[53] << 8) |
			((uint32_t)(input[54] & 0xfe));
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 439 to 469
	value = ((uint32_t)(input[54] & 0x01) << 31) |
			((uint32_t)input[55] << 23) |
			((uint32_t)input[56] << 15) |
			((uint32_t)input[57] << 7) |
			((uint32_t)(input[58] & 0xfc) >> 1);
	output[14] = (double)(value >> 1);
}

static void unpack_15_31bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 31-bit signed
	// Skip 6 bits, read 465 bits of data.
	// Input must be at least 59 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 161 to 191
	value = ((uint32_t)(input[20] & 0x7f) << 25) |
			((uint32_t)input[21] << 17) |
			((uint32_t)input[22] << 9) |
			((uint32_t)input[23] << 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 192 to 222
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xfe));
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 223 to 253
	value = ((uint32_t)(input[27] & 0x01) << 31) |
			((uint32_t)input[28] << 23) |
			((uint32_t)input[29] << 15) |
			((uint32_t)input[30] << 7) |
			((uint32_t)(input[31] & 0xfc) >> 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 254 to 284
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)input[34] << 6) |
			((uint32_t)(input[35] & 0xf8) >> 2);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 285 to 315
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13) |
			((uint32_t)input[38] << 5) |
			((uint32_t)(input[39] & 0xf0) >> 3);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 316 to 346
	value = ((uint32_t)(input[39] & 0x0f) << 28) |
			((uint32_t)input[40] << 20) |
			((uint32_t)input[41] << 12) |
			((uint32_t)input[42] << 4) |
			((uint32_t)(input[43] & 0xe0) >> 4);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 347 to 377
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)input[45] << 11) |
			((uint32_t)input[46] << 3) |
			((uint32_t)(input[47] & 0xc0) >> 5);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 378 to 408
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)input[50] << 2) |
			((uint32_t)(input[51] & 0x80) >> 6);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 409 to 439
	value = ((uint32_t)(input[51] & 0x7f) << 25) |
			((uint32_t)input[52] << 17) |
			((uint32_t)input[53] << 9) |
			((uint32_t)input[54] << 1);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 440 to 470
	value = ((uint32_t)input[55] << 24) |
			((uint32_t)input[56] << 16) |
			((uint32_t)input[57] << 8) |
			((uint32_t)(input[58] & 0xfe));
	output[14] = (double)(value >> 1);
}

static void unpack_15_31bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 31-bit unsigned
	// Skip 6 bits, read 465 bits of data.
	// Input must be at least 59 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 161 to 191
	value = ((uint32_t)(input[20] & 0x7f) << 25) |
			((uint32_t)input[21] << 17) |
			((uint32_t)input[22] << 9) |
			((uint32_t)input[23] << 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 192 to 222
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xfe));
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 223 to 253
	value = ((uint32_t)(input[27] & 0x01) << 31) |
			((uint32_t)input[28] << 23) |
			((uint32_t)input[29] << 15) |
			((uint32_t)input[30] << 7) |
			((uint32_t)(input[31] & 0xfc) >> 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 254 to 284
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)input[34] << 6) |
			((uint32_t)(input[35] & 0xf8) >> 2);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 285 to 315
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13) |
			((uint32_t)input[38] << 5) |
			((uint32_t)(input[39] & 0xf0) >> 3);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 316 to 346
	value = ((uint32_t)(input[39] & 0x0f) << 28) |
			((uint32_t)input[40] << 20) |
			((uint32_t)input[41] << 12) |
			((uint32_t)input[42] << 4) |
			((uint32_t)(input[43] & 0xe0) >> 4);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 347 to 377
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)input[45] << 11) |
			((uint32_t)input[46] << 3) |
			((uint32_t)(input[47] & 0xc0) >> 5);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 378 to 408
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)input[50] << 2) |
			((uint32_t)(input[51] & 0x80) >> 6);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 409 to 439
	value = ((uint32_t)(input[51] & 0x7f) << 25) |
			((uint32_t)input[52] << 17) |
			((uint32_t)input[53] << 9) |
			((uint32_t)input[54] << 1);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 440 to 470
	value = ((uint32_t)input[55] << 24) |
			((uint32_t)input[56] << 16) |
			((uint32_t)input[57] << 8) |
			((uint32_t)(input[58] & 0xfe));
	output[14] = (double)(value >> 1);
}

static void unpack_15_31bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 31-bit signed
	// Skip 7 bits, read 465 bits of data.
	// Input must be at least 59 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 162 to 192
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)input[23] << 2) |
			((uint32_t)(input[24] & 0x80) >> 6);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 193 to 223
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)input[26] << 9) |
			((uint32_t)input[27] << 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 224 to 254
	value = ((uint32_t)input[28] << 24) |
			((uint32_t)input[29] << 16) |
			((uint32_t)input[30] << 8) |
			((uint32_t)(input[31] & 0xfe));
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 255 to 285
	value = ((uint32_t)(input[31] & 0x01) << 31) |
			((uint32_t)input[32] << 23) |
			((uint32_t)input[33] << 15) |
			((uint32_t)input[34] << 7) |
			((uint32_t)(input[35] & 0xfc) >> 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 286 to 316
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)input[38] << 6) |
			((uint32_t)(input[39] & 0xf8) >> 2);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 317 to 347
	value = ((uint32_t)(input[39] & 0x07) << 29) |
			((uint32_t)input[40] << 21) |
			((uint32_t)input[41] << 13) |
			((uint32_t)input[42] << 5) |
			((uint32_t)(input[43] & 0xf0) >> 3);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 348 to 378
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)input[45] << 12) |
			((uint32_t)input[46] << 4) |
			((uint32_t)(input[47] & 0xe0) >> 4);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 379 to 409
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)input[50] << 3) |
			((uint32_t)(input[51] & 0xc0) >> 5);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 410 to 440
	value = ((uint32_t)(input[51] & 0x3f) << 26) |
			((uint32_t)input[52] << 18) |
			((uint32_t)input[53] << 10) |
			((uint32_t)input[54] << 2) |
			((uint32_t)(input[55] & 0x80) >> 6);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 441 to 471
	value = ((uint32_t)(input[55] & 0x7f) << 25) |
			((uint32_t)input[56] << 17) |
			((uint32_t)input[57] << 9) |
			((uint32_t)input[58] << 1);
	output[14] = (double)(value >> 1);
}

static void unpack_15_31bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 31-bit unsigned
	// Skip 7 bits, read 465 bits of data.
	// Input must be at least 59 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 162 to 192
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)input[23] << 2) |
			((uint32_t)(input[24] & 0x80) >> 6);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 193 to 223
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)input[26] << 9) |
			((uint32_t)input[27] << 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 224 to 254
	value = ((uint32_t)input[28] << 24) |
			((uint32_t)input[29] << 16) |
			((uint32_t)input[30] << 8) |
			((uint32_t)(input[31] & 0xfe));
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 255 to 285
	value = ((uint32_t)(input[31] & 0x01) << 31) |
			((uint32_t)input[32] << 23) |
			((uint32_t)input[33] << 15) |
			((uint32_t)input[34] << 7) |
			((uint32_t)(input[35] & 0xfc) >> 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 286 to 316
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)input[38] << 6) |
			((uint32_t)(input[39] & 0xf8) >> 2);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 317 to 347
	value = ((uint32_t)(input[39] & 0x07) << 29) |
			((uint32_t)input[40] << 21) |
			((uint32_t)input[41] << 13) |
			((uint32_t)input[42] << 5) |
			((uint32_t)(input[43] & 0xf0) >> 3);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 348 to 378
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)input[45] << 12) |
			((uint32_t)input[46] << 4) |
			((uint32_t)(input[47] & 0xe0) >> 4);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 379 to 409
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)input[50] << 3) |
			((uint32_t)(input[51] & 0xc0) >> 5);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 410 to 440
	value = ((uint32_t)(input[51] & 0x3f) << 26) |
			((uint32_t)input[52] << 18) |
			((uint32_t)input[53] << 10) |
			((uint32_t)input[54] << 2) |
			((uint32_t)(input[55] & 0x80) >> 6);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 441 to 471
	value = ((uint32_t)(input[55] & 0x7f) << 25) |
			((uint32_t)input[56] << 17) |
			((uint32_t)input[57] << 9) |
			((uint32_t)input[58] << 1);
	output[14] = (double)(value >> 1);
}

static void unpack_16_31bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 31-bit signed
	// Skip 0 bits, read 496 bits of data.
	// Input must be at least 62 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 155 to 185
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)input[21] << 11) |
			((uint32_t)input[22] << 3) |
			((uint32_t)(input[23] & 0xc0) >> 5);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 186 to 216
	value = ((uint32_t)(input[23] & 0x3f) << 26) |
			((uint32_t)input[24] << 18) |
			((uint32_t)input[25] << 10) |
			((uint32_t)input[26] << 2) |
			((uint32_t)(input[27] & 0x80) >> 6);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 217 to 247
	value = ((uint32_t)(input[27] & 0x7f) << 25) |
			((uint32_t)input[28] << 17) |
			((uint32_t)input[29] << 9) |
			((uint32_t)input[30] << 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 248 to 278
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xfe));
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 279 to 309
	value = ((uint32_t)(input[34] & 0x01) << 31) |
			((uint32_t)input[35] << 23) |
			((uint32_t)input[36] << 15) |
			((uint32_t)input[37] << 7) |
			((uint32_t)(input[38] & 0xfc) >> 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 310 to 340
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)input[41] << 6) |
			((uint32_t)(input[42] & 0xf8) >> 2);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 341 to 371
	value = ((uint32_t)(input[42] & 0x07) << 29) |
			((uint32_t)input[43] << 21) |
			((uint32_t)input[44] << 13) |
			((uint32_t)input[45] << 5) |
			((uint32_t)(input[46] & 0xf0) >> 3);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 372 to 402
	value = ((uint32_t)(input[46] & 0x0f) << 28) |
			((uint32_t)input[47] << 20) |
			((uint32_t)input[48] << 12) |
			((uint32_t)input[49] << 4) |
			((uint32_t)(input[50] & 0xe0) >> 4);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 403 to 433
	value = ((uint32_t)(input[50] & 0x1f) << 27) |
			((uint32_t)input[51] << 19) |
			((uint32_t)input[52] << 11) |
			((uint32_t)input[53] << 3) |
			((uint32_t)(input[54] & 0xc0) >> 5);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 434 to 464
	value = ((uint32_t)(input[54] & 0x3f) << 26) |
			((uint32_t)input[55] << 18) |
			((uint32_t)input[56] << 10) |
			((uint32_t)input[57] << 2) |
			((uint32_t)(input[58] & 0x80) >> 6);
	output[14] = (double)(value >> 1);

	// read output[15]: from bit 465 to 495
	value = ((uint32_t)(input[58] & 0x7f) << 25) |
			((uint32_t)input[59] << 17) |
			((uint32_t)input[60] << 9) |
			((uint32_t)input[61] << 1);
	output[15] = (double)(value >> 1);
}

static void unpack_16_31bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 31-bit unsigned
	// Skip 0 bits, read 496 bits of data.
	// Input must be at least 62 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 30
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xfe));
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 31 to 61
	value = ((uint32_t)(input[3] & 0x01) << 31) |
			((uint32_t)input[4] << 23) |
			((uint32_t)input[5] << 15) |
			((uint32_t)input[6] << 7) |
			((uint32_t)(input[7] & 0xfc) >> 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 62 to 92
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xf8) >> 2);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 93 to 123
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xf0) >> 3);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 124 to 154
	value = ((uint32_t)(input[15] & 0x0f) << 28) |
			((uint32_t)input[16] << 20) |
			((uint32_t)input[17] << 12) |
			((uint32_t)input[18] << 4) |
			((uint32_t)(input[19] & 0xe0) >> 4);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 155 to 185
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)input[21] << 11) |
			((uint32_t)input[22] << 3) |
			((uint32_t)(input[23] & 0xc0) >> 5);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 186 to 216
	value = ((uint32_t)(input[23] & 0x3f) << 26) |
			((uint32_t)input[24] << 18) |
			((uint32_t)input[25] << 10) |
			((uint32_t)input[26] << 2) |
			((uint32_t)(input[27] & 0x80) >> 6);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 217 to 247
	value = ((uint32_t)(input[27] & 0x7f) << 25) |
			((uint32_t)input[28] << 17) |
			((uint32_t)input[29] << 9) |
			((uint32_t)input[30] << 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 248 to 278
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xfe));
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 279 to 309
	value = ((uint32_t)(input[34] & 0x01) << 31) |
			((uint32_t)input[35] << 23) |
			((uint32_t)input[36] << 15) |
			((uint32_t)input[37] << 7) |
			((uint32_t)(input[38] & 0xfc) >> 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 310 to 340
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)input[41] << 6) |
			((uint32_t)(input[42] & 0xf8) >> 2);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 341 to 371
	value = ((uint32_t)(input[42] & 0x07) << 29) |
			((uint32_t)input[43] << 21) |
			((uint32_t)input[44] << 13) |
			((uint32_t)input[45] << 5) |
			((uint32_t)(input[46] & 0xf0) >> 3);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 372 to 402
	value = ((uint32_t)(input[46] & 0x0f) << 28) |
			((uint32_t)input[47] << 20) |
			((uint32_t)input[48] << 12) |
			((uint32_t)input[49] << 4) |
			((uint32_t)(input[50] & 0xe0) >> 4);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 403 to 433
	value = ((uint32_t)(input[50] & 0x1f) << 27) |
			((uint32_t)input[51] << 19) |
			((uint32_t)input[52] << 11) |
			((uint32_t)input[53] << 3) |
			((uint32_t)(input[54] & 0xc0) >> 5);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 434 to 464
	value = ((uint32_t)(input[54] & 0x3f) << 26) |
			((uint32_t)input[55] << 18) |
			((uint32_t)input[56] << 10) |
			((uint32_t)input[57] << 2) |
			((uint32_t)(input[58] & 0x80) >> 6);
	output[14] = (double)(value >> 1);

	// read output[15]: from bit 465 to 495
	value = ((uint32_t)(input[58] & 0x7f) << 25) |
			((uint32_t)input[59] << 17) |
			((uint32_t)input[60] << 9) |
			((uint32_t)input[61] << 1);
	output[15] = (double)(value >> 1);
}

static void unpack_16_31bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 31-bit signed
	// Skip 1 bits, read 496 bits of data.
	// Input must be at least 63 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 156 to 186
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)input[21] << 12) |
			((uint32_t)input[22] << 4) |
			((uint32_t)(input[23] & 0xe0) >> 4);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 187 to 217
	value = ((uint32_t)(input[23] & 0x1f) << 27) |
			((uint32_t)input[24] << 19) |
			((uint32_t)input[25] << 11) |
			((uint32_t)input[26] << 3) |
			((uint32_t)(input[27] & 0xc0) >> 5);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 218 to 248
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)input[30] << 2) |
			((uint32_t)(input[31] & 0x80) >> 6);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 249 to 279
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)input[33] << 9) |
			((uint32_t)input[34] << 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 280 to 310
	value = ((uint32_t)input[35] << 24) |
			((uint32_t)input[36] << 16) |
			((uint32_t)input[37] << 8) |
			((uint32_t)(input[38] & 0xfe));
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 311 to 341
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)input[41] << 7) |
			((uint32_t)(input[42] & 0xfc) >> 1);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 342 to 372
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)input[45] << 6) |
			((uint32_t)(input[46] & 0xf8) >> 2);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 373 to 403
	value = ((uint32_t)(input[46] & 0x07) << 29) |
			((uint32_t)input[47] << 21) |
			((uint32_t)input[48] << 13) |
			((uint32_t)input[49] << 5) |
			((uint32_t)(input[50] & 0xf0) >> 3);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 404 to 434
	value = ((uint32_t)(input[50] & 0x0f) << 28) |
			((uint32_t)input[51] << 20) |
			((uint32_t)input[52] << 12) |
			((uint32_t)input[53] << 4) |
			((uint32_t)(input[54] & 0xe0) >> 4);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 435 to 465
	value = ((uint32_t)(input[54] & 0x1f) << 27) |
			((uint32_t)input[55] << 19) |
			((uint32_t)input[56] << 11) |
			((uint32_t)input[57] << 3) |
			((uint32_t)(input[58] & 0xc0) >> 5);
	output[14] = (double)(value >> 1);

	// read output[15]: from bit 466 to 496
	value = ((uint32_t)(input[58] & 0x3f) << 26) |
			((uint32_t)input[59] << 18) |
			((uint32_t)input[60] << 10) |
			((uint32_t)input[61] << 2) |
			((uint32_t)(input[62] & 0x80) >> 6);
	output[15] = (double)(value >> 1);
}

static void unpack_16_31bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 31-bit unsigned
	// Skip 1 bits, read 496 bits of data.
	// Input must be at least 63 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 31
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)input[3] << 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 32 to 62
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xfe));
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 63 to 93
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xfc) >> 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 94 to 124
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xf8) >> 2);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 125 to 155
	value = ((uint32_t)(input[15] & 0x07) << 29) |
			((uint32_t)input[16] << 21) |
			((uint32_t)input[17] << 13) |
			((uint32_t)input[18] << 5) |
			((uint32_t)(input[19] & 0xf0) >> 3);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 156 to 186
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)input[21] << 12) |
			((uint32_t)input[22] << 4) |
			((uint32_t)(input[23] & 0xe0) >> 4);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 187 to 217
	value = ((uint32_t)(input[23] & 0x1f) << 27) |
			((uint32_t)input[24] << 19) |
			((uint32_t)input[25] << 11) |
			((uint32_t)input[26] << 3) |
			((uint32_t)(input[27] & 0xc0) >> 5);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 218 to 248
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)input[30] << 2) |
			((uint32_t)(input[31] & 0x80) >> 6);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 249 to 279
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)input[33] << 9) |
			((uint32_t)input[34] << 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 280 to 310
	value = ((uint32_t)input[35] << 24) |
			((uint32_t)input[36] << 16) |
			((uint32_t)input[37] << 8) |
			((uint32_t)(input[38] & 0xfe));
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 311 to 341
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)input[41] << 7) |
			((uint32_t)(input[42] & 0xfc) >> 1);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 342 to 372
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)input[45] << 6) |
			((uint32_t)(input[46] & 0xf8) >> 2);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 373 to 403
	value = ((uint32_t)(input[46] & 0x07) << 29) |
			((uint32_t)input[47] << 21) |
			((uint32_t)input[48] << 13) |
			((uint32_t)input[49] << 5) |
			((uint32_t)(input[50] & 0xf0) >> 3);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 404 to 434
	value = ((uint32_t)(input[50] & 0x0f) << 28) |
			((uint32_t)input[51] << 20) |
			((uint32_t)input[52] << 12) |
			((uint32_t)input[53] << 4) |
			((uint32_t)(input[54] & 0xe0) >> 4);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 435 to 465
	value = ((uint32_t)(input[54] & 0x1f) << 27) |
			((uint32_t)input[55] << 19) |
			((uint32_t)input[56] << 11) |
			((uint32_t)input[57] << 3) |
			((uint32_t)(input[58] & 0xc0) >> 5);
	output[14] = (double)(value >> 1);

	// read output[15]: from bit 466 to 496
	value = ((uint32_t)(input[58] & 0x3f) << 26) |
			((uint32_t)input[59] << 18) |
			((uint32_t)input[60] << 10) |
			((uint32_t)input[61] << 2) |
			((uint32_t)(input[62] & 0x80) >> 6);
	output[15] = (double)(value >> 1);
}

static void unpack_16_31bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 31-bit signed
	// Skip 2 bits, read 496 bits of data.
	// Input must be at least 63 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 157 to 187
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13) |
			((uint32_t)input[22] << 5) |
			((uint32_t)(input[23] & 0xf0) >> 3);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 188 to 218
	value = ((uint32_t)(input[23] & 0x0f) << 28) |
			((uint32_t)input[24] << 20) |
			((uint32_t)input[25] << 12) |
			((uint32_t)input[26] << 4) |
			((uint32_t)(input[27] & 0xe0) >> 4);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 219 to 249
	value = ((uint32_t)(input[27] & 0x1f) << 27) |
			((uint32_t)input[28] << 19) |
			((uint32_t)input[29] << 11) |
			((uint32_t)input[30] << 3) |
			((uint32_t)(input[31] & 0xc0) >> 5);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 250 to 280
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)input[34] << 2) |
			((uint32_t)(input[35] & 0x80) >> 6);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 281 to 311
	value = ((uint32_t)(input[35] & 0x7f) << 25) |
			((uint32_t)input[36] << 17) |
			((uint32_t)input[37] << 9) |
			((uint32_t)input[38] << 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 312 to 342
	value = ((uint32_t)input[39] << 24) |
			((uint32_t)input[40] << 16) |
			((uint32_t)input[41] << 8) |
			((uint32_t)(input[42] & 0xfe));
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 343 to 373
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)input[45] << 7) |
			((uint32_t)(input[46] & 0xfc) >> 1);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 374 to 404
	value = ((uint32_t)(input[46] & 0x03) << 30) |
			((uint32_t)input[47] << 22) |
			((uint32_t)input[48] << 14) |
			((uint32_t)input[49] << 6) |
			((uint32_t)(input[50] & 0xf8) >> 2);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 405 to 435
	value = ((uint32_t)(input[50] & 0x07) << 29) |
			((uint32_t)input[51] << 21) |
			((uint32_t)input[52] << 13) |
			((uint32_t)input[53] << 5) |
			((uint32_t)(input[54] & 0xf0) >> 3);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 436 to 466
	value = ((uint32_t)(input[54] & 0x0f) << 28) |
			((uint32_t)input[55] << 20) |
			((uint32_t)input[56] << 12) |
			((uint32_t)input[57] << 4) |
			((uint32_t)(input[58] & 0xe0) >> 4);
	output[14] = (double)(value >> 1);

	// read output[15]: from bit 467 to 497
	value = ((uint32_t)(input[58] & 0x1f) << 27) |
			((uint32_t)input[59] << 19) |
			((uint32_t)input[60] << 11) |
			((uint32_t)input[61] << 3) |
			((uint32_t)(input[62] & 0xc0) >> 5);
	output[15] = (double)(value >> 1);
}

static void unpack_16_31bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 31-bit unsigned
	// Skip 2 bits, read 496 bits of data.
	// Input must be at least 63 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 32
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)input[3] << 2) |
			((uint32_t)(input[4] & 0x80) >> 6);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 33 to 63
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)input[7] << 1);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 64 to 94
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xfe));
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 95 to 125
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)input[14] << 7) |
			((uint32_t)(input[15] & 0xfc) >> 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 126 to 156
	value = ((uint32_t)(input[15] & 0x03) << 30) |
			((uint32_t)input[16] << 22) |
			((uint32_t)input[17] << 14) |
			((uint32_t)input[18] << 6) |
			((uint32_t)(input[19] & 0xf8) >> 2);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 157 to 187
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13) |
			((uint32_t)input[22] << 5) |
			((uint32_t)(input[23] & 0xf0) >> 3);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 188 to 218
	value = ((uint32_t)(input[23] & 0x0f) << 28) |
			((uint32_t)input[24] << 20) |
			((uint32_t)input[25] << 12) |
			((uint32_t)input[26] << 4) |
			((uint32_t)(input[27] & 0xe0) >> 4);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 219 to 249
	value = ((uint32_t)(input[27] & 0x1f) << 27) |
			((uint32_t)input[28] << 19) |
			((uint32_t)input[29] << 11) |
			((uint32_t)input[30] << 3) |
			((uint32_t)(input[31] & 0xc0) >> 5);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 250 to 280
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)input[34] << 2) |
			((uint32_t)(input[35] & 0x80) >> 6);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 281 to 311
	value = ((uint32_t)(input[35] & 0x7f) << 25) |
			((uint32_t)input[36] << 17) |
			((uint32_t)input[37] << 9) |
			((uint32_t)input[38] << 1);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 312 to 342
	value = ((uint32_t)input[39] << 24) |
			((uint32_t)input[40] << 16) |
			((uint32_t)input[41] << 8) |
			((uint32_t)(input[42] & 0xfe));
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 343 to 373
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)input[45] << 7) |
			((uint32_t)(input[46] & 0xfc) >> 1);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 374 to 404
	value = ((uint32_t)(input[46] & 0x03) << 30) |
			((uint32_t)input[47] << 22) |
			((uint32_t)input[48] << 14) |
			((uint32_t)input[49] << 6) |
			((uint32_t)(input[50] & 0xf8) >> 2);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 405 to 435
	value = ((uint32_t)(input[50] & 0x07) << 29) |
			((uint32_t)input[51] << 21) |
			((uint32_t)input[52] << 13) |
			((uint32_t)input[53] << 5) |
			((uint32_t)(input[54] & 0xf0) >> 3);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 436 to 466
	value = ((uint32_t)(input[54] & 0x0f) << 28) |
			((uint32_t)input[55] << 20) |
			((uint32_t)input[56] << 12) |
			((uint32_t)input[57] << 4) |
			((uint32_t)(input[58] & 0xe0) >> 4);
	output[14] = (double)(value >> 1);

	// read output[15]: from bit 467 to 497
	value = ((uint32_t)(input[58] & 0x1f) << 27) |
			((uint32_t)input[59] << 19) |
			((uint32_t)input[60] << 11) |
			((uint32_t)input[61] << 3) |
			((uint32_t)(input[62] & 0xc0) >> 5);
	output[15] = (double)(value >> 1);
}

static void unpack_16_31bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 31-bit signed
	// Skip 3 bits, read 496 bits of data.
	// Input must be at least 63 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 158 to 188
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)input[22] << 6) |
			((uint32_t)(input[23] & 0xf8) >> 2);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 189 to 219
	value = ((uint32_t)(input[23] & 0x07) << 29) |
			((uint32_t)input[24] << 21) |
			((uint32_t)input[25] << 13) |
			((uint32_t)input[26] << 5) |
			((uint32_t)(input[27] & 0xf0) >> 3);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 220 to 250
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)input[30] << 4) |
			((uint32_t)(input[31] & 0xe0) >> 4);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 251 to 281
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)input[33] << 11) |
			((uint32_t)input[34] << 3) |
			((uint32_t)(input[35] & 0xc0) >> 5);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 282 to 312
	value = ((uint32_t)(input[35] & 0x3f) << 26) |
			((uint32_t)input[36] << 18) |
			((uint32_t)input[37] << 10) |
			((uint32_t)input[38] << 2) |
			((uint32_t)(input[39] & 0x80) >> 6);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 313 to 343
	value = ((uint32_t)(input[39] & 0x7f) << 25) |
			((uint32_t)input[40] << 17) |
			((uint32_t)input[41] << 9) |
			((uint32_t)input[42] << 1);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 344 to 374
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)input[45] << 8) |
			((uint32_t)(input[46] & 0xfe));
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 375 to 405
	value = ((uint32_t)(input[46] & 0x01) << 31) |
			((uint32_t)input[47] << 23) |
			((uint32_t)input[48] << 15) |
			((uint32_t)input[49] << 7) |
			((uint32_t)(input[50] & 0xfc) >> 1);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 406 to 436
	value = ((uint32_t)(input[50] & 0x03) << 30) |
			((uint32_t)input[51] << 22) |
			((uint32_t)input[52] << 14) |
			((uint32_t)input[53] << 6) |
			((uint32_t)(input[54] & 0xf8) >> 2);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 437 to 467
	value = ((uint32_t)(input[54] & 0x07) << 29) |
			((uint32_t)input[55] << 21) |
			((uint32_t)input[56] << 13) |
			((uint32_t)input[57] << 5) |
			((uint32_t)(input[58] & 0xf0) >> 3);
	output[14] = (double)(value >> 1);

	// read output[15]: from bit 468 to 498
	value = ((uint32_t)(input[58] & 0x0f) << 28) |
			((uint32_t)input[59] << 20) |
			((uint32_t)input[60] << 12) |
			((uint32_t)input[61] << 4) |
			((uint32_t)(input[62] & 0xe0) >> 4);
	output[15] = (double)(value >> 1);
}

static void unpack_16_31bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 31-bit unsigned
	// Skip 3 bits, read 496 bits of data.
	// Input must be at least 63 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 33
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3) |
			((uint32_t)(input[4] & 0xc0) >> 5);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 34 to 64
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)input[7] << 2) |
			((uint32_t)(input[8] & 0x80) >> 6);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 65 to 95
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)input[11] << 1);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 96 to 126
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)input[14] << 8) |
			((uint32_t)(input[15] & 0xfe));
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 127 to 157
	value = ((uint32_t)(input[15] & 0x01) << 31) |
			((uint32_t)input[16] << 23) |
			((uint32_t)input[17] << 15) |
			((uint32_t)input[18] << 7) |
			((uint32_t)(input[19] & 0xfc) >> 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 158 to 188
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)input[22] << 6) |
			((uint32_t)(input[23] & 0xf8) >> 2);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 189 to 219
	value = ((uint32_t)(input[23] & 0x07) << 29) |
			((uint32_t)input[24] << 21) |
			((uint32_t)input[25] << 13) |
			((uint32_t)input[26] << 5) |
			((uint32_t)(input[27] & 0xf0) >> 3);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 220 to 250
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)input[30] << 4) |
			((uint32_t)(input[31] & 0xe0) >> 4);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 251 to 281
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)input[33] << 11) |
			((uint32_t)input[34] << 3) |
			((uint32_t)(input[35] & 0xc0) >> 5);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 282 to 312
	value = ((uint32_t)(input[35] & 0x3f) << 26) |
			((uint32_t)input[36] << 18) |
			((uint32_t)input[37] << 10) |
			((uint32_t)input[38] << 2) |
			((uint32_t)(input[39] & 0x80) >> 6);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 313 to 343
	value = ((uint32_t)(input[39] & 0x7f) << 25) |
			((uint32_t)input[40] << 17) |
			((uint32_t)input[41] << 9) |
			((uint32_t)input[42] << 1);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 344 to 374
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)input[45] << 8) |
			((uint32_t)(input[46] & 0xfe));
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 375 to 405
	value = ((uint32_t)(input[46] & 0x01) << 31) |
			((uint32_t)input[47] << 23) |
			((uint32_t)input[48] << 15) |
			((uint32_t)input[49] << 7) |
			((uint32_t)(input[50] & 0xfc) >> 1);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 406 to 436
	value = ((uint32_t)(input[50] & 0x03) << 30) |
			((uint32_t)input[51] << 22) |
			((uint32_t)input[52] << 14) |
			((uint32_t)input[53] << 6) |
			((uint32_t)(input[54] & 0xf8) >> 2);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 437 to 467
	value = ((uint32_t)(input[54] & 0x07) << 29) |
			((uint32_t)input[55] << 21) |
			((uint32_t)input[56] << 13) |
			((uint32_t)input[57] << 5) |
			((uint32_t)(input[58] & 0xf0) >> 3);
	output[14] = (double)(value >> 1);

	// read output[15]: from bit 468 to 498
	value = ((uint32_t)(input[58] & 0x0f) << 28) |
			((uint32_t)input[59] << 20) |
			((uint32_t)input[60] << 12) |
			((uint32_t)input[61] << 4) |
			((uint32_t)(input[62] & 0xe0) >> 4);
	output[15] = (double)(value >> 1);
}

static void unpack_16_31bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 31-bit signed
	// Skip 4 bits, read 496 bits of data.
	// Input must be at least 63 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 159 to 189
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)input[22] << 7) |
			((uint32_t)(input[23] & 0xfc) >> 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 190 to 220
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)input[26] << 6) |
			((uint32_t)(input[27] & 0xf8) >> 2);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 221 to 251
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5) |
			((uint32_t)(input[31] & 0xf0) >> 3);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 252 to 282
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)input[33] << 12) |
			((uint32_t)input[34] << 4) |
			((uint32_t)(input[35] & 0xe0) >> 4);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 283 to 313
	value = ((uint32_t)(input[35] & 0x1f) << 27) |
			((uint32_t)input[36] << 19) |
			((uint32_t)input[37] << 11) |
			((uint32_t)input[38] << 3) |
			((uint32_t)(input[39] & 0xc0) >> 5);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 314 to 344
	value = ((uint32_t)(input[39] & 0x3f) << 26) |
			((uint32_t)input[40] << 18) |
			((uint32_t)input[41] << 10) |
			((uint32_t)input[42] << 2) |
			((uint32_t)(input[43] & 0x80) >> 6);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 345 to 375
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)input[45] << 9) |
			((uint32_t)input[46] << 1);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 376 to 406
	value = ((uint32_t)input[47] << 24) |
			((uint32_t)input[48] << 16) |
			((uint32_t)input[49] << 8) |
			((uint32_t)(input[50] & 0xfe));
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 407 to 437
	value = ((uint32_t)(input[50] & 0x01) << 31) |
			((uint32_t)input[51] << 23) |
			((uint32_t)input[52] << 15) |
			((uint32_t)input[53] << 7) |
			((uint32_t)(input[54] & 0xfc) >> 1);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 438 to 468
	value = ((uint32_t)(input[54] & 0x03) << 30) |
			((uint32_t)input[55] << 22) |
			((uint32_t)input[56] << 14) |
			((uint32_t)input[57] << 6) |
			((uint32_t)(input[58] & 0xf8) >> 2);
	output[14] = (double)(value >> 1);

	// read output[15]: from bit 469 to 499
	value = ((uint32_t)(input[58] & 0x07) << 29) |
			((uint32_t)input[59] << 21) |
			((uint32_t)input[60] << 13) |
			((uint32_t)input[61] << 5) |
			((uint32_t)(input[62] & 0xf0) >> 3);
	output[15] = (double)(value >> 1);
}

static void unpack_16_31bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 31-bit unsigned
	// Skip 4 bits, read 496 bits of data.
	// Input must be at least 63 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 34
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0xe0) >> 4);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 35 to 65
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3) |
			((uint32_t)(input[8] & 0xc0) >> 5);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 66 to 96
	value = ((uint32_t)(input[8] & 0x3f) << 26) |
			((uint32_t)input[9] << 18) |
			((uint32_t)input[10] << 10) |
			((uint32_t)input[11] << 2) |
			((uint32_t)(input[12] & 0x80) >> 6);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 97 to 127
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)input[14] << 9) |
			((uint32_t)input[15] << 1);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 128 to 158
	value = ((uint32_t)input[16] << 24) |
			((uint32_t)input[17] << 16) |
			((uint32_t)input[18] << 8) |
			((uint32_t)(input[19] & 0xfe));
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 159 to 189
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)input[22] << 7) |
			((uint32_t)(input[23] & 0xfc) >> 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 190 to 220
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)input[26] << 6) |
			((uint32_t)(input[27] & 0xf8) >> 2);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 221 to 251
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5) |
			((uint32_t)(input[31] & 0xf0) >> 3);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 252 to 282
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)input[33] << 12) |
			((uint32_t)input[34] << 4) |
			((uint32_t)(input[35] & 0xe0) >> 4);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 283 to 313
	value = ((uint32_t)(input[35] & 0x1f) << 27) |
			((uint32_t)input[36] << 19) |
			((uint32_t)input[37] << 11) |
			((uint32_t)input[38] << 3) |
			((uint32_t)(input[39] & 0xc0) >> 5);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 314 to 344
	value = ((uint32_t)(input[39] & 0x3f) << 26) |
			((uint32_t)input[40] << 18) |
			((uint32_t)input[41] << 10) |
			((uint32_t)input[42] << 2) |
			((uint32_t)(input[43] & 0x80) >> 6);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 345 to 375
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)input[45] << 9) |
			((uint32_t)input[46] << 1);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 376 to 406
	value = ((uint32_t)input[47] << 24) |
			((uint32_t)input[48] << 16) |
			((uint32_t)input[49] << 8) |
			((uint32_t)(input[50] & 0xfe));
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 407 to 437
	value = ((uint32_t)(input[50] & 0x01) << 31) |
			((uint32_t)input[51] << 23) |
			((uint32_t)input[52] << 15) |
			((uint32_t)input[53] << 7) |
			((uint32_t)(input[54] & 0xfc) >> 1);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 438 to 468
	value = ((uint32_t)(input[54] & 0x03) << 30) |
			((uint32_t)input[55] << 22) |
			((uint32_t)input[56] << 14) |
			((uint32_t)input[57] << 6) |
			((uint32_t)(input[58] & 0xf8) >> 2);
	output[14] = (double)(value >> 1);

	// read output[15]: from bit 469 to 499
	value = ((uint32_t)(input[58] & 0x07) << 29) |
			((uint32_t)input[59] << 21) |
			((uint32_t)input[60] << 13) |
			((uint32_t)input[61] << 5) |
			((uint32_t)(input[62] & 0xf0) >> 3);
	output[15] = (double)(value >> 1);
}

static void unpack_16_31bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 31-bit signed
	// Skip 5 bits, read 496 bits of data.
	// Input must be at least 63 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 160 to 190
	value = ((uint32_t)input[20] << 24) |
			((uint32_t)input[21] << 16) |
			((uint32_t)input[22] << 8) |
			((uint32_t)(input[23] & 0xfe));
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 191 to 221
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)input[26] << 7) |
			((uint32_t)(input[27] & 0xfc) >> 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 222 to 252
	value = ((uint32_t)(input[27] & 0x03) << 30) |
			((uint32_t)input[28] << 22) |
			((uint32_t)input[29] << 14) |
			((uint32_t)input[30] << 6) |
			((uint32_t)(input[31] & 0xf8) >> 2);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 253 to 283
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13) |
			((uint32_t)input[34] << 5) |
			((uint32_t)(input[35] & 0xf0) >> 3);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 284 to 314
	value = ((uint32_t)(input[35] & 0x0f) << 28) |
			((uint32_t)input[36] << 20) |
			((uint32_t)input[37] << 12) |
			((uint32_t)input[38] << 4) |
			((uint32_t)(input[39] & 0xe0) >> 4);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 315 to 345
	value = ((uint32_t)(input[39] & 0x1f) << 27) |
			((uint32_t)input[40] << 19) |
			((uint32_t)input[41] << 11) |
			((uint32_t)input[42] << 3) |
			((uint32_t)(input[43] & 0xc0) >> 5);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 346 to 376
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)input[45] << 10) |
			((uint32_t)input[46] << 2) |
			((uint32_t)(input[47] & 0x80) >> 6);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 377 to 407
	value = ((uint32_t)(input[47] & 0x7f) << 25) |
			((uint32_t)input[48] << 17) |
			((uint32_t)input[49] << 9) |
			((uint32_t)input[50] << 1);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 408 to 438
	value = ((uint32_t)input[51] << 24) |
			((uint32_t)input[52] << 16) |
			((uint32_t)input[53] << 8) |
			((uint32_t)(input[54] & 0xfe));
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 439 to 469
	value = ((uint32_t)(input[54] & 0x01) << 31) |
			((uint32_t)input[55] << 23) |
			((uint32_t)input[56] << 15) |
			((uint32_t)input[57] << 7) |
			((uint32_t)(input[58] & 0xfc) >> 1);
	output[14] = (double)(value >> 1);

	// read output[15]: from bit 470 to 500
	value = ((uint32_t)(input[58] & 0x03) << 30) |
			((uint32_t)input[59] << 22) |
			((uint32_t)input[60] << 14) |
			((uint32_t)input[61] << 6) |
			((uint32_t)(input[62] & 0xf8) >> 2);
	output[15] = (double)(value >> 1);
}

static void unpack_16_31bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 31-bit unsigned
	// Skip 5 bits, read 496 bits of data.
	// Input must be at least 63 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 35
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xf0) >> 3);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 36 to 66
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0xe0) >> 4);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 67 to 97
	value = ((uint32_t)(input[8] & 0x1f) << 27) |
			((uint32_t)input[9] << 19) |
			((uint32_t)input[10] << 11) |
			((uint32_t)input[11] << 3) |
			((uint32_t)(input[12] & 0xc0) >> 5);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 98 to 128
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)input[14] << 10) |
			((uint32_t)input[15] << 2) |
			((uint32_t)(input[16] & 0x80) >> 6);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 129 to 159
	value = ((uint32_t)(input[16] & 0x7f) << 25) |
			((uint32_t)input[17] << 17) |
			((uint32_t)input[18] << 9) |
			((uint32_t)input[19] << 1);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 160 to 190
	value = ((uint32_t)input[20] << 24) |
			((uint32_t)input[21] << 16) |
			((uint32_t)input[22] << 8) |
			((uint32_t)(input[23] & 0xfe));
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 191 to 221
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)input[26] << 7) |
			((uint32_t)(input[27] & 0xfc) >> 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 222 to 252
	value = ((uint32_t)(input[27] & 0x03) << 30) |
			((uint32_t)input[28] << 22) |
			((uint32_t)input[29] << 14) |
			((uint32_t)input[30] << 6) |
			((uint32_t)(input[31] & 0xf8) >> 2);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 253 to 283
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13) |
			((uint32_t)input[34] << 5) |
			((uint32_t)(input[35] & 0xf0) >> 3);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 284 to 314
	value = ((uint32_t)(input[35] & 0x0f) << 28) |
			((uint32_t)input[36] << 20) |
			((uint32_t)input[37] << 12) |
			((uint32_t)input[38] << 4) |
			((uint32_t)(input[39] & 0xe0) >> 4);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 315 to 345
	value = ((uint32_t)(input[39] & 0x1f) << 27) |
			((uint32_t)input[40] << 19) |
			((uint32_t)input[41] << 11) |
			((uint32_t)input[42] << 3) |
			((uint32_t)(input[43] & 0xc0) >> 5);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 346 to 376
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)input[45] << 10) |
			((uint32_t)input[46] << 2) |
			((uint32_t)(input[47] & 0x80) >> 6);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 377 to 407
	value = ((uint32_t)(input[47] & 0x7f) << 25) |
			((uint32_t)input[48] << 17) |
			((uint32_t)input[49] << 9) |
			((uint32_t)input[50] << 1);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 408 to 438
	value = ((uint32_t)input[51] << 24) |
			((uint32_t)input[52] << 16) |
			((uint32_t)input[53] << 8) |
			((uint32_t)(input[54] & 0xfe));
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 439 to 469
	value = ((uint32_t)(input[54] & 0x01) << 31) |
			((uint32_t)input[55] << 23) |
			((uint32_t)input[56] << 15) |
			((uint32_t)input[57] << 7) |
			((uint32_t)(input[58] & 0xfc) >> 1);
	output[14] = (double)(value >> 1);

	// read output[15]: from bit 470 to 500
	value = ((uint32_t)(input[58] & 0x03) << 30) |
			((uint32_t)input[59] << 22) |
			((uint32_t)input[60] << 14) |
			((uint32_t)input[61] << 6) |
			((uint32_t)(input[62] & 0xf8) >> 2);
	output[15] = (double)(value >> 1);
}

static void unpack_16_31bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 31-bit signed
	// Skip 6 bits, read 496 bits of data.
	// Input must be at least 63 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 161 to 191
	value = ((uint32_t)(input[20] & 0x7f) << 25) |
			((uint32_t)input[21] << 17) |
			((uint32_t)input[22] << 9) |
			((uint32_t)input[23] << 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 192 to 222
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xfe));
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 223 to 253
	value = ((uint32_t)(input[27] & 0x01) << 31) |
			((uint32_t)input[28] << 23) |
			((uint32_t)input[29] << 15) |
			((uint32_t)input[30] << 7) |
			((uint32_t)(input[31] & 0xfc) >> 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 254 to 284
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)input[34] << 6) |
			((uint32_t)(input[35] & 0xf8) >> 2);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 285 to 315
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13) |
			((uint32_t)input[38] << 5) |
			((uint32_t)(input[39] & 0xf0) >> 3);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 316 to 346
	value = ((uint32_t)(input[39] & 0x0f) << 28) |
			((uint32_t)input[40] << 20) |
			((uint32_t)input[41] << 12) |
			((uint32_t)input[42] << 4) |
			((uint32_t)(input[43] & 0xe0) >> 4);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 347 to 377
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)input[45] << 11) |
			((uint32_t)input[46] << 3) |
			((uint32_t)(input[47] & 0xc0) >> 5);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 378 to 408
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)input[50] << 2) |
			((uint32_t)(input[51] & 0x80) >> 6);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 409 to 439
	value = ((uint32_t)(input[51] & 0x7f) << 25) |
			((uint32_t)input[52] << 17) |
			((uint32_t)input[53] << 9) |
			((uint32_t)input[54] << 1);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 440 to 470
	value = ((uint32_t)input[55] << 24) |
			((uint32_t)input[56] << 16) |
			((uint32_t)input[57] << 8) |
			((uint32_t)(input[58] & 0xfe));
	output[14] = (double)(value >> 1);

	// read output[15]: from bit 471 to 501
	value = ((uint32_t)(input[58] & 0x01) << 31) |
			((uint32_t)input[59] << 23) |
			((uint32_t)input[60] << 15) |
			((uint32_t)input[61] << 7) |
			((uint32_t)(input[62] & 0xfc) >> 1);
	output[15] = (double)(value >> 1);
}

static void unpack_16_31bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 31-bit unsigned
	// Skip 6 bits, read 496 bits of data.
	// Input must be at least 63 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 36
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)input[3] << 6) |
			((uint32_t)(input[4] & 0xf8) >> 2);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 37 to 67
	value = ((uint32_t)(input[4] & 0x07) << 29) |
			((uint32_t)input[5] << 21) |
			((uint32_t)input[6] << 13) |
			((uint32_t)input[7] << 5) |
			((uint32_t)(input[8] & 0xf0) >> 3);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 68 to 98
	value = ((uint32_t)(input[8] & 0x0f) << 28) |
			((uint32_t)input[9] << 20) |
			((uint32_t)input[10] << 12) |
			((uint32_t)input[11] << 4) |
			((uint32_t)(input[12] & 0xe0) >> 4);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 99 to 129
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)input[14] << 11) |
			((uint32_t)input[15] << 3) |
			((uint32_t)(input[16] & 0xc0) >> 5);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 130 to 160
	value = ((uint32_t)(input[16] & 0x3f) << 26) |
			((uint32_t)input[17] << 18) |
			((uint32_t)input[18] << 10) |
			((uint32_t)input[19] << 2) |
			((uint32_t)(input[20] & 0x80) >> 6);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 161 to 191
	value = ((uint32_t)(input[20] & 0x7f) << 25) |
			((uint32_t)input[21] << 17) |
			((uint32_t)input[22] << 9) |
			((uint32_t)input[23] << 1);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 192 to 222
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xfe));
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 223 to 253
	value = ((uint32_t)(input[27] & 0x01) << 31) |
			((uint32_t)input[28] << 23) |
			((uint32_t)input[29] << 15) |
			((uint32_t)input[30] << 7) |
			((uint32_t)(input[31] & 0xfc) >> 1);
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 254 to 284
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)input[34] << 6) |
			((uint32_t)(input[35] & 0xf8) >> 2);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 285 to 315
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13) |
			((uint32_t)input[38] << 5) |
			((uint32_t)(input[39] & 0xf0) >> 3);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 316 to 346
	value = ((uint32_t)(input[39] & 0x0f) << 28) |
			((uint32_t)input[40] << 20) |
			((uint32_t)input[41] << 12) |
			((uint32_t)input[42] << 4) |
			((uint32_t)(input[43] & 0xe0) >> 4);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 347 to 377
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)input[45] << 11) |
			((uint32_t)input[46] << 3) |
			((uint32_t)(input[47] & 0xc0) >> 5);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 378 to 408
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)input[50] << 2) |
			((uint32_t)(input[51] & 0x80) >> 6);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 409 to 439
	value = ((uint32_t)(input[51] & 0x7f) << 25) |
			((uint32_t)input[52] << 17) |
			((uint32_t)input[53] << 9) |
			((uint32_t)input[54] << 1);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 440 to 470
	value = ((uint32_t)input[55] << 24) |
			((uint32_t)input[56] << 16) |
			((uint32_t)input[57] << 8) |
			((uint32_t)(input[58] & 0xfe));
	output[14] = (double)(value >> 1);

	// read output[15]: from bit 471 to 501
	value = ((uint32_t)(input[58] & 0x01) << 31) |
			((uint32_t)input[59] << 23) |
			((uint32_t)input[60] << 15) |
			((uint32_t)input[61] << 7) |
			((uint32_t)(input[62] & 0xfc) >> 1);
	output[15] = (double)(value >> 1);
}

static void unpack_16_31bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 31-bit signed
	// Skip 7 bits, read 496 bits of data.
	// Input must be at least 63 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 162 to 192
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)input[23] << 2) |
			((uint32_t)(input[24] & 0x80) >> 6);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 193 to 223
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)input[26] << 9) |
			((uint32_t)input[27] << 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 224 to 254
	value = ((uint32_t)input[28] << 24) |
			((uint32_t)input[29] << 16) |
			((uint32_t)input[30] << 8) |
			((uint32_t)(input[31] & 0xfe));
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 255 to 285
	value = ((uint32_t)(input[31] & 0x01) << 31) |
			((uint32_t)input[32] << 23) |
			((uint32_t)input[33] << 15) |
			((uint32_t)input[34] << 7) |
			((uint32_t)(input[35] & 0xfc) >> 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 286 to 316
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)input[38] << 6) |
			((uint32_t)(input[39] & 0xf8) >> 2);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 317 to 347
	value = ((uint32_t)(input[39] & 0x07) << 29) |
			((uint32_t)input[40] << 21) |
			((uint32_t)input[41] << 13) |
			((uint32_t)input[42] << 5) |
			((uint32_t)(input[43] & 0xf0) >> 3);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 348 to 378
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)input[45] << 12) |
			((uint32_t)input[46] << 4) |
			((uint32_t)(input[47] & 0xe0) >> 4);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 379 to 409
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)input[50] << 3) |
			((uint32_t)(input[51] & 0xc0) >> 5);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 410 to 440
	value = ((uint32_t)(input[51] & 0x3f) << 26) |
			((uint32_t)input[52] << 18) |
			((uint32_t)input[53] << 10) |
			((uint32_t)input[54] << 2) |
			((uint32_t)(input[55] & 0x80) >> 6);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 441 to 471
	value = ((uint32_t)(input[55] & 0x7f) << 25) |
			((uint32_t)input[56] << 17) |
			((uint32_t)input[57] << 9) |
			((uint32_t)input[58] << 1);
	output[14] = (double)(value >> 1);

	// read output[15]: from bit 472 to 502
	value = ((uint32_t)input[59] << 24) |
			((uint32_t)input[60] << 16) |
			((uint32_t)input[61] << 8) |
			((uint32_t)(input[62] & 0xfe));
	output[15] = (double)(value >> 1);
}

static void unpack_16_31bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 31-bit unsigned
	// Skip 7 bits, read 496 bits of data.
	// Input must be at least 63 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 37
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)input[3] << 7) |
			((uint32_t)(input[4] & 0xfc) >> 1);
	output[0] = (double)(value >> 1);

	// read output[1]: from bit 38 to 68
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)input[7] << 6) |
			((uint32_t)(input[8] & 0xf8) >> 2);
	output[1] = (double)(value >> 1);

	// read output[2]: from bit 69 to 99
	value = ((uint32_t)(input[8] & 0x07) << 29) |
			((uint32_t)input[9] << 21) |
			((uint32_t)input[10] << 13) |
			((uint32_t)input[11] << 5) |
			((uint32_t)(input[12] & 0xf0) >> 3);
	output[2] = (double)(value >> 1);

	// read output[3]: from bit 100 to 130
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)input[14] << 12) |
			((uint32_t)input[15] << 4) |
			((uint32_t)(input[16] & 0xe0) >> 4);
	output[3] = (double)(value >> 1);

	// read output[4]: from bit 131 to 161
	value = ((uint32_t)(input[16] & 0x1f) << 27) |
			((uint32_t)input[17] << 19) |
			((uint32_t)input[18] << 11) |
			((uint32_t)input[19] << 3) |
			((uint32_t)(input[20] & 0xc0) >> 5);
	output[4] = (double)(value >> 1);

	// read output[5]: from bit 162 to 192
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)input[23] << 2) |
			((uint32_t)(input[24] & 0x80) >> 6);
	output[5] = (double)(value >> 1);

	// read output[6]: from bit 193 to 223
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)input[26] << 9) |
			((uint32_t)input[27] << 1);
	output[6] = (double)(value >> 1);

	// read output[7]: from bit 224 to 254
	value = ((uint32_t)input[28] << 24) |
			((uint32_t)input[29] << 16) |
			((uint32_t)input[30] << 8) |
			((uint32_t)(input[31] & 0xfe));
	output[7] = (double)(value >> 1);

	// read output[8]: from bit 255 to 285
	value = ((uint32_t)(input[31] & 0x01) << 31) |
			((uint32_t)input[32] << 23) |
			((uint32_t)input[33] << 15) |
			((uint32_t)input[34] << 7) |
			((uint32_t)(input[35] & 0xfc) >> 1);
	output[8] = (double)(value >> 1);

	// read output[9]: from bit 286 to 316
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)input[38] << 6) |
			((uint32_t)(input[39] & 0xf8) >> 2);
	output[9] = (double)(value >> 1);

	// read output[10]: from bit 317 to 347
	value = ((uint32_t)(input[39] & 0x07) << 29) |
			((uint32_t)input[40] << 21) |
			((uint32_t)input[41] << 13) |
			((uint32_t)input[42] << 5) |
			((uint32_t)(input[43] & 0xf0) >> 3);
	output[10] = (double)(value >> 1);

	// read output[11]: from bit 348 to 378
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)input[45] << 12) |
			((uint32_t)input[46] << 4) |
			((uint32_t)(input[47] & 0xe0) >> 4);
	output[11] = (double)(value >> 1);

	// read output[12]: from bit 379 to 409
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)input[50] << 3) |
			((uint32_t)(input[51] & 0xc0) >> 5);
	output[12] = (double)(value >> 1);

	// read output[13]: from bit 410 to 440
	value = ((uint32_t)(input[51] & 0x3f) << 26) |
			((uint32_t)input[52] << 18) |
			((uint32_t)input[53] << 10) |
			((uint32_t)input[54] << 2) |
			((uint32_t)(input[55] & 0x80) >> 6);
	output[13] = (double)(value >> 1);

	// read output[14]: from bit 441 to 471
	value = ((uint32_t)(input[55] & 0x7f) << 25) |
			((uint32_t)input[56] << 17) |
			((uint32_t)input[57] << 9) |
			((uint32_t)input[58] << 1);
	output[14] = (double)(value >> 1);

	// read output[15]: from bit 472 to 502
	value = ((uint32_t)input[59] << 24) |
			((uint32_t)input[60] << 16) |
			((uint32_t)input[61] << 8) |
			((uint32_t)(input[62] & 0xfe));
	output[15] = (double)(value >> 1);
}


unpack_func_t unpack_31bit[UNPACK_31BIT_MAX_COUNT][8][2] = {
	{
		{
			unpack_1_31bit_unsigned_0off,
			unpack_1_31bit_signed_0off,
		},
		{
			unpack_1_31bit_unsigned_1off,
			unpack_1_31bit_signed_1off,
		},
		{
			unpack_1_31bit_unsigned_2off,
			unpack_1_31bit_signed_2off,
		},
		{
			unpack_1_31bit_unsigned_3off,
			unpack_1_31bit_signed_3off,
		},
		{
			unpack_1_31bit_unsigned_4off,
			unpack_1_31bit_signed_4off,
		},
		{
			unpack_1_31bit_unsigned_5off,
			unpack_1_31bit_signed_5off,
		},
		{
			unpack_1_31bit_unsigned_6off,
			unpack_1_31bit_signed_6off,
		},
		{
			unpack_1_31bit_unsigned_7off,
			unpack_1_31bit_signed_7off,
		},
	},
	{
		{
			unpack_2_31bit_unsigned_0off,
			unpack_2_31bit_signed_0off,
		},
		{
			unpack_2_31bit_unsigned_1off,
			unpack_2_31bit_signed_1off,
		},
		{
			unpack_2_31bit_unsigned_2off,
			unpack_2_31bit_signed_2off,
		},
		{
			unpack_2_31bit_unsigned_3off,
			unpack_2_31bit_signed_3off,
		},
		{
			unpack_2_31bit_unsigned_4off,
			unpack_2_31bit_signed_4off,
		},
		{
			unpack_2_31bit_unsigned_5off,
			unpack_2_31bit_signed_5off,
		},
		{
			unpack_2_31bit_unsigned_6off,
			unpack_2_31bit_signed_6off,
		},
		{
			unpack_2_31bit_unsigned_7off,
			unpack_2_31bit_signed_7off,
		},
	},
	{
		{
			unpack_3_31bit_unsigned_0off,
			unpack_3_31bit_signed_0off,
		},
		{
			unpack_3_31bit_unsigned_1off,
			unpack_3_31bit_signed_1off,
		},
		{
			unpack_3_31bit_unsigned_2off,
			unpack_3_31bit_signed_2off,
		},
		{
			unpack_3_31bit_unsigned_3off,
			unpack_3_31bit_signed_3off,
		},
		{
			unpack_3_31bit_unsigned_4off,
			unpack_3_31bit_signed_4off,
		},
		{
			unpack_3_31bit_unsigned_5off,
			unpack_3_31bit_signed_5off,
		},
		{
			unpack_3_31bit_unsigned_6off,
			unpack_3_31bit_signed_6off,
		},
		{
			unpack_3_31bit_unsigned_7off,
			unpack_3_31bit_signed_7off,
		},
	},
	{
		{
			unpack_4_31bit_unsigned_0off,
			unpack_4_31bit_signed_0off,
		},
		{
			unpack_4_31bit_unsigned_1off,
			unpack_4_31bit_signed_1off,
		},
		{
			unpack_4_31bit_unsigned_2off,
			unpack_4_31bit_signed_2off,
		},
		{
			unpack_4_31bit_unsigned_3off,
			unpack_4_31bit_signed_3off,
		},
		{
			unpack_4_31bit_unsigned_4off,
			unpack_4_31bit_signed_4off,
		},
		{
			unpack_4_31bit_unsigned_5off,
			unpack_4_31bit_signed_5off,
		},
		{
			unpack_4_31bit_unsigned_6off,
			unpack_4_31bit_signed_6off,
		},
		{
			unpack_4_31bit_unsigned_7off,
			unpack_4_31bit_signed_7off,
		},
	},
	{
		{
			unpack_5_31bit_unsigned_0off,
			unpack_5_31bit_signed_0off,
		},
		{
			unpack_5_31bit_unsigned_1off,
			unpack_5_31bit_signed_1off,
		},
		{
			unpack_5_31bit_unsigned_2off,
			unpack_5_31bit_signed_2off,
		},
		{
			unpack_5_31bit_unsigned_3off,
			unpack_5_31bit_signed_3off,
		},
		{
			unpack_5_31bit_unsigned_4off,
			unpack_5_31bit_signed_4off,
		},
		{
			unpack_5_31bit_unsigned_5off,
			unpack_5_31bit_signed_5off,
		},
		{
			unpack_5_31bit_unsigned_6off,
			unpack_5_31bit_signed_6off,
		},
		{
			unpack_5_31bit_unsigned_7off,
			unpack_5_31bit_signed_7off,
		},
	},
	{
		{
			unpack_6_31bit_unsigned_0off,
			unpack_6_31bit_signed_0off,
		},
		{
			unpack_6_31bit_unsigned_1off,
			unpack_6_31bit_signed_1off,
		},
		{
			unpack_6_31bit_unsigned_2off,
			unpack_6_31bit_signed_2off,
		},
		{
			unpack_6_31bit_unsigned_3off,
			unpack_6_31bit_signed_3off,
		},
		{
			unpack_6_31bit_unsigned_4off,
			unpack_6_31bit_signed_4off,
		},
		{
			unpack_6_31bit_unsigned_5off,
			unpack_6_31bit_signed_5off,
		},
		{
			unpack_6_31bit_unsigned_6off,
			unpack_6_31bit_signed_6off,
		},
		{
			unpack_6_31bit_unsigned_7off,
			unpack_6_31bit_signed_7off,
		},
	},
	{
		{
			unpack_7_31bit_unsigned_0off,
			unpack_7_31bit_signed_0off,
		},
		{
			unpack_7_31bit_unsigned_1off,
			unpack_7_31bit_signed_1off,
		},
		{
			unpack_7_31bit_unsigned_2off,
			unpack_7_31bit_signed_2off,
		},
		{
			unpack_7_31bit_unsigned_3off,
			unpack_7_31bit_signed_3off,
		},
		{
			unpack_7_31bit_unsigned_4off,
			unpack_7_31bit_signed_4off,
		},
		{
			unpack_7_31bit_unsigned_5off,
			unpack_7_31bit_signed_5off,
		},
		{
			unpack_7_31bit_unsigned_6off,
			unpack_7_31bit_signed_6off,
		},
		{
			unpack_7_31bit_unsigned_7off,
			unpack_7_31bit_signed_7off,
		},
	},
	{
		{
			unpack_8_31bit_unsigned_0off,
			unpack_8_31bit_signed_0off,
		},
		{
			unpack_8_31bit_unsigned_1off,
			unpack_8_31bit_signed_1off,
		},
		{
			unpack_8_31bit_unsigned_2off,
			unpack_8_31bit_signed_2off,
		},
		{
			unpack_8_31bit_unsigned_3off,
			unpack_8_31bit_signed_3off,
		},
		{
			unpack_8_31bit_unsigned_4off,
			unpack_8_31bit_signed_4off,
		},
		{
			unpack_8_31bit_unsigned_5off,
			unpack_8_31bit_signed_5off,
		},
		{
			unpack_8_31bit_unsigned_6off,
			unpack_8_31bit_signed_6off,
		},
		{
			unpack_8_31bit_unsigned_7off,
			unpack_8_31bit_signed_7off,
		},
	},
	{
		{
			unpack_9_31bit_unsigned_0off,
			unpack_9_31bit_signed_0off,
		},
		{
			unpack_9_31bit_unsigned_1off,
			unpack_9_31bit_signed_1off,
		},
		{
			unpack_9_31bit_unsigned_2off,
			unpack_9_31bit_signed_2off,
		},
		{
			unpack_9_31bit_unsigned_3off,
			unpack_9_31bit_signed_3off,
		},
		{
			unpack_9_31bit_unsigned_4off,
			unpack_9_31bit_signed_4off,
		},
		{
			unpack_9_31bit_unsigned_5off,
			unpack_9_31bit_signed_5off,
		},
		{
			unpack_9_31bit_unsigned_6off,
			unpack_9_31bit_signed_6off,
		},
		{
			unpack_9_31bit_unsigned_7off,
			unpack_9_31bit_signed_7off,
		},
	},
	{
		{
			unpack_10_31bit_unsigned_0off,
			unpack_10_31bit_signed_0off,
		},
		{
			unpack_10_31bit_unsigned_1off,
			unpack_10_31bit_signed_1off,
		},
		{
			unpack_10_31bit_unsigned_2off,
			unpack_10_31bit_signed_2off,
		},
		{
			unpack_10_31bit_unsigned_3off,
			unpack_10_31bit_signed_3off,
		},
		{
			unpack_10_31bit_unsigned_4off,
			unpack_10_31bit_signed_4off,
		},
		{
			unpack_10_31bit_unsigned_5off,
			unpack_10_31bit_signed_5off,
		},
		{
			unpack_10_31bit_unsigned_6off,
			unpack_10_31bit_signed_6off,
		},
		{
			unpack_10_31bit_unsigned_7off,
			unpack_10_31bit_signed_7off,
		},
	},
	{
		{
			unpack_11_31bit_unsigned_0off,
			unpack_11_31bit_signed_0off,
		},
		{
			unpack_11_31bit_unsigned_1off,
			unpack_11_31bit_signed_1off,
		},
		{
			unpack_11_31bit_unsigned_2off,
			unpack_11_31bit_signed_2off,
		},
		{
			unpack_11_31bit_unsigned_3off,
			unpack_11_31bit_signed_3off,
		},
		{
			unpack_11_31bit_unsigned_4off,
			unpack_11_31bit_signed_4off,
		},
		{
			unpack_11_31bit_unsigned_5off,
			unpack_11_31bit_signed_5off,
		},
		{
			unpack_11_31bit_unsigned_6off,
			unpack_11_31bit_signed_6off,
		},
		{
			unpack_11_31bit_unsigned_7off,
			unpack_11_31bit_signed_7off,
		},
	},
	{
		{
			unpack_12_31bit_unsigned_0off,
			unpack_12_31bit_signed_0off,
		},
		{
			unpack_12_31bit_unsigned_1off,
			unpack_12_31bit_signed_1off,
		},
		{
			unpack_12_31bit_unsigned_2off,
			unpack_12_31bit_signed_2off,
		},
		{
			unpack_12_31bit_unsigned_3off,
			unpack_12_31bit_signed_3off,
		},
		{
			unpack_12_31bit_unsigned_4off,
			unpack_12_31bit_signed_4off,
		},
		{
			unpack_12_31bit_unsigned_5off,
			unpack_12_31bit_signed_5off,
		},
		{
			unpack_12_31bit_unsigned_6off,
			unpack_12_31bit_signed_6off,
		},
		{
			unpack_12_31bit_unsigned_7off,
			unpack_12_31bit_signed_7off,
		},
	},
	{
		{
			unpack_13_31bit_unsigned_0off,
			unpack_13_31bit_signed_0off,
		},
		{
			unpack_13_31bit_unsigned_1off,
			unpack_13_31bit_signed_1off,
		},
		{
			unpack_13_31bit_unsigned_2off,
			unpack_13_31bit_signed_2off,
		},
		{
			unpack_13_31bit_unsigned_3off,
			unpack_13_31bit_signed_3off,
		},
		{
			unpack_13_31bit_unsigned_4off,
			unpack_13_31bit_signed_4off,
		},
		{
			unpack_13_31bit_unsigned_5off,
			unpack_13_31bit_signed_5off,
		},
		{
			unpack_13_31bit_unsigned_6off,
			unpack_13_31bit_signed_6off,
		},
		{
			unpack_13_31bit_unsigned_7off,
			unpack_13_31bit_signed_7off,
		},
	},
	{
		{
			unpack_14_31bit_unsigned_0off,
			unpack_14_31bit_signed_0off,
		},
		{
			unpack_14_31bit_unsigned_1off,
			unpack_14_31bit_signed_1off,
		},
		{
			unpack_14_31bit_unsigned_2off,
			unpack_14_31bit_signed_2off,
		},
		{
			unpack_14_31bit_unsigned_3off,
			unpack_14_31bit_signed_3off,
		},
		{
			unpack_14_31bit_unsigned_4off,
			unpack_14_31bit_signed_4off,
		},
		{
			unpack_14_31bit_unsigned_5off,
			unpack_14_31bit_signed_5off,
		},
		{
			unpack_14_31bit_unsigned_6off,
			unpack_14_31bit_signed_6off,
		},
		{
			unpack_14_31bit_unsigned_7off,
			unpack_14_31bit_signed_7off,
		},
	},
	{
		{
			unpack_15_31bit_unsigned_0off,
			unpack_15_31bit_signed_0off,
		},
		{
			unpack_15_31bit_unsigned_1off,
			unpack_15_31bit_signed_1off,
		},
		{
			unpack_15_31bit_unsigned_2off,
			unpack_15_31bit_signed_2off,
		},
		{
			unpack_15_31bit_unsigned_3off,
			unpack_15_31bit_signed_3off,
		},
		{
			unpack_15_31bit_unsigned_4off,
			unpack_15_31bit_signed_4off,
		},
		{
			unpack_15_31bit_unsigned_5off,
			unpack_15_31bit_signed_5off,
		},
		{
			unpack_15_31bit_unsigned_6off,
			unpack_15_31bit_signed_6off,
		},
		{
			unpack_15_31bit_unsigned_7off,
			unpack_15_31bit_signed_7off,
		},
	},
	{
		{
			unpack_16_31bit_unsigned_0off,
			unpack_16_31bit_signed_0off,
		},
		{
			unpack_16_31bit_unsigned_1off,
			unpack_16_31bit_signed_1off,
		},
		{
			unpack_16_31bit_unsigned_2off,
			unpack_16_31bit_signed_2off,
		},
		{
			unpack_16_31bit_unsigned_3off,
			unpack_16_31bit_signed_3off,
		},
		{
			unpack_16_31bit_unsigned_4off,
			unpack_16_31bit_signed_4off,
		},
		{
			unpack_16_31bit_unsigned_5off,
			unpack_16_31bit_signed_5off,
		},
		{
			unpack_16_31bit_unsigned_6off,
			unpack_16_31bit_signed_6off,
		},
		{
			unpack_16_31bit_unsigned_7off,
			unpack_16_31bit_signed_7off,
		},
	},
};
