// AUTOGENERATED FILE. DO NOT MODIFY.

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

#include "unpack27.h"



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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);
}

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

	uint32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);
}

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

	int32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);
}

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

	uint32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);
}

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

	int32_t value;

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

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

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

	uint32_t value;

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

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

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

	int32_t value;

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

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

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

	uint32_t value;

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

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

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

	int32_t value;

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

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

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

	uint32_t value;

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

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

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

	int32_t value;

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

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

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

	uint32_t value;

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

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

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

	int32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);
}

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

	uint32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);
}

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

	int32_t value;

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

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

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

	uint32_t value;

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

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

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

	int32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

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

	uint32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

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

	int32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

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

	uint32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

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

	int32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);
}

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

	int32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);
}

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

	uint32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);
}

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

	int32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);
}

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

	uint32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);
}

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

	int32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);
}

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

	uint32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);
}

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

	int32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);
}

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

	uint32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);
}

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

	int32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

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

	uint32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

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

	int32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);
}

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

	uint32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);
}

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

	int32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);
}

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

	uint32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);
}

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

	int32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);
}

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

	uint32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);
}

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

	int32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);
}

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

	uint32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);
}

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

	int32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);
}

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

	uint32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);
}

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

	int32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);
}

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

	uint32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);
}

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

	int32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);
}

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

	uint32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

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

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

	uint32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

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

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

	int32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

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

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

	uint32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

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

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

	int32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);
}

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

	int32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);
}

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

	uint32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);
}

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

	int32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);
}

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

	uint32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);
}

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

	int32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

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

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

	uint32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

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

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

	int32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

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

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

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

	uint32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

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

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

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

	int32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

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

	// read output[7]: from bit 190 to 216
	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] & 0x80) >> 2);
	output[7] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

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

	// read output[7]: from bit 190 to 216
	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] & 0x80) >> 2);
	output[7] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 191 to 217
	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] & 0xc0) >> 1);
	output[7] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 191 to 217
	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] & 0xc0) >> 1);
	output[7] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 192 to 218
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xe0));
	output[7] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 192 to 218
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xe0));
	output[7] = (double)(value >> 5);
}

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

	int32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);

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

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

	uint32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);

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

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

	int32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 194 to 220
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)input[26] << 10) |
			((uint32_t)(input[27] & 0xf8) << 2);
	output[7] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 194 to 220
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)input[26] << 10) |
			((uint32_t)(input[27] & 0xf8) << 2);
	output[7] = (double)(value >> 5);
}

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

	int32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 195 to 221
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)input[26] << 11) |
			((uint32_t)(input[27] & 0xfc) << 3);
	output[7] = (double)(value >> 5);
}

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

	uint32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 195 to 221
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)input[26] << 11) |
			((uint32_t)(input[27] & 0xfc) << 3);
	output[7] = (double)(value >> 5);
}

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

	int32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 169 to 195
	value = ((uint32_t)(input[21] & 0x7f) << 25) |
			((uint32_t)input[22] << 17) |
			((uint32_t)input[23] << 9) |
			((uint32_t)(input[24] & 0xf0) << 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 196 to 222
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)input[26] << 12) |
			((uint32_t)(input[27] & 0xfe) << 4);
	output[7] = (double)(value >> 5);
}

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

	uint32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 169 to 195
	value = ((uint32_t)(input[21] & 0x7f) << 25) |
			((uint32_t)input[22] << 17) |
			((uint32_t)input[23] << 9) |
			((uint32_t)(input[24] & 0xf0) << 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 196 to 222
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)input[26] << 12) |
			((uint32_t)(input[27] & 0xfe) << 4);
	output[7] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

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

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

	// read output[8]: from bit 216 to 242
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)input[29] << 8) |
			((uint32_t)(input[30] & 0xe0));
	output[8] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

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

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

	// read output[8]: from bit 216 to 242
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)input[29] << 8) |
			((uint32_t)(input[30] & 0xe0));
	output[8] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

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

	// read output[7]: from bit 190 to 216
	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] & 0x80) >> 2);
	output[7] = (double)(value >> 5);

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

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

	uint32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

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

	// read output[7]: from bit 190 to 216
	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] & 0x80) >> 2);
	output[7] = (double)(value >> 5);

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

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

	int32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 191 to 217
	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] & 0xc0) >> 1);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 218 to 244
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)(input[30] & 0xf8) << 2);
	output[8] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 191 to 217
	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] & 0xc0) >> 1);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 218 to 244
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)(input[30] & 0xf8) << 2);
	output[8] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 192 to 218
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xe0));
	output[7] = (double)(value >> 5);

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

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

	uint32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 192 to 218
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xe0));
	output[7] = (double)(value >> 5);

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

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

	int32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);

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

	// read output[8]: from bit 220 to 246
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)(input[30] & 0xfe) << 4);
	output[8] = (double)(value >> 5);
}

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

	uint32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);

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

	// read output[8]: from bit 220 to 246
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)(input[30] & 0xfe) << 4);
	output[8] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 194 to 220
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)input[26] << 10) |
			((uint32_t)(input[27] & 0xf8) << 2);
	output[7] = (double)(value >> 5);

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

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

	uint32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 194 to 220
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)input[26] << 10) |
			((uint32_t)(input[27] & 0xf8) << 2);
	output[7] = (double)(value >> 5);

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

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

	int32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 195 to 221
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)input[26] << 11) |
			((uint32_t)(input[27] & 0xfc) << 3);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 222 to 248
	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] & 0x80) >> 2);
	output[8] = (double)(value >> 5);
}

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

	uint32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 195 to 221
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)input[26] << 11) |
			((uint32_t)(input[27] & 0xfc) << 3);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 222 to 248
	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] & 0x80) >> 2);
	output[8] = (double)(value >> 5);
}

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

	int32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 169 to 195
	value = ((uint32_t)(input[21] & 0x7f) << 25) |
			((uint32_t)input[22] << 17) |
			((uint32_t)input[23] << 9) |
			((uint32_t)(input[24] & 0xf0) << 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 196 to 222
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)input[26] << 12) |
			((uint32_t)(input[27] & 0xfe) << 4);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 223 to 249
	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] & 0xc0) >> 1);
	output[8] = (double)(value >> 5);
}

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

	uint32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 169 to 195
	value = ((uint32_t)(input[21] & 0x7f) << 25) |
			((uint32_t)input[22] << 17) |
			((uint32_t)input[23] << 9) |
			((uint32_t)(input[24] & 0xf0) << 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 196 to 222
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)input[26] << 12) |
			((uint32_t)(input[27] & 0xfe) << 4);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 223 to 249
	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] & 0xc0) >> 1);
	output[8] = (double)(value >> 5);
}

static void unpack_10_27bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 27-bit signed
	// Skip 0 bits, read 270 bits of data.
	// Input must be at least 34 bytes long

	int32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

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

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

	// read output[8]: from bit 216 to 242
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)input[29] << 8) |
			((uint32_t)(input[30] & 0xe0));
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 243 to 269
	value = ((uint32_t)(input[30] & 0x1f) << 27) |
			((uint32_t)input[31] << 19) |
			((uint32_t)input[32] << 11) |
			((uint32_t)(input[33] & 0xfc) << 3);
	output[9] = (double)(value >> 5);
}

static void unpack_10_27bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 27-bit unsigned
	// Skip 0 bits, read 270 bits of data.
	// Input must be at least 34 bytes long

	uint32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

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

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

	// read output[8]: from bit 216 to 242
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)input[29] << 8) |
			((uint32_t)(input[30] & 0xe0));
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 243 to 269
	value = ((uint32_t)(input[30] & 0x1f) << 27) |
			((uint32_t)input[31] << 19) |
			((uint32_t)input[32] << 11) |
			((uint32_t)(input[33] & 0xfc) << 3);
	output[9] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

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

	// read output[7]: from bit 190 to 216
	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] & 0x80) >> 2);
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 244 to 270
	value = ((uint32_t)(input[30] & 0x0f) << 28) |
			((uint32_t)input[31] << 20) |
			((uint32_t)input[32] << 12) |
			((uint32_t)(input[33] & 0xfe) << 4);
	output[9] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

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

	// read output[7]: from bit 190 to 216
	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] & 0x80) >> 2);
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 244 to 270
	value = ((uint32_t)(input[30] & 0x0f) << 28) |
			((uint32_t)input[31] << 20) |
			((uint32_t)input[32] << 12) |
			((uint32_t)(input[33] & 0xfe) << 4);
	output[9] = (double)(value >> 5);
}

static void unpack_10_27bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 27-bit signed
	// Skip 2 bits, read 270 bits of data.
	// Input must be at least 34 bytes long

	int32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 191 to 217
	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] & 0xc0) >> 1);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 218 to 244
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)(input[30] & 0xf8) << 2);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 245 to 271
	value = ((uint32_t)(input[30] & 0x07) << 29) |
			((uint32_t)input[31] << 21) |
			((uint32_t)input[32] << 13) |
			((uint32_t)input[33] << 5);
	output[9] = (double)(value >> 5);
}

static void unpack_10_27bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 27-bit unsigned
	// Skip 2 bits, read 270 bits of data.
	// Input must be at least 34 bytes long

	uint32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 191 to 217
	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] & 0xc0) >> 1);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 218 to 244
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)(input[30] & 0xf8) << 2);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 245 to 271
	value = ((uint32_t)(input[30] & 0x07) << 29) |
			((uint32_t)input[31] << 21) |
			((uint32_t)input[32] << 13) |
			((uint32_t)input[33] << 5);
	output[9] = (double)(value >> 5);
}

static void unpack_10_27bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 27-bit signed
	// Skip 3 bits, read 270 bits of data.
	// Input must be at least 35 bytes long

	int32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 192 to 218
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xe0));
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 246 to 272
	value = ((uint32_t)(input[30] & 0x03) << 30) |
			((uint32_t)input[31] << 22) |
			((uint32_t)input[32] << 14) |
			((uint32_t)input[33] << 6) |
			((uint32_t)(input[34] & 0x80) >> 2);
	output[9] = (double)(value >> 5);
}

static void unpack_10_27bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 27-bit unsigned
	// Skip 3 bits, read 270 bits of data.
	// Input must be at least 35 bytes long

	uint32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 192 to 218
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xe0));
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 246 to 272
	value = ((uint32_t)(input[30] & 0x03) << 30) |
			((uint32_t)input[31] << 22) |
			((uint32_t)input[32] << 14) |
			((uint32_t)input[33] << 6) |
			((uint32_t)(input[34] & 0x80) >> 2);
	output[9] = (double)(value >> 5);
}

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

	int32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);

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

	// read output[8]: from bit 220 to 246
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)(input[30] & 0xfe) << 4);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 247 to 273
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)input[33] << 7) |
			((uint32_t)(input[34] & 0xc0) >> 1);
	output[9] = (double)(value >> 5);
}

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

	uint32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);

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

	// read output[8]: from bit 220 to 246
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)(input[30] & 0xfe) << 4);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 247 to 273
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)input[33] << 7) |
			((uint32_t)(input[34] & 0xc0) >> 1);
	output[9] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 194 to 220
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)input[26] << 10) |
			((uint32_t)(input[27] & 0xf8) << 2);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 221 to 247
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5);
	output[8] = (double)(value >> 5);

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

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

	uint32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 194 to 220
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)input[26] << 10) |
			((uint32_t)(input[27] & 0xf8) << 2);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 221 to 247
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5);
	output[8] = (double)(value >> 5);

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

static void unpack_10_27bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 27-bit signed
	// Skip 6 bits, read 270 bits of data.
	// Input must be at least 35 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 195 to 221
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)input[26] << 11) |
			((uint32_t)(input[27] & 0xfc) << 3);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 222 to 248
	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] & 0x80) >> 2);
	output[8] = (double)(value >> 5);

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

static void unpack_10_27bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 27-bit unsigned
	// Skip 6 bits, read 270 bits of data.
	// Input must be at least 35 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 195 to 221
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)input[26] << 11) |
			((uint32_t)(input[27] & 0xfc) << 3);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 222 to 248
	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] & 0x80) >> 2);
	output[8] = (double)(value >> 5);

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

static void unpack_10_27bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 27-bit signed
	// Skip 7 bits, read 270 bits of data.
	// Input must be at least 35 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 169 to 195
	value = ((uint32_t)(input[21] & 0x7f) << 25) |
			((uint32_t)input[22] << 17) |
			((uint32_t)input[23] << 9) |
			((uint32_t)(input[24] & 0xf0) << 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 196 to 222
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)input[26] << 12) |
			((uint32_t)(input[27] & 0xfe) << 4);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 223 to 249
	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] & 0xc0) >> 1);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 250 to 276
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)(input[34] & 0xf8) << 2);
	output[9] = (double)(value >> 5);
}

static void unpack_10_27bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 27-bit unsigned
	// Skip 7 bits, read 270 bits of data.
	// Input must be at least 35 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 169 to 195
	value = ((uint32_t)(input[21] & 0x7f) << 25) |
			((uint32_t)input[22] << 17) |
			((uint32_t)input[23] << 9) |
			((uint32_t)(input[24] & 0xf0) << 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 196 to 222
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)input[26] << 12) |
			((uint32_t)(input[27] & 0xfe) << 4);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 223 to 249
	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] & 0xc0) >> 1);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 250 to 276
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)(input[34] & 0xf8) << 2);
	output[9] = (double)(value >> 5);
}

static void unpack_11_27bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 27-bit signed
	// Skip 0 bits, read 297 bits of data.
	// Input must be at least 38 bytes long

	int32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

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

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

	// read output[8]: from bit 216 to 242
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)input[29] << 8) |
			((uint32_t)(input[30] & 0xe0));
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 243 to 269
	value = ((uint32_t)(input[30] & 0x1f) << 27) |
			((uint32_t)input[31] << 19) |
			((uint32_t)input[32] << 11) |
			((uint32_t)(input[33] & 0xfc) << 3);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 270 to 296
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)input[36] << 6) |
			((uint32_t)(input[37] & 0x80) >> 2);
	output[10] = (double)(value >> 5);
}

static void unpack_11_27bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 27-bit unsigned
	// Skip 0 bits, read 297 bits of data.
	// Input must be at least 38 bytes long

	uint32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

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

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

	// read output[8]: from bit 216 to 242
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)input[29] << 8) |
			((uint32_t)(input[30] & 0xe0));
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 243 to 269
	value = ((uint32_t)(input[30] & 0x1f) << 27) |
			((uint32_t)input[31] << 19) |
			((uint32_t)input[32] << 11) |
			((uint32_t)(input[33] & 0xfc) << 3);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 270 to 296
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)input[36] << 6) |
			((uint32_t)(input[37] & 0x80) >> 2);
	output[10] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

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

	// read output[7]: from bit 190 to 216
	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] & 0x80) >> 2);
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 244 to 270
	value = ((uint32_t)(input[30] & 0x0f) << 28) |
			((uint32_t)input[31] << 20) |
			((uint32_t)input[32] << 12) |
			((uint32_t)(input[33] & 0xfe) << 4);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 271 to 297
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)input[36] << 7) |
			((uint32_t)(input[37] & 0xc0) >> 1);
	output[10] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

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

	// read output[7]: from bit 190 to 216
	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] & 0x80) >> 2);
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 244 to 270
	value = ((uint32_t)(input[30] & 0x0f) << 28) |
			((uint32_t)input[31] << 20) |
			((uint32_t)input[32] << 12) |
			((uint32_t)(input[33] & 0xfe) << 4);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 271 to 297
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)input[36] << 7) |
			((uint32_t)(input[37] & 0xc0) >> 1);
	output[10] = (double)(value >> 5);
}

static void unpack_11_27bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 27-bit signed
	// Skip 2 bits, read 297 bits of data.
	// Input must be at least 38 bytes long

	int32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 191 to 217
	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] & 0xc0) >> 1);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 218 to 244
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)(input[30] & 0xf8) << 2);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 245 to 271
	value = ((uint32_t)(input[30] & 0x07) << 29) |
			((uint32_t)input[31] << 21) |
			((uint32_t)input[32] << 13) |
			((uint32_t)input[33] << 5);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 272 to 298
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)input[36] << 8) |
			((uint32_t)(input[37] & 0xe0));
	output[10] = (double)(value >> 5);
}

static void unpack_11_27bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 27-bit unsigned
	// Skip 2 bits, read 297 bits of data.
	// Input must be at least 38 bytes long

	uint32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 191 to 217
	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] & 0xc0) >> 1);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 218 to 244
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)(input[30] & 0xf8) << 2);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 245 to 271
	value = ((uint32_t)(input[30] & 0x07) << 29) |
			((uint32_t)input[31] << 21) |
			((uint32_t)input[32] << 13) |
			((uint32_t)input[33] << 5);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 272 to 298
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)input[36] << 8) |
			((uint32_t)(input[37] & 0xe0));
	output[10] = (double)(value >> 5);
}

static void unpack_11_27bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 27-bit signed
	// Skip 3 bits, read 297 bits of data.
	// Input must be at least 38 bytes long

	int32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 192 to 218
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xe0));
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 246 to 272
	value = ((uint32_t)(input[30] & 0x03) << 30) |
			((uint32_t)input[31] << 22) |
			((uint32_t)input[32] << 14) |
			((uint32_t)input[33] << 6) |
			((uint32_t)(input[34] & 0x80) >> 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 273 to 299
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)input[36] << 9) |
			((uint32_t)(input[37] & 0xf0) << 1);
	output[10] = (double)(value >> 5);
}

static void unpack_11_27bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 27-bit unsigned
	// Skip 3 bits, read 297 bits of data.
	// Input must be at least 38 bytes long

	uint32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 192 to 218
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xe0));
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 246 to 272
	value = ((uint32_t)(input[30] & 0x03) << 30) |
			((uint32_t)input[31] << 22) |
			((uint32_t)input[32] << 14) |
			((uint32_t)input[33] << 6) |
			((uint32_t)(input[34] & 0x80) >> 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 273 to 299
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)input[36] << 9) |
			((uint32_t)(input[37] & 0xf0) << 1);
	output[10] = (double)(value >> 5);
}

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

	int32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);

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

	// read output[8]: from bit 220 to 246
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)(input[30] & 0xfe) << 4);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 247 to 273
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)input[33] << 7) |
			((uint32_t)(input[34] & 0xc0) >> 1);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 274 to 300
	value = ((uint32_t)(input[34] & 0x3f) << 26) |
			((uint32_t)input[35] << 18) |
			((uint32_t)input[36] << 10) |
			((uint32_t)(input[37] & 0xf8) << 2);
	output[10] = (double)(value >> 5);
}

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

	uint32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);

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

	// read output[8]: from bit 220 to 246
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)(input[30] & 0xfe) << 4);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 247 to 273
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)input[33] << 7) |
			((uint32_t)(input[34] & 0xc0) >> 1);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 274 to 300
	value = ((uint32_t)(input[34] & 0x3f) << 26) |
			((uint32_t)input[35] << 18) |
			((uint32_t)input[36] << 10) |
			((uint32_t)(input[37] & 0xf8) << 2);
	output[10] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 194 to 220
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)input[26] << 10) |
			((uint32_t)(input[27] & 0xf8) << 2);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 221 to 247
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 248 to 274
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xe0));
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 275 to 301
	value = ((uint32_t)(input[34] & 0x1f) << 27) |
			((uint32_t)input[35] << 19) |
			((uint32_t)input[36] << 11) |
			((uint32_t)(input[37] & 0xfc) << 3);
	output[10] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 194 to 220
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)input[26] << 10) |
			((uint32_t)(input[27] & 0xf8) << 2);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 221 to 247
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 248 to 274
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xe0));
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 275 to 301
	value = ((uint32_t)(input[34] & 0x1f) << 27) |
			((uint32_t)input[35] << 19) |
			((uint32_t)input[36] << 11) |
			((uint32_t)(input[37] & 0xfc) << 3);
	output[10] = (double)(value >> 5);
}

static void unpack_11_27bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 27-bit signed
	// Skip 6 bits, read 297 bits of data.
	// Input must be at least 38 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 195 to 221
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)input[26] << 11) |
			((uint32_t)(input[27] & 0xfc) << 3);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 222 to 248
	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] & 0x80) >> 2);
	output[8] = (double)(value >> 5);

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

	// read output[10]: from bit 276 to 302
	value = ((uint32_t)(input[34] & 0x0f) << 28) |
			((uint32_t)input[35] << 20) |
			((uint32_t)input[36] << 12) |
			((uint32_t)(input[37] & 0xfe) << 4);
	output[10] = (double)(value >> 5);
}

static void unpack_11_27bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 27-bit unsigned
	// Skip 6 bits, read 297 bits of data.
	// Input must be at least 38 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 195 to 221
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)input[26] << 11) |
			((uint32_t)(input[27] & 0xfc) << 3);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 222 to 248
	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] & 0x80) >> 2);
	output[8] = (double)(value >> 5);

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

	// read output[10]: from bit 276 to 302
	value = ((uint32_t)(input[34] & 0x0f) << 28) |
			((uint32_t)input[35] << 20) |
			((uint32_t)input[36] << 12) |
			((uint32_t)(input[37] & 0xfe) << 4);
	output[10] = (double)(value >> 5);
}

static void unpack_11_27bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 27-bit signed
	// Skip 7 bits, read 297 bits of data.
	// Input must be at least 38 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 169 to 195
	value = ((uint32_t)(input[21] & 0x7f) << 25) |
			((uint32_t)input[22] << 17) |
			((uint32_t)input[23] << 9) |
			((uint32_t)(input[24] & 0xf0) << 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 196 to 222
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)input[26] << 12) |
			((uint32_t)(input[27] & 0xfe) << 4);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 223 to 249
	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] & 0xc0) >> 1);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 250 to 276
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)(input[34] & 0xf8) << 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 277 to 303
	value = ((uint32_t)(input[34] & 0x07) << 29) |
			((uint32_t)input[35] << 21) |
			((uint32_t)input[36] << 13) |
			((uint32_t)input[37] << 5);
	output[10] = (double)(value >> 5);
}

static void unpack_11_27bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 27-bit unsigned
	// Skip 7 bits, read 297 bits of data.
	// Input must be at least 38 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 169 to 195
	value = ((uint32_t)(input[21] & 0x7f) << 25) |
			((uint32_t)input[22] << 17) |
			((uint32_t)input[23] << 9) |
			((uint32_t)(input[24] & 0xf0) << 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 196 to 222
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)input[26] << 12) |
			((uint32_t)(input[27] & 0xfe) << 4);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 223 to 249
	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] & 0xc0) >> 1);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 250 to 276
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)(input[34] & 0xf8) << 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 277 to 303
	value = ((uint32_t)(input[34] & 0x07) << 29) |
			((uint32_t)input[35] << 21) |
			((uint32_t)input[36] << 13) |
			((uint32_t)input[37] << 5);
	output[10] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

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

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

	// read output[8]: from bit 216 to 242
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)input[29] << 8) |
			((uint32_t)(input[30] & 0xe0));
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 243 to 269
	value = ((uint32_t)(input[30] & 0x1f) << 27) |
			((uint32_t)input[31] << 19) |
			((uint32_t)input[32] << 11) |
			((uint32_t)(input[33] & 0xfc) << 3);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 270 to 296
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)input[36] << 6) |
			((uint32_t)(input[37] & 0x80) >> 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 297 to 323
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xf0) << 1);
	output[11] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

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

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

	// read output[8]: from bit 216 to 242
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)input[29] << 8) |
			((uint32_t)(input[30] & 0xe0));
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 243 to 269
	value = ((uint32_t)(input[30] & 0x1f) << 27) |
			((uint32_t)input[31] << 19) |
			((uint32_t)input[32] << 11) |
			((uint32_t)(input[33] & 0xfc) << 3);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 270 to 296
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)input[36] << 6) |
			((uint32_t)(input[37] & 0x80) >> 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 297 to 323
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xf0) << 1);
	output[11] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

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

	// read output[7]: from bit 190 to 216
	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] & 0x80) >> 2);
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 244 to 270
	value = ((uint32_t)(input[30] & 0x0f) << 28) |
			((uint32_t)input[31] << 20) |
			((uint32_t)input[32] << 12) |
			((uint32_t)(input[33] & 0xfe) << 4);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 271 to 297
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)input[36] << 7) |
			((uint32_t)(input[37] & 0xc0) >> 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 298 to 324
	value = ((uint32_t)(input[37] & 0x3f) << 26) |
			((uint32_t)input[38] << 18) |
			((uint32_t)input[39] << 10) |
			((uint32_t)(input[40] & 0xf8) << 2);
	output[11] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

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

	// read output[7]: from bit 190 to 216
	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] & 0x80) >> 2);
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 244 to 270
	value = ((uint32_t)(input[30] & 0x0f) << 28) |
			((uint32_t)input[31] << 20) |
			((uint32_t)input[32] << 12) |
			((uint32_t)(input[33] & 0xfe) << 4);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 271 to 297
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)input[36] << 7) |
			((uint32_t)(input[37] & 0xc0) >> 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 298 to 324
	value = ((uint32_t)(input[37] & 0x3f) << 26) |
			((uint32_t)input[38] << 18) |
			((uint32_t)input[39] << 10) |
			((uint32_t)(input[40] & 0xf8) << 2);
	output[11] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 191 to 217
	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] & 0xc0) >> 1);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 218 to 244
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)(input[30] & 0xf8) << 2);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 245 to 271
	value = ((uint32_t)(input[30] & 0x07) << 29) |
			((uint32_t)input[31] << 21) |
			((uint32_t)input[32] << 13) |
			((uint32_t)input[33] << 5);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 272 to 298
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)input[36] << 8) |
			((uint32_t)(input[37] & 0xe0));
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 299 to 325
	value = ((uint32_t)(input[37] & 0x1f) << 27) |
			((uint32_t)input[38] << 19) |
			((uint32_t)input[39] << 11) |
			((uint32_t)(input[40] & 0xfc) << 3);
	output[11] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 191 to 217
	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] & 0xc0) >> 1);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 218 to 244
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)(input[30] & 0xf8) << 2);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 245 to 271
	value = ((uint32_t)(input[30] & 0x07) << 29) |
			((uint32_t)input[31] << 21) |
			((uint32_t)input[32] << 13) |
			((uint32_t)input[33] << 5);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 272 to 298
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)input[36] << 8) |
			((uint32_t)(input[37] & 0xe0));
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 299 to 325
	value = ((uint32_t)(input[37] & 0x1f) << 27) |
			((uint32_t)input[38] << 19) |
			((uint32_t)input[39] << 11) |
			((uint32_t)(input[40] & 0xfc) << 3);
	output[11] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 192 to 218
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xe0));
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 246 to 272
	value = ((uint32_t)(input[30] & 0x03) << 30) |
			((uint32_t)input[31] << 22) |
			((uint32_t)input[32] << 14) |
			((uint32_t)input[33] << 6) |
			((uint32_t)(input[34] & 0x80) >> 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 273 to 299
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)input[36] << 9) |
			((uint32_t)(input[37] & 0xf0) << 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 300 to 326
	value = ((uint32_t)(input[37] & 0x0f) << 28) |
			((uint32_t)input[38] << 20) |
			((uint32_t)input[39] << 12) |
			((uint32_t)(input[40] & 0xfe) << 4);
	output[11] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 192 to 218
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xe0));
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 246 to 272
	value = ((uint32_t)(input[30] & 0x03) << 30) |
			((uint32_t)input[31] << 22) |
			((uint32_t)input[32] << 14) |
			((uint32_t)input[33] << 6) |
			((uint32_t)(input[34] & 0x80) >> 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 273 to 299
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)input[36] << 9) |
			((uint32_t)(input[37] & 0xf0) << 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 300 to 326
	value = ((uint32_t)(input[37] & 0x0f) << 28) |
			((uint32_t)input[38] << 20) |
			((uint32_t)input[39] << 12) |
			((uint32_t)(input[40] & 0xfe) << 4);
	output[11] = (double)(value >> 5);
}

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

	int32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);

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

	// read output[8]: from bit 220 to 246
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)(input[30] & 0xfe) << 4);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 247 to 273
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)input[33] << 7) |
			((uint32_t)(input[34] & 0xc0) >> 1);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 274 to 300
	value = ((uint32_t)(input[34] & 0x3f) << 26) |
			((uint32_t)input[35] << 18) |
			((uint32_t)input[36] << 10) |
			((uint32_t)(input[37] & 0xf8) << 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 301 to 327
	value = ((uint32_t)(input[37] & 0x07) << 29) |
			((uint32_t)input[38] << 21) |
			((uint32_t)input[39] << 13) |
			((uint32_t)input[40] << 5);
	output[11] = (double)(value >> 5);
}

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

	uint32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);

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

	// read output[8]: from bit 220 to 246
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)(input[30] & 0xfe) << 4);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 247 to 273
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)input[33] << 7) |
			((uint32_t)(input[34] & 0xc0) >> 1);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 274 to 300
	value = ((uint32_t)(input[34] & 0x3f) << 26) |
			((uint32_t)input[35] << 18) |
			((uint32_t)input[36] << 10) |
			((uint32_t)(input[37] & 0xf8) << 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 301 to 327
	value = ((uint32_t)(input[37] & 0x07) << 29) |
			((uint32_t)input[38] << 21) |
			((uint32_t)input[39] << 13) |
			((uint32_t)input[40] << 5);
	output[11] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 194 to 220
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)input[26] << 10) |
			((uint32_t)(input[27] & 0xf8) << 2);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 221 to 247
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 248 to 274
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xe0));
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 275 to 301
	value = ((uint32_t)(input[34] & 0x1f) << 27) |
			((uint32_t)input[35] << 19) |
			((uint32_t)input[36] << 11) |
			((uint32_t)(input[37] & 0xfc) << 3);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 302 to 328
	value = ((uint32_t)(input[37] & 0x03) << 30) |
			((uint32_t)input[38] << 22) |
			((uint32_t)input[39] << 14) |
			((uint32_t)input[40] << 6) |
			((uint32_t)(input[41] & 0x80) >> 2);
	output[11] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 194 to 220
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)input[26] << 10) |
			((uint32_t)(input[27] & 0xf8) << 2);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 221 to 247
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 248 to 274
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xe0));
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 275 to 301
	value = ((uint32_t)(input[34] & 0x1f) << 27) |
			((uint32_t)input[35] << 19) |
			((uint32_t)input[36] << 11) |
			((uint32_t)(input[37] & 0xfc) << 3);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 302 to 328
	value = ((uint32_t)(input[37] & 0x03) << 30) |
			((uint32_t)input[38] << 22) |
			((uint32_t)input[39] << 14) |
			((uint32_t)input[40] << 6) |
			((uint32_t)(input[41] & 0x80) >> 2);
	output[11] = (double)(value >> 5);
}

static void unpack_12_27bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 27-bit signed
	// Skip 6 bits, read 324 bits of data.
	// Input must be at least 42 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 195 to 221
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)input[26] << 11) |
			((uint32_t)(input[27] & 0xfc) << 3);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 222 to 248
	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] & 0x80) >> 2);
	output[8] = (double)(value >> 5);

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

	// read output[10]: from bit 276 to 302
	value = ((uint32_t)(input[34] & 0x0f) << 28) |
			((uint32_t)input[35] << 20) |
			((uint32_t)input[36] << 12) |
			((uint32_t)(input[37] & 0xfe) << 4);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 303 to 329
	value = ((uint32_t)(input[37] & 0x01) << 31) |
			((uint32_t)input[38] << 23) |
			((uint32_t)input[39] << 15) |
			((uint32_t)input[40] << 7) |
			((uint32_t)(input[41] & 0xc0) >> 1);
	output[11] = (double)(value >> 5);
}

static void unpack_12_27bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 27-bit unsigned
	// Skip 6 bits, read 324 bits of data.
	// Input must be at least 42 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 195 to 221
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)input[26] << 11) |
			((uint32_t)(input[27] & 0xfc) << 3);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 222 to 248
	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] & 0x80) >> 2);
	output[8] = (double)(value >> 5);

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

	// read output[10]: from bit 276 to 302
	value = ((uint32_t)(input[34] & 0x0f) << 28) |
			((uint32_t)input[35] << 20) |
			((uint32_t)input[36] << 12) |
			((uint32_t)(input[37] & 0xfe) << 4);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 303 to 329
	value = ((uint32_t)(input[37] & 0x01) << 31) |
			((uint32_t)input[38] << 23) |
			((uint32_t)input[39] << 15) |
			((uint32_t)input[40] << 7) |
			((uint32_t)(input[41] & 0xc0) >> 1);
	output[11] = (double)(value >> 5);
}

static void unpack_12_27bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 27-bit signed
	// Skip 7 bits, read 324 bits of data.
	// Input must be at least 42 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 169 to 195
	value = ((uint32_t)(input[21] & 0x7f) << 25) |
			((uint32_t)input[22] << 17) |
			((uint32_t)input[23] << 9) |
			((uint32_t)(input[24] & 0xf0) << 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 196 to 222
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)input[26] << 12) |
			((uint32_t)(input[27] & 0xfe) << 4);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 223 to 249
	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] & 0xc0) >> 1);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 250 to 276
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)(input[34] & 0xf8) << 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 277 to 303
	value = ((uint32_t)(input[34] & 0x07) << 29) |
			((uint32_t)input[35] << 21) |
			((uint32_t)input[36] << 13) |
			((uint32_t)input[37] << 5);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 304 to 330
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)input[40] << 8) |
			((uint32_t)(input[41] & 0xe0));
	output[11] = (double)(value >> 5);
}

static void unpack_12_27bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 27-bit unsigned
	// Skip 7 bits, read 324 bits of data.
	// Input must be at least 42 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 169 to 195
	value = ((uint32_t)(input[21] & 0x7f) << 25) |
			((uint32_t)input[22] << 17) |
			((uint32_t)input[23] << 9) |
			((uint32_t)(input[24] & 0xf0) << 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 196 to 222
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)input[26] << 12) |
			((uint32_t)(input[27] & 0xfe) << 4);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 223 to 249
	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] & 0xc0) >> 1);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 250 to 276
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)(input[34] & 0xf8) << 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 277 to 303
	value = ((uint32_t)(input[34] & 0x07) << 29) |
			((uint32_t)input[35] << 21) |
			((uint32_t)input[36] << 13) |
			((uint32_t)input[37] << 5);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 304 to 330
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)input[40] << 8) |
			((uint32_t)(input[41] & 0xe0));
	output[11] = (double)(value >> 5);
}

static void unpack_13_27bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 27-bit signed
	// Skip 0 bits, read 351 bits of data.
	// Input must be at least 44 bytes long

	int32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

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

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

	// read output[8]: from bit 216 to 242
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)input[29] << 8) |
			((uint32_t)(input[30] & 0xe0));
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 243 to 269
	value = ((uint32_t)(input[30] & 0x1f) << 27) |
			((uint32_t)input[31] << 19) |
			((uint32_t)input[32] << 11) |
			((uint32_t)(input[33] & 0xfc) << 3);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 270 to 296
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)input[36] << 6) |
			((uint32_t)(input[37] & 0x80) >> 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 297 to 323
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xf0) << 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 324 to 350
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)(input[43] & 0xfe) << 4);
	output[12] = (double)(value >> 5);
}

static void unpack_13_27bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 27-bit unsigned
	// Skip 0 bits, read 351 bits of data.
	// Input must be at least 44 bytes long

	uint32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

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

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

	// read output[8]: from bit 216 to 242
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)input[29] << 8) |
			((uint32_t)(input[30] & 0xe0));
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 243 to 269
	value = ((uint32_t)(input[30] & 0x1f) << 27) |
			((uint32_t)input[31] << 19) |
			((uint32_t)input[32] << 11) |
			((uint32_t)(input[33] & 0xfc) << 3);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 270 to 296
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)input[36] << 6) |
			((uint32_t)(input[37] & 0x80) >> 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 297 to 323
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xf0) << 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 324 to 350
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)(input[43] & 0xfe) << 4);
	output[12] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

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

	// read output[7]: from bit 190 to 216
	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] & 0x80) >> 2);
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 244 to 270
	value = ((uint32_t)(input[30] & 0x0f) << 28) |
			((uint32_t)input[31] << 20) |
			((uint32_t)input[32] << 12) |
			((uint32_t)(input[33] & 0xfe) << 4);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 271 to 297
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)input[36] << 7) |
			((uint32_t)(input[37] & 0xc0) >> 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 298 to 324
	value = ((uint32_t)(input[37] & 0x3f) << 26) |
			((uint32_t)input[38] << 18) |
			((uint32_t)input[39] << 10) |
			((uint32_t)(input[40] & 0xf8) << 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 325 to 351
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5);
	output[12] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

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

	// read output[7]: from bit 190 to 216
	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] & 0x80) >> 2);
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 244 to 270
	value = ((uint32_t)(input[30] & 0x0f) << 28) |
			((uint32_t)input[31] << 20) |
			((uint32_t)input[32] << 12) |
			((uint32_t)(input[33] & 0xfe) << 4);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 271 to 297
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)input[36] << 7) |
			((uint32_t)(input[37] & 0xc0) >> 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 298 to 324
	value = ((uint32_t)(input[37] & 0x3f) << 26) |
			((uint32_t)input[38] << 18) |
			((uint32_t)input[39] << 10) |
			((uint32_t)(input[40] & 0xf8) << 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 325 to 351
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5);
	output[12] = (double)(value >> 5);
}

static void unpack_13_27bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 27-bit signed
	// Skip 2 bits, read 351 bits of data.
	// Input must be at least 45 bytes long

	int32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 191 to 217
	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] & 0xc0) >> 1);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 218 to 244
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)(input[30] & 0xf8) << 2);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 245 to 271
	value = ((uint32_t)(input[30] & 0x07) << 29) |
			((uint32_t)input[31] << 21) |
			((uint32_t)input[32] << 13) |
			((uint32_t)input[33] << 5);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 272 to 298
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)input[36] << 8) |
			((uint32_t)(input[37] & 0xe0));
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 299 to 325
	value = ((uint32_t)(input[37] & 0x1f) << 27) |
			((uint32_t)input[38] << 19) |
			((uint32_t)input[39] << 11) |
			((uint32_t)(input[40] & 0xfc) << 3);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 326 to 352
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)input[43] << 6) |
			((uint32_t)(input[44] & 0x80) >> 2);
	output[12] = (double)(value >> 5);
}

static void unpack_13_27bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 27-bit unsigned
	// Skip 2 bits, read 351 bits of data.
	// Input must be at least 45 bytes long

	uint32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 191 to 217
	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] & 0xc0) >> 1);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 218 to 244
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)(input[30] & 0xf8) << 2);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 245 to 271
	value = ((uint32_t)(input[30] & 0x07) << 29) |
			((uint32_t)input[31] << 21) |
			((uint32_t)input[32] << 13) |
			((uint32_t)input[33] << 5);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 272 to 298
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)input[36] << 8) |
			((uint32_t)(input[37] & 0xe0));
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 299 to 325
	value = ((uint32_t)(input[37] & 0x1f) << 27) |
			((uint32_t)input[38] << 19) |
			((uint32_t)input[39] << 11) |
			((uint32_t)(input[40] & 0xfc) << 3);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 326 to 352
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)input[43] << 6) |
			((uint32_t)(input[44] & 0x80) >> 2);
	output[12] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 192 to 218
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xe0));
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 246 to 272
	value = ((uint32_t)(input[30] & 0x03) << 30) |
			((uint32_t)input[31] << 22) |
			((uint32_t)input[32] << 14) |
			((uint32_t)input[33] << 6) |
			((uint32_t)(input[34] & 0x80) >> 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 273 to 299
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)input[36] << 9) |
			((uint32_t)(input[37] & 0xf0) << 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 300 to 326
	value = ((uint32_t)(input[37] & 0x0f) << 28) |
			((uint32_t)input[38] << 20) |
			((uint32_t)input[39] << 12) |
			((uint32_t)(input[40] & 0xfe) << 4);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 327 to 353
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)input[43] << 7) |
			((uint32_t)(input[44] & 0xc0) >> 1);
	output[12] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 192 to 218
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xe0));
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 246 to 272
	value = ((uint32_t)(input[30] & 0x03) << 30) |
			((uint32_t)input[31] << 22) |
			((uint32_t)input[32] << 14) |
			((uint32_t)input[33] << 6) |
			((uint32_t)(input[34] & 0x80) >> 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 273 to 299
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)input[36] << 9) |
			((uint32_t)(input[37] & 0xf0) << 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 300 to 326
	value = ((uint32_t)(input[37] & 0x0f) << 28) |
			((uint32_t)input[38] << 20) |
			((uint32_t)input[39] << 12) |
			((uint32_t)(input[40] & 0xfe) << 4);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 327 to 353
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)input[43] << 7) |
			((uint32_t)(input[44] & 0xc0) >> 1);
	output[12] = (double)(value >> 5);
}

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

	int32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);

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

	// read output[8]: from bit 220 to 246
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)(input[30] & 0xfe) << 4);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 247 to 273
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)input[33] << 7) |
			((uint32_t)(input[34] & 0xc0) >> 1);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 274 to 300
	value = ((uint32_t)(input[34] & 0x3f) << 26) |
			((uint32_t)input[35] << 18) |
			((uint32_t)input[36] << 10) |
			((uint32_t)(input[37] & 0xf8) << 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 301 to 327
	value = ((uint32_t)(input[37] & 0x07) << 29) |
			((uint32_t)input[38] << 21) |
			((uint32_t)input[39] << 13) |
			((uint32_t)input[40] << 5);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 328 to 354
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)input[43] << 8) |
			((uint32_t)(input[44] & 0xe0));
	output[12] = (double)(value >> 5);
}

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

	uint32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);

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

	// read output[8]: from bit 220 to 246
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)(input[30] & 0xfe) << 4);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 247 to 273
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)input[33] << 7) |
			((uint32_t)(input[34] & 0xc0) >> 1);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 274 to 300
	value = ((uint32_t)(input[34] & 0x3f) << 26) |
			((uint32_t)input[35] << 18) |
			((uint32_t)input[36] << 10) |
			((uint32_t)(input[37] & 0xf8) << 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 301 to 327
	value = ((uint32_t)(input[37] & 0x07) << 29) |
			((uint32_t)input[38] << 21) |
			((uint32_t)input[39] << 13) |
			((uint32_t)input[40] << 5);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 328 to 354
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)input[43] << 8) |
			((uint32_t)(input[44] & 0xe0));
	output[12] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 194 to 220
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)input[26] << 10) |
			((uint32_t)(input[27] & 0xf8) << 2);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 221 to 247
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 248 to 274
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xe0));
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 275 to 301
	value = ((uint32_t)(input[34] & 0x1f) << 27) |
			((uint32_t)input[35] << 19) |
			((uint32_t)input[36] << 11) |
			((uint32_t)(input[37] & 0xfc) << 3);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 302 to 328
	value = ((uint32_t)(input[37] & 0x03) << 30) |
			((uint32_t)input[38] << 22) |
			((uint32_t)input[39] << 14) |
			((uint32_t)input[40] << 6) |
			((uint32_t)(input[41] & 0x80) >> 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 329 to 355
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)input[43] << 9) |
			((uint32_t)(input[44] & 0xf0) << 1);
	output[12] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 194 to 220
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)input[26] << 10) |
			((uint32_t)(input[27] & 0xf8) << 2);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 221 to 247
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 248 to 274
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xe0));
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 275 to 301
	value = ((uint32_t)(input[34] & 0x1f) << 27) |
			((uint32_t)input[35] << 19) |
			((uint32_t)input[36] << 11) |
			((uint32_t)(input[37] & 0xfc) << 3);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 302 to 328
	value = ((uint32_t)(input[37] & 0x03) << 30) |
			((uint32_t)input[38] << 22) |
			((uint32_t)input[39] << 14) |
			((uint32_t)input[40] << 6) |
			((uint32_t)(input[41] & 0x80) >> 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 329 to 355
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)input[43] << 9) |
			((uint32_t)(input[44] & 0xf0) << 1);
	output[12] = (double)(value >> 5);
}

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

	int32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 195 to 221
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)input[26] << 11) |
			((uint32_t)(input[27] & 0xfc) << 3);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 222 to 248
	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] & 0x80) >> 2);
	output[8] = (double)(value >> 5);

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

	// read output[10]: from bit 276 to 302
	value = ((uint32_t)(input[34] & 0x0f) << 28) |
			((uint32_t)input[35] << 20) |
			((uint32_t)input[36] << 12) |
			((uint32_t)(input[37] & 0xfe) << 4);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 303 to 329
	value = ((uint32_t)(input[37] & 0x01) << 31) |
			((uint32_t)input[38] << 23) |
			((uint32_t)input[39] << 15) |
			((uint32_t)input[40] << 7) |
			((uint32_t)(input[41] & 0xc0) >> 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 330 to 356
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)input[43] << 10) |
			((uint32_t)(input[44] & 0xf8) << 2);
	output[12] = (double)(value >> 5);
}

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

	uint32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 195 to 221
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)input[26] << 11) |
			((uint32_t)(input[27] & 0xfc) << 3);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 222 to 248
	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] & 0x80) >> 2);
	output[8] = (double)(value >> 5);

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

	// read output[10]: from bit 276 to 302
	value = ((uint32_t)(input[34] & 0x0f) << 28) |
			((uint32_t)input[35] << 20) |
			((uint32_t)input[36] << 12) |
			((uint32_t)(input[37] & 0xfe) << 4);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 303 to 329
	value = ((uint32_t)(input[37] & 0x01) << 31) |
			((uint32_t)input[38] << 23) |
			((uint32_t)input[39] << 15) |
			((uint32_t)input[40] << 7) |
			((uint32_t)(input[41] & 0xc0) >> 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 330 to 356
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)input[43] << 10) |
			((uint32_t)(input[44] & 0xf8) << 2);
	output[12] = (double)(value >> 5);
}

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

	int32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 169 to 195
	value = ((uint32_t)(input[21] & 0x7f) << 25) |
			((uint32_t)input[22] << 17) |
			((uint32_t)input[23] << 9) |
			((uint32_t)(input[24] & 0xf0) << 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 196 to 222
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)input[26] << 12) |
			((uint32_t)(input[27] & 0xfe) << 4);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 223 to 249
	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] & 0xc0) >> 1);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 250 to 276
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)(input[34] & 0xf8) << 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 277 to 303
	value = ((uint32_t)(input[34] & 0x07) << 29) |
			((uint32_t)input[35] << 21) |
			((uint32_t)input[36] << 13) |
			((uint32_t)input[37] << 5);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 304 to 330
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)input[40] << 8) |
			((uint32_t)(input[41] & 0xe0));
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 331 to 357
	value = ((uint32_t)(input[41] & 0x1f) << 27) |
			((uint32_t)input[42] << 19) |
			((uint32_t)input[43] << 11) |
			((uint32_t)(input[44] & 0xfc) << 3);
	output[12] = (double)(value >> 5);
}

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

	uint32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 169 to 195
	value = ((uint32_t)(input[21] & 0x7f) << 25) |
			((uint32_t)input[22] << 17) |
			((uint32_t)input[23] << 9) |
			((uint32_t)(input[24] & 0xf0) << 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 196 to 222
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)input[26] << 12) |
			((uint32_t)(input[27] & 0xfe) << 4);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 223 to 249
	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] & 0xc0) >> 1);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 250 to 276
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)(input[34] & 0xf8) << 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 277 to 303
	value = ((uint32_t)(input[34] & 0x07) << 29) |
			((uint32_t)input[35] << 21) |
			((uint32_t)input[36] << 13) |
			((uint32_t)input[37] << 5);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 304 to 330
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)input[40] << 8) |
			((uint32_t)(input[41] & 0xe0));
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 331 to 357
	value = ((uint32_t)(input[41] & 0x1f) << 27) |
			((uint32_t)input[42] << 19) |
			((uint32_t)input[43] << 11) |
			((uint32_t)(input[44] & 0xfc) << 3);
	output[12] = (double)(value >> 5);
}

static void unpack_14_27bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 27-bit signed
	// Skip 0 bits, read 378 bits of data.
	// Input must be at least 48 bytes long

	int32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

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

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

	// read output[8]: from bit 216 to 242
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)input[29] << 8) |
			((uint32_t)(input[30] & 0xe0));
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 243 to 269
	value = ((uint32_t)(input[30] & 0x1f) << 27) |
			((uint32_t)input[31] << 19) |
			((uint32_t)input[32] << 11) |
			((uint32_t)(input[33] & 0xfc) << 3);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 270 to 296
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)input[36] << 6) |
			((uint32_t)(input[37] & 0x80) >> 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 297 to 323
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xf0) << 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 324 to 350
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)(input[43] & 0xfe) << 4);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 351 to 377
	value = ((uint32_t)(input[43] & 0x01) << 31) |
			((uint32_t)input[44] << 23) |
			((uint32_t)input[45] << 15) |
			((uint32_t)input[46] << 7) |
			((uint32_t)(input[47] & 0xc0) >> 1);
	output[13] = (double)(value >> 5);
}

static void unpack_14_27bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 27-bit unsigned
	// Skip 0 bits, read 378 bits of data.
	// Input must be at least 48 bytes long

	uint32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

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

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

	// read output[8]: from bit 216 to 242
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)input[29] << 8) |
			((uint32_t)(input[30] & 0xe0));
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 243 to 269
	value = ((uint32_t)(input[30] & 0x1f) << 27) |
			((uint32_t)input[31] << 19) |
			((uint32_t)input[32] << 11) |
			((uint32_t)(input[33] & 0xfc) << 3);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 270 to 296
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)input[36] << 6) |
			((uint32_t)(input[37] & 0x80) >> 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 297 to 323
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xf0) << 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 324 to 350
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)(input[43] & 0xfe) << 4);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 351 to 377
	value = ((uint32_t)(input[43] & 0x01) << 31) |
			((uint32_t)input[44] << 23) |
			((uint32_t)input[45] << 15) |
			((uint32_t)input[46] << 7) |
			((uint32_t)(input[47] & 0xc0) >> 1);
	output[13] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

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

	// read output[7]: from bit 190 to 216
	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] & 0x80) >> 2);
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 244 to 270
	value = ((uint32_t)(input[30] & 0x0f) << 28) |
			((uint32_t)input[31] << 20) |
			((uint32_t)input[32] << 12) |
			((uint32_t)(input[33] & 0xfe) << 4);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 271 to 297
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)input[36] << 7) |
			((uint32_t)(input[37] & 0xc0) >> 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 298 to 324
	value = ((uint32_t)(input[37] & 0x3f) << 26) |
			((uint32_t)input[38] << 18) |
			((uint32_t)input[39] << 10) |
			((uint32_t)(input[40] & 0xf8) << 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 325 to 351
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 352 to 378
	value = ((uint32_t)input[44] << 24) |
			((uint32_t)input[45] << 16) |
			((uint32_t)input[46] << 8) |
			((uint32_t)(input[47] & 0xe0));
	output[13] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

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

	// read output[7]: from bit 190 to 216
	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] & 0x80) >> 2);
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 244 to 270
	value = ((uint32_t)(input[30] & 0x0f) << 28) |
			((uint32_t)input[31] << 20) |
			((uint32_t)input[32] << 12) |
			((uint32_t)(input[33] & 0xfe) << 4);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 271 to 297
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)input[36] << 7) |
			((uint32_t)(input[37] & 0xc0) >> 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 298 to 324
	value = ((uint32_t)(input[37] & 0x3f) << 26) |
			((uint32_t)input[38] << 18) |
			((uint32_t)input[39] << 10) |
			((uint32_t)(input[40] & 0xf8) << 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 325 to 351
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 352 to 378
	value = ((uint32_t)input[44] << 24) |
			((uint32_t)input[45] << 16) |
			((uint32_t)input[46] << 8) |
			((uint32_t)(input[47] & 0xe0));
	output[13] = (double)(value >> 5);
}

static void unpack_14_27bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 27-bit signed
	// Skip 2 bits, read 378 bits of data.
	// Input must be at least 48 bytes long

	int32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 191 to 217
	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] & 0xc0) >> 1);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 218 to 244
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)(input[30] & 0xf8) << 2);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 245 to 271
	value = ((uint32_t)(input[30] & 0x07) << 29) |
			((uint32_t)input[31] << 21) |
			((uint32_t)input[32] << 13) |
			((uint32_t)input[33] << 5);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 272 to 298
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)input[36] << 8) |
			((uint32_t)(input[37] & 0xe0));
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 299 to 325
	value = ((uint32_t)(input[37] & 0x1f) << 27) |
			((uint32_t)input[38] << 19) |
			((uint32_t)input[39] << 11) |
			((uint32_t)(input[40] & 0xfc) << 3);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 326 to 352
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)input[43] << 6) |
			((uint32_t)(input[44] & 0x80) >> 2);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 353 to 379
	value = ((uint32_t)(input[44] & 0x7f) << 25) |
			((uint32_t)input[45] << 17) |
			((uint32_t)input[46] << 9) |
			((uint32_t)(input[47] & 0xf0) << 1);
	output[13] = (double)(value >> 5);
}

static void unpack_14_27bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 27-bit unsigned
	// Skip 2 bits, read 378 bits of data.
	// Input must be at least 48 bytes long

	uint32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 191 to 217
	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] & 0xc0) >> 1);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 218 to 244
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)(input[30] & 0xf8) << 2);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 245 to 271
	value = ((uint32_t)(input[30] & 0x07) << 29) |
			((uint32_t)input[31] << 21) |
			((uint32_t)input[32] << 13) |
			((uint32_t)input[33] << 5);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 272 to 298
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)input[36] << 8) |
			((uint32_t)(input[37] & 0xe0));
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 299 to 325
	value = ((uint32_t)(input[37] & 0x1f) << 27) |
			((uint32_t)input[38] << 19) |
			((uint32_t)input[39] << 11) |
			((uint32_t)(input[40] & 0xfc) << 3);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 326 to 352
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)input[43] << 6) |
			((uint32_t)(input[44] & 0x80) >> 2);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 353 to 379
	value = ((uint32_t)(input[44] & 0x7f) << 25) |
			((uint32_t)input[45] << 17) |
			((uint32_t)input[46] << 9) |
			((uint32_t)(input[47] & 0xf0) << 1);
	output[13] = (double)(value >> 5);
}

static void unpack_14_27bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 27-bit signed
	// Skip 3 bits, read 378 bits of data.
	// Input must be at least 48 bytes long

	int32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 192 to 218
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xe0));
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 246 to 272
	value = ((uint32_t)(input[30] & 0x03) << 30) |
			((uint32_t)input[31] << 22) |
			((uint32_t)input[32] << 14) |
			((uint32_t)input[33] << 6) |
			((uint32_t)(input[34] & 0x80) >> 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 273 to 299
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)input[36] << 9) |
			((uint32_t)(input[37] & 0xf0) << 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 300 to 326
	value = ((uint32_t)(input[37] & 0x0f) << 28) |
			((uint32_t)input[38] << 20) |
			((uint32_t)input[39] << 12) |
			((uint32_t)(input[40] & 0xfe) << 4);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 327 to 353
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)input[43] << 7) |
			((uint32_t)(input[44] & 0xc0) >> 1);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 354 to 380
	value = ((uint32_t)(input[44] & 0x3f) << 26) |
			((uint32_t)input[45] << 18) |
			((uint32_t)input[46] << 10) |
			((uint32_t)(input[47] & 0xf8) << 2);
	output[13] = (double)(value >> 5);
}

static void unpack_14_27bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 27-bit unsigned
	// Skip 3 bits, read 378 bits of data.
	// Input must be at least 48 bytes long

	uint32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 192 to 218
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xe0));
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 246 to 272
	value = ((uint32_t)(input[30] & 0x03) << 30) |
			((uint32_t)input[31] << 22) |
			((uint32_t)input[32] << 14) |
			((uint32_t)input[33] << 6) |
			((uint32_t)(input[34] & 0x80) >> 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 273 to 299
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)input[36] << 9) |
			((uint32_t)(input[37] & 0xf0) << 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 300 to 326
	value = ((uint32_t)(input[37] & 0x0f) << 28) |
			((uint32_t)input[38] << 20) |
			((uint32_t)input[39] << 12) |
			((uint32_t)(input[40] & 0xfe) << 4);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 327 to 353
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)input[43] << 7) |
			((uint32_t)(input[44] & 0xc0) >> 1);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 354 to 380
	value = ((uint32_t)(input[44] & 0x3f) << 26) |
			((uint32_t)input[45] << 18) |
			((uint32_t)input[46] << 10) |
			((uint32_t)(input[47] & 0xf8) << 2);
	output[13] = (double)(value >> 5);
}

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

	int32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);

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

	// read output[8]: from bit 220 to 246
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)(input[30] & 0xfe) << 4);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 247 to 273
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)input[33] << 7) |
			((uint32_t)(input[34] & 0xc0) >> 1);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 274 to 300
	value = ((uint32_t)(input[34] & 0x3f) << 26) |
			((uint32_t)input[35] << 18) |
			((uint32_t)input[36] << 10) |
			((uint32_t)(input[37] & 0xf8) << 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 301 to 327
	value = ((uint32_t)(input[37] & 0x07) << 29) |
			((uint32_t)input[38] << 21) |
			((uint32_t)input[39] << 13) |
			((uint32_t)input[40] << 5);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 328 to 354
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)input[43] << 8) |
			((uint32_t)(input[44] & 0xe0));
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 355 to 381
	value = ((uint32_t)(input[44] & 0x1f) << 27) |
			((uint32_t)input[45] << 19) |
			((uint32_t)input[46] << 11) |
			((uint32_t)(input[47] & 0xfc) << 3);
	output[13] = (double)(value >> 5);
}

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

	uint32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);

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

	// read output[8]: from bit 220 to 246
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)(input[30] & 0xfe) << 4);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 247 to 273
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)input[33] << 7) |
			((uint32_t)(input[34] & 0xc0) >> 1);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 274 to 300
	value = ((uint32_t)(input[34] & 0x3f) << 26) |
			((uint32_t)input[35] << 18) |
			((uint32_t)input[36] << 10) |
			((uint32_t)(input[37] & 0xf8) << 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 301 to 327
	value = ((uint32_t)(input[37] & 0x07) << 29) |
			((uint32_t)input[38] << 21) |
			((uint32_t)input[39] << 13) |
			((uint32_t)input[40] << 5);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 328 to 354
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)input[43] << 8) |
			((uint32_t)(input[44] & 0xe0));
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 355 to 381
	value = ((uint32_t)(input[44] & 0x1f) << 27) |
			((uint32_t)input[45] << 19) |
			((uint32_t)input[46] << 11) |
			((uint32_t)(input[47] & 0xfc) << 3);
	output[13] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 194 to 220
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)input[26] << 10) |
			((uint32_t)(input[27] & 0xf8) << 2);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 221 to 247
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 248 to 274
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xe0));
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 275 to 301
	value = ((uint32_t)(input[34] & 0x1f) << 27) |
			((uint32_t)input[35] << 19) |
			((uint32_t)input[36] << 11) |
			((uint32_t)(input[37] & 0xfc) << 3);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 302 to 328
	value = ((uint32_t)(input[37] & 0x03) << 30) |
			((uint32_t)input[38] << 22) |
			((uint32_t)input[39] << 14) |
			((uint32_t)input[40] << 6) |
			((uint32_t)(input[41] & 0x80) >> 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 329 to 355
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)input[43] << 9) |
			((uint32_t)(input[44] & 0xf0) << 1);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 356 to 382
	value = ((uint32_t)(input[44] & 0x0f) << 28) |
			((uint32_t)input[45] << 20) |
			((uint32_t)input[46] << 12) |
			((uint32_t)(input[47] & 0xfe) << 4);
	output[13] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 194 to 220
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)input[26] << 10) |
			((uint32_t)(input[27] & 0xf8) << 2);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 221 to 247
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 248 to 274
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xe0));
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 275 to 301
	value = ((uint32_t)(input[34] & 0x1f) << 27) |
			((uint32_t)input[35] << 19) |
			((uint32_t)input[36] << 11) |
			((uint32_t)(input[37] & 0xfc) << 3);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 302 to 328
	value = ((uint32_t)(input[37] & 0x03) << 30) |
			((uint32_t)input[38] << 22) |
			((uint32_t)input[39] << 14) |
			((uint32_t)input[40] << 6) |
			((uint32_t)(input[41] & 0x80) >> 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 329 to 355
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)input[43] << 9) |
			((uint32_t)(input[44] & 0xf0) << 1);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 356 to 382
	value = ((uint32_t)(input[44] & 0x0f) << 28) |
			((uint32_t)input[45] << 20) |
			((uint32_t)input[46] << 12) |
			((uint32_t)(input[47] & 0xfe) << 4);
	output[13] = (double)(value >> 5);
}

static void unpack_14_27bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 27-bit signed
	// Skip 6 bits, read 378 bits of data.
	// Input must be at least 48 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 195 to 221
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)input[26] << 11) |
			((uint32_t)(input[27] & 0xfc) << 3);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 222 to 248
	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] & 0x80) >> 2);
	output[8] = (double)(value >> 5);

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

	// read output[10]: from bit 276 to 302
	value = ((uint32_t)(input[34] & 0x0f) << 28) |
			((uint32_t)input[35] << 20) |
			((uint32_t)input[36] << 12) |
			((uint32_t)(input[37] & 0xfe) << 4);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 303 to 329
	value = ((uint32_t)(input[37] & 0x01) << 31) |
			((uint32_t)input[38] << 23) |
			((uint32_t)input[39] << 15) |
			((uint32_t)input[40] << 7) |
			((uint32_t)(input[41] & 0xc0) >> 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 330 to 356
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)input[43] << 10) |
			((uint32_t)(input[44] & 0xf8) << 2);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 357 to 383
	value = ((uint32_t)(input[44] & 0x07) << 29) |
			((uint32_t)input[45] << 21) |
			((uint32_t)input[46] << 13) |
			((uint32_t)input[47] << 5);
	output[13] = (double)(value >> 5);
}

static void unpack_14_27bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 27-bit unsigned
	// Skip 6 bits, read 378 bits of data.
	// Input must be at least 48 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 195 to 221
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)input[26] << 11) |
			((uint32_t)(input[27] & 0xfc) << 3);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 222 to 248
	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] & 0x80) >> 2);
	output[8] = (double)(value >> 5);

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

	// read output[10]: from bit 276 to 302
	value = ((uint32_t)(input[34] & 0x0f) << 28) |
			((uint32_t)input[35] << 20) |
			((uint32_t)input[36] << 12) |
			((uint32_t)(input[37] & 0xfe) << 4);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 303 to 329
	value = ((uint32_t)(input[37] & 0x01) << 31) |
			((uint32_t)input[38] << 23) |
			((uint32_t)input[39] << 15) |
			((uint32_t)input[40] << 7) |
			((uint32_t)(input[41] & 0xc0) >> 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 330 to 356
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)input[43] << 10) |
			((uint32_t)(input[44] & 0xf8) << 2);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 357 to 383
	value = ((uint32_t)(input[44] & 0x07) << 29) |
			((uint32_t)input[45] << 21) |
			((uint32_t)input[46] << 13) |
			((uint32_t)input[47] << 5);
	output[13] = (double)(value >> 5);
}

static void unpack_14_27bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 27-bit signed
	// Skip 7 bits, read 378 bits of data.
	// Input must be at least 49 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 169 to 195
	value = ((uint32_t)(input[21] & 0x7f) << 25) |
			((uint32_t)input[22] << 17) |
			((uint32_t)input[23] << 9) |
			((uint32_t)(input[24] & 0xf0) << 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 196 to 222
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)input[26] << 12) |
			((uint32_t)(input[27] & 0xfe) << 4);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 223 to 249
	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] & 0xc0) >> 1);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 250 to 276
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)(input[34] & 0xf8) << 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 277 to 303
	value = ((uint32_t)(input[34] & 0x07) << 29) |
			((uint32_t)input[35] << 21) |
			((uint32_t)input[36] << 13) |
			((uint32_t)input[37] << 5);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 304 to 330
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)input[40] << 8) |
			((uint32_t)(input[41] & 0xe0));
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 331 to 357
	value = ((uint32_t)(input[41] & 0x1f) << 27) |
			((uint32_t)input[42] << 19) |
			((uint32_t)input[43] << 11) |
			((uint32_t)(input[44] & 0xfc) << 3);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 358 to 384
	value = ((uint32_t)(input[44] & 0x03) << 30) |
			((uint32_t)input[45] << 22) |
			((uint32_t)input[46] << 14) |
			((uint32_t)input[47] << 6) |
			((uint32_t)(input[48] & 0x80) >> 2);
	output[13] = (double)(value >> 5);
}

static void unpack_14_27bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 27-bit unsigned
	// Skip 7 bits, read 378 bits of data.
	// Input must be at least 49 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 169 to 195
	value = ((uint32_t)(input[21] & 0x7f) << 25) |
			((uint32_t)input[22] << 17) |
			((uint32_t)input[23] << 9) |
			((uint32_t)(input[24] & 0xf0) << 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 196 to 222
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)input[26] << 12) |
			((uint32_t)(input[27] & 0xfe) << 4);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 223 to 249
	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] & 0xc0) >> 1);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 250 to 276
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)(input[34] & 0xf8) << 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 277 to 303
	value = ((uint32_t)(input[34] & 0x07) << 29) |
			((uint32_t)input[35] << 21) |
			((uint32_t)input[36] << 13) |
			((uint32_t)input[37] << 5);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 304 to 330
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)input[40] << 8) |
			((uint32_t)(input[41] & 0xe0));
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 331 to 357
	value = ((uint32_t)(input[41] & 0x1f) << 27) |
			((uint32_t)input[42] << 19) |
			((uint32_t)input[43] << 11) |
			((uint32_t)(input[44] & 0xfc) << 3);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 358 to 384
	value = ((uint32_t)(input[44] & 0x03) << 30) |
			((uint32_t)input[45] << 22) |
			((uint32_t)input[46] << 14) |
			((uint32_t)input[47] << 6) |
			((uint32_t)(input[48] & 0x80) >> 2);
	output[13] = (double)(value >> 5);
}

static void unpack_15_27bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 27-bit signed
	// Skip 0 bits, read 405 bits of data.
	// Input must be at least 51 bytes long

	int32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

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

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

	// read output[8]: from bit 216 to 242
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)input[29] << 8) |
			((uint32_t)(input[30] & 0xe0));
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 243 to 269
	value = ((uint32_t)(input[30] & 0x1f) << 27) |
			((uint32_t)input[31] << 19) |
			((uint32_t)input[32] << 11) |
			((uint32_t)(input[33] & 0xfc) << 3);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 270 to 296
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)input[36] << 6) |
			((uint32_t)(input[37] & 0x80) >> 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 297 to 323
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xf0) << 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 324 to 350
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)(input[43] & 0xfe) << 4);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 351 to 377
	value = ((uint32_t)(input[43] & 0x01) << 31) |
			((uint32_t)input[44] << 23) |
			((uint32_t)input[45] << 15) |
			((uint32_t)input[46] << 7) |
			((uint32_t)(input[47] & 0xc0) >> 1);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 378 to 404
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)(input[50] & 0xf8) << 2);
	output[14] = (double)(value >> 5);
}

static void unpack_15_27bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 27-bit unsigned
	// Skip 0 bits, read 405 bits of data.
	// Input must be at least 51 bytes long

	uint32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

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

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

	// read output[8]: from bit 216 to 242
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)input[29] << 8) |
			((uint32_t)(input[30] & 0xe0));
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 243 to 269
	value = ((uint32_t)(input[30] & 0x1f) << 27) |
			((uint32_t)input[31] << 19) |
			((uint32_t)input[32] << 11) |
			((uint32_t)(input[33] & 0xfc) << 3);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 270 to 296
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)input[36] << 6) |
			((uint32_t)(input[37] & 0x80) >> 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 297 to 323
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xf0) << 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 324 to 350
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)(input[43] & 0xfe) << 4);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 351 to 377
	value = ((uint32_t)(input[43] & 0x01) << 31) |
			((uint32_t)input[44] << 23) |
			((uint32_t)input[45] << 15) |
			((uint32_t)input[46] << 7) |
			((uint32_t)(input[47] & 0xc0) >> 1);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 378 to 404
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)(input[50] & 0xf8) << 2);
	output[14] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

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

	// read output[7]: from bit 190 to 216
	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] & 0x80) >> 2);
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 244 to 270
	value = ((uint32_t)(input[30] & 0x0f) << 28) |
			((uint32_t)input[31] << 20) |
			((uint32_t)input[32] << 12) |
			((uint32_t)(input[33] & 0xfe) << 4);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 271 to 297
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)input[36] << 7) |
			((uint32_t)(input[37] & 0xc0) >> 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 298 to 324
	value = ((uint32_t)(input[37] & 0x3f) << 26) |
			((uint32_t)input[38] << 18) |
			((uint32_t)input[39] << 10) |
			((uint32_t)(input[40] & 0xf8) << 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 325 to 351
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 352 to 378
	value = ((uint32_t)input[44] << 24) |
			((uint32_t)input[45] << 16) |
			((uint32_t)input[46] << 8) |
			((uint32_t)(input[47] & 0xe0));
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 379 to 405
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)(input[50] & 0xfc) << 3);
	output[14] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

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

	// read output[7]: from bit 190 to 216
	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] & 0x80) >> 2);
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 244 to 270
	value = ((uint32_t)(input[30] & 0x0f) << 28) |
			((uint32_t)input[31] << 20) |
			((uint32_t)input[32] << 12) |
			((uint32_t)(input[33] & 0xfe) << 4);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 271 to 297
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)input[36] << 7) |
			((uint32_t)(input[37] & 0xc0) >> 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 298 to 324
	value = ((uint32_t)(input[37] & 0x3f) << 26) |
			((uint32_t)input[38] << 18) |
			((uint32_t)input[39] << 10) |
			((uint32_t)(input[40] & 0xf8) << 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 325 to 351
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 352 to 378
	value = ((uint32_t)input[44] << 24) |
			((uint32_t)input[45] << 16) |
			((uint32_t)input[46] << 8) |
			((uint32_t)(input[47] & 0xe0));
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 379 to 405
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)(input[50] & 0xfc) << 3);
	output[14] = (double)(value >> 5);
}

static void unpack_15_27bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 27-bit signed
	// Skip 2 bits, read 405 bits of data.
	// Input must be at least 51 bytes long

	int32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 191 to 217
	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] & 0xc0) >> 1);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 218 to 244
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)(input[30] & 0xf8) << 2);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 245 to 271
	value = ((uint32_t)(input[30] & 0x07) << 29) |
			((uint32_t)input[31] << 21) |
			((uint32_t)input[32] << 13) |
			((uint32_t)input[33] << 5);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 272 to 298
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)input[36] << 8) |
			((uint32_t)(input[37] & 0xe0));
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 299 to 325
	value = ((uint32_t)(input[37] & 0x1f) << 27) |
			((uint32_t)input[38] << 19) |
			((uint32_t)input[39] << 11) |
			((uint32_t)(input[40] & 0xfc) << 3);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 326 to 352
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)input[43] << 6) |
			((uint32_t)(input[44] & 0x80) >> 2);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 353 to 379
	value = ((uint32_t)(input[44] & 0x7f) << 25) |
			((uint32_t)input[45] << 17) |
			((uint32_t)input[46] << 9) |
			((uint32_t)(input[47] & 0xf0) << 1);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 380 to 406
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)input[49] << 12) |
			((uint32_t)(input[50] & 0xfe) << 4);
	output[14] = (double)(value >> 5);
}

static void unpack_15_27bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 27-bit unsigned
	// Skip 2 bits, read 405 bits of data.
	// Input must be at least 51 bytes long

	uint32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 191 to 217
	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] & 0xc0) >> 1);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 218 to 244
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)(input[30] & 0xf8) << 2);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 245 to 271
	value = ((uint32_t)(input[30] & 0x07) << 29) |
			((uint32_t)input[31] << 21) |
			((uint32_t)input[32] << 13) |
			((uint32_t)input[33] << 5);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 272 to 298
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)input[36] << 8) |
			((uint32_t)(input[37] & 0xe0));
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 299 to 325
	value = ((uint32_t)(input[37] & 0x1f) << 27) |
			((uint32_t)input[38] << 19) |
			((uint32_t)input[39] << 11) |
			((uint32_t)(input[40] & 0xfc) << 3);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 326 to 352
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)input[43] << 6) |
			((uint32_t)(input[44] & 0x80) >> 2);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 353 to 379
	value = ((uint32_t)(input[44] & 0x7f) << 25) |
			((uint32_t)input[45] << 17) |
			((uint32_t)input[46] << 9) |
			((uint32_t)(input[47] & 0xf0) << 1);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 380 to 406
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)input[49] << 12) |
			((uint32_t)(input[50] & 0xfe) << 4);
	output[14] = (double)(value >> 5);
}

static void unpack_15_27bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 27-bit signed
	// Skip 3 bits, read 405 bits of data.
	// Input must be at least 51 bytes long

	int32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 192 to 218
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xe0));
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 246 to 272
	value = ((uint32_t)(input[30] & 0x03) << 30) |
			((uint32_t)input[31] << 22) |
			((uint32_t)input[32] << 14) |
			((uint32_t)input[33] << 6) |
			((uint32_t)(input[34] & 0x80) >> 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 273 to 299
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)input[36] << 9) |
			((uint32_t)(input[37] & 0xf0) << 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 300 to 326
	value = ((uint32_t)(input[37] & 0x0f) << 28) |
			((uint32_t)input[38] << 20) |
			((uint32_t)input[39] << 12) |
			((uint32_t)(input[40] & 0xfe) << 4);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 327 to 353
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)input[43] << 7) |
			((uint32_t)(input[44] & 0xc0) >> 1);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 354 to 380
	value = ((uint32_t)(input[44] & 0x3f) << 26) |
			((uint32_t)input[45] << 18) |
			((uint32_t)input[46] << 10) |
			((uint32_t)(input[47] & 0xf8) << 2);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 381 to 407
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13) |
			((uint32_t)input[50] << 5);
	output[14] = (double)(value >> 5);
}

static void unpack_15_27bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 27-bit unsigned
	// Skip 3 bits, read 405 bits of data.
	// Input must be at least 51 bytes long

	uint32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 192 to 218
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xe0));
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 246 to 272
	value = ((uint32_t)(input[30] & 0x03) << 30) |
			((uint32_t)input[31] << 22) |
			((uint32_t)input[32] << 14) |
			((uint32_t)input[33] << 6) |
			((uint32_t)(input[34] & 0x80) >> 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 273 to 299
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)input[36] << 9) |
			((uint32_t)(input[37] & 0xf0) << 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 300 to 326
	value = ((uint32_t)(input[37] & 0x0f) << 28) |
			((uint32_t)input[38] << 20) |
			((uint32_t)input[39] << 12) |
			((uint32_t)(input[40] & 0xfe) << 4);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 327 to 353
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)input[43] << 7) |
			((uint32_t)(input[44] & 0xc0) >> 1);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 354 to 380
	value = ((uint32_t)(input[44] & 0x3f) << 26) |
			((uint32_t)input[45] << 18) |
			((uint32_t)input[46] << 10) |
			((uint32_t)(input[47] & 0xf8) << 2);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 381 to 407
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13) |
			((uint32_t)input[50] << 5);
	output[14] = (double)(value >> 5);
}

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

	int32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);

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

	// read output[8]: from bit 220 to 246
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)(input[30] & 0xfe) << 4);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 247 to 273
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)input[33] << 7) |
			((uint32_t)(input[34] & 0xc0) >> 1);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 274 to 300
	value = ((uint32_t)(input[34] & 0x3f) << 26) |
			((uint32_t)input[35] << 18) |
			((uint32_t)input[36] << 10) |
			((uint32_t)(input[37] & 0xf8) << 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 301 to 327
	value = ((uint32_t)(input[37] & 0x07) << 29) |
			((uint32_t)input[38] << 21) |
			((uint32_t)input[39] << 13) |
			((uint32_t)input[40] << 5);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 328 to 354
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)input[43] << 8) |
			((uint32_t)(input[44] & 0xe0));
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 355 to 381
	value = ((uint32_t)(input[44] & 0x1f) << 27) |
			((uint32_t)input[45] << 19) |
			((uint32_t)input[46] << 11) |
			((uint32_t)(input[47] & 0xfc) << 3);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 382 to 408
	value = ((uint32_t)(input[47] & 0x03) << 30) |
			((uint32_t)input[48] << 22) |
			((uint32_t)input[49] << 14) |
			((uint32_t)input[50] << 6) |
			((uint32_t)(input[51] & 0x80) >> 2);
	output[14] = (double)(value >> 5);
}

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

	uint32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);

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

	// read output[8]: from bit 220 to 246
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)(input[30] & 0xfe) << 4);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 247 to 273
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)input[33] << 7) |
			((uint32_t)(input[34] & 0xc0) >> 1);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 274 to 300
	value = ((uint32_t)(input[34] & 0x3f) << 26) |
			((uint32_t)input[35] << 18) |
			((uint32_t)input[36] << 10) |
			((uint32_t)(input[37] & 0xf8) << 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 301 to 327
	value = ((uint32_t)(input[37] & 0x07) << 29) |
			((uint32_t)input[38] << 21) |
			((uint32_t)input[39] << 13) |
			((uint32_t)input[40] << 5);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 328 to 354
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)input[43] << 8) |
			((uint32_t)(input[44] & 0xe0));
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 355 to 381
	value = ((uint32_t)(input[44] & 0x1f) << 27) |
			((uint32_t)input[45] << 19) |
			((uint32_t)input[46] << 11) |
			((uint32_t)(input[47] & 0xfc) << 3);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 382 to 408
	value = ((uint32_t)(input[47] & 0x03) << 30) |
			((uint32_t)input[48] << 22) |
			((uint32_t)input[49] << 14) |
			((uint32_t)input[50] << 6) |
			((uint32_t)(input[51] & 0x80) >> 2);
	output[14] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 194 to 220
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)input[26] << 10) |
			((uint32_t)(input[27] & 0xf8) << 2);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 221 to 247
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 248 to 274
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xe0));
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 275 to 301
	value = ((uint32_t)(input[34] & 0x1f) << 27) |
			((uint32_t)input[35] << 19) |
			((uint32_t)input[36] << 11) |
			((uint32_t)(input[37] & 0xfc) << 3);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 302 to 328
	value = ((uint32_t)(input[37] & 0x03) << 30) |
			((uint32_t)input[38] << 22) |
			((uint32_t)input[39] << 14) |
			((uint32_t)input[40] << 6) |
			((uint32_t)(input[41] & 0x80) >> 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 329 to 355
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)input[43] << 9) |
			((uint32_t)(input[44] & 0xf0) << 1);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 356 to 382
	value = ((uint32_t)(input[44] & 0x0f) << 28) |
			((uint32_t)input[45] << 20) |
			((uint32_t)input[46] << 12) |
			((uint32_t)(input[47] & 0xfe) << 4);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 383 to 409
	value = ((uint32_t)(input[47] & 0x01) << 31) |
			((uint32_t)input[48] << 23) |
			((uint32_t)input[49] << 15) |
			((uint32_t)input[50] << 7) |
			((uint32_t)(input[51] & 0xc0) >> 1);
	output[14] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 194 to 220
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)input[26] << 10) |
			((uint32_t)(input[27] & 0xf8) << 2);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 221 to 247
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 248 to 274
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xe0));
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 275 to 301
	value = ((uint32_t)(input[34] & 0x1f) << 27) |
			((uint32_t)input[35] << 19) |
			((uint32_t)input[36] << 11) |
			((uint32_t)(input[37] & 0xfc) << 3);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 302 to 328
	value = ((uint32_t)(input[37] & 0x03) << 30) |
			((uint32_t)input[38] << 22) |
			((uint32_t)input[39] << 14) |
			((uint32_t)input[40] << 6) |
			((uint32_t)(input[41] & 0x80) >> 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 329 to 355
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)input[43] << 9) |
			((uint32_t)(input[44] & 0xf0) << 1);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 356 to 382
	value = ((uint32_t)(input[44] & 0x0f) << 28) |
			((uint32_t)input[45] << 20) |
			((uint32_t)input[46] << 12) |
			((uint32_t)(input[47] & 0xfe) << 4);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 383 to 409
	value = ((uint32_t)(input[47] & 0x01) << 31) |
			((uint32_t)input[48] << 23) |
			((uint32_t)input[49] << 15) |
			((uint32_t)input[50] << 7) |
			((uint32_t)(input[51] & 0xc0) >> 1);
	output[14] = (double)(value >> 5);
}

static void unpack_15_27bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 27-bit signed
	// Skip 6 bits, read 405 bits of data.
	// Input must be at least 52 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 195 to 221
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)input[26] << 11) |
			((uint32_t)(input[27] & 0xfc) << 3);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 222 to 248
	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] & 0x80) >> 2);
	output[8] = (double)(value >> 5);

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

	// read output[10]: from bit 276 to 302
	value = ((uint32_t)(input[34] & 0x0f) << 28) |
			((uint32_t)input[35] << 20) |
			((uint32_t)input[36] << 12) |
			((uint32_t)(input[37] & 0xfe) << 4);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 303 to 329
	value = ((uint32_t)(input[37] & 0x01) << 31) |
			((uint32_t)input[38] << 23) |
			((uint32_t)input[39] << 15) |
			((uint32_t)input[40] << 7) |
			((uint32_t)(input[41] & 0xc0) >> 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 330 to 356
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)input[43] << 10) |
			((uint32_t)(input[44] & 0xf8) << 2);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 357 to 383
	value = ((uint32_t)(input[44] & 0x07) << 29) |
			((uint32_t)input[45] << 21) |
			((uint32_t)input[46] << 13) |
			((uint32_t)input[47] << 5);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 384 to 410
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)input[50] << 8) |
			((uint32_t)(input[51] & 0xe0));
	output[14] = (double)(value >> 5);
}

static void unpack_15_27bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 27-bit unsigned
	// Skip 6 bits, read 405 bits of data.
	// Input must be at least 52 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 195 to 221
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)input[26] << 11) |
			((uint32_t)(input[27] & 0xfc) << 3);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 222 to 248
	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] & 0x80) >> 2);
	output[8] = (double)(value >> 5);

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

	// read output[10]: from bit 276 to 302
	value = ((uint32_t)(input[34] & 0x0f) << 28) |
			((uint32_t)input[35] << 20) |
			((uint32_t)input[36] << 12) |
			((uint32_t)(input[37] & 0xfe) << 4);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 303 to 329
	value = ((uint32_t)(input[37] & 0x01) << 31) |
			((uint32_t)input[38] << 23) |
			((uint32_t)input[39] << 15) |
			((uint32_t)input[40] << 7) |
			((uint32_t)(input[41] & 0xc0) >> 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 330 to 356
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)input[43] << 10) |
			((uint32_t)(input[44] & 0xf8) << 2);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 357 to 383
	value = ((uint32_t)(input[44] & 0x07) << 29) |
			((uint32_t)input[45] << 21) |
			((uint32_t)input[46] << 13) |
			((uint32_t)input[47] << 5);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 384 to 410
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)input[50] << 8) |
			((uint32_t)(input[51] & 0xe0));
	output[14] = (double)(value >> 5);
}

static void unpack_15_27bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 27-bit signed
	// Skip 7 bits, read 405 bits of data.
	// Input must be at least 52 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 169 to 195
	value = ((uint32_t)(input[21] & 0x7f) << 25) |
			((uint32_t)input[22] << 17) |
			((uint32_t)input[23] << 9) |
			((uint32_t)(input[24] & 0xf0) << 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 196 to 222
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)input[26] << 12) |
			((uint32_t)(input[27] & 0xfe) << 4);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 223 to 249
	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] & 0xc0) >> 1);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 250 to 276
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)(input[34] & 0xf8) << 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 277 to 303
	value = ((uint32_t)(input[34] & 0x07) << 29) |
			((uint32_t)input[35] << 21) |
			((uint32_t)input[36] << 13) |
			((uint32_t)input[37] << 5);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 304 to 330
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)input[40] << 8) |
			((uint32_t)(input[41] & 0xe0));
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 331 to 357
	value = ((uint32_t)(input[41] & 0x1f) << 27) |
			((uint32_t)input[42] << 19) |
			((uint32_t)input[43] << 11) |
			((uint32_t)(input[44] & 0xfc) << 3);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 358 to 384
	value = ((uint32_t)(input[44] & 0x03) << 30) |
			((uint32_t)input[45] << 22) |
			((uint32_t)input[46] << 14) |
			((uint32_t)input[47] << 6) |
			((uint32_t)(input[48] & 0x80) >> 2);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 385 to 411
	value = ((uint32_t)(input[48] & 0x7f) << 25) |
			((uint32_t)input[49] << 17) |
			((uint32_t)input[50] << 9) |
			((uint32_t)(input[51] & 0xf0) << 1);
	output[14] = (double)(value >> 5);
}

static void unpack_15_27bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 27-bit unsigned
	// Skip 7 bits, read 405 bits of data.
	// Input must be at least 52 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 169 to 195
	value = ((uint32_t)(input[21] & 0x7f) << 25) |
			((uint32_t)input[22] << 17) |
			((uint32_t)input[23] << 9) |
			((uint32_t)(input[24] & 0xf0) << 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 196 to 222
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)input[26] << 12) |
			((uint32_t)(input[27] & 0xfe) << 4);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 223 to 249
	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] & 0xc0) >> 1);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 250 to 276
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)(input[34] & 0xf8) << 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 277 to 303
	value = ((uint32_t)(input[34] & 0x07) << 29) |
			((uint32_t)input[35] << 21) |
			((uint32_t)input[36] << 13) |
			((uint32_t)input[37] << 5);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 304 to 330
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)input[40] << 8) |
			((uint32_t)(input[41] & 0xe0));
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 331 to 357
	value = ((uint32_t)(input[41] & 0x1f) << 27) |
			((uint32_t)input[42] << 19) |
			((uint32_t)input[43] << 11) |
			((uint32_t)(input[44] & 0xfc) << 3);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 358 to 384
	value = ((uint32_t)(input[44] & 0x03) << 30) |
			((uint32_t)input[45] << 22) |
			((uint32_t)input[46] << 14) |
			((uint32_t)input[47] << 6) |
			((uint32_t)(input[48] & 0x80) >> 2);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 385 to 411
	value = ((uint32_t)(input[48] & 0x7f) << 25) |
			((uint32_t)input[49] << 17) |
			((uint32_t)input[50] << 9) |
			((uint32_t)(input[51] & 0xf0) << 1);
	output[14] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

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

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

	// read output[8]: from bit 216 to 242
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)input[29] << 8) |
			((uint32_t)(input[30] & 0xe0));
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 243 to 269
	value = ((uint32_t)(input[30] & 0x1f) << 27) |
			((uint32_t)input[31] << 19) |
			((uint32_t)input[32] << 11) |
			((uint32_t)(input[33] & 0xfc) << 3);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 270 to 296
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)input[36] << 6) |
			((uint32_t)(input[37] & 0x80) >> 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 297 to 323
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xf0) << 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 324 to 350
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)(input[43] & 0xfe) << 4);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 351 to 377
	value = ((uint32_t)(input[43] & 0x01) << 31) |
			((uint32_t)input[44] << 23) |
			((uint32_t)input[45] << 15) |
			((uint32_t)input[46] << 7) |
			((uint32_t)(input[47] & 0xc0) >> 1);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 378 to 404
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)(input[50] & 0xf8) << 2);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 405 to 431
	value = ((uint32_t)(input[50] & 0x07) << 29) |
			((uint32_t)input[51] << 21) |
			((uint32_t)input[52] << 13) |
			((uint32_t)input[53] << 5);
	output[15] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

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

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

	// read output[8]: from bit 216 to 242
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)input[29] << 8) |
			((uint32_t)(input[30] & 0xe0));
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 243 to 269
	value = ((uint32_t)(input[30] & 0x1f) << 27) |
			((uint32_t)input[31] << 19) |
			((uint32_t)input[32] << 11) |
			((uint32_t)(input[33] & 0xfc) << 3);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 270 to 296
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)input[36] << 6) |
			((uint32_t)(input[37] & 0x80) >> 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 297 to 323
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xf0) << 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 324 to 350
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)(input[43] & 0xfe) << 4);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 351 to 377
	value = ((uint32_t)(input[43] & 0x01) << 31) |
			((uint32_t)input[44] << 23) |
			((uint32_t)input[45] << 15) |
			((uint32_t)input[46] << 7) |
			((uint32_t)(input[47] & 0xc0) >> 1);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 378 to 404
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)(input[50] & 0xf8) << 2);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 405 to 431
	value = ((uint32_t)(input[50] & 0x07) << 29) |
			((uint32_t)input[51] << 21) |
			((uint32_t)input[52] << 13) |
			((uint32_t)input[53] << 5);
	output[15] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

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

	// read output[7]: from bit 190 to 216
	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] & 0x80) >> 2);
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 244 to 270
	value = ((uint32_t)(input[30] & 0x0f) << 28) |
			((uint32_t)input[31] << 20) |
			((uint32_t)input[32] << 12) |
			((uint32_t)(input[33] & 0xfe) << 4);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 271 to 297
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)input[36] << 7) |
			((uint32_t)(input[37] & 0xc0) >> 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 298 to 324
	value = ((uint32_t)(input[37] & 0x3f) << 26) |
			((uint32_t)input[38] << 18) |
			((uint32_t)input[39] << 10) |
			((uint32_t)(input[40] & 0xf8) << 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 325 to 351
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 352 to 378
	value = ((uint32_t)input[44] << 24) |
			((uint32_t)input[45] << 16) |
			((uint32_t)input[46] << 8) |
			((uint32_t)(input[47] & 0xe0));
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 379 to 405
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)(input[50] & 0xfc) << 3);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 406 to 432
	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] & 0x80) >> 2);
	output[15] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

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

	// read output[7]: from bit 190 to 216
	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] & 0x80) >> 2);
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 244 to 270
	value = ((uint32_t)(input[30] & 0x0f) << 28) |
			((uint32_t)input[31] << 20) |
			((uint32_t)input[32] << 12) |
			((uint32_t)(input[33] & 0xfe) << 4);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 271 to 297
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)input[36] << 7) |
			((uint32_t)(input[37] & 0xc0) >> 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 298 to 324
	value = ((uint32_t)(input[37] & 0x3f) << 26) |
			((uint32_t)input[38] << 18) |
			((uint32_t)input[39] << 10) |
			((uint32_t)(input[40] & 0xf8) << 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 325 to 351
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 352 to 378
	value = ((uint32_t)input[44] << 24) |
			((uint32_t)input[45] << 16) |
			((uint32_t)input[46] << 8) |
			((uint32_t)(input[47] & 0xe0));
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 379 to 405
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)(input[50] & 0xfc) << 3);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 406 to 432
	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] & 0x80) >> 2);
	output[15] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 191 to 217
	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] & 0xc0) >> 1);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 218 to 244
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)(input[30] & 0xf8) << 2);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 245 to 271
	value = ((uint32_t)(input[30] & 0x07) << 29) |
			((uint32_t)input[31] << 21) |
			((uint32_t)input[32] << 13) |
			((uint32_t)input[33] << 5);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 272 to 298
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)input[36] << 8) |
			((uint32_t)(input[37] & 0xe0));
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 299 to 325
	value = ((uint32_t)(input[37] & 0x1f) << 27) |
			((uint32_t)input[38] << 19) |
			((uint32_t)input[39] << 11) |
			((uint32_t)(input[40] & 0xfc) << 3);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 326 to 352
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)input[43] << 6) |
			((uint32_t)(input[44] & 0x80) >> 2);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 353 to 379
	value = ((uint32_t)(input[44] & 0x7f) << 25) |
			((uint32_t)input[45] << 17) |
			((uint32_t)input[46] << 9) |
			((uint32_t)(input[47] & 0xf0) << 1);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 380 to 406
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)input[49] << 12) |
			((uint32_t)(input[50] & 0xfe) << 4);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 407 to 433
	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] & 0xc0) >> 1);
	output[15] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 191 to 217
	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] & 0xc0) >> 1);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 218 to 244
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)(input[30] & 0xf8) << 2);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 245 to 271
	value = ((uint32_t)(input[30] & 0x07) << 29) |
			((uint32_t)input[31] << 21) |
			((uint32_t)input[32] << 13) |
			((uint32_t)input[33] << 5);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 272 to 298
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)input[36] << 8) |
			((uint32_t)(input[37] & 0xe0));
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 299 to 325
	value = ((uint32_t)(input[37] & 0x1f) << 27) |
			((uint32_t)input[38] << 19) |
			((uint32_t)input[39] << 11) |
			((uint32_t)(input[40] & 0xfc) << 3);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 326 to 352
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)input[43] << 6) |
			((uint32_t)(input[44] & 0x80) >> 2);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 353 to 379
	value = ((uint32_t)(input[44] & 0x7f) << 25) |
			((uint32_t)input[45] << 17) |
			((uint32_t)input[46] << 9) |
			((uint32_t)(input[47] & 0xf0) << 1);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 380 to 406
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)input[49] << 12) |
			((uint32_t)(input[50] & 0xfe) << 4);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 407 to 433
	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] & 0xc0) >> 1);
	output[15] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 192 to 218
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xe0));
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 246 to 272
	value = ((uint32_t)(input[30] & 0x03) << 30) |
			((uint32_t)input[31] << 22) |
			((uint32_t)input[32] << 14) |
			((uint32_t)input[33] << 6) |
			((uint32_t)(input[34] & 0x80) >> 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 273 to 299
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)input[36] << 9) |
			((uint32_t)(input[37] & 0xf0) << 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 300 to 326
	value = ((uint32_t)(input[37] & 0x0f) << 28) |
			((uint32_t)input[38] << 20) |
			((uint32_t)input[39] << 12) |
			((uint32_t)(input[40] & 0xfe) << 4);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 327 to 353
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)input[43] << 7) |
			((uint32_t)(input[44] & 0xc0) >> 1);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 354 to 380
	value = ((uint32_t)(input[44] & 0x3f) << 26) |
			((uint32_t)input[45] << 18) |
			((uint32_t)input[46] << 10) |
			((uint32_t)(input[47] & 0xf8) << 2);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 381 to 407
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13) |
			((uint32_t)input[50] << 5);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 408 to 434
	value = ((uint32_t)input[51] << 24) |
			((uint32_t)input[52] << 16) |
			((uint32_t)input[53] << 8) |
			((uint32_t)(input[54] & 0xe0));
	output[15] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 192 to 218
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xe0));
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 246 to 272
	value = ((uint32_t)(input[30] & 0x03) << 30) |
			((uint32_t)input[31] << 22) |
			((uint32_t)input[32] << 14) |
			((uint32_t)input[33] << 6) |
			((uint32_t)(input[34] & 0x80) >> 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 273 to 299
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)input[36] << 9) |
			((uint32_t)(input[37] & 0xf0) << 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 300 to 326
	value = ((uint32_t)(input[37] & 0x0f) << 28) |
			((uint32_t)input[38] << 20) |
			((uint32_t)input[39] << 12) |
			((uint32_t)(input[40] & 0xfe) << 4);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 327 to 353
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)input[43] << 7) |
			((uint32_t)(input[44] & 0xc0) >> 1);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 354 to 380
	value = ((uint32_t)(input[44] & 0x3f) << 26) |
			((uint32_t)input[45] << 18) |
			((uint32_t)input[46] << 10) |
			((uint32_t)(input[47] & 0xf8) << 2);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 381 to 407
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13) |
			((uint32_t)input[50] << 5);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 408 to 434
	value = ((uint32_t)input[51] << 24) |
			((uint32_t)input[52] << 16) |
			((uint32_t)input[53] << 8) |
			((uint32_t)(input[54] & 0xe0));
	output[15] = (double)(value >> 5);
}

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

	int32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);

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

	// read output[8]: from bit 220 to 246
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)(input[30] & 0xfe) << 4);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 247 to 273
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)input[33] << 7) |
			((uint32_t)(input[34] & 0xc0) >> 1);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 274 to 300
	value = ((uint32_t)(input[34] & 0x3f) << 26) |
			((uint32_t)input[35] << 18) |
			((uint32_t)input[36] << 10) |
			((uint32_t)(input[37] & 0xf8) << 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 301 to 327
	value = ((uint32_t)(input[37] & 0x07) << 29) |
			((uint32_t)input[38] << 21) |
			((uint32_t)input[39] << 13) |
			((uint32_t)input[40] << 5);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 328 to 354
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)input[43] << 8) |
			((uint32_t)(input[44] & 0xe0));
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 355 to 381
	value = ((uint32_t)(input[44] & 0x1f) << 27) |
			((uint32_t)input[45] << 19) |
			((uint32_t)input[46] << 11) |
			((uint32_t)(input[47] & 0xfc) << 3);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 382 to 408
	value = ((uint32_t)(input[47] & 0x03) << 30) |
			((uint32_t)input[48] << 22) |
			((uint32_t)input[49] << 14) |
			((uint32_t)input[50] << 6) |
			((uint32_t)(input[51] & 0x80) >> 2);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 409 to 435
	value = ((uint32_t)(input[51] & 0x7f) << 25) |
			((uint32_t)input[52] << 17) |
			((uint32_t)input[53] << 9) |
			((uint32_t)(input[54] & 0xf0) << 1);
	output[15] = (double)(value >> 5);
}

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

	uint32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);

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

	// read output[8]: from bit 220 to 246
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)(input[30] & 0xfe) << 4);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 247 to 273
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)input[33] << 7) |
			((uint32_t)(input[34] & 0xc0) >> 1);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 274 to 300
	value = ((uint32_t)(input[34] & 0x3f) << 26) |
			((uint32_t)input[35] << 18) |
			((uint32_t)input[36] << 10) |
			((uint32_t)(input[37] & 0xf8) << 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 301 to 327
	value = ((uint32_t)(input[37] & 0x07) << 29) |
			((uint32_t)input[38] << 21) |
			((uint32_t)input[39] << 13) |
			((uint32_t)input[40] << 5);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 328 to 354
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)input[43] << 8) |
			((uint32_t)(input[44] & 0xe0));
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 355 to 381
	value = ((uint32_t)(input[44] & 0x1f) << 27) |
			((uint32_t)input[45] << 19) |
			((uint32_t)input[46] << 11) |
			((uint32_t)(input[47] & 0xfc) << 3);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 382 to 408
	value = ((uint32_t)(input[47] & 0x03) << 30) |
			((uint32_t)input[48] << 22) |
			((uint32_t)input[49] << 14) |
			((uint32_t)input[50] << 6) |
			((uint32_t)(input[51] & 0x80) >> 2);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 409 to 435
	value = ((uint32_t)(input[51] & 0x7f) << 25) |
			((uint32_t)input[52] << 17) |
			((uint32_t)input[53] << 9) |
			((uint32_t)(input[54] & 0xf0) << 1);
	output[15] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 194 to 220
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)input[26] << 10) |
			((uint32_t)(input[27] & 0xf8) << 2);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 221 to 247
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 248 to 274
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xe0));
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 275 to 301
	value = ((uint32_t)(input[34] & 0x1f) << 27) |
			((uint32_t)input[35] << 19) |
			((uint32_t)input[36] << 11) |
			((uint32_t)(input[37] & 0xfc) << 3);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 302 to 328
	value = ((uint32_t)(input[37] & 0x03) << 30) |
			((uint32_t)input[38] << 22) |
			((uint32_t)input[39] << 14) |
			((uint32_t)input[40] << 6) |
			((uint32_t)(input[41] & 0x80) >> 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 329 to 355
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)input[43] << 9) |
			((uint32_t)(input[44] & 0xf0) << 1);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 356 to 382
	value = ((uint32_t)(input[44] & 0x0f) << 28) |
			((uint32_t)input[45] << 20) |
			((uint32_t)input[46] << 12) |
			((uint32_t)(input[47] & 0xfe) << 4);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 383 to 409
	value = ((uint32_t)(input[47] & 0x01) << 31) |
			((uint32_t)input[48] << 23) |
			((uint32_t)input[49] << 15) |
			((uint32_t)input[50] << 7) |
			((uint32_t)(input[51] & 0xc0) >> 1);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 410 to 436
	value = ((uint32_t)(input[51] & 0x3f) << 26) |
			((uint32_t)input[52] << 18) |
			((uint32_t)input[53] << 10) |
			((uint32_t)(input[54] & 0xf8) << 2);
	output[15] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 194 to 220
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)input[26] << 10) |
			((uint32_t)(input[27] & 0xf8) << 2);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 221 to 247
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 248 to 274
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xe0));
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 275 to 301
	value = ((uint32_t)(input[34] & 0x1f) << 27) |
			((uint32_t)input[35] << 19) |
			((uint32_t)input[36] << 11) |
			((uint32_t)(input[37] & 0xfc) << 3);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 302 to 328
	value = ((uint32_t)(input[37] & 0x03) << 30) |
			((uint32_t)input[38] << 22) |
			((uint32_t)input[39] << 14) |
			((uint32_t)input[40] << 6) |
			((uint32_t)(input[41] & 0x80) >> 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 329 to 355
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)input[43] << 9) |
			((uint32_t)(input[44] & 0xf0) << 1);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 356 to 382
	value = ((uint32_t)(input[44] & 0x0f) << 28) |
			((uint32_t)input[45] << 20) |
			((uint32_t)input[46] << 12) |
			((uint32_t)(input[47] & 0xfe) << 4);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 383 to 409
	value = ((uint32_t)(input[47] & 0x01) << 31) |
			((uint32_t)input[48] << 23) |
			((uint32_t)input[49] << 15) |
			((uint32_t)input[50] << 7) |
			((uint32_t)(input[51] & 0xc0) >> 1);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 410 to 436
	value = ((uint32_t)(input[51] & 0x3f) << 26) |
			((uint32_t)input[52] << 18) |
			((uint32_t)input[53] << 10) |
			((uint32_t)(input[54] & 0xf8) << 2);
	output[15] = (double)(value >> 5);
}

static void unpack_16_27bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 27-bit signed
	// Skip 6 bits, read 432 bits of data.
	// Input must be at least 55 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 195 to 221
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)input[26] << 11) |
			((uint32_t)(input[27] & 0xfc) << 3);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 222 to 248
	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] & 0x80) >> 2);
	output[8] = (double)(value >> 5);

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

	// read output[10]: from bit 276 to 302
	value = ((uint32_t)(input[34] & 0x0f) << 28) |
			((uint32_t)input[35] << 20) |
			((uint32_t)input[36] << 12) |
			((uint32_t)(input[37] & 0xfe) << 4);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 303 to 329
	value = ((uint32_t)(input[37] & 0x01) << 31) |
			((uint32_t)input[38] << 23) |
			((uint32_t)input[39] << 15) |
			((uint32_t)input[40] << 7) |
			((uint32_t)(input[41] & 0xc0) >> 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 330 to 356
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)input[43] << 10) |
			((uint32_t)(input[44] & 0xf8) << 2);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 357 to 383
	value = ((uint32_t)(input[44] & 0x07) << 29) |
			((uint32_t)input[45] << 21) |
			((uint32_t)input[46] << 13) |
			((uint32_t)input[47] << 5);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 384 to 410
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)input[50] << 8) |
			((uint32_t)(input[51] & 0xe0));
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 411 to 437
	value = ((uint32_t)(input[51] & 0x1f) << 27) |
			((uint32_t)input[52] << 19) |
			((uint32_t)input[53] << 11) |
			((uint32_t)(input[54] & 0xfc) << 3);
	output[15] = (double)(value >> 5);
}

static void unpack_16_27bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 27-bit unsigned
	// Skip 6 bits, read 432 bits of data.
	// Input must be at least 55 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

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

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 195 to 221
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)input[26] << 11) |
			((uint32_t)(input[27] & 0xfc) << 3);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 222 to 248
	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] & 0x80) >> 2);
	output[8] = (double)(value >> 5);

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

	// read output[10]: from bit 276 to 302
	value = ((uint32_t)(input[34] & 0x0f) << 28) |
			((uint32_t)input[35] << 20) |
			((uint32_t)input[36] << 12) |
			((uint32_t)(input[37] & 0xfe) << 4);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 303 to 329
	value = ((uint32_t)(input[37] & 0x01) << 31) |
			((uint32_t)input[38] << 23) |
			((uint32_t)input[39] << 15) |
			((uint32_t)input[40] << 7) |
			((uint32_t)(input[41] & 0xc0) >> 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 330 to 356
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)input[43] << 10) |
			((uint32_t)(input[44] & 0xf8) << 2);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 357 to 383
	value = ((uint32_t)(input[44] & 0x07) << 29) |
			((uint32_t)input[45] << 21) |
			((uint32_t)input[46] << 13) |
			((uint32_t)input[47] << 5);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 384 to 410
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)input[50] << 8) |
			((uint32_t)(input[51] & 0xe0));
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 411 to 437
	value = ((uint32_t)(input[51] & 0x1f) << 27) |
			((uint32_t)input[52] << 19) |
			((uint32_t)input[53] << 11) |
			((uint32_t)(input[54] & 0xfc) << 3);
	output[15] = (double)(value >> 5);
}

static void unpack_16_27bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 27-bit signed
	// Skip 7 bits, read 432 bits of data.
	// Input must be at least 55 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 169 to 195
	value = ((uint32_t)(input[21] & 0x7f) << 25) |
			((uint32_t)input[22] << 17) |
			((uint32_t)input[23] << 9) |
			((uint32_t)(input[24] & 0xf0) << 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 196 to 222
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)input[26] << 12) |
			((uint32_t)(input[27] & 0xfe) << 4);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 223 to 249
	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] & 0xc0) >> 1);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 250 to 276
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)(input[34] & 0xf8) << 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 277 to 303
	value = ((uint32_t)(input[34] & 0x07) << 29) |
			((uint32_t)input[35] << 21) |
			((uint32_t)input[36] << 13) |
			((uint32_t)input[37] << 5);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 304 to 330
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)input[40] << 8) |
			((uint32_t)(input[41] & 0xe0));
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 331 to 357
	value = ((uint32_t)(input[41] & 0x1f) << 27) |
			((uint32_t)input[42] << 19) |
			((uint32_t)input[43] << 11) |
			((uint32_t)(input[44] & 0xfc) << 3);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 358 to 384
	value = ((uint32_t)(input[44] & 0x03) << 30) |
			((uint32_t)input[45] << 22) |
			((uint32_t)input[46] << 14) |
			((uint32_t)input[47] << 6) |
			((uint32_t)(input[48] & 0x80) >> 2);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 385 to 411
	value = ((uint32_t)(input[48] & 0x7f) << 25) |
			((uint32_t)input[49] << 17) |
			((uint32_t)input[50] << 9) |
			((uint32_t)(input[51] & 0xf0) << 1);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 412 to 438
	value = ((uint32_t)(input[51] & 0x0f) << 28) |
			((uint32_t)input[52] << 20) |
			((uint32_t)input[53] << 12) |
			((uint32_t)(input[54] & 0xfe) << 4);
	output[15] = (double)(value >> 5);
}

static void unpack_16_27bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 27-bit unsigned
	// Skip 7 bits, read 432 bits of data.
	// Input must be at least 55 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

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

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 169 to 195
	value = ((uint32_t)(input[21] & 0x7f) << 25) |
			((uint32_t)input[22] << 17) |
			((uint32_t)input[23] << 9) |
			((uint32_t)(input[24] & 0xf0) << 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 196 to 222
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)input[26] << 12) |
			((uint32_t)(input[27] & 0xfe) << 4);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 223 to 249
	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] & 0xc0) >> 1);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 250 to 276
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)(input[34] & 0xf8) << 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 277 to 303
	value = ((uint32_t)(input[34] & 0x07) << 29) |
			((uint32_t)input[35] << 21) |
			((uint32_t)input[36] << 13) |
			((uint32_t)input[37] << 5);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 304 to 330
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)input[40] << 8) |
			((uint32_t)(input[41] & 0xe0));
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 331 to 357
	value = ((uint32_t)(input[41] & 0x1f) << 27) |
			((uint32_t)input[42] << 19) |
			((uint32_t)input[43] << 11) |
			((uint32_t)(input[44] & 0xfc) << 3);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 358 to 384
	value = ((uint32_t)(input[44] & 0x03) << 30) |
			((uint32_t)input[45] << 22) |
			((uint32_t)input[46] << 14) |
			((uint32_t)input[47] << 6) |
			((uint32_t)(input[48] & 0x80) >> 2);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 385 to 411
	value = ((uint32_t)(input[48] & 0x7f) << 25) |
			((uint32_t)input[49] << 17) |
			((uint32_t)input[50] << 9) |
			((uint32_t)(input[51] & 0xf0) << 1);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 412 to 438
	value = ((uint32_t)(input[51] & 0x0f) << 28) |
			((uint32_t)input[52] << 20) |
			((uint32_t)input[53] << 12) |
			((uint32_t)(input[54] & 0xfe) << 4);
	output[15] = (double)(value >> 5);
}

static void unpack_17_27bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 27-bit signed
	// Skip 0 bits, read 459 bits of data.
	// Input must be at least 58 bytes long

	int32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

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

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

	// read output[8]: from bit 216 to 242
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)input[29] << 8) |
			((uint32_t)(input[30] & 0xe0));
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 243 to 269
	value = ((uint32_t)(input[30] & 0x1f) << 27) |
			((uint32_t)input[31] << 19) |
			((uint32_t)input[32] << 11) |
			((uint32_t)(input[33] & 0xfc) << 3);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 270 to 296
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)input[36] << 6) |
			((uint32_t)(input[37] & 0x80) >> 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 297 to 323
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xf0) << 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 324 to 350
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)(input[43] & 0xfe) << 4);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 351 to 377
	value = ((uint32_t)(input[43] & 0x01) << 31) |
			((uint32_t)input[44] << 23) |
			((uint32_t)input[45] << 15) |
			((uint32_t)input[46] << 7) |
			((uint32_t)(input[47] & 0xc0) >> 1);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 378 to 404
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)(input[50] & 0xf8) << 2);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 405 to 431
	value = ((uint32_t)(input[50] & 0x07) << 29) |
			((uint32_t)input[51] << 21) |
			((uint32_t)input[52] << 13) |
			((uint32_t)input[53] << 5);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 432 to 458
	value = ((uint32_t)input[54] << 24) |
			((uint32_t)input[55] << 16) |
			((uint32_t)input[56] << 8) |
			((uint32_t)(input[57] & 0xe0));
	output[16] = (double)(value >> 5);
}

static void unpack_17_27bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 27-bit unsigned
	// Skip 0 bits, read 459 bits of data.
	// Input must be at least 58 bytes long

	uint32_t value;

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

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

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

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

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

	// read output[8]: from bit 216 to 242
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)input[29] << 8) |
			((uint32_t)(input[30] & 0xe0));
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 243 to 269
	value = ((uint32_t)(input[30] & 0x1f) << 27) |
			((uint32_t)input[31] << 19) |
			((uint32_t)input[32] << 11) |
			((uint32_t)(input[33] & 0xfc) << 3);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 270 to 296
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)input[36] << 6) |
			((uint32_t)(input[37] & 0x80) >> 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 297 to 323
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xf0) << 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 324 to 350
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)(input[43] & 0xfe) << 4);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 351 to 377
	value = ((uint32_t)(input[43] & 0x01) << 31) |
			((uint32_t)input[44] << 23) |
			((uint32_t)input[45] << 15) |
			((uint32_t)input[46] << 7) |
			((uint32_t)(input[47] & 0xc0) >> 1);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 378 to 404
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)(input[50] & 0xf8) << 2);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 405 to 431
	value = ((uint32_t)(input[50] & 0x07) << 29) |
			((uint32_t)input[51] << 21) |
			((uint32_t)input[52] << 13) |
			((uint32_t)input[53] << 5);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 432 to 458
	value = ((uint32_t)input[54] << 24) |
			((uint32_t)input[55] << 16) |
			((uint32_t)input[56] << 8) |
			((uint32_t)(input[57] & 0xe0));
	output[16] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

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

	// read output[7]: from bit 190 to 216
	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] & 0x80) >> 2);
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 244 to 270
	value = ((uint32_t)(input[30] & 0x0f) << 28) |
			((uint32_t)input[31] << 20) |
			((uint32_t)input[32] << 12) |
			((uint32_t)(input[33] & 0xfe) << 4);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 271 to 297
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)input[36] << 7) |
			((uint32_t)(input[37] & 0xc0) >> 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 298 to 324
	value = ((uint32_t)(input[37] & 0x3f) << 26) |
			((uint32_t)input[38] << 18) |
			((uint32_t)input[39] << 10) |
			((uint32_t)(input[40] & 0xf8) << 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 325 to 351
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 352 to 378
	value = ((uint32_t)input[44] << 24) |
			((uint32_t)input[45] << 16) |
			((uint32_t)input[46] << 8) |
			((uint32_t)(input[47] & 0xe0));
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 379 to 405
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)(input[50] & 0xfc) << 3);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 406 to 432
	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] & 0x80) >> 2);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 433 to 459
	value = ((uint32_t)(input[54] & 0x7f) << 25) |
			((uint32_t)input[55] << 17) |
			((uint32_t)input[56] << 9) |
			((uint32_t)(input[57] & 0xf0) << 1);
	output[16] = (double)(value >> 5);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

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

	// read output[7]: from bit 190 to 216
	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] & 0x80) >> 2);
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 244 to 270
	value = ((uint32_t)(input[30] & 0x0f) << 28) |
			((uint32_t)input[31] << 20) |
			((uint32_t)input[32] << 12) |
			((uint32_t)(input[33] & 0xfe) << 4);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 271 to 297
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)input[36] << 7) |
			((uint32_t)(input[37] & 0xc0) >> 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 298 to 324
	value = ((uint32_t)(input[37] & 0x3f) << 26) |
			((uint32_t)input[38] << 18) |
			((uint32_t)input[39] << 10) |
			((uint32_t)(input[40] & 0xf8) << 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 325 to 351
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 352 to 378
	value = ((uint32_t)input[44] << 24) |
			((uint32_t)input[45] << 16) |
			((uint32_t)input[46] << 8) |
			((uint32_t)(input[47] & 0xe0));
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 379 to 405
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)(input[50] & 0xfc) << 3);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 406 to 432
	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] & 0x80) >> 2);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 433 to 459
	value = ((uint32_t)(input[54] & 0x7f) << 25) |
			((uint32_t)input[55] << 17) |
			((uint32_t)input[56] << 9) |
			((uint32_t)(input[57] & 0xf0) << 1);
	output[16] = (double)(value >> 5);
}

static void unpack_17_27bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 27-bit signed
	// Skip 2 bits, read 459 bits of data.
	// Input must be at least 58 bytes long

	int32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 191 to 217
	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] & 0xc0) >> 1);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 218 to 244
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)(input[30] & 0xf8) << 2);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 245 to 271
	value = ((uint32_t)(input[30] & 0x07) << 29) |
			((uint32_t)input[31] << 21) |
			((uint32_t)input[32] << 13) |
			((uint32_t)input[33] << 5);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 272 to 298
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)input[36] << 8) |
			((uint32_t)(input[37] & 0xe0));
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 299 to 325
	value = ((uint32_t)(input[37] & 0x1f) << 27) |
			((uint32_t)input[38] << 19) |
			((uint32_t)input[39] << 11) |
			((uint32_t)(input[40] & 0xfc) << 3);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 326 to 352
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)input[43] << 6) |
			((uint32_t)(input[44] & 0x80) >> 2);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 353 to 379
	value = ((uint32_t)(input[44] & 0x7f) << 25) |
			((uint32_t)input[45] << 17) |
			((uint32_t)input[46] << 9) |
			((uint32_t)(input[47] & 0xf0) << 1);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 380 to 406
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)input[49] << 12) |
			((uint32_t)(input[50] & 0xfe) << 4);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 407 to 433
	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] & 0xc0) >> 1);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 434 to 460
	value = ((uint32_t)(input[54] & 0x3f) << 26) |
			((uint32_t)input[55] << 18) |
			((uint32_t)input[56] << 10) |
			((uint32_t)(input[57] & 0xf8) << 2);
	output[16] = (double)(value >> 5);
}

static void unpack_17_27bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 27-bit unsigned
	// Skip 2 bits, read 459 bits of data.
	// Input must be at least 58 bytes long

	uint32_t value;

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

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

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 191 to 217
	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] & 0xc0) >> 1);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 218 to 244
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)(input[30] & 0xf8) << 2);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 245 to 271
	value = ((uint32_t)(input[30] & 0x07) << 29) |
			((uint32_t)input[31] << 21) |
			((uint32_t)input[32] << 13) |
			((uint32_t)input[33] << 5);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 272 to 298
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)input[36] << 8) |
			((uint32_t)(input[37] & 0xe0));
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 299 to 325
	value = ((uint32_t)(input[37] & 0x1f) << 27) |
			((uint32_t)input[38] << 19) |
			((uint32_t)input[39] << 11) |
			((uint32_t)(input[40] & 0xfc) << 3);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 326 to 352
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)input[43] << 6) |
			((uint32_t)(input[44] & 0x80) >> 2);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 353 to 379
	value = ((uint32_t)(input[44] & 0x7f) << 25) |
			((uint32_t)input[45] << 17) |
			((uint32_t)input[46] << 9) |
			((uint32_t)(input[47] & 0xf0) << 1);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 380 to 406
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)input[49] << 12) |
			((uint32_t)(input[50] & 0xfe) << 4);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 407 to 433
	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] & 0xc0) >> 1);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 434 to 460
	value = ((uint32_t)(input[54] & 0x3f) << 26) |
			((uint32_t)input[55] << 18) |
			((uint32_t)input[56] << 10) |
			((uint32_t)(input[57] & 0xf8) << 2);
	output[16] = (double)(value >> 5);
}

static void unpack_17_27bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 27-bit signed
	// Skip 3 bits, read 459 bits of data.
	// Input must be at least 58 bytes long

	int32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 192 to 218
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xe0));
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 246 to 272
	value = ((uint32_t)(input[30] & 0x03) << 30) |
			((uint32_t)input[31] << 22) |
			((uint32_t)input[32] << 14) |
			((uint32_t)input[33] << 6) |
			((uint32_t)(input[34] & 0x80) >> 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 273 to 299
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)input[36] << 9) |
			((uint32_t)(input[37] & 0xf0) << 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 300 to 326
	value = ((uint32_t)(input[37] & 0x0f) << 28) |
			((uint32_t)input[38] << 20) |
			((uint32_t)input[39] << 12) |
			((uint32_t)(input[40] & 0xfe) << 4);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 327 to 353
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)input[43] << 7) |
			((uint32_t)(input[44] & 0xc0) >> 1);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 354 to 380
	value = ((uint32_t)(input[44] & 0x3f) << 26) |
			((uint32_t)input[45] << 18) |
			((uint32_t)input[46] << 10) |
			((uint32_t)(input[47] & 0xf8) << 2);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 381 to 407
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13) |
			((uint32_t)input[50] << 5);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 408 to 434
	value = ((uint32_t)input[51] << 24) |
			((uint32_t)input[52] << 16) |
			((uint32_t)input[53] << 8) |
			((uint32_t)(input[54] & 0xe0));
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 435 to 461
	value = ((uint32_t)(input[54] & 0x1f) << 27) |
			((uint32_t)input[55] << 19) |
			((uint32_t)input[56] << 11) |
			((uint32_t)(input[57] & 0xfc) << 3);
	output[16] = (double)(value >> 5);
}

static void unpack_17_27bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 27-bit unsigned
	// Skip 3 bits, read 459 bits of data.
	// Input must be at least 58 bytes long

	uint32_t value;

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

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

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 192 to 218
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xe0));
	output[7] = (double)(value >> 5);

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

	// read output[9]: from bit 246 to 272
	value = ((uint32_t)(input[30] & 0x03) << 30) |
			((uint32_t)input[31] << 22) |
			((uint32_t)input[32] << 14) |
			((uint32_t)input[33] << 6) |
			((uint32_t)(input[34] & 0x80) >> 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 273 to 299
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)input[36] << 9) |
			((uint32_t)(input[37] & 0xf0) << 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 300 to 326
	value = ((uint32_t)(input[37] & 0x0f) << 28) |
			((uint32_t)input[38] << 20) |
			((uint32_t)input[39] << 12) |
			((uint32_t)(input[40] & 0xfe) << 4);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 327 to 353
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)input[43] << 7) |
			((uint32_t)(input[44] & 0xc0) >> 1);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 354 to 380
	value = ((uint32_t)(input[44] & 0x3f) << 26) |
			((uint32_t)input[45] << 18) |
			((uint32_t)input[46] << 10) |
			((uint32_t)(input[47] & 0xf8) << 2);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 381 to 407
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13) |
			((uint32_t)input[50] << 5);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 408 to 434
	value = ((uint32_t)input[51] << 24) |
			((uint32_t)input[52] << 16) |
			((uint32_t)input[53] << 8) |
			((uint32_t)(input[54] & 0xe0));
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 435 to 461
	value = ((uint32_t)(input[54] & 0x1f) << 27) |
			((uint32_t)input[55] << 19) |
			((uint32_t)input[56] << 11) |
			((uint32_t)(input[57] & 0xfc) << 3);
	output[16] = (double)(value >> 5);
}

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

	int32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);

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

	// read output[8]: from bit 220 to 246
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)(input[30] & 0xfe) << 4);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 247 to 273
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)input[33] << 7) |
			((uint32_t)(input[34] & 0xc0) >> 1);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 274 to 300
	value = ((uint32_t)(input[34] & 0x3f) << 26) |
			((uint32_t)input[35] << 18) |
			((uint32_t)input[36] << 10) |
			((uint32_t)(input[37] & 0xf8) << 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 301 to 327
	value = ((uint32_t)(input[37] & 0x07) << 29) |
			((uint32_t)input[38] << 21) |
			((uint32_t)input[39] << 13) |
			((uint32_t)input[40] << 5);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 328 to 354
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)input[43] << 8) |
			((uint32_t)(input[44] & 0xe0));
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 355 to 381
	value = ((uint32_t)(input[44] & 0x1f) << 27) |
			((uint32_t)input[45] << 19) |
			((uint32_t)input[46] << 11) |
			((uint32_t)(input[47] & 0xfc) << 3);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 382 to 408
	value = ((uint32_t)(input[47] & 0x03) << 30) |
			((uint32_t)input[48] << 22) |
			((uint32_t)input[49] << 14) |
			((uint32_t)input[50] << 6) |
			((uint32_t)(input[51] & 0x80) >> 2);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 409 to 435
	value = ((uint32_t)(input[51] & 0x7f) << 25) |
			((uint32_t)input[52] << 17) |
			((uint32_t)input[53] << 9) |
			((uint32_t)(input[54] & 0xf0) << 1);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 436 to 462
	value = ((uint32_t)(input[54] & 0x0f) << 28) |
			((uint32_t)input[55] << 20) |
			((uint32_t)input[56] << 12) |
			((uint32_t)(input[57] & 0xfe) << 4);
	output[16] = (double)(value >> 5);
}

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

	uint32_t value;

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

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);

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

	// read output[8]: from bit 220 to 246
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)(input[30] & 0xfe) << 4);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 247 to 273
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)input[33] << 7) |
			((uint32_t)(input[34] & 0xc0) >> 1);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 274 to 300
	value = ((uint32_t)(input[34] & 0x3f) << 26) |
			((uint32_t)input[35] << 18) |
			((uint32_t)input[36] << 10) |
			((uint32_t)(input[37] & 0xf8) << 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 301 to 327
	value = ((uint32_t)(input[37] & 0x07) << 29) |
			((uint32_t)input[38] << 21) |
			((uint32_t)input[39] << 13) |
			((uint32_t)input[40] << 5);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 328 to 354
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)input[43] << 8) |
			((uint32_t)(input[44] & 0xe0));
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 355 to 381
	value = ((uint32_t)(input[44] & 0x1f) << 27) |
			((uint32_t)input[45] << 19) |
			((uint32_t)input[46] << 11) |
			((uint32_t)(input[47] & 0xfc) << 3);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 382 to 408
	value = ((uint32_t)(input[47] & 0x03) << 30) |
			((uint32_t)input[48] << 22) |
			((uint32_t)input[49] << 14) |
			((uint32_t)input[50] << 6) |
			((uint32_t)(input[51] & 0x80) >> 2);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 409 to 435
	value = ((uint32_t)(input[51] & 0x7f) << 25) |
			((uint32_t)input[52] << 17) |
			((uint32_t)input[53] << 9) |
			((uint32_t)(input[54] & 0xf0) << 1);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 436 to 462
	value = ((uint32_t)(input[54] & 0x0f) << 28) |
			((uint32_t)input[55] << 20) |
			((uint32_t)input[56] << 12) |
			((uint32_t)(input[57] & 0xfe) << 4);
	output[16] = (double)(value >> 5);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 194 to 220
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)input[26] << 10) |
			((uint32_t)(input[27] & 0xf8) << 2);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 221 to 247
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 248 to 274
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xe0));
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 275 to 301
	value = ((uint32_t)(input[34] & 0x1f) << 27) |
			((uint32_t)input[35] << 19) |
			((uint32_t)input[36] << 11) |
			((uint32_t)(input[37] & 0xfc) << 3);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 302 to 328
	value = ((uint32_t)(input[37] & 0x03) << 30) |
			((uint32_t)input[38] << 22) |
			((uint32_t)input[39] << 14) |
			((uint32_t)input[40] << 6) |
			((uint32_t)(input[41] & 0x80) >> 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 329 to 355
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)input[43] << 9) |
			((uint32_t)(input[44] & 0xf0) << 1);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 356 to 382
	value = ((uint32_t)(input[44] & 0x0f) << 28) |
			((uint32_t)input[45] << 20) |
			((uint32_t)input[46] << 12) |
			((uint32_t)(input[47] & 0xfe) << 4);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 383 to 409
	value = ((uint32_t)(input[47] & 0x01) << 31) |
			((uint32_t)input[48] << 23) |
			((uint32_t)input[49] << 15) |
			((uint32_t)input[50] << 7) |
			((uint32_t)(input[51] & 0xc0) >> 1);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 410 to 436
	value = ((uint32_t)(input[51] & 0x3f) << 26) |
			((uint32_t)input[52] << 18) |
			((uint32_t)input[53] << 10) |
			((uint32_t)(input[54] & 0xf8) << 2);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 437 to 463
	value = ((uint32_t)(input[54] & 0x07) << 29) |
			((uint32_t)input[55] << 21) |
			((uint32_t)input[56] << 13) |
			((uint32_t)input[57] << 5);
	output[16] = (double)(value >> 5);
}

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

	uint32_t value;

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

	// read output[1]: from bit 32 to 58
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xe0));
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 194 to 220
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)input[26] << 10) |
			((uint32_t)(input[27] & 0xf8) << 2);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 221 to 247
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 248 to 274
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xe0));
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 275 to 301
	value = ((uint32_t)(input[34] & 0x1f) << 27) |
			((uint32_t)input[35] << 19) |
			((uint32_t)input[36] << 11) |
			((uint32_t)(input[37] & 0xfc) << 3);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 302 to 328
	value = ((uint32_t)(input[37] & 0x03) << 30) |
			((uint32_t)input[38] << 22) |
			((uint32_t)input[39] << 14) |
			((uint32_t)input[40] << 6) |
			((uint32_t)(input[41] & 0x80) >> 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 329 to 355
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)input[43] << 9) |
			((uint32_t)(input[44] & 0xf0) << 1);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 356 to 382
	value = ((uint32_t)(input[44] & 0x0f) << 28) |
			((uint32_t)input[45] << 20) |
			((uint32_t)input[46] << 12) |
			((uint32_t)(input[47] & 0xfe) << 4);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 383 to 409
	value = ((uint32_t)(input[47] & 0x01) << 31) |
			((uint32_t)input[48] << 23) |
			((uint32_t)input[49] << 15) |
			((uint32_t)input[50] << 7) |
			((uint32_t)(input[51] & 0xc0) >> 1);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 410 to 436
	value = ((uint32_t)(input[51] & 0x3f) << 26) |
			((uint32_t)input[52] << 18) |
			((uint32_t)input[53] << 10) |
			((uint32_t)(input[54] & 0xf8) << 2);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 437 to 463
	value = ((uint32_t)(input[54] & 0x07) << 29) |
			((uint32_t)input[55] << 21) |
			((uint32_t)input[56] << 13) |
			((uint32_t)input[57] << 5);
	output[16] = (double)(value >> 5);
}

static void unpack_17_27bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 27-bit signed
	// Skip 6 bits, read 459 bits of data.
	// Input must be at least 59 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

	// read output[1]: from bit 33 to 59
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)(input[7] & 0xf0) << 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 87 to 113
	value = ((uint32_t)(input[10] & 0x01) << 31) |
			((uint32_t)input[11] << 23) |
			((uint32_t)input[12] << 15) |
			((uint32_t)input[13] << 7) |
			((uint32_t)(input[14] & 0xc0) >> 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 195 to 221
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)input[26] << 11) |
			((uint32_t)(input[27] & 0xfc) << 3);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 222 to 248
	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] & 0x80) >> 2);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 249 to 275
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)input[33] << 9) |
			((uint32_t)(input[34] & 0xf0) << 1);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 276 to 302
	value = ((uint32_t)(input[34] & 0x0f) << 28) |
			((uint32_t)input[35] << 20) |
			((uint32_t)input[36] << 12) |
			((uint32_t)(input[37] & 0xfe) << 4);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 303 to 329
	value = ((uint32_t)(input[37] & 0x01) << 31) |
			((uint32_t)input[38] << 23) |
			((uint32_t)input[39] << 15) |
			((uint32_t)input[40] << 7) |
			((uint32_t)(input[41] & 0xc0) >> 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 330 to 356
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)input[43] << 10) |
			((uint32_t)(input[44] & 0xf8) << 2);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 357 to 383
	value = ((uint32_t)(input[44] & 0x07) << 29) |
			((uint32_t)input[45] << 21) |
			((uint32_t)input[46] << 13) |
			((uint32_t)input[47] << 5);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 384 to 410
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)input[50] << 8) |
			((uint32_t)(input[51] & 0xe0));
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 411 to 437
	value = ((uint32_t)(input[51] & 0x1f) << 27) |
			((uint32_t)input[52] << 19) |
			((uint32_t)input[53] << 11) |
			((uint32_t)(input[54] & 0xfc) << 3);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 438 to 464
	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] & 0x80) >> 2);
	output[16] = (double)(value >> 5);
}

static void unpack_17_27bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 27-bit unsigned
	// Skip 6 bits, read 459 bits of data.
	// Input must be at least 59 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

	// read output[1]: from bit 33 to 59
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)(input[7] & 0xf0) << 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 87 to 113
	value = ((uint32_t)(input[10] & 0x01) << 31) |
			((uint32_t)input[11] << 23) |
			((uint32_t)input[12] << 15) |
			((uint32_t)input[13] << 7) |
			((uint32_t)(input[14] & 0xc0) >> 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 195 to 221
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)input[26] << 11) |
			((uint32_t)(input[27] & 0xfc) << 3);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 222 to 248
	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] & 0x80) >> 2);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 249 to 275
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)input[33] << 9) |
			((uint32_t)(input[34] & 0xf0) << 1);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 276 to 302
	value = ((uint32_t)(input[34] & 0x0f) << 28) |
			((uint32_t)input[35] << 20) |
			((uint32_t)input[36] << 12) |
			((uint32_t)(input[37] & 0xfe) << 4);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 303 to 329
	value = ((uint32_t)(input[37] & 0x01) << 31) |
			((uint32_t)input[38] << 23) |
			((uint32_t)input[39] << 15) |
			((uint32_t)input[40] << 7) |
			((uint32_t)(input[41] & 0xc0) >> 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 330 to 356
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)input[43] << 10) |
			((uint32_t)(input[44] & 0xf8) << 2);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 357 to 383
	value = ((uint32_t)(input[44] & 0x07) << 29) |
			((uint32_t)input[45] << 21) |
			((uint32_t)input[46] << 13) |
			((uint32_t)input[47] << 5);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 384 to 410
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)input[50] << 8) |
			((uint32_t)(input[51] & 0xe0));
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 411 to 437
	value = ((uint32_t)(input[51] & 0x1f) << 27) |
			((uint32_t)input[52] << 19) |
			((uint32_t)input[53] << 11) |
			((uint32_t)(input[54] & 0xfc) << 3);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 438 to 464
	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] & 0x80) >> 2);
	output[16] = (double)(value >> 5);
}

static void unpack_17_27bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 27-bit signed
	// Skip 7 bits, read 459 bits of data.
	// Input must be at least 59 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

	// read output[1]: from bit 34 to 60
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)(input[7] & 0xf8) << 2);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 169 to 195
	value = ((uint32_t)(input[21] & 0x7f) << 25) |
			((uint32_t)input[22] << 17) |
			((uint32_t)input[23] << 9) |
			((uint32_t)(input[24] & 0xf0) << 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 196 to 222
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)input[26] << 12) |
			((uint32_t)(input[27] & 0xfe) << 4);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 223 to 249
	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] & 0xc0) >> 1);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 250 to 276
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)(input[34] & 0xf8) << 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 277 to 303
	value = ((uint32_t)(input[34] & 0x07) << 29) |
			((uint32_t)input[35] << 21) |
			((uint32_t)input[36] << 13) |
			((uint32_t)input[37] << 5);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 304 to 330
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)input[40] << 8) |
			((uint32_t)(input[41] & 0xe0));
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 331 to 357
	value = ((uint32_t)(input[41] & 0x1f) << 27) |
			((uint32_t)input[42] << 19) |
			((uint32_t)input[43] << 11) |
			((uint32_t)(input[44] & 0xfc) << 3);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 358 to 384
	value = ((uint32_t)(input[44] & 0x03) << 30) |
			((uint32_t)input[45] << 22) |
			((uint32_t)input[46] << 14) |
			((uint32_t)input[47] << 6) |
			((uint32_t)(input[48] & 0x80) >> 2);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 385 to 411
	value = ((uint32_t)(input[48] & 0x7f) << 25) |
			((uint32_t)input[49] << 17) |
			((uint32_t)input[50] << 9) |
			((uint32_t)(input[51] & 0xf0) << 1);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 412 to 438
	value = ((uint32_t)(input[51] & 0x0f) << 28) |
			((uint32_t)input[52] << 20) |
			((uint32_t)input[53] << 12) |
			((uint32_t)(input[54] & 0xfe) << 4);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 439 to 465
	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] & 0xc0) >> 1);
	output[16] = (double)(value >> 5);
}

static void unpack_17_27bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 27-bit unsigned
	// Skip 7 bits, read 459 bits of data.
	// Input must be at least 59 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

	// read output[1]: from bit 34 to 60
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)(input[7] & 0xf8) << 2);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 169 to 195
	value = ((uint32_t)(input[21] & 0x7f) << 25) |
			((uint32_t)input[22] << 17) |
			((uint32_t)input[23] << 9) |
			((uint32_t)(input[24] & 0xf0) << 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 196 to 222
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)input[26] << 12) |
			((uint32_t)(input[27] & 0xfe) << 4);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 223 to 249
	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] & 0xc0) >> 1);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 250 to 276
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)(input[34] & 0xf8) << 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 277 to 303
	value = ((uint32_t)(input[34] & 0x07) << 29) |
			((uint32_t)input[35] << 21) |
			((uint32_t)input[36] << 13) |
			((uint32_t)input[37] << 5);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 304 to 330
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)input[40] << 8) |
			((uint32_t)(input[41] & 0xe0));
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 331 to 357
	value = ((uint32_t)(input[41] & 0x1f) << 27) |
			((uint32_t)input[42] << 19) |
			((uint32_t)input[43] << 11) |
			((uint32_t)(input[44] & 0xfc) << 3);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 358 to 384
	value = ((uint32_t)(input[44] & 0x03) << 30) |
			((uint32_t)input[45] << 22) |
			((uint32_t)input[46] << 14) |
			((uint32_t)input[47] << 6) |
			((uint32_t)(input[48] & 0x80) >> 2);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 385 to 411
	value = ((uint32_t)(input[48] & 0x7f) << 25) |
			((uint32_t)input[49] << 17) |
			((uint32_t)input[50] << 9) |
			((uint32_t)(input[51] & 0xf0) << 1);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 412 to 438
	value = ((uint32_t)(input[51] & 0x0f) << 28) |
			((uint32_t)input[52] << 20) |
			((uint32_t)input[53] << 12) |
			((uint32_t)(input[54] & 0xfe) << 4);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 439 to 465
	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] & 0xc0) >> 1);
	output[16] = (double)(value >> 5);
}

static void unpack_18_27bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 27-bit signed
	// Skip 0 bits, read 486 bits of data.
	// Input must be at least 61 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 26
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xe0));
	output[0] = (double)(value >> 5);

	// read output[1]: from bit 27 to 53
	value = ((uint32_t)(input[3] & 0x1f) << 27) |
			((uint32_t)input[4] << 19) |
			((uint32_t)input[5] << 11) |
			((uint32_t)(input[6] & 0xfc) << 3);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 162 to 188
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)(input[23] & 0xf8) << 2);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 189 to 215
	value = ((uint32_t)(input[23] & 0x07) << 29) |
			((uint32_t)input[24] << 21) |
			((uint32_t)input[25] << 13) |
			((uint32_t)input[26] << 5);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 216 to 242
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)input[29] << 8) |
			((uint32_t)(input[30] & 0xe0));
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 243 to 269
	value = ((uint32_t)(input[30] & 0x1f) << 27) |
			((uint32_t)input[31] << 19) |
			((uint32_t)input[32] << 11) |
			((uint32_t)(input[33] & 0xfc) << 3);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 270 to 296
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)input[36] << 6) |
			((uint32_t)(input[37] & 0x80) >> 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 297 to 323
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xf0) << 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 324 to 350
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)(input[43] & 0xfe) << 4);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 351 to 377
	value = ((uint32_t)(input[43] & 0x01) << 31) |
			((uint32_t)input[44] << 23) |
			((uint32_t)input[45] << 15) |
			((uint32_t)input[46] << 7) |
			((uint32_t)(input[47] & 0xc0) >> 1);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 378 to 404
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)(input[50] & 0xf8) << 2);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 405 to 431
	value = ((uint32_t)(input[50] & 0x07) << 29) |
			((uint32_t)input[51] << 21) |
			((uint32_t)input[52] << 13) |
			((uint32_t)input[53] << 5);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 432 to 458
	value = ((uint32_t)input[54] << 24) |
			((uint32_t)input[55] << 16) |
			((uint32_t)input[56] << 8) |
			((uint32_t)(input[57] & 0xe0));
	output[16] = (double)(value >> 5);

	// read output[17]: from bit 459 to 485
	value = ((uint32_t)(input[57] & 0x1f) << 27) |
			((uint32_t)input[58] << 19) |
			((uint32_t)input[59] << 11) |
			((uint32_t)(input[60] & 0xfc) << 3);
	output[17] = (double)(value >> 5);
}

static void unpack_18_27bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 27-bit unsigned
	// Skip 0 bits, read 486 bits of data.
	// Input must be at least 61 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 26
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xe0));
	output[0] = (double)(value >> 5);

	// read output[1]: from bit 27 to 53
	value = ((uint32_t)(input[3] & 0x1f) << 27) |
			((uint32_t)input[4] << 19) |
			((uint32_t)input[5] << 11) |
			((uint32_t)(input[6] & 0xfc) << 3);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 54 to 80
	value = ((uint32_t)(input[6] & 0x03) << 30) |
			((uint32_t)input[7] << 22) |
			((uint32_t)input[8] << 14) |
			((uint32_t)input[9] << 6) |
			((uint32_t)(input[10] & 0x80) >> 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 81 to 107
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)input[12] << 9) |
			((uint32_t)(input[13] & 0xf0) << 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 108 to 134
	value = ((uint32_t)(input[13] & 0x0f) << 28) |
			((uint32_t)input[14] << 20) |
			((uint32_t)input[15] << 12) |
			((uint32_t)(input[16] & 0xfe) << 4);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 135 to 161
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)input[19] << 7) |
			((uint32_t)(input[20] & 0xc0) >> 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 162 to 188
	value = ((uint32_t)(input[20] & 0x3f) << 26) |
			((uint32_t)input[21] << 18) |
			((uint32_t)input[22] << 10) |
			((uint32_t)(input[23] & 0xf8) << 2);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 189 to 215
	value = ((uint32_t)(input[23] & 0x07) << 29) |
			((uint32_t)input[24] << 21) |
			((uint32_t)input[25] << 13) |
			((uint32_t)input[26] << 5);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 216 to 242
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)input[29] << 8) |
			((uint32_t)(input[30] & 0xe0));
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 243 to 269
	value = ((uint32_t)(input[30] & 0x1f) << 27) |
			((uint32_t)input[31] << 19) |
			((uint32_t)input[32] << 11) |
			((uint32_t)(input[33] & 0xfc) << 3);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 270 to 296
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)input[36] << 6) |
			((uint32_t)(input[37] & 0x80) >> 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 297 to 323
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xf0) << 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 324 to 350
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)(input[43] & 0xfe) << 4);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 351 to 377
	value = ((uint32_t)(input[43] & 0x01) << 31) |
			((uint32_t)input[44] << 23) |
			((uint32_t)input[45] << 15) |
			((uint32_t)input[46] << 7) |
			((uint32_t)(input[47] & 0xc0) >> 1);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 378 to 404
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)(input[50] & 0xf8) << 2);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 405 to 431
	value = ((uint32_t)(input[50] & 0x07) << 29) |
			((uint32_t)input[51] << 21) |
			((uint32_t)input[52] << 13) |
			((uint32_t)input[53] << 5);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 432 to 458
	value = ((uint32_t)input[54] << 24) |
			((uint32_t)input[55] << 16) |
			((uint32_t)input[56] << 8) |
			((uint32_t)(input[57] & 0xe0));
	output[16] = (double)(value >> 5);

	// read output[17]: from bit 459 to 485
	value = ((uint32_t)(input[57] & 0x1f) << 27) |
			((uint32_t)input[58] << 19) |
			((uint32_t)input[59] << 11) |
			((uint32_t)(input[60] & 0xfc) << 3);
	output[17] = (double)(value >> 5);
}

static void unpack_18_27bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 27-bit signed
	// Skip 1 bits, read 486 bits of data.
	// Input must be at least 61 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 27
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)(input[3] & 0xf0) << 1);
	output[0] = (double)(value >> 5);

	// read output[1]: from bit 28 to 54
	value = ((uint32_t)(input[3] & 0x0f) << 28) |
			((uint32_t)input[4] << 20) |
			((uint32_t)input[5] << 12) |
			((uint32_t)(input[6] & 0xfe) << 4);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 163 to 189
	value = ((uint32_t)(input[20] & 0x1f) << 27) |
			((uint32_t)input[21] << 19) |
			((uint32_t)input[22] << 11) |
			((uint32_t)(input[23] & 0xfc) << 3);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 190 to 216
	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] & 0x80) >> 2);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 217 to 243
	value = ((uint32_t)(input[27] & 0x7f) << 25) |
			((uint32_t)input[28] << 17) |
			((uint32_t)input[29] << 9) |
			((uint32_t)(input[30] & 0xf0) << 1);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 244 to 270
	value = ((uint32_t)(input[30] & 0x0f) << 28) |
			((uint32_t)input[31] << 20) |
			((uint32_t)input[32] << 12) |
			((uint32_t)(input[33] & 0xfe) << 4);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 271 to 297
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)input[36] << 7) |
			((uint32_t)(input[37] & 0xc0) >> 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 298 to 324
	value = ((uint32_t)(input[37] & 0x3f) << 26) |
			((uint32_t)input[38] << 18) |
			((uint32_t)input[39] << 10) |
			((uint32_t)(input[40] & 0xf8) << 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 325 to 351
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 352 to 378
	value = ((uint32_t)input[44] << 24) |
			((uint32_t)input[45] << 16) |
			((uint32_t)input[46] << 8) |
			((uint32_t)(input[47] & 0xe0));
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 379 to 405
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)(input[50] & 0xfc) << 3);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 406 to 432
	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] & 0x80) >> 2);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 433 to 459
	value = ((uint32_t)(input[54] & 0x7f) << 25) |
			((uint32_t)input[55] << 17) |
			((uint32_t)input[56] << 9) |
			((uint32_t)(input[57] & 0xf0) << 1);
	output[16] = (double)(value >> 5);

	// read output[17]: from bit 460 to 486
	value = ((uint32_t)(input[57] & 0x0f) << 28) |
			((uint32_t)input[58] << 20) |
			((uint32_t)input[59] << 12) |
			((uint32_t)(input[60] & 0xfe) << 4);
	output[17] = (double)(value >> 5);
}

static void unpack_18_27bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 27-bit unsigned
	// Skip 1 bits, read 486 bits of data.
	// Input must be at least 61 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 27
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)(input[3] & 0xf0) << 1);
	output[0] = (double)(value >> 5);

	// read output[1]: from bit 28 to 54
	value = ((uint32_t)(input[3] & 0x0f) << 28) |
			((uint32_t)input[4] << 20) |
			((uint32_t)input[5] << 12) |
			((uint32_t)(input[6] & 0xfe) << 4);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 55 to 81
	value = ((uint32_t)(input[6] & 0x01) << 31) |
			((uint32_t)input[7] << 23) |
			((uint32_t)input[8] << 15) |
			((uint32_t)input[9] << 7) |
			((uint32_t)(input[10] & 0xc0) >> 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 82 to 108
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)input[12] << 10) |
			((uint32_t)(input[13] & 0xf8) << 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 109 to 135
	value = ((uint32_t)(input[13] & 0x07) << 29) |
			((uint32_t)input[14] << 21) |
			((uint32_t)input[15] << 13) |
			((uint32_t)input[16] << 5);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 136 to 162
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)input[19] << 8) |
			((uint32_t)(input[20] & 0xe0));
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 163 to 189
	value = ((uint32_t)(input[20] & 0x1f) << 27) |
			((uint32_t)input[21] << 19) |
			((uint32_t)input[22] << 11) |
			((uint32_t)(input[23] & 0xfc) << 3);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 190 to 216
	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] & 0x80) >> 2);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 217 to 243
	value = ((uint32_t)(input[27] & 0x7f) << 25) |
			((uint32_t)input[28] << 17) |
			((uint32_t)input[29] << 9) |
			((uint32_t)(input[30] & 0xf0) << 1);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 244 to 270
	value = ((uint32_t)(input[30] & 0x0f) << 28) |
			((uint32_t)input[31] << 20) |
			((uint32_t)input[32] << 12) |
			((uint32_t)(input[33] & 0xfe) << 4);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 271 to 297
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)input[36] << 7) |
			((uint32_t)(input[37] & 0xc0) >> 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 298 to 324
	value = ((uint32_t)(input[37] & 0x3f) << 26) |
			((uint32_t)input[38] << 18) |
			((uint32_t)input[39] << 10) |
			((uint32_t)(input[40] & 0xf8) << 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 325 to 351
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 352 to 378
	value = ((uint32_t)input[44] << 24) |
			((uint32_t)input[45] << 16) |
			((uint32_t)input[46] << 8) |
			((uint32_t)(input[47] & 0xe0));
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 379 to 405
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)(input[50] & 0xfc) << 3);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 406 to 432
	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] & 0x80) >> 2);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 433 to 459
	value = ((uint32_t)(input[54] & 0x7f) << 25) |
			((uint32_t)input[55] << 17) |
			((uint32_t)input[56] << 9) |
			((uint32_t)(input[57] & 0xf0) << 1);
	output[16] = (double)(value >> 5);

	// read output[17]: from bit 460 to 486
	value = ((uint32_t)(input[57] & 0x0f) << 28) |
			((uint32_t)input[58] << 20) |
			((uint32_t)input[59] << 12) |
			((uint32_t)(input[60] & 0xfe) << 4);
	output[17] = (double)(value >> 5);
}

static void unpack_18_27bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 27-bit signed
	// Skip 2 bits, read 486 bits of data.
	// Input must be at least 61 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 28
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)(input[3] & 0xf8) << 2);
	output[0] = (double)(value >> 5);

	// read output[1]: from bit 29 to 55
	value = ((uint32_t)(input[3] & 0x07) << 29) |
			((uint32_t)input[4] << 21) |
			((uint32_t)input[5] << 13) |
			((uint32_t)input[6] << 5);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 191 to 217
	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] & 0xc0) >> 1);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 218 to 244
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)(input[30] & 0xf8) << 2);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 245 to 271
	value = ((uint32_t)(input[30] & 0x07) << 29) |
			((uint32_t)input[31] << 21) |
			((uint32_t)input[32] << 13) |
			((uint32_t)input[33] << 5);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 272 to 298
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)input[36] << 8) |
			((uint32_t)(input[37] & 0xe0));
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 299 to 325
	value = ((uint32_t)(input[37] & 0x1f) << 27) |
			((uint32_t)input[38] << 19) |
			((uint32_t)input[39] << 11) |
			((uint32_t)(input[40] & 0xfc) << 3);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 326 to 352
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)input[43] << 6) |
			((uint32_t)(input[44] & 0x80) >> 2);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 353 to 379
	value = ((uint32_t)(input[44] & 0x7f) << 25) |
			((uint32_t)input[45] << 17) |
			((uint32_t)input[46] << 9) |
			((uint32_t)(input[47] & 0xf0) << 1);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 380 to 406
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)input[49] << 12) |
			((uint32_t)(input[50] & 0xfe) << 4);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 407 to 433
	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] & 0xc0) >> 1);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 434 to 460
	value = ((uint32_t)(input[54] & 0x3f) << 26) |
			((uint32_t)input[55] << 18) |
			((uint32_t)input[56] << 10) |
			((uint32_t)(input[57] & 0xf8) << 2);
	output[16] = (double)(value >> 5);

	// read output[17]: from bit 461 to 487
	value = ((uint32_t)(input[57] & 0x07) << 29) |
			((uint32_t)input[58] << 21) |
			((uint32_t)input[59] << 13) |
			((uint32_t)input[60] << 5);
	output[17] = (double)(value >> 5);
}

static void unpack_18_27bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 27-bit unsigned
	// Skip 2 bits, read 486 bits of data.
	// Input must be at least 61 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 28
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)(input[3] & 0xf8) << 2);
	output[0] = (double)(value >> 5);

	// read output[1]: from bit 29 to 55
	value = ((uint32_t)(input[3] & 0x07) << 29) |
			((uint32_t)input[4] << 21) |
			((uint32_t)input[5] << 13) |
			((uint32_t)input[6] << 5);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 56 to 82
	value = ((uint32_t)input[7] << 24) |
			((uint32_t)input[8] << 16) |
			((uint32_t)input[9] << 8) |
			((uint32_t)(input[10] & 0xe0));
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 83 to 109
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)input[12] << 11) |
			((uint32_t)(input[13] & 0xfc) << 3);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 110 to 136
	value = ((uint32_t)(input[13] & 0x03) << 30) |
			((uint32_t)input[14] << 22) |
			((uint32_t)input[15] << 14) |
			((uint32_t)input[16] << 6) |
			((uint32_t)(input[17] & 0x80) >> 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 137 to 163
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)input[19] << 9) |
			((uint32_t)(input[20] & 0xf0) << 1);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 164 to 190
	value = ((uint32_t)(input[20] & 0x0f) << 28) |
			((uint32_t)input[21] << 20) |
			((uint32_t)input[22] << 12) |
			((uint32_t)(input[23] & 0xfe) << 4);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 191 to 217
	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] & 0xc0) >> 1);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 218 to 244
	value = ((uint32_t)(input[27] & 0x3f) << 26) |
			((uint32_t)input[28] << 18) |
			((uint32_t)input[29] << 10) |
			((uint32_t)(input[30] & 0xf8) << 2);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 245 to 271
	value = ((uint32_t)(input[30] & 0x07) << 29) |
			((uint32_t)input[31] << 21) |
			((uint32_t)input[32] << 13) |
			((uint32_t)input[33] << 5);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 272 to 298
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)input[36] << 8) |
			((uint32_t)(input[37] & 0xe0));
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 299 to 325
	value = ((uint32_t)(input[37] & 0x1f) << 27) |
			((uint32_t)input[38] << 19) |
			((uint32_t)input[39] << 11) |
			((uint32_t)(input[40] & 0xfc) << 3);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 326 to 352
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)input[43] << 6) |
			((uint32_t)(input[44] & 0x80) >> 2);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 353 to 379
	value = ((uint32_t)(input[44] & 0x7f) << 25) |
			((uint32_t)input[45] << 17) |
			((uint32_t)input[46] << 9) |
			((uint32_t)(input[47] & 0xf0) << 1);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 380 to 406
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)input[49] << 12) |
			((uint32_t)(input[50] & 0xfe) << 4);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 407 to 433
	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] & 0xc0) >> 1);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 434 to 460
	value = ((uint32_t)(input[54] & 0x3f) << 26) |
			((uint32_t)input[55] << 18) |
			((uint32_t)input[56] << 10) |
			((uint32_t)(input[57] & 0xf8) << 2);
	output[16] = (double)(value >> 5);

	// read output[17]: from bit 461 to 487
	value = ((uint32_t)(input[57] & 0x07) << 29) |
			((uint32_t)input[58] << 21) |
			((uint32_t)input[59] << 13) |
			((uint32_t)input[60] << 5);
	output[17] = (double)(value >> 5);
}

static void unpack_18_27bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 27-bit signed
	// Skip 3 bits, read 486 bits of data.
	// Input must be at least 62 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 29
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)(input[3] & 0xfc) << 3);
	output[0] = (double)(value >> 5);

	// read output[1]: from bit 30 to 56
	value = ((uint32_t)(input[3] & 0x03) << 30) |
			((uint32_t)input[4] << 22) |
			((uint32_t)input[5] << 14) |
			((uint32_t)input[6] << 6) |
			((uint32_t)(input[7] & 0x80) >> 2);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 192 to 218
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xe0));
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 219 to 245
	value = ((uint32_t)(input[27] & 0x1f) << 27) |
			((uint32_t)input[28] << 19) |
			((uint32_t)input[29] << 11) |
			((uint32_t)(input[30] & 0xfc) << 3);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 246 to 272
	value = ((uint32_t)(input[30] & 0x03) << 30) |
			((uint32_t)input[31] << 22) |
			((uint32_t)input[32] << 14) |
			((uint32_t)input[33] << 6) |
			((uint32_t)(input[34] & 0x80) >> 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 273 to 299
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)input[36] << 9) |
			((uint32_t)(input[37] & 0xf0) << 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 300 to 326
	value = ((uint32_t)(input[37] & 0x0f) << 28) |
			((uint32_t)input[38] << 20) |
			((uint32_t)input[39] << 12) |
			((uint32_t)(input[40] & 0xfe) << 4);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 327 to 353
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)input[43] << 7) |
			((uint32_t)(input[44] & 0xc0) >> 1);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 354 to 380
	value = ((uint32_t)(input[44] & 0x3f) << 26) |
			((uint32_t)input[45] << 18) |
			((uint32_t)input[46] << 10) |
			((uint32_t)(input[47] & 0xf8) << 2);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 381 to 407
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13) |
			((uint32_t)input[50] << 5);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 408 to 434
	value = ((uint32_t)input[51] << 24) |
			((uint32_t)input[52] << 16) |
			((uint32_t)input[53] << 8) |
			((uint32_t)(input[54] & 0xe0));
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 435 to 461
	value = ((uint32_t)(input[54] & 0x1f) << 27) |
			((uint32_t)input[55] << 19) |
			((uint32_t)input[56] << 11) |
			((uint32_t)(input[57] & 0xfc) << 3);
	output[16] = (double)(value >> 5);

	// read output[17]: from bit 462 to 488
	value = ((uint32_t)(input[57] & 0x03) << 30) |
			((uint32_t)input[58] << 22) |
			((uint32_t)input[59] << 14) |
			((uint32_t)input[60] << 6) |
			((uint32_t)(input[61] & 0x80) >> 2);
	output[17] = (double)(value >> 5);
}

static void unpack_18_27bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 27-bit unsigned
	// Skip 3 bits, read 486 bits of data.
	// Input must be at least 62 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 29
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)(input[3] & 0xfc) << 3);
	output[0] = (double)(value >> 5);

	// read output[1]: from bit 30 to 56
	value = ((uint32_t)(input[3] & 0x03) << 30) |
			((uint32_t)input[4] << 22) |
			((uint32_t)input[5] << 14) |
			((uint32_t)input[6] << 6) |
			((uint32_t)(input[7] & 0x80) >> 2);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 57 to 83
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)input[9] << 9) |
			((uint32_t)(input[10] & 0xf0) << 1);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 84 to 110
	value = ((uint32_t)(input[10] & 0x0f) << 28) |
			((uint32_t)input[11] << 20) |
			((uint32_t)input[12] << 12) |
			((uint32_t)(input[13] & 0xfe) << 4);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 111 to 137
	value = ((uint32_t)(input[13] & 0x01) << 31) |
			((uint32_t)input[14] << 23) |
			((uint32_t)input[15] << 15) |
			((uint32_t)input[16] << 7) |
			((uint32_t)(input[17] & 0xc0) >> 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 138 to 164
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)input[19] << 10) |
			((uint32_t)(input[20] & 0xf8) << 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 165 to 191
	value = ((uint32_t)(input[20] & 0x07) << 29) |
			((uint32_t)input[21] << 21) |
			((uint32_t)input[22] << 13) |
			((uint32_t)input[23] << 5);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 192 to 218
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)input[26] << 8) |
			((uint32_t)(input[27] & 0xe0));
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 219 to 245
	value = ((uint32_t)(input[27] & 0x1f) << 27) |
			((uint32_t)input[28] << 19) |
			((uint32_t)input[29] << 11) |
			((uint32_t)(input[30] & 0xfc) << 3);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 246 to 272
	value = ((uint32_t)(input[30] & 0x03) << 30) |
			((uint32_t)input[31] << 22) |
			((uint32_t)input[32] << 14) |
			((uint32_t)input[33] << 6) |
			((uint32_t)(input[34] & 0x80) >> 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 273 to 299
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)input[36] << 9) |
			((uint32_t)(input[37] & 0xf0) << 1);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 300 to 326
	value = ((uint32_t)(input[37] & 0x0f) << 28) |
			((uint32_t)input[38] << 20) |
			((uint32_t)input[39] << 12) |
			((uint32_t)(input[40] & 0xfe) << 4);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 327 to 353
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)input[43] << 7) |
			((uint32_t)(input[44] & 0xc0) >> 1);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 354 to 380
	value = ((uint32_t)(input[44] & 0x3f) << 26) |
			((uint32_t)input[45] << 18) |
			((uint32_t)input[46] << 10) |
			((uint32_t)(input[47] & 0xf8) << 2);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 381 to 407
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13) |
			((uint32_t)input[50] << 5);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 408 to 434
	value = ((uint32_t)input[51] << 24) |
			((uint32_t)input[52] << 16) |
			((uint32_t)input[53] << 8) |
			((uint32_t)(input[54] & 0xe0));
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 435 to 461
	value = ((uint32_t)(input[54] & 0x1f) << 27) |
			((uint32_t)input[55] << 19) |
			((uint32_t)input[56] << 11) |
			((uint32_t)(input[57] & 0xfc) << 3);
	output[16] = (double)(value >> 5);

	// read output[17]: from bit 462 to 488
	value = ((uint32_t)(input[57] & 0x03) << 30) |
			((uint32_t)input[58] << 22) |
			((uint32_t)input[59] << 14) |
			((uint32_t)input[60] << 6) |
			((uint32_t)(input[61] & 0x80) >> 2);
	output[17] = (double)(value >> 5);
}

static void unpack_18_27bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 27-bit signed
	// Skip 4 bits, read 486 bits of data.
	// Input must be at least 62 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 30
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)(input[3] & 0xfe) << 4);
	output[0] = (double)(value >> 5);

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 193 to 219
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)input[26] << 9) |
			((uint32_t)(input[27] & 0xf0) << 1);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 220 to 246
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)(input[30] & 0xfe) << 4);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 247 to 273
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)input[33] << 7) |
			((uint32_t)(input[34] & 0xc0) >> 1);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 274 to 300
	value = ((uint32_t)(input[34] & 0x3f) << 26) |
			((uint32_t)input[35] << 18) |
			((uint32_t)input[36] << 10) |
			((uint32_t)(input[37] & 0xf8) << 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 301 to 327
	value = ((uint32_t)(input[37] & 0x07) << 29) |
			((uint32_t)input[38] << 21) |
			((uint32_t)input[39] << 13) |
			((uint32_t)input[40] << 5);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 328 to 354
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)input[43] << 8) |
			((uint32_t)(input[44] & 0xe0));
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 355 to 381
	value = ((uint32_t)(input[44] & 0x1f) << 27) |
			((uint32_t)input[45] << 19) |
			((uint32_t)input[46] << 11) |
			((uint32_t)(input[47] & 0xfc) << 3);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 382 to 408
	value = ((uint32_t)(input[47] & 0x03) << 30) |
			((uint32_t)input[48] << 22) |
			((uint32_t)input[49] << 14) |
			((uint32_t)input[50] << 6) |
			((uint32_t)(input[51] & 0x80) >> 2);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 409 to 435
	value = ((uint32_t)(input[51] & 0x7f) << 25) |
			((uint32_t)input[52] << 17) |
			((uint32_t)input[53] << 9) |
			((uint32_t)(input[54] & 0xf0) << 1);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 436 to 462
	value = ((uint32_t)(input[54] & 0x0f) << 28) |
			((uint32_t)input[55] << 20) |
			((uint32_t)input[56] << 12) |
			((uint32_t)(input[57] & 0xfe) << 4);
	output[16] = (double)(value >> 5);

	// read output[17]: from bit 463 to 489
	value = ((uint32_t)(input[57] & 0x01) << 31) |
			((uint32_t)input[58] << 23) |
			((uint32_t)input[59] << 15) |
			((uint32_t)input[60] << 7) |
			((uint32_t)(input[61] & 0xc0) >> 1);
	output[17] = (double)(value >> 5);
}

static void unpack_18_27bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 27-bit unsigned
	// Skip 4 bits, read 486 bits of data.
	// Input must be at least 62 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 30
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)(input[3] & 0xfe) << 4);
	output[0] = (double)(value >> 5);

	// read output[1]: from bit 31 to 57
	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] & 0xc0) >> 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 58 to 84
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xf8) << 2);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 85 to 111
	value = ((uint32_t)(input[10] & 0x07) << 29) |
			((uint32_t)input[11] << 21) |
			((uint32_t)input[12] << 13) |
			((uint32_t)input[13] << 5);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 112 to 138
	value = ((uint32_t)input[14] << 24) |
			((uint32_t)input[15] << 16) |
			((uint32_t)input[16] << 8) |
			((uint32_t)(input[17] & 0xe0));
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 139 to 165
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)input[19] << 11) |
			((uint32_t)(input[20] & 0xfc) << 3);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 166 to 192
	value = ((uint32_t)(input[20] & 0x03) << 30) |
			((uint32_t)input[21] << 22) |
			((uint32_t)input[22] << 14) |
			((uint32_t)input[23] << 6) |
			((uint32_t)(input[24] & 0x80) >> 2);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 193 to 219
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)input[26] << 9) |
			((uint32_t)(input[27] & 0xf0) << 1);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 220 to 246
	value = ((uint32_t)(input[27] & 0x0f) << 28) |
			((uint32_t)input[28] << 20) |
			((uint32_t)input[29] << 12) |
			((uint32_t)(input[30] & 0xfe) << 4);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 247 to 273
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)input[33] << 7) |
			((uint32_t)(input[34] & 0xc0) >> 1);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 274 to 300
	value = ((uint32_t)(input[34] & 0x3f) << 26) |
			((uint32_t)input[35] << 18) |
			((uint32_t)input[36] << 10) |
			((uint32_t)(input[37] & 0xf8) << 2);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 301 to 327
	value = ((uint32_t)(input[37] & 0x07) << 29) |
			((uint32_t)input[38] << 21) |
			((uint32_t)input[39] << 13) |
			((uint32_t)input[40] << 5);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 328 to 354
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)input[43] << 8) |
			((uint32_t)(input[44] & 0xe0));
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 355 to 381
	value = ((uint32_t)(input[44] & 0x1f) << 27) |
			((uint32_t)input[45] << 19) |
			((uint32_t)input[46] << 11) |
			((uint32_t)(input[47] & 0xfc) << 3);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 382 to 408
	value = ((uint32_t)(input[47] & 0x03) << 30) |
			((uint32_t)input[48] << 22) |
			((uint32_t)input[49] << 14) |
			((uint32_t)input[50] << 6) |
			((uint32_t)(input[51] & 0x80) >> 2);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 409 to 435
	value = ((uint32_t)(input[51] & 0x7f) << 25) |
			((uint32_t)input[52] << 17) |
			((uint32_t)input[53] << 9) |
			((uint32_t)(input[54] & 0xf0) << 1);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 436 to 462
	value = ((uint32_t)(input[54] & 0x0f) << 28) |
			((uint32_t)input[55] << 20) |
			((uint32_t)input[56] << 12) |
			((uint32_t)(input[57] & 0xfe) << 4);
	output[16] = (double)(value >> 5);

	// read output[17]: from bit 463 to 489
	value = ((uint32_t)(input[57] & 0x01) << 31) |
			((uint32_t)input[58] << 23) |
			((uint32_t)input[59] << 15) |
			((uint32_t)input[60] << 7) |
			((uint32_t)(input[61] & 0xc0) >> 1);
	output[17] = (double)(value >> 5);
}

static void unpack_18_27bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 27-bit signed
	// Skip 5 bits, read 486 bits of data.
	// Input must be at least 62 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 31
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5);
	output[0] = (double)(value >> 5);

	// read output[1]: from bit 32 to 58
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xe0));
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 194 to 220
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)input[26] << 10) |
			((uint32_t)(input[27] & 0xf8) << 2);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 221 to 247
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 248 to 274
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xe0));
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 275 to 301
	value = ((uint32_t)(input[34] & 0x1f) << 27) |
			((uint32_t)input[35] << 19) |
			((uint32_t)input[36] << 11) |
			((uint32_t)(input[37] & 0xfc) << 3);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 302 to 328
	value = ((uint32_t)(input[37] & 0x03) << 30) |
			((uint32_t)input[38] << 22) |
			((uint32_t)input[39] << 14) |
			((uint32_t)input[40] << 6) |
			((uint32_t)(input[41] & 0x80) >> 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 329 to 355
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)input[43] << 9) |
			((uint32_t)(input[44] & 0xf0) << 1);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 356 to 382
	value = ((uint32_t)(input[44] & 0x0f) << 28) |
			((uint32_t)input[45] << 20) |
			((uint32_t)input[46] << 12) |
			((uint32_t)(input[47] & 0xfe) << 4);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 383 to 409
	value = ((uint32_t)(input[47] & 0x01) << 31) |
			((uint32_t)input[48] << 23) |
			((uint32_t)input[49] << 15) |
			((uint32_t)input[50] << 7) |
			((uint32_t)(input[51] & 0xc0) >> 1);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 410 to 436
	value = ((uint32_t)(input[51] & 0x3f) << 26) |
			((uint32_t)input[52] << 18) |
			((uint32_t)input[53] << 10) |
			((uint32_t)(input[54] & 0xf8) << 2);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 437 to 463
	value = ((uint32_t)(input[54] & 0x07) << 29) |
			((uint32_t)input[55] << 21) |
			((uint32_t)input[56] << 13) |
			((uint32_t)input[57] << 5);
	output[16] = (double)(value >> 5);

	// read output[17]: from bit 464 to 490
	value = ((uint32_t)input[58] << 24) |
			((uint32_t)input[59] << 16) |
			((uint32_t)input[60] << 8) |
			((uint32_t)(input[61] & 0xe0));
	output[17] = (double)(value >> 5);
}

static void unpack_18_27bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 27-bit unsigned
	// Skip 5 bits, read 486 bits of data.
	// Input must be at least 62 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 31
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5);
	output[0] = (double)(value >> 5);

	// read output[1]: from bit 32 to 58
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xe0));
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 59 to 85
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)(input[10] & 0xfc) << 3);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 86 to 112
	value = ((uint32_t)(input[10] & 0x03) << 30) |
			((uint32_t)input[11] << 22) |
			((uint32_t)input[12] << 14) |
			((uint32_t)input[13] << 6) |
			((uint32_t)(input[14] & 0x80) >> 2);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 113 to 139
	value = ((uint32_t)(input[14] & 0x7f) << 25) |
			((uint32_t)input[15] << 17) |
			((uint32_t)input[16] << 9) |
			((uint32_t)(input[17] & 0xf0) << 1);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 140 to 166
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)input[19] << 12) |
			((uint32_t)(input[20] & 0xfe) << 4);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 167 to 193
	value = ((uint32_t)(input[20] & 0x01) << 31) |
			((uint32_t)input[21] << 23) |
			((uint32_t)input[22] << 15) |
			((uint32_t)input[23] << 7) |
			((uint32_t)(input[24] & 0xc0) >> 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 194 to 220
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)input[26] << 10) |
			((uint32_t)(input[27] & 0xf8) << 2);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 221 to 247
	value = ((uint32_t)(input[27] & 0x07) << 29) |
			((uint32_t)input[28] << 21) |
			((uint32_t)input[29] << 13) |
			((uint32_t)input[30] << 5);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 248 to 274
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)input[33] << 8) |
			((uint32_t)(input[34] & 0xe0));
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 275 to 301
	value = ((uint32_t)(input[34] & 0x1f) << 27) |
			((uint32_t)input[35] << 19) |
			((uint32_t)input[36] << 11) |
			((uint32_t)(input[37] & 0xfc) << 3);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 302 to 328
	value = ((uint32_t)(input[37] & 0x03) << 30) |
			((uint32_t)input[38] << 22) |
			((uint32_t)input[39] << 14) |
			((uint32_t)input[40] << 6) |
			((uint32_t)(input[41] & 0x80) >> 2);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 329 to 355
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)input[43] << 9) |
			((uint32_t)(input[44] & 0xf0) << 1);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 356 to 382
	value = ((uint32_t)(input[44] & 0x0f) << 28) |
			((uint32_t)input[45] << 20) |
			((uint32_t)input[46] << 12) |
			((uint32_t)(input[47] & 0xfe) << 4);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 383 to 409
	value = ((uint32_t)(input[47] & 0x01) << 31) |
			((uint32_t)input[48] << 23) |
			((uint32_t)input[49] << 15) |
			((uint32_t)input[50] << 7) |
			((uint32_t)(input[51] & 0xc0) >> 1);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 410 to 436
	value = ((uint32_t)(input[51] & 0x3f) << 26) |
			((uint32_t)input[52] << 18) |
			((uint32_t)input[53] << 10) |
			((uint32_t)(input[54] & 0xf8) << 2);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 437 to 463
	value = ((uint32_t)(input[54] & 0x07) << 29) |
			((uint32_t)input[55] << 21) |
			((uint32_t)input[56] << 13) |
			((uint32_t)input[57] << 5);
	output[16] = (double)(value >> 5);

	// read output[17]: from bit 464 to 490
	value = ((uint32_t)input[58] << 24) |
			((uint32_t)input[59] << 16) |
			((uint32_t)input[60] << 8) |
			((uint32_t)(input[61] & 0xe0));
	output[17] = (double)(value >> 5);
}

static void unpack_18_27bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 27-bit signed
	// Skip 6 bits, read 486 bits of data.
	// Input must be at least 62 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

	// read output[1]: from bit 33 to 59
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)(input[7] & 0xf0) << 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 87 to 113
	value = ((uint32_t)(input[10] & 0x01) << 31) |
			((uint32_t)input[11] << 23) |
			((uint32_t)input[12] << 15) |
			((uint32_t)input[13] << 7) |
			((uint32_t)(input[14] & 0xc0) >> 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 195 to 221
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)input[26] << 11) |
			((uint32_t)(input[27] & 0xfc) << 3);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 222 to 248
	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] & 0x80) >> 2);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 249 to 275
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)input[33] << 9) |
			((uint32_t)(input[34] & 0xf0) << 1);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 276 to 302
	value = ((uint32_t)(input[34] & 0x0f) << 28) |
			((uint32_t)input[35] << 20) |
			((uint32_t)input[36] << 12) |
			((uint32_t)(input[37] & 0xfe) << 4);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 303 to 329
	value = ((uint32_t)(input[37] & 0x01) << 31) |
			((uint32_t)input[38] << 23) |
			((uint32_t)input[39] << 15) |
			((uint32_t)input[40] << 7) |
			((uint32_t)(input[41] & 0xc0) >> 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 330 to 356
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)input[43] << 10) |
			((uint32_t)(input[44] & 0xf8) << 2);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 357 to 383
	value = ((uint32_t)(input[44] & 0x07) << 29) |
			((uint32_t)input[45] << 21) |
			((uint32_t)input[46] << 13) |
			((uint32_t)input[47] << 5);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 384 to 410
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)input[50] << 8) |
			((uint32_t)(input[51] & 0xe0));
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 411 to 437
	value = ((uint32_t)(input[51] & 0x1f) << 27) |
			((uint32_t)input[52] << 19) |
			((uint32_t)input[53] << 11) |
			((uint32_t)(input[54] & 0xfc) << 3);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 438 to 464
	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] & 0x80) >> 2);
	output[16] = (double)(value >> 5);

	// read output[17]: from bit 465 to 491
	value = ((uint32_t)(input[58] & 0x7f) << 25) |
			((uint32_t)input[59] << 17) |
			((uint32_t)input[60] << 9) |
			((uint32_t)(input[61] & 0xf0) << 1);
	output[17] = (double)(value >> 5);
}

static void unpack_18_27bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 27-bit unsigned
	// Skip 6 bits, read 486 bits of data.
	// Input must be at least 62 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 32
	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] & 0x80) >> 2);
	output[0] = (double)(value >> 5);

	// read output[1]: from bit 33 to 59
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)(input[7] & 0xf0) << 1);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 60 to 86
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)(input[10] & 0xfe) << 4);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 87 to 113
	value = ((uint32_t)(input[10] & 0x01) << 31) |
			((uint32_t)input[11] << 23) |
			((uint32_t)input[12] << 15) |
			((uint32_t)input[13] << 7) |
			((uint32_t)(input[14] & 0xc0) >> 1);
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 114 to 140
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)input[16] << 10) |
			((uint32_t)(input[17] & 0xf8) << 2);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 141 to 167
	value = ((uint32_t)(input[17] & 0x07) << 29) |
			((uint32_t)input[18] << 21) |
			((uint32_t)input[19] << 13) |
			((uint32_t)input[20] << 5);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 168 to 194
	value = ((uint32_t)input[21] << 24) |
			((uint32_t)input[22] << 16) |
			((uint32_t)input[23] << 8) |
			((uint32_t)(input[24] & 0xe0));
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 195 to 221
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)input[26] << 11) |
			((uint32_t)(input[27] & 0xfc) << 3);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 222 to 248
	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] & 0x80) >> 2);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 249 to 275
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)input[33] << 9) |
			((uint32_t)(input[34] & 0xf0) << 1);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 276 to 302
	value = ((uint32_t)(input[34] & 0x0f) << 28) |
			((uint32_t)input[35] << 20) |
			((uint32_t)input[36] << 12) |
			((uint32_t)(input[37] & 0xfe) << 4);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 303 to 329
	value = ((uint32_t)(input[37] & 0x01) << 31) |
			((uint32_t)input[38] << 23) |
			((uint32_t)input[39] << 15) |
			((uint32_t)input[40] << 7) |
			((uint32_t)(input[41] & 0xc0) >> 1);
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 330 to 356
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)input[43] << 10) |
			((uint32_t)(input[44] & 0xf8) << 2);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 357 to 383
	value = ((uint32_t)(input[44] & 0x07) << 29) |
			((uint32_t)input[45] << 21) |
			((uint32_t)input[46] << 13) |
			((uint32_t)input[47] << 5);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 384 to 410
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)input[50] << 8) |
			((uint32_t)(input[51] & 0xe0));
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 411 to 437
	value = ((uint32_t)(input[51] & 0x1f) << 27) |
			((uint32_t)input[52] << 19) |
			((uint32_t)input[53] << 11) |
			((uint32_t)(input[54] & 0xfc) << 3);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 438 to 464
	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] & 0x80) >> 2);
	output[16] = (double)(value >> 5);

	// read output[17]: from bit 465 to 491
	value = ((uint32_t)(input[58] & 0x7f) << 25) |
			((uint32_t)input[59] << 17) |
			((uint32_t)input[60] << 9) |
			((uint32_t)(input[61] & 0xf0) << 1);
	output[17] = (double)(value >> 5);
}

static void unpack_18_27bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 27-bit signed
	// Skip 7 bits, read 486 bits of data.
	// Input must be at least 62 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

	// read output[1]: from bit 34 to 60
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)(input[7] & 0xf8) << 2);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 169 to 195
	value = ((uint32_t)(input[21] & 0x7f) << 25) |
			((uint32_t)input[22] << 17) |
			((uint32_t)input[23] << 9) |
			((uint32_t)(input[24] & 0xf0) << 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 196 to 222
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)input[26] << 12) |
			((uint32_t)(input[27] & 0xfe) << 4);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 223 to 249
	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] & 0xc0) >> 1);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 250 to 276
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)(input[34] & 0xf8) << 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 277 to 303
	value = ((uint32_t)(input[34] & 0x07) << 29) |
			((uint32_t)input[35] << 21) |
			((uint32_t)input[36] << 13) |
			((uint32_t)input[37] << 5);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 304 to 330
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)input[40] << 8) |
			((uint32_t)(input[41] & 0xe0));
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 331 to 357
	value = ((uint32_t)(input[41] & 0x1f) << 27) |
			((uint32_t)input[42] << 19) |
			((uint32_t)input[43] << 11) |
			((uint32_t)(input[44] & 0xfc) << 3);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 358 to 384
	value = ((uint32_t)(input[44] & 0x03) << 30) |
			((uint32_t)input[45] << 22) |
			((uint32_t)input[46] << 14) |
			((uint32_t)input[47] << 6) |
			((uint32_t)(input[48] & 0x80) >> 2);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 385 to 411
	value = ((uint32_t)(input[48] & 0x7f) << 25) |
			((uint32_t)input[49] << 17) |
			((uint32_t)input[50] << 9) |
			((uint32_t)(input[51] & 0xf0) << 1);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 412 to 438
	value = ((uint32_t)(input[51] & 0x0f) << 28) |
			((uint32_t)input[52] << 20) |
			((uint32_t)input[53] << 12) |
			((uint32_t)(input[54] & 0xfe) << 4);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 439 to 465
	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] & 0xc0) >> 1);
	output[16] = (double)(value >> 5);

	// read output[17]: from bit 466 to 492
	value = ((uint32_t)(input[58] & 0x3f) << 26) |
			((uint32_t)input[59] << 18) |
			((uint32_t)input[60] << 10) |
			((uint32_t)(input[61] & 0xf8) << 2);
	output[17] = (double)(value >> 5);
}

static void unpack_18_27bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 27-bit unsigned
	// Skip 7 bits, read 486 bits of data.
	// Input must be at least 62 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 33
	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] & 0xc0) >> 1);
	output[0] = (double)(value >> 5);

	// read output[1]: from bit 34 to 60
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)(input[7] & 0xf8) << 2);
	output[1] = (double)(value >> 5);

	// read output[2]: from bit 61 to 87
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5);
	output[2] = (double)(value >> 5);

	// read output[3]: from bit 88 to 114
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xe0));
	output[3] = (double)(value >> 5);

	// read output[4]: from bit 115 to 141
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)input[16] << 11) |
			((uint32_t)(input[17] & 0xfc) << 3);
	output[4] = (double)(value >> 5);

	// read output[5]: from bit 142 to 168
	value = ((uint32_t)(input[17] & 0x03) << 30) |
			((uint32_t)input[18] << 22) |
			((uint32_t)input[19] << 14) |
			((uint32_t)input[20] << 6) |
			((uint32_t)(input[21] & 0x80) >> 2);
	output[5] = (double)(value >> 5);

	// read output[6]: from bit 169 to 195
	value = ((uint32_t)(input[21] & 0x7f) << 25) |
			((uint32_t)input[22] << 17) |
			((uint32_t)input[23] << 9) |
			((uint32_t)(input[24] & 0xf0) << 1);
	output[6] = (double)(value >> 5);

	// read output[7]: from bit 196 to 222
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)input[26] << 12) |
			((uint32_t)(input[27] & 0xfe) << 4);
	output[7] = (double)(value >> 5);

	// read output[8]: from bit 223 to 249
	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] & 0xc0) >> 1);
	output[8] = (double)(value >> 5);

	// read output[9]: from bit 250 to 276
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)input[33] << 10) |
			((uint32_t)(input[34] & 0xf8) << 2);
	output[9] = (double)(value >> 5);

	// read output[10]: from bit 277 to 303
	value = ((uint32_t)(input[34] & 0x07) << 29) |
			((uint32_t)input[35] << 21) |
			((uint32_t)input[36] << 13) |
			((uint32_t)input[37] << 5);
	output[10] = (double)(value >> 5);

	// read output[11]: from bit 304 to 330
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)input[40] << 8) |
			((uint32_t)(input[41] & 0xe0));
	output[11] = (double)(value >> 5);

	// read output[12]: from bit 331 to 357
	value = ((uint32_t)(input[41] & 0x1f) << 27) |
			((uint32_t)input[42] << 19) |
			((uint32_t)input[43] << 11) |
			((uint32_t)(input[44] & 0xfc) << 3);
	output[12] = (double)(value >> 5);

	// read output[13]: from bit 358 to 384
	value = ((uint32_t)(input[44] & 0x03) << 30) |
			((uint32_t)input[45] << 22) |
			((uint32_t)input[46] << 14) |
			((uint32_t)input[47] << 6) |
			((uint32_t)(input[48] & 0x80) >> 2);
	output[13] = (double)(value >> 5);

	// read output[14]: from bit 385 to 411
	value = ((uint32_t)(input[48] & 0x7f) << 25) |
			((uint32_t)input[49] << 17) |
			((uint32_t)input[50] << 9) |
			((uint32_t)(input[51] & 0xf0) << 1);
	output[14] = (double)(value >> 5);

	// read output[15]: from bit 412 to 438
	value = ((uint32_t)(input[51] & 0x0f) << 28) |
			((uint32_t)input[52] << 20) |
			((uint32_t)input[53] << 12) |
			((uint32_t)(input[54] & 0xfe) << 4);
	output[15] = (double)(value >> 5);

	// read output[16]: from bit 439 to 465
	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] & 0xc0) >> 1);
	output[16] = (double)(value >> 5);

	// read output[17]: from bit 466 to 492
	value = ((uint32_t)(input[58] & 0x3f) << 26) |
			((uint32_t)input[59] << 18) |
			((uint32_t)input[60] << 10) |
			((uint32_t)(input[61] & 0xf8) << 2);
	output[17] = (double)(value >> 5);
}


unpack_func_t unpack_27bit[UNPACK_27BIT_MAX_COUNT][8][2] = {
	{
		{
			unpack_1_27bit_unsigned_0off,
			unpack_1_27bit_signed_0off,
		},
		{
			unpack_1_27bit_unsigned_1off,
			unpack_1_27bit_signed_1off,
		},
		{
			unpack_1_27bit_unsigned_2off,
			unpack_1_27bit_signed_2off,
		},
		{
			unpack_1_27bit_unsigned_3off,
			unpack_1_27bit_signed_3off,
		},
		{
			unpack_1_27bit_unsigned_4off,
			unpack_1_27bit_signed_4off,
		},
		{
			unpack_1_27bit_unsigned_5off,
			unpack_1_27bit_signed_5off,
		},
		{
			unpack_1_27bit_unsigned_6off,
			unpack_1_27bit_signed_6off,
		},
		{
			unpack_1_27bit_unsigned_7off,
			unpack_1_27bit_signed_7off,
		},
	},
	{
		{
			unpack_2_27bit_unsigned_0off,
			unpack_2_27bit_signed_0off,
		},
		{
			unpack_2_27bit_unsigned_1off,
			unpack_2_27bit_signed_1off,
		},
		{
			unpack_2_27bit_unsigned_2off,
			unpack_2_27bit_signed_2off,
		},
		{
			unpack_2_27bit_unsigned_3off,
			unpack_2_27bit_signed_3off,
		},
		{
			unpack_2_27bit_unsigned_4off,
			unpack_2_27bit_signed_4off,
		},
		{
			unpack_2_27bit_unsigned_5off,
			unpack_2_27bit_signed_5off,
		},
		{
			unpack_2_27bit_unsigned_6off,
			unpack_2_27bit_signed_6off,
		},
		{
			unpack_2_27bit_unsigned_7off,
			unpack_2_27bit_signed_7off,
		},
	},
	{
		{
			unpack_3_27bit_unsigned_0off,
			unpack_3_27bit_signed_0off,
		},
		{
			unpack_3_27bit_unsigned_1off,
			unpack_3_27bit_signed_1off,
		},
		{
			unpack_3_27bit_unsigned_2off,
			unpack_3_27bit_signed_2off,
		},
		{
			unpack_3_27bit_unsigned_3off,
			unpack_3_27bit_signed_3off,
		},
		{
			unpack_3_27bit_unsigned_4off,
			unpack_3_27bit_signed_4off,
		},
		{
			unpack_3_27bit_unsigned_5off,
			unpack_3_27bit_signed_5off,
		},
		{
			unpack_3_27bit_unsigned_6off,
			unpack_3_27bit_signed_6off,
		},
		{
			unpack_3_27bit_unsigned_7off,
			unpack_3_27bit_signed_7off,
		},
	},
	{
		{
			unpack_4_27bit_unsigned_0off,
			unpack_4_27bit_signed_0off,
		},
		{
			unpack_4_27bit_unsigned_1off,
			unpack_4_27bit_signed_1off,
		},
		{
			unpack_4_27bit_unsigned_2off,
			unpack_4_27bit_signed_2off,
		},
		{
			unpack_4_27bit_unsigned_3off,
			unpack_4_27bit_signed_3off,
		},
		{
			unpack_4_27bit_unsigned_4off,
			unpack_4_27bit_signed_4off,
		},
		{
			unpack_4_27bit_unsigned_5off,
			unpack_4_27bit_signed_5off,
		},
		{
			unpack_4_27bit_unsigned_6off,
			unpack_4_27bit_signed_6off,
		},
		{
			unpack_4_27bit_unsigned_7off,
			unpack_4_27bit_signed_7off,
		},
	},
	{
		{
			unpack_5_27bit_unsigned_0off,
			unpack_5_27bit_signed_0off,
		},
		{
			unpack_5_27bit_unsigned_1off,
			unpack_5_27bit_signed_1off,
		},
		{
			unpack_5_27bit_unsigned_2off,
			unpack_5_27bit_signed_2off,
		},
		{
			unpack_5_27bit_unsigned_3off,
			unpack_5_27bit_signed_3off,
		},
		{
			unpack_5_27bit_unsigned_4off,
			unpack_5_27bit_signed_4off,
		},
		{
			unpack_5_27bit_unsigned_5off,
			unpack_5_27bit_signed_5off,
		},
		{
			unpack_5_27bit_unsigned_6off,
			unpack_5_27bit_signed_6off,
		},
		{
			unpack_5_27bit_unsigned_7off,
			unpack_5_27bit_signed_7off,
		},
	},
	{
		{
			unpack_6_27bit_unsigned_0off,
			unpack_6_27bit_signed_0off,
		},
		{
			unpack_6_27bit_unsigned_1off,
			unpack_6_27bit_signed_1off,
		},
		{
			unpack_6_27bit_unsigned_2off,
			unpack_6_27bit_signed_2off,
		},
		{
			unpack_6_27bit_unsigned_3off,
			unpack_6_27bit_signed_3off,
		},
		{
			unpack_6_27bit_unsigned_4off,
			unpack_6_27bit_signed_4off,
		},
		{
			unpack_6_27bit_unsigned_5off,
			unpack_6_27bit_signed_5off,
		},
		{
			unpack_6_27bit_unsigned_6off,
			unpack_6_27bit_signed_6off,
		},
		{
			unpack_6_27bit_unsigned_7off,
			unpack_6_27bit_signed_7off,
		},
	},
	{
		{
			unpack_7_27bit_unsigned_0off,
			unpack_7_27bit_signed_0off,
		},
		{
			unpack_7_27bit_unsigned_1off,
			unpack_7_27bit_signed_1off,
		},
		{
			unpack_7_27bit_unsigned_2off,
			unpack_7_27bit_signed_2off,
		},
		{
			unpack_7_27bit_unsigned_3off,
			unpack_7_27bit_signed_3off,
		},
		{
			unpack_7_27bit_unsigned_4off,
			unpack_7_27bit_signed_4off,
		},
		{
			unpack_7_27bit_unsigned_5off,
			unpack_7_27bit_signed_5off,
		},
		{
			unpack_7_27bit_unsigned_6off,
			unpack_7_27bit_signed_6off,
		},
		{
			unpack_7_27bit_unsigned_7off,
			unpack_7_27bit_signed_7off,
		},
	},
	{
		{
			unpack_8_27bit_unsigned_0off,
			unpack_8_27bit_signed_0off,
		},
		{
			unpack_8_27bit_unsigned_1off,
			unpack_8_27bit_signed_1off,
		},
		{
			unpack_8_27bit_unsigned_2off,
			unpack_8_27bit_signed_2off,
		},
		{
			unpack_8_27bit_unsigned_3off,
			unpack_8_27bit_signed_3off,
		},
		{
			unpack_8_27bit_unsigned_4off,
			unpack_8_27bit_signed_4off,
		},
		{
			unpack_8_27bit_unsigned_5off,
			unpack_8_27bit_signed_5off,
		},
		{
			unpack_8_27bit_unsigned_6off,
			unpack_8_27bit_signed_6off,
		},
		{
			unpack_8_27bit_unsigned_7off,
			unpack_8_27bit_signed_7off,
		},
	},
	{
		{
			unpack_9_27bit_unsigned_0off,
			unpack_9_27bit_signed_0off,
		},
		{
			unpack_9_27bit_unsigned_1off,
			unpack_9_27bit_signed_1off,
		},
		{
			unpack_9_27bit_unsigned_2off,
			unpack_9_27bit_signed_2off,
		},
		{
			unpack_9_27bit_unsigned_3off,
			unpack_9_27bit_signed_3off,
		},
		{
			unpack_9_27bit_unsigned_4off,
			unpack_9_27bit_signed_4off,
		},
		{
			unpack_9_27bit_unsigned_5off,
			unpack_9_27bit_signed_5off,
		},
		{
			unpack_9_27bit_unsigned_6off,
			unpack_9_27bit_signed_6off,
		},
		{
			unpack_9_27bit_unsigned_7off,
			unpack_9_27bit_signed_7off,
		},
	},
	{
		{
			unpack_10_27bit_unsigned_0off,
			unpack_10_27bit_signed_0off,
		},
		{
			unpack_10_27bit_unsigned_1off,
			unpack_10_27bit_signed_1off,
		},
		{
			unpack_10_27bit_unsigned_2off,
			unpack_10_27bit_signed_2off,
		},
		{
			unpack_10_27bit_unsigned_3off,
			unpack_10_27bit_signed_3off,
		},
		{
			unpack_10_27bit_unsigned_4off,
			unpack_10_27bit_signed_4off,
		},
		{
			unpack_10_27bit_unsigned_5off,
			unpack_10_27bit_signed_5off,
		},
		{
			unpack_10_27bit_unsigned_6off,
			unpack_10_27bit_signed_6off,
		},
		{
			unpack_10_27bit_unsigned_7off,
			unpack_10_27bit_signed_7off,
		},
	},
	{
		{
			unpack_11_27bit_unsigned_0off,
			unpack_11_27bit_signed_0off,
		},
		{
			unpack_11_27bit_unsigned_1off,
			unpack_11_27bit_signed_1off,
		},
		{
			unpack_11_27bit_unsigned_2off,
			unpack_11_27bit_signed_2off,
		},
		{
			unpack_11_27bit_unsigned_3off,
			unpack_11_27bit_signed_3off,
		},
		{
			unpack_11_27bit_unsigned_4off,
			unpack_11_27bit_signed_4off,
		},
		{
			unpack_11_27bit_unsigned_5off,
			unpack_11_27bit_signed_5off,
		},
		{
			unpack_11_27bit_unsigned_6off,
			unpack_11_27bit_signed_6off,
		},
		{
			unpack_11_27bit_unsigned_7off,
			unpack_11_27bit_signed_7off,
		},
	},
	{
		{
			unpack_12_27bit_unsigned_0off,
			unpack_12_27bit_signed_0off,
		},
		{
			unpack_12_27bit_unsigned_1off,
			unpack_12_27bit_signed_1off,
		},
		{
			unpack_12_27bit_unsigned_2off,
			unpack_12_27bit_signed_2off,
		},
		{
			unpack_12_27bit_unsigned_3off,
			unpack_12_27bit_signed_3off,
		},
		{
			unpack_12_27bit_unsigned_4off,
			unpack_12_27bit_signed_4off,
		},
		{
			unpack_12_27bit_unsigned_5off,
			unpack_12_27bit_signed_5off,
		},
		{
			unpack_12_27bit_unsigned_6off,
			unpack_12_27bit_signed_6off,
		},
		{
			unpack_12_27bit_unsigned_7off,
			unpack_12_27bit_signed_7off,
		},
	},
	{
		{
			unpack_13_27bit_unsigned_0off,
			unpack_13_27bit_signed_0off,
		},
		{
			unpack_13_27bit_unsigned_1off,
			unpack_13_27bit_signed_1off,
		},
		{
			unpack_13_27bit_unsigned_2off,
			unpack_13_27bit_signed_2off,
		},
		{
			unpack_13_27bit_unsigned_3off,
			unpack_13_27bit_signed_3off,
		},
		{
			unpack_13_27bit_unsigned_4off,
			unpack_13_27bit_signed_4off,
		},
		{
			unpack_13_27bit_unsigned_5off,
			unpack_13_27bit_signed_5off,
		},
		{
			unpack_13_27bit_unsigned_6off,
			unpack_13_27bit_signed_6off,
		},
		{
			unpack_13_27bit_unsigned_7off,
			unpack_13_27bit_signed_7off,
		},
	},
	{
		{
			unpack_14_27bit_unsigned_0off,
			unpack_14_27bit_signed_0off,
		},
		{
			unpack_14_27bit_unsigned_1off,
			unpack_14_27bit_signed_1off,
		},
		{
			unpack_14_27bit_unsigned_2off,
			unpack_14_27bit_signed_2off,
		},
		{
			unpack_14_27bit_unsigned_3off,
			unpack_14_27bit_signed_3off,
		},
		{
			unpack_14_27bit_unsigned_4off,
			unpack_14_27bit_signed_4off,
		},
		{
			unpack_14_27bit_unsigned_5off,
			unpack_14_27bit_signed_5off,
		},
		{
			unpack_14_27bit_unsigned_6off,
			unpack_14_27bit_signed_6off,
		},
		{
			unpack_14_27bit_unsigned_7off,
			unpack_14_27bit_signed_7off,
		},
	},
	{
		{
			unpack_15_27bit_unsigned_0off,
			unpack_15_27bit_signed_0off,
		},
		{
			unpack_15_27bit_unsigned_1off,
			unpack_15_27bit_signed_1off,
		},
		{
			unpack_15_27bit_unsigned_2off,
			unpack_15_27bit_signed_2off,
		},
		{
			unpack_15_27bit_unsigned_3off,
			unpack_15_27bit_signed_3off,
		},
		{
			unpack_15_27bit_unsigned_4off,
			unpack_15_27bit_signed_4off,
		},
		{
			unpack_15_27bit_unsigned_5off,
			unpack_15_27bit_signed_5off,
		},
		{
			unpack_15_27bit_unsigned_6off,
			unpack_15_27bit_signed_6off,
		},
		{
			unpack_15_27bit_unsigned_7off,
			unpack_15_27bit_signed_7off,
		},
	},
	{
		{
			unpack_16_27bit_unsigned_0off,
			unpack_16_27bit_signed_0off,
		},
		{
			unpack_16_27bit_unsigned_1off,
			unpack_16_27bit_signed_1off,
		},
		{
			unpack_16_27bit_unsigned_2off,
			unpack_16_27bit_signed_2off,
		},
		{
			unpack_16_27bit_unsigned_3off,
			unpack_16_27bit_signed_3off,
		},
		{
			unpack_16_27bit_unsigned_4off,
			unpack_16_27bit_signed_4off,
		},
		{
			unpack_16_27bit_unsigned_5off,
			unpack_16_27bit_signed_5off,
		},
		{
			unpack_16_27bit_unsigned_6off,
			unpack_16_27bit_signed_6off,
		},
		{
			unpack_16_27bit_unsigned_7off,
			unpack_16_27bit_signed_7off,
		},
	},
	{
		{
			unpack_17_27bit_unsigned_0off,
			unpack_17_27bit_signed_0off,
		},
		{
			unpack_17_27bit_unsigned_1off,
			unpack_17_27bit_signed_1off,
		},
		{
			unpack_17_27bit_unsigned_2off,
			unpack_17_27bit_signed_2off,
		},
		{
			unpack_17_27bit_unsigned_3off,
			unpack_17_27bit_signed_3off,
		},
		{
			unpack_17_27bit_unsigned_4off,
			unpack_17_27bit_signed_4off,
		},
		{
			unpack_17_27bit_unsigned_5off,
			unpack_17_27bit_signed_5off,
		},
		{
			unpack_17_27bit_unsigned_6off,
			unpack_17_27bit_signed_6off,
		},
		{
			unpack_17_27bit_unsigned_7off,
			unpack_17_27bit_signed_7off,
		},
	},
	{
		{
			unpack_18_27bit_unsigned_0off,
			unpack_18_27bit_signed_0off,
		},
		{
			unpack_18_27bit_unsigned_1off,
			unpack_18_27bit_signed_1off,
		},
		{
			unpack_18_27bit_unsigned_2off,
			unpack_18_27bit_signed_2off,
		},
		{
			unpack_18_27bit_unsigned_3off,
			unpack_18_27bit_signed_3off,
		},
		{
			unpack_18_27bit_unsigned_4off,
			unpack_18_27bit_signed_4off,
		},
		{
			unpack_18_27bit_unsigned_5off,
			unpack_18_27bit_signed_5off,
		},
		{
			unpack_18_27bit_unsigned_6off,
			unpack_18_27bit_signed_6off,
		},
		{
			unpack_18_27bit_unsigned_7off,
			unpack_18_27bit_signed_7off,
		},
	},
};
