// AUTOGENERATED FILE. DO NOT MODIFY.

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

#include "unpack29.h"



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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

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

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

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

	uint32_t value;

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

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

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

	int32_t value;

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

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);
}

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

	uint32_t value;

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

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	uint32_t value;

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

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

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

	int32_t value;

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

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

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

	uint32_t value;

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

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

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

	int32_t value;

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

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

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

	uint32_t value;

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

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

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

	int32_t value;

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

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

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

	uint32_t value;

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

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

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

	int32_t value;

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

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

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

	uint32_t value;

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

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

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

	int32_t value;

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

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

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

	uint32_t value;

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

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

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

	int32_t value;

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

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

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

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

	uint32_t value;

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

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

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

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

	int32_t value;

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

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

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

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

	uint32_t value;

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

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

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

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

	int32_t value;

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

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

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

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

	uint32_t value;

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

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

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

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

	int32_t value;

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

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

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

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

	uint32_t value;

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

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

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

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

	int32_t value;

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

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

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

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

	uint32_t value;

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

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

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

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

	int32_t value;

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

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

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

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

	uint32_t value;

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

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

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

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

	int32_t value;

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

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

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

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

	uint32_t value;

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

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

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

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

	int32_t value;

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

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

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

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

	uint32_t value;

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

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

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

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

	int32_t value;

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

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

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

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);
}

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

	int32_t value;

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

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

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

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

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

	uint32_t value;

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

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

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

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

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

	int32_t value;

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

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

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

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

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

	uint32_t value;

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

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

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

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

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

	int32_t value;

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

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

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

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

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

	uint32_t value;

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

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

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

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

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

	int32_t value;

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

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

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

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

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

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

	uint32_t value;

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

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

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

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

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

	int32_t value;

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

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

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

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

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

	uint32_t value;

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

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

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

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

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

	int32_t value;

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

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

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

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);
}

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

	int32_t value;

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

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

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

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

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

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

	uint32_t value;

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

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

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

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

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

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

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

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

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

	uint32_t value;

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

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

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

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

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

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

	int32_t value;

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

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

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

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

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

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

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

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

	int32_t value;

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

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

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

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

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);
}

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

	uint32_t value;

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

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

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

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

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

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

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

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

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

	int32_t value;

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

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

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

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

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

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

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

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

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

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

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

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 145 to 173
	value = ((uint32_t)(input[18] & 0x7f) << 25) |
			((uint32_t)input[19] << 17) |
			((uint32_t)input[20] << 9) |
			((uint32_t)(input[21] & 0xfc) << 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 174 to 202
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)input[24] << 6) |
			((uint32_t)(input[25] & 0xe0) >> 2);
	output[6] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 145 to 173
	value = ((uint32_t)(input[18] & 0x7f) << 25) |
			((uint32_t)input[19] << 17) |
			((uint32_t)input[20] << 9) |
			((uint32_t)(input[21] & 0xfc) << 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 174 to 202
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)input[24] << 6) |
			((uint32_t)(input[25] & 0xe0) >> 2);
	output[6] = (double)(value >> 3);
}

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

	int32_t value;

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

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

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

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

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 175 to 203
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)input[24] << 7) |
			((uint32_t)(input[25] & 0xf0) >> 1);
	output[6] = (double)(value >> 3);
}

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

	uint32_t value;

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

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

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

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

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 175 to 203
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)input[24] << 7) |
			((uint32_t)(input[25] & 0xf0) >> 1);
	output[6] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 176 to 204
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)input[24] << 8) |
			((uint32_t)(input[25] & 0xf8));
	output[6] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 176 to 204
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)input[24] << 8) |
			((uint32_t)(input[25] & 0xf8));
	output[6] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 177 to 205
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)input[24] << 9) |
			((uint32_t)(input[25] & 0xfc) << 1);
	output[6] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 177 to 205
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)input[24] << 9) |
			((uint32_t)(input[25] & 0xfc) << 1);
	output[6] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 178 to 206
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)input[24] << 10) |
			((uint32_t)(input[25] & 0xfe) << 2);
	output[6] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 178 to 206
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)input[24] << 10) |
			((uint32_t)(input[25] & 0xfe) << 2);
	output[6] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 179 to 207
	value = ((uint32_t)(input[22] & 0x1f) << 27) |
			((uint32_t)input[23] << 19) |
			((uint32_t)input[24] << 11) |
			((uint32_t)input[25] << 3);
	output[6] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 179 to 207
	value = ((uint32_t)(input[22] & 0x1f) << 27) |
			((uint32_t)input[23] << 19) |
			((uint32_t)input[24] << 11) |
			((uint32_t)input[25] << 3);
	output[6] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 180 to 208
	value = ((uint32_t)(input[22] & 0x0f) << 28) |
			((uint32_t)input[23] << 20) |
			((uint32_t)input[24] << 12) |
			((uint32_t)input[25] << 4) |
			((uint32_t)(input[26] & 0x80) >> 4);
	output[6] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 180 to 208
	value = ((uint32_t)(input[22] & 0x0f) << 28) |
			((uint32_t)input[23] << 20) |
			((uint32_t)input[24] << 12) |
			((uint32_t)input[25] << 4) |
			((uint32_t)(input[26] & 0x80) >> 4);
	output[6] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 181 to 209
	value = ((uint32_t)(input[22] & 0x07) << 29) |
			((uint32_t)input[23] << 21) |
			((uint32_t)input[24] << 13) |
			((uint32_t)input[25] << 5) |
			((uint32_t)(input[26] & 0xc0) >> 3);
	output[6] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 181 to 209
	value = ((uint32_t)(input[22] & 0x07) << 29) |
			((uint32_t)input[23] << 21) |
			((uint32_t)input[24] << 13) |
			((uint32_t)input[25] << 5) |
			((uint32_t)(input[26] & 0xc0) >> 3);
	output[6] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 145 to 173
	value = ((uint32_t)(input[18] & 0x7f) << 25) |
			((uint32_t)input[19] << 17) |
			((uint32_t)input[20] << 9) |
			((uint32_t)(input[21] & 0xfc) << 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 174 to 202
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)input[24] << 6) |
			((uint32_t)(input[25] & 0xe0) >> 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 203 to 231
	value = ((uint32_t)(input[25] & 0x1f) << 27) |
			((uint32_t)input[26] << 19) |
			((uint32_t)input[27] << 11) |
			((uint32_t)input[28] << 3);
	output[7] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 145 to 173
	value = ((uint32_t)(input[18] & 0x7f) << 25) |
			((uint32_t)input[19] << 17) |
			((uint32_t)input[20] << 9) |
			((uint32_t)(input[21] & 0xfc) << 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 174 to 202
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)input[24] << 6) |
			((uint32_t)(input[25] & 0xe0) >> 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 203 to 231
	value = ((uint32_t)(input[25] & 0x1f) << 27) |
			((uint32_t)input[26] << 19) |
			((uint32_t)input[27] << 11) |
			((uint32_t)input[28] << 3);
	output[7] = (double)(value >> 3);
}

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

	int32_t value;

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

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

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

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

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 175 to 203
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)input[24] << 7) |
			((uint32_t)(input[25] & 0xf0) >> 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 204 to 232
	value = ((uint32_t)(input[25] & 0x0f) << 28) |
			((uint32_t)input[26] << 20) |
			((uint32_t)input[27] << 12) |
			((uint32_t)input[28] << 4) |
			((uint32_t)(input[29] & 0x80) >> 4);
	output[7] = (double)(value >> 3);
}

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

	uint32_t value;

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

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

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

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

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 175 to 203
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)input[24] << 7) |
			((uint32_t)(input[25] & 0xf0) >> 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 204 to 232
	value = ((uint32_t)(input[25] & 0x0f) << 28) |
			((uint32_t)input[26] << 20) |
			((uint32_t)input[27] << 12) |
			((uint32_t)input[28] << 4) |
			((uint32_t)(input[29] & 0x80) >> 4);
	output[7] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 176 to 204
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)input[24] << 8) |
			((uint32_t)(input[25] & 0xf8));
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 205 to 233
	value = ((uint32_t)(input[25] & 0x07) << 29) |
			((uint32_t)input[26] << 21) |
			((uint32_t)input[27] << 13) |
			((uint32_t)input[28] << 5) |
			((uint32_t)(input[29] & 0xc0) >> 3);
	output[7] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 176 to 204
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)input[24] << 8) |
			((uint32_t)(input[25] & 0xf8));
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 205 to 233
	value = ((uint32_t)(input[25] & 0x07) << 29) |
			((uint32_t)input[26] << 21) |
			((uint32_t)input[27] << 13) |
			((uint32_t)input[28] << 5) |
			((uint32_t)(input[29] & 0xc0) >> 3);
	output[7] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 177 to 205
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)input[24] << 9) |
			((uint32_t)(input[25] & 0xfc) << 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 206 to 234
	value = ((uint32_t)(input[25] & 0x03) << 30) |
			((uint32_t)input[26] << 22) |
			((uint32_t)input[27] << 14) |
			((uint32_t)input[28] << 6) |
			((uint32_t)(input[29] & 0xe0) >> 2);
	output[7] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 177 to 205
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)input[24] << 9) |
			((uint32_t)(input[25] & 0xfc) << 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 206 to 234
	value = ((uint32_t)(input[25] & 0x03) << 30) |
			((uint32_t)input[26] << 22) |
			((uint32_t)input[27] << 14) |
			((uint32_t)input[28] << 6) |
			((uint32_t)(input[29] & 0xe0) >> 2);
	output[7] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 178 to 206
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)input[24] << 10) |
			((uint32_t)(input[25] & 0xfe) << 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 207 to 235
	value = ((uint32_t)(input[25] & 0x01) << 31) |
			((uint32_t)input[26] << 23) |
			((uint32_t)input[27] << 15) |
			((uint32_t)input[28] << 7) |
			((uint32_t)(input[29] & 0xf0) >> 1);
	output[7] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 178 to 206
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)input[24] << 10) |
			((uint32_t)(input[25] & 0xfe) << 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 207 to 235
	value = ((uint32_t)(input[25] & 0x01) << 31) |
			((uint32_t)input[26] << 23) |
			((uint32_t)input[27] << 15) |
			((uint32_t)input[28] << 7) |
			((uint32_t)(input[29] & 0xf0) >> 1);
	output[7] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 179 to 207
	value = ((uint32_t)(input[22] & 0x1f) << 27) |
			((uint32_t)input[23] << 19) |
			((uint32_t)input[24] << 11) |
			((uint32_t)input[25] << 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 208 to 236
	value = ((uint32_t)input[26] << 24) |
			((uint32_t)input[27] << 16) |
			((uint32_t)input[28] << 8) |
			((uint32_t)(input[29] & 0xf8));
	output[7] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 179 to 207
	value = ((uint32_t)(input[22] & 0x1f) << 27) |
			((uint32_t)input[23] << 19) |
			((uint32_t)input[24] << 11) |
			((uint32_t)input[25] << 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 208 to 236
	value = ((uint32_t)input[26] << 24) |
			((uint32_t)input[27] << 16) |
			((uint32_t)input[28] << 8) |
			((uint32_t)(input[29] & 0xf8));
	output[7] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 180 to 208
	value = ((uint32_t)(input[22] & 0x0f) << 28) |
			((uint32_t)input[23] << 20) |
			((uint32_t)input[24] << 12) |
			((uint32_t)input[25] << 4) |
			((uint32_t)(input[26] & 0x80) >> 4);
	output[6] = (double)(value >> 3);

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

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 180 to 208
	value = ((uint32_t)(input[22] & 0x0f) << 28) |
			((uint32_t)input[23] << 20) |
			((uint32_t)input[24] << 12) |
			((uint32_t)input[25] << 4) |
			((uint32_t)(input[26] & 0x80) >> 4);
	output[6] = (double)(value >> 3);

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

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 181 to 209
	value = ((uint32_t)(input[22] & 0x07) << 29) |
			((uint32_t)input[23] << 21) |
			((uint32_t)input[24] << 13) |
			((uint32_t)input[25] << 5) |
			((uint32_t)(input[26] & 0xc0) >> 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 210 to 238
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)input[28] << 10) |
			((uint32_t)(input[29] & 0xfe) << 2);
	output[7] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 181 to 209
	value = ((uint32_t)(input[22] & 0x07) << 29) |
			((uint32_t)input[23] << 21) |
			((uint32_t)input[24] << 13) |
			((uint32_t)input[25] << 5) |
			((uint32_t)(input[26] & 0xc0) >> 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 210 to 238
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)input[28] << 10) |
			((uint32_t)(input[29] & 0xfe) << 2);
	output[7] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 145 to 173
	value = ((uint32_t)(input[18] & 0x7f) << 25) |
			((uint32_t)input[19] << 17) |
			((uint32_t)input[20] << 9) |
			((uint32_t)(input[21] & 0xfc) << 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 174 to 202
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)input[24] << 6) |
			((uint32_t)(input[25] & 0xe0) >> 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 203 to 231
	value = ((uint32_t)(input[25] & 0x1f) << 27) |
			((uint32_t)input[26] << 19) |
			((uint32_t)input[27] << 11) |
			((uint32_t)input[28] << 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 232 to 260
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)input[31] << 8) |
			((uint32_t)(input[32] & 0xf8));
	output[8] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 145 to 173
	value = ((uint32_t)(input[18] & 0x7f) << 25) |
			((uint32_t)input[19] << 17) |
			((uint32_t)input[20] << 9) |
			((uint32_t)(input[21] & 0xfc) << 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 174 to 202
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)input[24] << 6) |
			((uint32_t)(input[25] & 0xe0) >> 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 203 to 231
	value = ((uint32_t)(input[25] & 0x1f) << 27) |
			((uint32_t)input[26] << 19) |
			((uint32_t)input[27] << 11) |
			((uint32_t)input[28] << 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 232 to 260
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)input[31] << 8) |
			((uint32_t)(input[32] & 0xf8));
	output[8] = (double)(value >> 3);
}

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

	int32_t value;

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

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

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

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

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 175 to 203
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)input[24] << 7) |
			((uint32_t)(input[25] & 0xf0) >> 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 204 to 232
	value = ((uint32_t)(input[25] & 0x0f) << 28) |
			((uint32_t)input[26] << 20) |
			((uint32_t)input[27] << 12) |
			((uint32_t)input[28] << 4) |
			((uint32_t)(input[29] & 0x80) >> 4);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 233 to 261
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)input[31] << 9) |
			((uint32_t)(input[32] & 0xfc) << 1);
	output[8] = (double)(value >> 3);
}

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

	uint32_t value;

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

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

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

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

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 175 to 203
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)input[24] << 7) |
			((uint32_t)(input[25] & 0xf0) >> 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 204 to 232
	value = ((uint32_t)(input[25] & 0x0f) << 28) |
			((uint32_t)input[26] << 20) |
			((uint32_t)input[27] << 12) |
			((uint32_t)input[28] << 4) |
			((uint32_t)(input[29] & 0x80) >> 4);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 233 to 261
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)input[31] << 9) |
			((uint32_t)(input[32] & 0xfc) << 1);
	output[8] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 176 to 204
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)input[24] << 8) |
			((uint32_t)(input[25] & 0xf8));
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 205 to 233
	value = ((uint32_t)(input[25] & 0x07) << 29) |
			((uint32_t)input[26] << 21) |
			((uint32_t)input[27] << 13) |
			((uint32_t)input[28] << 5) |
			((uint32_t)(input[29] & 0xc0) >> 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 234 to 262
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)input[31] << 10) |
			((uint32_t)(input[32] & 0xfe) << 2);
	output[8] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 176 to 204
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)input[24] << 8) |
			((uint32_t)(input[25] & 0xf8));
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 205 to 233
	value = ((uint32_t)(input[25] & 0x07) << 29) |
			((uint32_t)input[26] << 21) |
			((uint32_t)input[27] << 13) |
			((uint32_t)input[28] << 5) |
			((uint32_t)(input[29] & 0xc0) >> 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 234 to 262
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)input[31] << 10) |
			((uint32_t)(input[32] & 0xfe) << 2);
	output[8] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 177 to 205
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)input[24] << 9) |
			((uint32_t)(input[25] & 0xfc) << 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 206 to 234
	value = ((uint32_t)(input[25] & 0x03) << 30) |
			((uint32_t)input[26] << 22) |
			((uint32_t)input[27] << 14) |
			((uint32_t)input[28] << 6) |
			((uint32_t)(input[29] & 0xe0) >> 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 235 to 263
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)input[31] << 11) |
			((uint32_t)input[32] << 3);
	output[8] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 177 to 205
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)input[24] << 9) |
			((uint32_t)(input[25] & 0xfc) << 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 206 to 234
	value = ((uint32_t)(input[25] & 0x03) << 30) |
			((uint32_t)input[26] << 22) |
			((uint32_t)input[27] << 14) |
			((uint32_t)input[28] << 6) |
			((uint32_t)(input[29] & 0xe0) >> 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 235 to 263
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)input[31] << 11) |
			((uint32_t)input[32] << 3);
	output[8] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 178 to 206
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)input[24] << 10) |
			((uint32_t)(input[25] & 0xfe) << 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 207 to 235
	value = ((uint32_t)(input[25] & 0x01) << 31) |
			((uint32_t)input[26] << 23) |
			((uint32_t)input[27] << 15) |
			((uint32_t)input[28] << 7) |
			((uint32_t)(input[29] & 0xf0) >> 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 236 to 264
	value = ((uint32_t)(input[29] & 0x0f) << 28) |
			((uint32_t)input[30] << 20) |
			((uint32_t)input[31] << 12) |
			((uint32_t)input[32] << 4) |
			((uint32_t)(input[33] & 0x80) >> 4);
	output[8] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 178 to 206
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)input[24] << 10) |
			((uint32_t)(input[25] & 0xfe) << 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 207 to 235
	value = ((uint32_t)(input[25] & 0x01) << 31) |
			((uint32_t)input[26] << 23) |
			((uint32_t)input[27] << 15) |
			((uint32_t)input[28] << 7) |
			((uint32_t)(input[29] & 0xf0) >> 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 236 to 264
	value = ((uint32_t)(input[29] & 0x0f) << 28) |
			((uint32_t)input[30] << 20) |
			((uint32_t)input[31] << 12) |
			((uint32_t)input[32] << 4) |
			((uint32_t)(input[33] & 0x80) >> 4);
	output[8] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 179 to 207
	value = ((uint32_t)(input[22] & 0x1f) << 27) |
			((uint32_t)input[23] << 19) |
			((uint32_t)input[24] << 11) |
			((uint32_t)input[25] << 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 208 to 236
	value = ((uint32_t)input[26] << 24) |
			((uint32_t)input[27] << 16) |
			((uint32_t)input[28] << 8) |
			((uint32_t)(input[29] & 0xf8));
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 237 to 265
	value = ((uint32_t)(input[29] & 0x07) << 29) |
			((uint32_t)input[30] << 21) |
			((uint32_t)input[31] << 13) |
			((uint32_t)input[32] << 5) |
			((uint32_t)(input[33] & 0xc0) >> 3);
	output[8] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 179 to 207
	value = ((uint32_t)(input[22] & 0x1f) << 27) |
			((uint32_t)input[23] << 19) |
			((uint32_t)input[24] << 11) |
			((uint32_t)input[25] << 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 208 to 236
	value = ((uint32_t)input[26] << 24) |
			((uint32_t)input[27] << 16) |
			((uint32_t)input[28] << 8) |
			((uint32_t)(input[29] & 0xf8));
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 237 to 265
	value = ((uint32_t)(input[29] & 0x07) << 29) |
			((uint32_t)input[30] << 21) |
			((uint32_t)input[31] << 13) |
			((uint32_t)input[32] << 5) |
			((uint32_t)(input[33] & 0xc0) >> 3);
	output[8] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 180 to 208
	value = ((uint32_t)(input[22] & 0x0f) << 28) |
			((uint32_t)input[23] << 20) |
			((uint32_t)input[24] << 12) |
			((uint32_t)input[25] << 4) |
			((uint32_t)(input[26] & 0x80) >> 4);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 209 to 237
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)input[28] << 9) |
			((uint32_t)(input[29] & 0xfc) << 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 238 to 266
	value = ((uint32_t)(input[29] & 0x03) << 30) |
			((uint32_t)input[30] << 22) |
			((uint32_t)input[31] << 14) |
			((uint32_t)input[32] << 6) |
			((uint32_t)(input[33] & 0xe0) >> 2);
	output[8] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 180 to 208
	value = ((uint32_t)(input[22] & 0x0f) << 28) |
			((uint32_t)input[23] << 20) |
			((uint32_t)input[24] << 12) |
			((uint32_t)input[25] << 4) |
			((uint32_t)(input[26] & 0x80) >> 4);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 209 to 237
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)input[28] << 9) |
			((uint32_t)(input[29] & 0xfc) << 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 238 to 266
	value = ((uint32_t)(input[29] & 0x03) << 30) |
			((uint32_t)input[30] << 22) |
			((uint32_t)input[31] << 14) |
			((uint32_t)input[32] << 6) |
			((uint32_t)(input[33] & 0xe0) >> 2);
	output[8] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 181 to 209
	value = ((uint32_t)(input[22] & 0x07) << 29) |
			((uint32_t)input[23] << 21) |
			((uint32_t)input[24] << 13) |
			((uint32_t)input[25] << 5) |
			((uint32_t)(input[26] & 0xc0) >> 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 210 to 238
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)input[28] << 10) |
			((uint32_t)(input[29] & 0xfe) << 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 239 to 267
	value = ((uint32_t)(input[29] & 0x01) << 31) |
			((uint32_t)input[30] << 23) |
			((uint32_t)input[31] << 15) |
			((uint32_t)input[32] << 7) |
			((uint32_t)(input[33] & 0xf0) >> 1);
	output[8] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 181 to 209
	value = ((uint32_t)(input[22] & 0x07) << 29) |
			((uint32_t)input[23] << 21) |
			((uint32_t)input[24] << 13) |
			((uint32_t)input[25] << 5) |
			((uint32_t)(input[26] & 0xc0) >> 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 210 to 238
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)input[28] << 10) |
			((uint32_t)(input[29] & 0xfe) << 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 239 to 267
	value = ((uint32_t)(input[29] & 0x01) << 31) |
			((uint32_t)input[30] << 23) |
			((uint32_t)input[31] << 15) |
			((uint32_t)input[32] << 7) |
			((uint32_t)(input[33] & 0xf0) >> 1);
	output[8] = (double)(value >> 3);
}

static void unpack_10_29bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 29-bit signed
	// Skip 0 bits, read 290 bits of data.
	// Input must be at least 37 bytes long

	int32_t value;

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

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

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

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 145 to 173
	value = ((uint32_t)(input[18] & 0x7f) << 25) |
			((uint32_t)input[19] << 17) |
			((uint32_t)input[20] << 9) |
			((uint32_t)(input[21] & 0xfc) << 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 174 to 202
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)input[24] << 6) |
			((uint32_t)(input[25] & 0xe0) >> 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 203 to 231
	value = ((uint32_t)(input[25] & 0x1f) << 27) |
			((uint32_t)input[26] << 19) |
			((uint32_t)input[27] << 11) |
			((uint32_t)input[28] << 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 232 to 260
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)input[31] << 8) |
			((uint32_t)(input[32] & 0xf8));
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 261 to 289
	value = ((uint32_t)(input[32] & 0x07) << 29) |
			((uint32_t)input[33] << 21) |
			((uint32_t)input[34] << 13) |
			((uint32_t)input[35] << 5) |
			((uint32_t)(input[36] & 0xc0) >> 3);
	output[9] = (double)(value >> 3);
}

static void unpack_10_29bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 29-bit unsigned
	// Skip 0 bits, read 290 bits of data.
	// Input must be at least 37 bytes long

	uint32_t value;

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

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

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

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 145 to 173
	value = ((uint32_t)(input[18] & 0x7f) << 25) |
			((uint32_t)input[19] << 17) |
			((uint32_t)input[20] << 9) |
			((uint32_t)(input[21] & 0xfc) << 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 174 to 202
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)input[24] << 6) |
			((uint32_t)(input[25] & 0xe0) >> 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 203 to 231
	value = ((uint32_t)(input[25] & 0x1f) << 27) |
			((uint32_t)input[26] << 19) |
			((uint32_t)input[27] << 11) |
			((uint32_t)input[28] << 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 232 to 260
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)input[31] << 8) |
			((uint32_t)(input[32] & 0xf8));
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 261 to 289
	value = ((uint32_t)(input[32] & 0x07) << 29) |
			((uint32_t)input[33] << 21) |
			((uint32_t)input[34] << 13) |
			((uint32_t)input[35] << 5) |
			((uint32_t)(input[36] & 0xc0) >> 3);
	output[9] = (double)(value >> 3);
}

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

	int32_t value;

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

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

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

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

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 175 to 203
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)input[24] << 7) |
			((uint32_t)(input[25] & 0xf0) >> 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 204 to 232
	value = ((uint32_t)(input[25] & 0x0f) << 28) |
			((uint32_t)input[26] << 20) |
			((uint32_t)input[27] << 12) |
			((uint32_t)input[28] << 4) |
			((uint32_t)(input[29] & 0x80) >> 4);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 233 to 261
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)input[31] << 9) |
			((uint32_t)(input[32] & 0xfc) << 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 262 to 290
	value = ((uint32_t)(input[32] & 0x03) << 30) |
			((uint32_t)input[33] << 22) |
			((uint32_t)input[34] << 14) |
			((uint32_t)input[35] << 6) |
			((uint32_t)(input[36] & 0xe0) >> 2);
	output[9] = (double)(value >> 3);
}

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

	uint32_t value;

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

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

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

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

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 175 to 203
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)input[24] << 7) |
			((uint32_t)(input[25] & 0xf0) >> 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 204 to 232
	value = ((uint32_t)(input[25] & 0x0f) << 28) |
			((uint32_t)input[26] << 20) |
			((uint32_t)input[27] << 12) |
			((uint32_t)input[28] << 4) |
			((uint32_t)(input[29] & 0x80) >> 4);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 233 to 261
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)input[31] << 9) |
			((uint32_t)(input[32] & 0xfc) << 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 262 to 290
	value = ((uint32_t)(input[32] & 0x03) << 30) |
			((uint32_t)input[33] << 22) |
			((uint32_t)input[34] << 14) |
			((uint32_t)input[35] << 6) |
			((uint32_t)(input[36] & 0xe0) >> 2);
	output[9] = (double)(value >> 3);
}

static void unpack_10_29bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 29-bit signed
	// Skip 2 bits, read 290 bits of data.
	// Input must be at least 37 bytes long

	int32_t value;

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

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

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

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

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 176 to 204
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)input[24] << 8) |
			((uint32_t)(input[25] & 0xf8));
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 205 to 233
	value = ((uint32_t)(input[25] & 0x07) << 29) |
			((uint32_t)input[26] << 21) |
			((uint32_t)input[27] << 13) |
			((uint32_t)input[28] << 5) |
			((uint32_t)(input[29] & 0xc0) >> 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 234 to 262
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)input[31] << 10) |
			((uint32_t)(input[32] & 0xfe) << 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 263 to 291
	value = ((uint32_t)(input[32] & 0x01) << 31) |
			((uint32_t)input[33] << 23) |
			((uint32_t)input[34] << 15) |
			((uint32_t)input[35] << 7) |
			((uint32_t)(input[36] & 0xf0) >> 1);
	output[9] = (double)(value >> 3);
}

static void unpack_10_29bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 29-bit unsigned
	// Skip 2 bits, read 290 bits of data.
	// Input must be at least 37 bytes long

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 176 to 204
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)input[24] << 8) |
			((uint32_t)(input[25] & 0xf8));
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 205 to 233
	value = ((uint32_t)(input[25] & 0x07) << 29) |
			((uint32_t)input[26] << 21) |
			((uint32_t)input[27] << 13) |
			((uint32_t)input[28] << 5) |
			((uint32_t)(input[29] & 0xc0) >> 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 234 to 262
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)input[31] << 10) |
			((uint32_t)(input[32] & 0xfe) << 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 263 to 291
	value = ((uint32_t)(input[32] & 0x01) << 31) |
			((uint32_t)input[33] << 23) |
			((uint32_t)input[34] << 15) |
			((uint32_t)input[35] << 7) |
			((uint32_t)(input[36] & 0xf0) >> 1);
	output[9] = (double)(value >> 3);
}

static void unpack_10_29bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 29-bit signed
	// Skip 3 bits, read 290 bits of data.
	// Input must be at least 37 bytes long

	int32_t value;

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

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

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

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 177 to 205
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)input[24] << 9) |
			((uint32_t)(input[25] & 0xfc) << 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 206 to 234
	value = ((uint32_t)(input[25] & 0x03) << 30) |
			((uint32_t)input[26] << 22) |
			((uint32_t)input[27] << 14) |
			((uint32_t)input[28] << 6) |
			((uint32_t)(input[29] & 0xe0) >> 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 235 to 263
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)input[31] << 11) |
			((uint32_t)input[32] << 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 264 to 292
	value = ((uint32_t)input[33] << 24) |
			((uint32_t)input[34] << 16) |
			((uint32_t)input[35] << 8) |
			((uint32_t)(input[36] & 0xf8));
	output[9] = (double)(value >> 3);
}

static void unpack_10_29bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 29-bit unsigned
	// Skip 3 bits, read 290 bits of data.
	// Input must be at least 37 bytes long

	uint32_t value;

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

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

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

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 177 to 205
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)input[24] << 9) |
			((uint32_t)(input[25] & 0xfc) << 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 206 to 234
	value = ((uint32_t)(input[25] & 0x03) << 30) |
			((uint32_t)input[26] << 22) |
			((uint32_t)input[27] << 14) |
			((uint32_t)input[28] << 6) |
			((uint32_t)(input[29] & 0xe0) >> 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 235 to 263
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)input[31] << 11) |
			((uint32_t)input[32] << 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 264 to 292
	value = ((uint32_t)input[33] << 24) |
			((uint32_t)input[34] << 16) |
			((uint32_t)input[35] << 8) |
			((uint32_t)(input[36] & 0xf8));
	output[9] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 178 to 206
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)input[24] << 10) |
			((uint32_t)(input[25] & 0xfe) << 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 207 to 235
	value = ((uint32_t)(input[25] & 0x01) << 31) |
			((uint32_t)input[26] << 23) |
			((uint32_t)input[27] << 15) |
			((uint32_t)input[28] << 7) |
			((uint32_t)(input[29] & 0xf0) >> 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 236 to 264
	value = ((uint32_t)(input[29] & 0x0f) << 28) |
			((uint32_t)input[30] << 20) |
			((uint32_t)input[31] << 12) |
			((uint32_t)input[32] << 4) |
			((uint32_t)(input[33] & 0x80) >> 4);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 265 to 293
	value = ((uint32_t)(input[33] & 0x7f) << 25) |
			((uint32_t)input[34] << 17) |
			((uint32_t)input[35] << 9) |
			((uint32_t)(input[36] & 0xfc) << 1);
	output[9] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 178 to 206
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)input[24] << 10) |
			((uint32_t)(input[25] & 0xfe) << 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 207 to 235
	value = ((uint32_t)(input[25] & 0x01) << 31) |
			((uint32_t)input[26] << 23) |
			((uint32_t)input[27] << 15) |
			((uint32_t)input[28] << 7) |
			((uint32_t)(input[29] & 0xf0) >> 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 236 to 264
	value = ((uint32_t)(input[29] & 0x0f) << 28) |
			((uint32_t)input[30] << 20) |
			((uint32_t)input[31] << 12) |
			((uint32_t)input[32] << 4) |
			((uint32_t)(input[33] & 0x80) >> 4);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 265 to 293
	value = ((uint32_t)(input[33] & 0x7f) << 25) |
			((uint32_t)input[34] << 17) |
			((uint32_t)input[35] << 9) |
			((uint32_t)(input[36] & 0xfc) << 1);
	output[9] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 179 to 207
	value = ((uint32_t)(input[22] & 0x1f) << 27) |
			((uint32_t)input[23] << 19) |
			((uint32_t)input[24] << 11) |
			((uint32_t)input[25] << 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 208 to 236
	value = ((uint32_t)input[26] << 24) |
			((uint32_t)input[27] << 16) |
			((uint32_t)input[28] << 8) |
			((uint32_t)(input[29] & 0xf8));
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 237 to 265
	value = ((uint32_t)(input[29] & 0x07) << 29) |
			((uint32_t)input[30] << 21) |
			((uint32_t)input[31] << 13) |
			((uint32_t)input[32] << 5) |
			((uint32_t)(input[33] & 0xc0) >> 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 266 to 294
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)input[35] << 10) |
			((uint32_t)(input[36] & 0xfe) << 2);
	output[9] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 179 to 207
	value = ((uint32_t)(input[22] & 0x1f) << 27) |
			((uint32_t)input[23] << 19) |
			((uint32_t)input[24] << 11) |
			((uint32_t)input[25] << 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 208 to 236
	value = ((uint32_t)input[26] << 24) |
			((uint32_t)input[27] << 16) |
			((uint32_t)input[28] << 8) |
			((uint32_t)(input[29] & 0xf8));
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 237 to 265
	value = ((uint32_t)(input[29] & 0x07) << 29) |
			((uint32_t)input[30] << 21) |
			((uint32_t)input[31] << 13) |
			((uint32_t)input[32] << 5) |
			((uint32_t)(input[33] & 0xc0) >> 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 266 to 294
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)input[35] << 10) |
			((uint32_t)(input[36] & 0xfe) << 2);
	output[9] = (double)(value >> 3);
}

static void unpack_10_29bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 29-bit signed
	// Skip 6 bits, read 290 bits of data.
	// Input must be at least 37 bytes long

	int32_t value;

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

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

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

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

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 180 to 208
	value = ((uint32_t)(input[22] & 0x0f) << 28) |
			((uint32_t)input[23] << 20) |
			((uint32_t)input[24] << 12) |
			((uint32_t)input[25] << 4) |
			((uint32_t)(input[26] & 0x80) >> 4);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 209 to 237
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)input[28] << 9) |
			((uint32_t)(input[29] & 0xfc) << 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 238 to 266
	value = ((uint32_t)(input[29] & 0x03) << 30) |
			((uint32_t)input[30] << 22) |
			((uint32_t)input[31] << 14) |
			((uint32_t)input[32] << 6) |
			((uint32_t)(input[33] & 0xe0) >> 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 267 to 295
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)input[35] << 11) |
			((uint32_t)input[36] << 3);
	output[9] = (double)(value >> 3);
}

static void unpack_10_29bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 29-bit unsigned
	// Skip 6 bits, read 290 bits of data.
	// Input must be at least 37 bytes long

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 180 to 208
	value = ((uint32_t)(input[22] & 0x0f) << 28) |
			((uint32_t)input[23] << 20) |
			((uint32_t)input[24] << 12) |
			((uint32_t)input[25] << 4) |
			((uint32_t)(input[26] & 0x80) >> 4);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 209 to 237
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)input[28] << 9) |
			((uint32_t)(input[29] & 0xfc) << 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 238 to 266
	value = ((uint32_t)(input[29] & 0x03) << 30) |
			((uint32_t)input[30] << 22) |
			((uint32_t)input[31] << 14) |
			((uint32_t)input[32] << 6) |
			((uint32_t)(input[33] & 0xe0) >> 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 267 to 295
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)input[35] << 11) |
			((uint32_t)input[36] << 3);
	output[9] = (double)(value >> 3);
}

static void unpack_10_29bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 29-bit signed
	// Skip 7 bits, read 290 bits of data.
	// Input must be at least 38 bytes long

	int32_t value;

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

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

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

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

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 181 to 209
	value = ((uint32_t)(input[22] & 0x07) << 29) |
			((uint32_t)input[23] << 21) |
			((uint32_t)input[24] << 13) |
			((uint32_t)input[25] << 5) |
			((uint32_t)(input[26] & 0xc0) >> 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 210 to 238
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)input[28] << 10) |
			((uint32_t)(input[29] & 0xfe) << 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 239 to 267
	value = ((uint32_t)(input[29] & 0x01) << 31) |
			((uint32_t)input[30] << 23) |
			((uint32_t)input[31] << 15) |
			((uint32_t)input[32] << 7) |
			((uint32_t)(input[33] & 0xf0) >> 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 268 to 296
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)input[35] << 12) |
			((uint32_t)input[36] << 4) |
			((uint32_t)(input[37] & 0x80) >> 4);
	output[9] = (double)(value >> 3);
}

static void unpack_10_29bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 29-bit unsigned
	// Skip 7 bits, read 290 bits of data.
	// Input must be at least 38 bytes long

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 181 to 209
	value = ((uint32_t)(input[22] & 0x07) << 29) |
			((uint32_t)input[23] << 21) |
			((uint32_t)input[24] << 13) |
			((uint32_t)input[25] << 5) |
			((uint32_t)(input[26] & 0xc0) >> 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 210 to 238
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)input[28] << 10) |
			((uint32_t)(input[29] & 0xfe) << 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 239 to 267
	value = ((uint32_t)(input[29] & 0x01) << 31) |
			((uint32_t)input[30] << 23) |
			((uint32_t)input[31] << 15) |
			((uint32_t)input[32] << 7) |
			((uint32_t)(input[33] & 0xf0) >> 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 268 to 296
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)input[35] << 12) |
			((uint32_t)input[36] << 4) |
			((uint32_t)(input[37] & 0x80) >> 4);
	output[9] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 145 to 173
	value = ((uint32_t)(input[18] & 0x7f) << 25) |
			((uint32_t)input[19] << 17) |
			((uint32_t)input[20] << 9) |
			((uint32_t)(input[21] & 0xfc) << 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 174 to 202
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)input[24] << 6) |
			((uint32_t)(input[25] & 0xe0) >> 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 203 to 231
	value = ((uint32_t)(input[25] & 0x1f) << 27) |
			((uint32_t)input[26] << 19) |
			((uint32_t)input[27] << 11) |
			((uint32_t)input[28] << 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 232 to 260
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)input[31] << 8) |
			((uint32_t)(input[32] & 0xf8));
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 261 to 289
	value = ((uint32_t)(input[32] & 0x07) << 29) |
			((uint32_t)input[33] << 21) |
			((uint32_t)input[34] << 13) |
			((uint32_t)input[35] << 5) |
			((uint32_t)(input[36] & 0xc0) >> 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 290 to 318
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)input[38] << 10) |
			((uint32_t)(input[39] & 0xfe) << 2);
	output[10] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 145 to 173
	value = ((uint32_t)(input[18] & 0x7f) << 25) |
			((uint32_t)input[19] << 17) |
			((uint32_t)input[20] << 9) |
			((uint32_t)(input[21] & 0xfc) << 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 174 to 202
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)input[24] << 6) |
			((uint32_t)(input[25] & 0xe0) >> 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 203 to 231
	value = ((uint32_t)(input[25] & 0x1f) << 27) |
			((uint32_t)input[26] << 19) |
			((uint32_t)input[27] << 11) |
			((uint32_t)input[28] << 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 232 to 260
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)input[31] << 8) |
			((uint32_t)(input[32] & 0xf8));
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 261 to 289
	value = ((uint32_t)(input[32] & 0x07) << 29) |
			((uint32_t)input[33] << 21) |
			((uint32_t)input[34] << 13) |
			((uint32_t)input[35] << 5) |
			((uint32_t)(input[36] & 0xc0) >> 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 290 to 318
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)input[38] << 10) |
			((uint32_t)(input[39] & 0xfe) << 2);
	output[10] = (double)(value >> 3);
}

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

	int32_t value;

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

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

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

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

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 175 to 203
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)input[24] << 7) |
			((uint32_t)(input[25] & 0xf0) >> 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 204 to 232
	value = ((uint32_t)(input[25] & 0x0f) << 28) |
			((uint32_t)input[26] << 20) |
			((uint32_t)input[27] << 12) |
			((uint32_t)input[28] << 4) |
			((uint32_t)(input[29] & 0x80) >> 4);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 233 to 261
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)input[31] << 9) |
			((uint32_t)(input[32] & 0xfc) << 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 262 to 290
	value = ((uint32_t)(input[32] & 0x03) << 30) |
			((uint32_t)input[33] << 22) |
			((uint32_t)input[34] << 14) |
			((uint32_t)input[35] << 6) |
			((uint32_t)(input[36] & 0xe0) >> 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 291 to 319
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)input[38] << 11) |
			((uint32_t)input[39] << 3);
	output[10] = (double)(value >> 3);
}

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

	uint32_t value;

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

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

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

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

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 175 to 203
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)input[24] << 7) |
			((uint32_t)(input[25] & 0xf0) >> 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 204 to 232
	value = ((uint32_t)(input[25] & 0x0f) << 28) |
			((uint32_t)input[26] << 20) |
			((uint32_t)input[27] << 12) |
			((uint32_t)input[28] << 4) |
			((uint32_t)(input[29] & 0x80) >> 4);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 233 to 261
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)input[31] << 9) |
			((uint32_t)(input[32] & 0xfc) << 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 262 to 290
	value = ((uint32_t)(input[32] & 0x03) << 30) |
			((uint32_t)input[33] << 22) |
			((uint32_t)input[34] << 14) |
			((uint32_t)input[35] << 6) |
			((uint32_t)(input[36] & 0xe0) >> 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 291 to 319
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)input[38] << 11) |
			((uint32_t)input[39] << 3);
	output[10] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 176 to 204
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)input[24] << 8) |
			((uint32_t)(input[25] & 0xf8));
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 205 to 233
	value = ((uint32_t)(input[25] & 0x07) << 29) |
			((uint32_t)input[26] << 21) |
			((uint32_t)input[27] << 13) |
			((uint32_t)input[28] << 5) |
			((uint32_t)(input[29] & 0xc0) >> 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 234 to 262
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)input[31] << 10) |
			((uint32_t)(input[32] & 0xfe) << 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 263 to 291
	value = ((uint32_t)(input[32] & 0x01) << 31) |
			((uint32_t)input[33] << 23) |
			((uint32_t)input[34] << 15) |
			((uint32_t)input[35] << 7) |
			((uint32_t)(input[36] & 0xf0) >> 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 292 to 320
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)input[38] << 12) |
			((uint32_t)input[39] << 4) |
			((uint32_t)(input[40] & 0x80) >> 4);
	output[10] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 176 to 204
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)input[24] << 8) |
			((uint32_t)(input[25] & 0xf8));
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 205 to 233
	value = ((uint32_t)(input[25] & 0x07) << 29) |
			((uint32_t)input[26] << 21) |
			((uint32_t)input[27] << 13) |
			((uint32_t)input[28] << 5) |
			((uint32_t)(input[29] & 0xc0) >> 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 234 to 262
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)input[31] << 10) |
			((uint32_t)(input[32] & 0xfe) << 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 263 to 291
	value = ((uint32_t)(input[32] & 0x01) << 31) |
			((uint32_t)input[33] << 23) |
			((uint32_t)input[34] << 15) |
			((uint32_t)input[35] << 7) |
			((uint32_t)(input[36] & 0xf0) >> 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 292 to 320
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)input[38] << 12) |
			((uint32_t)input[39] << 4) |
			((uint32_t)(input[40] & 0x80) >> 4);
	output[10] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 177 to 205
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)input[24] << 9) |
			((uint32_t)(input[25] & 0xfc) << 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 206 to 234
	value = ((uint32_t)(input[25] & 0x03) << 30) |
			((uint32_t)input[26] << 22) |
			((uint32_t)input[27] << 14) |
			((uint32_t)input[28] << 6) |
			((uint32_t)(input[29] & 0xe0) >> 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 235 to 263
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)input[31] << 11) |
			((uint32_t)input[32] << 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 264 to 292
	value = ((uint32_t)input[33] << 24) |
			((uint32_t)input[34] << 16) |
			((uint32_t)input[35] << 8) |
			((uint32_t)(input[36] & 0xf8));
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 293 to 321
	value = ((uint32_t)(input[36] & 0x07) << 29) |
			((uint32_t)input[37] << 21) |
			((uint32_t)input[38] << 13) |
			((uint32_t)input[39] << 5) |
			((uint32_t)(input[40] & 0xc0) >> 3);
	output[10] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 177 to 205
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)input[24] << 9) |
			((uint32_t)(input[25] & 0xfc) << 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 206 to 234
	value = ((uint32_t)(input[25] & 0x03) << 30) |
			((uint32_t)input[26] << 22) |
			((uint32_t)input[27] << 14) |
			((uint32_t)input[28] << 6) |
			((uint32_t)(input[29] & 0xe0) >> 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 235 to 263
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)input[31] << 11) |
			((uint32_t)input[32] << 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 264 to 292
	value = ((uint32_t)input[33] << 24) |
			((uint32_t)input[34] << 16) |
			((uint32_t)input[35] << 8) |
			((uint32_t)(input[36] & 0xf8));
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 293 to 321
	value = ((uint32_t)(input[36] & 0x07) << 29) |
			((uint32_t)input[37] << 21) |
			((uint32_t)input[38] << 13) |
			((uint32_t)input[39] << 5) |
			((uint32_t)(input[40] & 0xc0) >> 3);
	output[10] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 178 to 206
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)input[24] << 10) |
			((uint32_t)(input[25] & 0xfe) << 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 207 to 235
	value = ((uint32_t)(input[25] & 0x01) << 31) |
			((uint32_t)input[26] << 23) |
			((uint32_t)input[27] << 15) |
			((uint32_t)input[28] << 7) |
			((uint32_t)(input[29] & 0xf0) >> 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 236 to 264
	value = ((uint32_t)(input[29] & 0x0f) << 28) |
			((uint32_t)input[30] << 20) |
			((uint32_t)input[31] << 12) |
			((uint32_t)input[32] << 4) |
			((uint32_t)(input[33] & 0x80) >> 4);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 265 to 293
	value = ((uint32_t)(input[33] & 0x7f) << 25) |
			((uint32_t)input[34] << 17) |
			((uint32_t)input[35] << 9) |
			((uint32_t)(input[36] & 0xfc) << 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 294 to 322
	value = ((uint32_t)(input[36] & 0x03) << 30) |
			((uint32_t)input[37] << 22) |
			((uint32_t)input[38] << 14) |
			((uint32_t)input[39] << 6) |
			((uint32_t)(input[40] & 0xe0) >> 2);
	output[10] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 178 to 206
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)input[24] << 10) |
			((uint32_t)(input[25] & 0xfe) << 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 207 to 235
	value = ((uint32_t)(input[25] & 0x01) << 31) |
			((uint32_t)input[26] << 23) |
			((uint32_t)input[27] << 15) |
			((uint32_t)input[28] << 7) |
			((uint32_t)(input[29] & 0xf0) >> 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 236 to 264
	value = ((uint32_t)(input[29] & 0x0f) << 28) |
			((uint32_t)input[30] << 20) |
			((uint32_t)input[31] << 12) |
			((uint32_t)input[32] << 4) |
			((uint32_t)(input[33] & 0x80) >> 4);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 265 to 293
	value = ((uint32_t)(input[33] & 0x7f) << 25) |
			((uint32_t)input[34] << 17) |
			((uint32_t)input[35] << 9) |
			((uint32_t)(input[36] & 0xfc) << 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 294 to 322
	value = ((uint32_t)(input[36] & 0x03) << 30) |
			((uint32_t)input[37] << 22) |
			((uint32_t)input[38] << 14) |
			((uint32_t)input[39] << 6) |
			((uint32_t)(input[40] & 0xe0) >> 2);
	output[10] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 179 to 207
	value = ((uint32_t)(input[22] & 0x1f) << 27) |
			((uint32_t)input[23] << 19) |
			((uint32_t)input[24] << 11) |
			((uint32_t)input[25] << 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 208 to 236
	value = ((uint32_t)input[26] << 24) |
			((uint32_t)input[27] << 16) |
			((uint32_t)input[28] << 8) |
			((uint32_t)(input[29] & 0xf8));
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 237 to 265
	value = ((uint32_t)(input[29] & 0x07) << 29) |
			((uint32_t)input[30] << 21) |
			((uint32_t)input[31] << 13) |
			((uint32_t)input[32] << 5) |
			((uint32_t)(input[33] & 0xc0) >> 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 266 to 294
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)input[35] << 10) |
			((uint32_t)(input[36] & 0xfe) << 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 295 to 323
	value = ((uint32_t)(input[36] & 0x01) << 31) |
			((uint32_t)input[37] << 23) |
			((uint32_t)input[38] << 15) |
			((uint32_t)input[39] << 7) |
			((uint32_t)(input[40] & 0xf0) >> 1);
	output[10] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 179 to 207
	value = ((uint32_t)(input[22] & 0x1f) << 27) |
			((uint32_t)input[23] << 19) |
			((uint32_t)input[24] << 11) |
			((uint32_t)input[25] << 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 208 to 236
	value = ((uint32_t)input[26] << 24) |
			((uint32_t)input[27] << 16) |
			((uint32_t)input[28] << 8) |
			((uint32_t)(input[29] & 0xf8));
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 237 to 265
	value = ((uint32_t)(input[29] & 0x07) << 29) |
			((uint32_t)input[30] << 21) |
			((uint32_t)input[31] << 13) |
			((uint32_t)input[32] << 5) |
			((uint32_t)(input[33] & 0xc0) >> 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 266 to 294
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)input[35] << 10) |
			((uint32_t)(input[36] & 0xfe) << 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 295 to 323
	value = ((uint32_t)(input[36] & 0x01) << 31) |
			((uint32_t)input[37] << 23) |
			((uint32_t)input[38] << 15) |
			((uint32_t)input[39] << 7) |
			((uint32_t)(input[40] & 0xf0) >> 1);
	output[10] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 180 to 208
	value = ((uint32_t)(input[22] & 0x0f) << 28) |
			((uint32_t)input[23] << 20) |
			((uint32_t)input[24] << 12) |
			((uint32_t)input[25] << 4) |
			((uint32_t)(input[26] & 0x80) >> 4);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 209 to 237
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)input[28] << 9) |
			((uint32_t)(input[29] & 0xfc) << 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 238 to 266
	value = ((uint32_t)(input[29] & 0x03) << 30) |
			((uint32_t)input[30] << 22) |
			((uint32_t)input[31] << 14) |
			((uint32_t)input[32] << 6) |
			((uint32_t)(input[33] & 0xe0) >> 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 267 to 295
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)input[35] << 11) |
			((uint32_t)input[36] << 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 296 to 324
	value = ((uint32_t)input[37] << 24) |
			((uint32_t)input[38] << 16) |
			((uint32_t)input[39] << 8) |
			((uint32_t)(input[40] & 0xf8));
	output[10] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 180 to 208
	value = ((uint32_t)(input[22] & 0x0f) << 28) |
			((uint32_t)input[23] << 20) |
			((uint32_t)input[24] << 12) |
			((uint32_t)input[25] << 4) |
			((uint32_t)(input[26] & 0x80) >> 4);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 209 to 237
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)input[28] << 9) |
			((uint32_t)(input[29] & 0xfc) << 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 238 to 266
	value = ((uint32_t)(input[29] & 0x03) << 30) |
			((uint32_t)input[30] << 22) |
			((uint32_t)input[31] << 14) |
			((uint32_t)input[32] << 6) |
			((uint32_t)(input[33] & 0xe0) >> 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 267 to 295
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)input[35] << 11) |
			((uint32_t)input[36] << 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 296 to 324
	value = ((uint32_t)input[37] << 24) |
			((uint32_t)input[38] << 16) |
			((uint32_t)input[39] << 8) |
			((uint32_t)(input[40] & 0xf8));
	output[10] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 181 to 209
	value = ((uint32_t)(input[22] & 0x07) << 29) |
			((uint32_t)input[23] << 21) |
			((uint32_t)input[24] << 13) |
			((uint32_t)input[25] << 5) |
			((uint32_t)(input[26] & 0xc0) >> 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 210 to 238
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)input[28] << 10) |
			((uint32_t)(input[29] & 0xfe) << 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 239 to 267
	value = ((uint32_t)(input[29] & 0x01) << 31) |
			((uint32_t)input[30] << 23) |
			((uint32_t)input[31] << 15) |
			((uint32_t)input[32] << 7) |
			((uint32_t)(input[33] & 0xf0) >> 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 268 to 296
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)input[35] << 12) |
			((uint32_t)input[36] << 4) |
			((uint32_t)(input[37] & 0x80) >> 4);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 297 to 325
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xfc) << 1);
	output[10] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 181 to 209
	value = ((uint32_t)(input[22] & 0x07) << 29) |
			((uint32_t)input[23] << 21) |
			((uint32_t)input[24] << 13) |
			((uint32_t)input[25] << 5) |
			((uint32_t)(input[26] & 0xc0) >> 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 210 to 238
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)input[28] << 10) |
			((uint32_t)(input[29] & 0xfe) << 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 239 to 267
	value = ((uint32_t)(input[29] & 0x01) << 31) |
			((uint32_t)input[30] << 23) |
			((uint32_t)input[31] << 15) |
			((uint32_t)input[32] << 7) |
			((uint32_t)(input[33] & 0xf0) >> 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 268 to 296
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)input[35] << 12) |
			((uint32_t)input[36] << 4) |
			((uint32_t)(input[37] & 0x80) >> 4);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 297 to 325
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xfc) << 1);
	output[10] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 145 to 173
	value = ((uint32_t)(input[18] & 0x7f) << 25) |
			((uint32_t)input[19] << 17) |
			((uint32_t)input[20] << 9) |
			((uint32_t)(input[21] & 0xfc) << 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 174 to 202
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)input[24] << 6) |
			((uint32_t)(input[25] & 0xe0) >> 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 203 to 231
	value = ((uint32_t)(input[25] & 0x1f) << 27) |
			((uint32_t)input[26] << 19) |
			((uint32_t)input[27] << 11) |
			((uint32_t)input[28] << 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 232 to 260
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)input[31] << 8) |
			((uint32_t)(input[32] & 0xf8));
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 261 to 289
	value = ((uint32_t)(input[32] & 0x07) << 29) |
			((uint32_t)input[33] << 21) |
			((uint32_t)input[34] << 13) |
			((uint32_t)input[35] << 5) |
			((uint32_t)(input[36] & 0xc0) >> 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 290 to 318
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)input[38] << 10) |
			((uint32_t)(input[39] & 0xfe) << 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 319 to 347
	value = ((uint32_t)(input[39] & 0x01) << 31) |
			((uint32_t)input[40] << 23) |
			((uint32_t)input[41] << 15) |
			((uint32_t)input[42] << 7) |
			((uint32_t)(input[43] & 0xf0) >> 1);
	output[11] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 145 to 173
	value = ((uint32_t)(input[18] & 0x7f) << 25) |
			((uint32_t)input[19] << 17) |
			((uint32_t)input[20] << 9) |
			((uint32_t)(input[21] & 0xfc) << 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 174 to 202
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)input[24] << 6) |
			((uint32_t)(input[25] & 0xe0) >> 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 203 to 231
	value = ((uint32_t)(input[25] & 0x1f) << 27) |
			((uint32_t)input[26] << 19) |
			((uint32_t)input[27] << 11) |
			((uint32_t)input[28] << 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 232 to 260
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)input[31] << 8) |
			((uint32_t)(input[32] & 0xf8));
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 261 to 289
	value = ((uint32_t)(input[32] & 0x07) << 29) |
			((uint32_t)input[33] << 21) |
			((uint32_t)input[34] << 13) |
			((uint32_t)input[35] << 5) |
			((uint32_t)(input[36] & 0xc0) >> 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 290 to 318
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)input[38] << 10) |
			((uint32_t)(input[39] & 0xfe) << 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 319 to 347
	value = ((uint32_t)(input[39] & 0x01) << 31) |
			((uint32_t)input[40] << 23) |
			((uint32_t)input[41] << 15) |
			((uint32_t)input[42] << 7) |
			((uint32_t)(input[43] & 0xf0) >> 1);
	output[11] = (double)(value >> 3);
}

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

	int32_t value;

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

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

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

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

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 175 to 203
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)input[24] << 7) |
			((uint32_t)(input[25] & 0xf0) >> 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 204 to 232
	value = ((uint32_t)(input[25] & 0x0f) << 28) |
			((uint32_t)input[26] << 20) |
			((uint32_t)input[27] << 12) |
			((uint32_t)input[28] << 4) |
			((uint32_t)(input[29] & 0x80) >> 4);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 233 to 261
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)input[31] << 9) |
			((uint32_t)(input[32] & 0xfc) << 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 262 to 290
	value = ((uint32_t)(input[32] & 0x03) << 30) |
			((uint32_t)input[33] << 22) |
			((uint32_t)input[34] << 14) |
			((uint32_t)input[35] << 6) |
			((uint32_t)(input[36] & 0xe0) >> 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 291 to 319
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)input[38] << 11) |
			((uint32_t)input[39] << 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 320 to 348
	value = ((uint32_t)input[40] << 24) |
			((uint32_t)input[41] << 16) |
			((uint32_t)input[42] << 8) |
			((uint32_t)(input[43] & 0xf8));
	output[11] = (double)(value >> 3);
}

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

	uint32_t value;

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

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

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

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

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 175 to 203
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)input[24] << 7) |
			((uint32_t)(input[25] & 0xf0) >> 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 204 to 232
	value = ((uint32_t)(input[25] & 0x0f) << 28) |
			((uint32_t)input[26] << 20) |
			((uint32_t)input[27] << 12) |
			((uint32_t)input[28] << 4) |
			((uint32_t)(input[29] & 0x80) >> 4);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 233 to 261
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)input[31] << 9) |
			((uint32_t)(input[32] & 0xfc) << 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 262 to 290
	value = ((uint32_t)(input[32] & 0x03) << 30) |
			((uint32_t)input[33] << 22) |
			((uint32_t)input[34] << 14) |
			((uint32_t)input[35] << 6) |
			((uint32_t)(input[36] & 0xe0) >> 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 291 to 319
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)input[38] << 11) |
			((uint32_t)input[39] << 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 320 to 348
	value = ((uint32_t)input[40] << 24) |
			((uint32_t)input[41] << 16) |
			((uint32_t)input[42] << 8) |
			((uint32_t)(input[43] & 0xf8));
	output[11] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 176 to 204
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)input[24] << 8) |
			((uint32_t)(input[25] & 0xf8));
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 205 to 233
	value = ((uint32_t)(input[25] & 0x07) << 29) |
			((uint32_t)input[26] << 21) |
			((uint32_t)input[27] << 13) |
			((uint32_t)input[28] << 5) |
			((uint32_t)(input[29] & 0xc0) >> 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 234 to 262
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)input[31] << 10) |
			((uint32_t)(input[32] & 0xfe) << 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 263 to 291
	value = ((uint32_t)(input[32] & 0x01) << 31) |
			((uint32_t)input[33] << 23) |
			((uint32_t)input[34] << 15) |
			((uint32_t)input[35] << 7) |
			((uint32_t)(input[36] & 0xf0) >> 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 292 to 320
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)input[38] << 12) |
			((uint32_t)input[39] << 4) |
			((uint32_t)(input[40] & 0x80) >> 4);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 321 to 349
	value = ((uint32_t)(input[40] & 0x7f) << 25) |
			((uint32_t)input[41] << 17) |
			((uint32_t)input[42] << 9) |
			((uint32_t)(input[43] & 0xfc) << 1);
	output[11] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 176 to 204
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)input[24] << 8) |
			((uint32_t)(input[25] & 0xf8));
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 205 to 233
	value = ((uint32_t)(input[25] & 0x07) << 29) |
			((uint32_t)input[26] << 21) |
			((uint32_t)input[27] << 13) |
			((uint32_t)input[28] << 5) |
			((uint32_t)(input[29] & 0xc0) >> 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 234 to 262
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)input[31] << 10) |
			((uint32_t)(input[32] & 0xfe) << 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 263 to 291
	value = ((uint32_t)(input[32] & 0x01) << 31) |
			((uint32_t)input[33] << 23) |
			((uint32_t)input[34] << 15) |
			((uint32_t)input[35] << 7) |
			((uint32_t)(input[36] & 0xf0) >> 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 292 to 320
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)input[38] << 12) |
			((uint32_t)input[39] << 4) |
			((uint32_t)(input[40] & 0x80) >> 4);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 321 to 349
	value = ((uint32_t)(input[40] & 0x7f) << 25) |
			((uint32_t)input[41] << 17) |
			((uint32_t)input[42] << 9) |
			((uint32_t)(input[43] & 0xfc) << 1);
	output[11] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 177 to 205
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)input[24] << 9) |
			((uint32_t)(input[25] & 0xfc) << 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 206 to 234
	value = ((uint32_t)(input[25] & 0x03) << 30) |
			((uint32_t)input[26] << 22) |
			((uint32_t)input[27] << 14) |
			((uint32_t)input[28] << 6) |
			((uint32_t)(input[29] & 0xe0) >> 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 235 to 263
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)input[31] << 11) |
			((uint32_t)input[32] << 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 264 to 292
	value = ((uint32_t)input[33] << 24) |
			((uint32_t)input[34] << 16) |
			((uint32_t)input[35] << 8) |
			((uint32_t)(input[36] & 0xf8));
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 293 to 321
	value = ((uint32_t)(input[36] & 0x07) << 29) |
			((uint32_t)input[37] << 21) |
			((uint32_t)input[38] << 13) |
			((uint32_t)input[39] << 5) |
			((uint32_t)(input[40] & 0xc0) >> 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 322 to 350
	value = ((uint32_t)(input[40] & 0x3f) << 26) |
			((uint32_t)input[41] << 18) |
			((uint32_t)input[42] << 10) |
			((uint32_t)(input[43] & 0xfe) << 2);
	output[11] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 177 to 205
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)input[24] << 9) |
			((uint32_t)(input[25] & 0xfc) << 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 206 to 234
	value = ((uint32_t)(input[25] & 0x03) << 30) |
			((uint32_t)input[26] << 22) |
			((uint32_t)input[27] << 14) |
			((uint32_t)input[28] << 6) |
			((uint32_t)(input[29] & 0xe0) >> 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 235 to 263
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)input[31] << 11) |
			((uint32_t)input[32] << 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 264 to 292
	value = ((uint32_t)input[33] << 24) |
			((uint32_t)input[34] << 16) |
			((uint32_t)input[35] << 8) |
			((uint32_t)(input[36] & 0xf8));
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 293 to 321
	value = ((uint32_t)(input[36] & 0x07) << 29) |
			((uint32_t)input[37] << 21) |
			((uint32_t)input[38] << 13) |
			((uint32_t)input[39] << 5) |
			((uint32_t)(input[40] & 0xc0) >> 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 322 to 350
	value = ((uint32_t)(input[40] & 0x3f) << 26) |
			((uint32_t)input[41] << 18) |
			((uint32_t)input[42] << 10) |
			((uint32_t)(input[43] & 0xfe) << 2);
	output[11] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 178 to 206
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)input[24] << 10) |
			((uint32_t)(input[25] & 0xfe) << 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 207 to 235
	value = ((uint32_t)(input[25] & 0x01) << 31) |
			((uint32_t)input[26] << 23) |
			((uint32_t)input[27] << 15) |
			((uint32_t)input[28] << 7) |
			((uint32_t)(input[29] & 0xf0) >> 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 236 to 264
	value = ((uint32_t)(input[29] & 0x0f) << 28) |
			((uint32_t)input[30] << 20) |
			((uint32_t)input[31] << 12) |
			((uint32_t)input[32] << 4) |
			((uint32_t)(input[33] & 0x80) >> 4);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 265 to 293
	value = ((uint32_t)(input[33] & 0x7f) << 25) |
			((uint32_t)input[34] << 17) |
			((uint32_t)input[35] << 9) |
			((uint32_t)(input[36] & 0xfc) << 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 294 to 322
	value = ((uint32_t)(input[36] & 0x03) << 30) |
			((uint32_t)input[37] << 22) |
			((uint32_t)input[38] << 14) |
			((uint32_t)input[39] << 6) |
			((uint32_t)(input[40] & 0xe0) >> 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 323 to 351
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)input[42] << 11) |
			((uint32_t)input[43] << 3);
	output[11] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 178 to 206
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)input[24] << 10) |
			((uint32_t)(input[25] & 0xfe) << 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 207 to 235
	value = ((uint32_t)(input[25] & 0x01) << 31) |
			((uint32_t)input[26] << 23) |
			((uint32_t)input[27] << 15) |
			((uint32_t)input[28] << 7) |
			((uint32_t)(input[29] & 0xf0) >> 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 236 to 264
	value = ((uint32_t)(input[29] & 0x0f) << 28) |
			((uint32_t)input[30] << 20) |
			((uint32_t)input[31] << 12) |
			((uint32_t)input[32] << 4) |
			((uint32_t)(input[33] & 0x80) >> 4);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 265 to 293
	value = ((uint32_t)(input[33] & 0x7f) << 25) |
			((uint32_t)input[34] << 17) |
			((uint32_t)input[35] << 9) |
			((uint32_t)(input[36] & 0xfc) << 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 294 to 322
	value = ((uint32_t)(input[36] & 0x03) << 30) |
			((uint32_t)input[37] << 22) |
			((uint32_t)input[38] << 14) |
			((uint32_t)input[39] << 6) |
			((uint32_t)(input[40] & 0xe0) >> 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 323 to 351
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)input[42] << 11) |
			((uint32_t)input[43] << 3);
	output[11] = (double)(value >> 3);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 179 to 207
	value = ((uint32_t)(input[22] & 0x1f) << 27) |
			((uint32_t)input[23] << 19) |
			((uint32_t)input[24] << 11) |
			((uint32_t)input[25] << 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 208 to 236
	value = ((uint32_t)input[26] << 24) |
			((uint32_t)input[27] << 16) |
			((uint32_t)input[28] << 8) |
			((uint32_t)(input[29] & 0xf8));
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 237 to 265
	value = ((uint32_t)(input[29] & 0x07) << 29) |
			((uint32_t)input[30] << 21) |
			((uint32_t)input[31] << 13) |
			((uint32_t)input[32] << 5) |
			((uint32_t)(input[33] & 0xc0) >> 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 266 to 294
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)input[35] << 10) |
			((uint32_t)(input[36] & 0xfe) << 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 295 to 323
	value = ((uint32_t)(input[36] & 0x01) << 31) |
			((uint32_t)input[37] << 23) |
			((uint32_t)input[38] << 15) |
			((uint32_t)input[39] << 7) |
			((uint32_t)(input[40] & 0xf0) >> 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 324 to 352
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)input[43] << 4) |
			((uint32_t)(input[44] & 0x80) >> 4);
	output[11] = (double)(value >> 3);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 179 to 207
	value = ((uint32_t)(input[22] & 0x1f) << 27) |
			((uint32_t)input[23] << 19) |
			((uint32_t)input[24] << 11) |
			((uint32_t)input[25] << 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 208 to 236
	value = ((uint32_t)input[26] << 24) |
			((uint32_t)input[27] << 16) |
			((uint32_t)input[28] << 8) |
			((uint32_t)(input[29] & 0xf8));
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 237 to 265
	value = ((uint32_t)(input[29] & 0x07) << 29) |
			((uint32_t)input[30] << 21) |
			((uint32_t)input[31] << 13) |
			((uint32_t)input[32] << 5) |
			((uint32_t)(input[33] & 0xc0) >> 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 266 to 294
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)input[35] << 10) |
			((uint32_t)(input[36] & 0xfe) << 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 295 to 323
	value = ((uint32_t)(input[36] & 0x01) << 31) |
			((uint32_t)input[37] << 23) |
			((uint32_t)input[38] << 15) |
			((uint32_t)input[39] << 7) |
			((uint32_t)(input[40] & 0xf0) >> 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 324 to 352
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)input[43] << 4) |
			((uint32_t)(input[44] & 0x80) >> 4);
	output[11] = (double)(value >> 3);
}

static void unpack_12_29bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 29-bit signed
	// Skip 6 bits, read 348 bits of data.
	// Input must be at least 45 bytes long

	int32_t value;

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

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

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

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

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

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

	// read output[6]: from bit 180 to 208
	value = ((uint32_t)(input[22] & 0x0f) << 28) |
			((uint32_t)input[23] << 20) |
			((uint32_t)input[24] << 12) |
			((uint32_t)input[25] << 4) |
			((uint32_t)(input[26] & 0x80) >> 4);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 209 to 237
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)input[28] << 9) |
			((uint32_t)(input[29] & 0xfc) << 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 238 to 266
	value = ((uint32_t)(input[29] & 0x03) << 30) |
			((uint32_t)input[30] << 22) |
			((uint32_t)input[31] << 14) |
			((uint32_t)input[32] << 6) |
			((uint32_t)(input[33] & 0xe0) >> 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 267 to 295
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)input[35] << 11) |
			((uint32_t)input[36] << 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 296 to 324
	value = ((uint32_t)input[37] << 24) |
			((uint32_t)input[38] << 16) |
			((uint32_t)input[39] << 8) |
			((uint32_t)(input[40] & 0xf8));
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 325 to 353
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5) |
			((uint32_t)(input[44] & 0xc0) >> 3);
	output[11] = (double)(value >> 3);
}

static void unpack_12_29bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 29-bit unsigned
	// Skip 6 bits, read 348 bits of data.
	// Input must be at least 45 bytes long

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 151 to 179
	value = ((uint32_t)(input[18] & 0x01) << 31) |
			((uint32_t)input[19] << 23) |
			((uint32_t)input[20] << 15) |
			((uint32_t)input[21] << 7) |
			((uint32_t)(input[22] & 0xf0) >> 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 180 to 208
	value = ((uint32_t)(input[22] & 0x0f) << 28) |
			((uint32_t)input[23] << 20) |
			((uint32_t)input[24] << 12) |
			((uint32_t)input[25] << 4) |
			((uint32_t)(input[26] & 0x80) >> 4);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 209 to 237
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)input[28] << 9) |
			((uint32_t)(input[29] & 0xfc) << 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 238 to 266
	value = ((uint32_t)(input[29] & 0x03) << 30) |
			((uint32_t)input[30] << 22) |
			((uint32_t)input[31] << 14) |
			((uint32_t)input[32] << 6) |
			((uint32_t)(input[33] & 0xe0) >> 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 267 to 295
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)input[35] << 11) |
			((uint32_t)input[36] << 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 296 to 324
	value = ((uint32_t)input[37] << 24) |
			((uint32_t)input[38] << 16) |
			((uint32_t)input[39] << 8) |
			((uint32_t)(input[40] & 0xf8));
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 325 to 353
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5) |
			((uint32_t)(input[44] & 0xc0) >> 3);
	output[11] = (double)(value >> 3);
}

static void unpack_12_29bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 29-bit signed
	// Skip 7 bits, read 348 bits of data.
	// Input must be at least 45 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 35
	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] & 0xf0) >> 1);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 36 to 64
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0x80) >> 4);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 65 to 93
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)(input[11] & 0xfc) << 1);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 94 to 122
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xe0) >> 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 181 to 209
	value = ((uint32_t)(input[22] & 0x07) << 29) |
			((uint32_t)input[23] << 21) |
			((uint32_t)input[24] << 13) |
			((uint32_t)input[25] << 5) |
			((uint32_t)(input[26] & 0xc0) >> 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 210 to 238
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)input[28] << 10) |
			((uint32_t)(input[29] & 0xfe) << 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 239 to 267
	value = ((uint32_t)(input[29] & 0x01) << 31) |
			((uint32_t)input[30] << 23) |
			((uint32_t)input[31] << 15) |
			((uint32_t)input[32] << 7) |
			((uint32_t)(input[33] & 0xf0) >> 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 268 to 296
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)input[35] << 12) |
			((uint32_t)input[36] << 4) |
			((uint32_t)(input[37] & 0x80) >> 4);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 297 to 325
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xfc) << 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 326 to 354
	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] & 0xe0) >> 2);
	output[11] = (double)(value >> 3);
}

static void unpack_12_29bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 29-bit unsigned
	// Skip 7 bits, read 348 bits of data.
	// Input must be at least 45 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 35
	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] & 0xf0) >> 1);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 36 to 64
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0x80) >> 4);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 65 to 93
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)(input[11] & 0xfc) << 1);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 94 to 122
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xe0) >> 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 181 to 209
	value = ((uint32_t)(input[22] & 0x07) << 29) |
			((uint32_t)input[23] << 21) |
			((uint32_t)input[24] << 13) |
			((uint32_t)input[25] << 5) |
			((uint32_t)(input[26] & 0xc0) >> 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 210 to 238
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)input[28] << 10) |
			((uint32_t)(input[29] & 0xfe) << 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 239 to 267
	value = ((uint32_t)(input[29] & 0x01) << 31) |
			((uint32_t)input[30] << 23) |
			((uint32_t)input[31] << 15) |
			((uint32_t)input[32] << 7) |
			((uint32_t)(input[33] & 0xf0) >> 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 268 to 296
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)input[35] << 12) |
			((uint32_t)input[36] << 4) |
			((uint32_t)(input[37] & 0x80) >> 4);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 297 to 325
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xfc) << 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 326 to 354
	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] & 0xe0) >> 2);
	output[11] = (double)(value >> 3);
}

static void unpack_13_29bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 29-bit signed
	// Skip 0 bits, read 377 bits of data.
	// Input must be at least 48 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 28
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xf8));
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 29 to 57
	value = ((uint32_t)(input[3] & 0x07) << 29) |
			((uint32_t)input[4] << 21) |
			((uint32_t)input[5] << 13) |
			((uint32_t)input[6] << 5) |
			((uint32_t)(input[7] & 0xc0) >> 3);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 58 to 86
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xfe) << 2);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 145 to 173
	value = ((uint32_t)(input[18] & 0x7f) << 25) |
			((uint32_t)input[19] << 17) |
			((uint32_t)input[20] << 9) |
			((uint32_t)(input[21] & 0xfc) << 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 174 to 202
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)input[24] << 6) |
			((uint32_t)(input[25] & 0xe0) >> 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 203 to 231
	value = ((uint32_t)(input[25] & 0x1f) << 27) |
			((uint32_t)input[26] << 19) |
			((uint32_t)input[27] << 11) |
			((uint32_t)input[28] << 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 232 to 260
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)input[31] << 8) |
			((uint32_t)(input[32] & 0xf8));
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 261 to 289
	value = ((uint32_t)(input[32] & 0x07) << 29) |
			((uint32_t)input[33] << 21) |
			((uint32_t)input[34] << 13) |
			((uint32_t)input[35] << 5) |
			((uint32_t)(input[36] & 0xc0) >> 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 290 to 318
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)input[38] << 10) |
			((uint32_t)(input[39] & 0xfe) << 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 319 to 347
	value = ((uint32_t)(input[39] & 0x01) << 31) |
			((uint32_t)input[40] << 23) |
			((uint32_t)input[41] << 15) |
			((uint32_t)input[42] << 7) |
			((uint32_t)(input[43] & 0xf0) >> 1);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 348 to 376
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)input[45] << 12) |
			((uint32_t)input[46] << 4) |
			((uint32_t)(input[47] & 0x80) >> 4);
	output[12] = (double)(value >> 3);
}

static void unpack_13_29bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 29-bit unsigned
	// Skip 0 bits, read 377 bits of data.
	// Input must be at least 48 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 28
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xf8));
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 29 to 57
	value = ((uint32_t)(input[3] & 0x07) << 29) |
			((uint32_t)input[4] << 21) |
			((uint32_t)input[5] << 13) |
			((uint32_t)input[6] << 5) |
			((uint32_t)(input[7] & 0xc0) >> 3);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 58 to 86
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xfe) << 2);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 145 to 173
	value = ((uint32_t)(input[18] & 0x7f) << 25) |
			((uint32_t)input[19] << 17) |
			((uint32_t)input[20] << 9) |
			((uint32_t)(input[21] & 0xfc) << 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 174 to 202
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)input[24] << 6) |
			((uint32_t)(input[25] & 0xe0) >> 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 203 to 231
	value = ((uint32_t)(input[25] & 0x1f) << 27) |
			((uint32_t)input[26] << 19) |
			((uint32_t)input[27] << 11) |
			((uint32_t)input[28] << 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 232 to 260
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)input[31] << 8) |
			((uint32_t)(input[32] & 0xf8));
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 261 to 289
	value = ((uint32_t)(input[32] & 0x07) << 29) |
			((uint32_t)input[33] << 21) |
			((uint32_t)input[34] << 13) |
			((uint32_t)input[35] << 5) |
			((uint32_t)(input[36] & 0xc0) >> 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 290 to 318
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)input[38] << 10) |
			((uint32_t)(input[39] & 0xfe) << 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 319 to 347
	value = ((uint32_t)(input[39] & 0x01) << 31) |
			((uint32_t)input[40] << 23) |
			((uint32_t)input[41] << 15) |
			((uint32_t)input[42] << 7) |
			((uint32_t)(input[43] & 0xf0) >> 1);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 348 to 376
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)input[45] << 12) |
			((uint32_t)input[46] << 4) |
			((uint32_t)(input[47] & 0x80) >> 4);
	output[12] = (double)(value >> 3);
}

static void unpack_13_29bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 29-bit signed
	// Skip 1 bits, read 377 bits of data.
	// Input must be at least 48 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 29
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)(input[3] & 0xfc) << 1);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 59 to 87
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)input[10] << 3);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 88 to 116
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xf8));
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 175 to 203
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)input[24] << 7) |
			((uint32_t)(input[25] & 0xf0) >> 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 204 to 232
	value = ((uint32_t)(input[25] & 0x0f) << 28) |
			((uint32_t)input[26] << 20) |
			((uint32_t)input[27] << 12) |
			((uint32_t)input[28] << 4) |
			((uint32_t)(input[29] & 0x80) >> 4);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 233 to 261
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)input[31] << 9) |
			((uint32_t)(input[32] & 0xfc) << 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 262 to 290
	value = ((uint32_t)(input[32] & 0x03) << 30) |
			((uint32_t)input[33] << 22) |
			((uint32_t)input[34] << 14) |
			((uint32_t)input[35] << 6) |
			((uint32_t)(input[36] & 0xe0) >> 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 291 to 319
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)input[38] << 11) |
			((uint32_t)input[39] << 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 320 to 348
	value = ((uint32_t)input[40] << 24) |
			((uint32_t)input[41] << 16) |
			((uint32_t)input[42] << 8) |
			((uint32_t)(input[43] & 0xf8));
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 349 to 377
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13) |
			((uint32_t)input[46] << 5) |
			((uint32_t)(input[47] & 0xc0) >> 3);
	output[12] = (double)(value >> 3);
}

static void unpack_13_29bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 29-bit unsigned
	// Skip 1 bits, read 377 bits of data.
	// Input must be at least 48 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 29
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)(input[3] & 0xfc) << 1);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 59 to 87
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)input[10] << 3);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 88 to 116
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xf8));
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 175 to 203
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)input[24] << 7) |
			((uint32_t)(input[25] & 0xf0) >> 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 204 to 232
	value = ((uint32_t)(input[25] & 0x0f) << 28) |
			((uint32_t)input[26] << 20) |
			((uint32_t)input[27] << 12) |
			((uint32_t)input[28] << 4) |
			((uint32_t)(input[29] & 0x80) >> 4);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 233 to 261
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)input[31] << 9) |
			((uint32_t)(input[32] & 0xfc) << 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 262 to 290
	value = ((uint32_t)(input[32] & 0x03) << 30) |
			((uint32_t)input[33] << 22) |
			((uint32_t)input[34] << 14) |
			((uint32_t)input[35] << 6) |
			((uint32_t)(input[36] & 0xe0) >> 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 291 to 319
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)input[38] << 11) |
			((uint32_t)input[39] << 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 320 to 348
	value = ((uint32_t)input[40] << 24) |
			((uint32_t)input[41] << 16) |
			((uint32_t)input[42] << 8) |
			((uint32_t)(input[43] & 0xf8));
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 349 to 377
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13) |
			((uint32_t)input[46] << 5) |
			((uint32_t)(input[47] & 0xc0) >> 3);
	output[12] = (double)(value >> 3);
}

static void unpack_13_29bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 29-bit signed
	// Skip 2 bits, read 377 bits of data.
	// Input must be at least 48 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 30
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)(input[3] & 0xfe) << 2);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 31 to 59
	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] & 0xf0) >> 1);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 60 to 88
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)input[10] << 4) |
			((uint32_t)(input[11] & 0x80) >> 4);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 89 to 117
	value = ((uint32_t)(input[11] & 0x7f) << 25) |
			((uint32_t)input[12] << 17) |
			((uint32_t)input[13] << 9) |
			((uint32_t)(input[14] & 0xfc) << 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 147 to 175
	value = ((uint32_t)(input[18] & 0x1f) << 27) |
			((uint32_t)input[19] << 19) |
			((uint32_t)input[20] << 11) |
			((uint32_t)input[21] << 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 176 to 204
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)input[24] << 8) |
			((uint32_t)(input[25] & 0xf8));
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 205 to 233
	value = ((uint32_t)(input[25] & 0x07) << 29) |
			((uint32_t)input[26] << 21) |
			((uint32_t)input[27] << 13) |
			((uint32_t)input[28] << 5) |
			((uint32_t)(input[29] & 0xc0) >> 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 234 to 262
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)input[31] << 10) |
			((uint32_t)(input[32] & 0xfe) << 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 263 to 291
	value = ((uint32_t)(input[32] & 0x01) << 31) |
			((uint32_t)input[33] << 23) |
			((uint32_t)input[34] << 15) |
			((uint32_t)input[35] << 7) |
			((uint32_t)(input[36] & 0xf0) >> 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 292 to 320
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)input[38] << 12) |
			((uint32_t)input[39] << 4) |
			((uint32_t)(input[40] & 0x80) >> 4);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 321 to 349
	value = ((uint32_t)(input[40] & 0x7f) << 25) |
			((uint32_t)input[41] << 17) |
			((uint32_t)input[42] << 9) |
			((uint32_t)(input[43] & 0xfc) << 1);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 350 to 378
	value = ((uint32_t)(input[43] & 0x03) << 30) |
			((uint32_t)input[44] << 22) |
			((uint32_t)input[45] << 14) |
			((uint32_t)input[46] << 6) |
			((uint32_t)(input[47] & 0xe0) >> 2);
	output[12] = (double)(value >> 3);
}

static void unpack_13_29bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 29-bit unsigned
	// Skip 2 bits, read 377 bits of data.
	// Input must be at least 48 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 30
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)(input[3] & 0xfe) << 2);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 31 to 59
	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] & 0xf0) >> 1);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 60 to 88
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)input[10] << 4) |
			((uint32_t)(input[11] & 0x80) >> 4);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 89 to 117
	value = ((uint32_t)(input[11] & 0x7f) << 25) |
			((uint32_t)input[12] << 17) |
			((uint32_t)input[13] << 9) |
			((uint32_t)(input[14] & 0xfc) << 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 147 to 175
	value = ((uint32_t)(input[18] & 0x1f) << 27) |
			((uint32_t)input[19] << 19) |
			((uint32_t)input[20] << 11) |
			((uint32_t)input[21] << 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 176 to 204
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)input[24] << 8) |
			((uint32_t)(input[25] & 0xf8));
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 205 to 233
	value = ((uint32_t)(input[25] & 0x07) << 29) |
			((uint32_t)input[26] << 21) |
			((uint32_t)input[27] << 13) |
			((uint32_t)input[28] << 5) |
			((uint32_t)(input[29] & 0xc0) >> 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 234 to 262
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)input[31] << 10) |
			((uint32_t)(input[32] & 0xfe) << 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 263 to 291
	value = ((uint32_t)(input[32] & 0x01) << 31) |
			((uint32_t)input[33] << 23) |
			((uint32_t)input[34] << 15) |
			((uint32_t)input[35] << 7) |
			((uint32_t)(input[36] & 0xf0) >> 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 292 to 320
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)input[38] << 12) |
			((uint32_t)input[39] << 4) |
			((uint32_t)(input[40] & 0x80) >> 4);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 321 to 349
	value = ((uint32_t)(input[40] & 0x7f) << 25) |
			((uint32_t)input[41] << 17) |
			((uint32_t)input[42] << 9) |
			((uint32_t)(input[43] & 0xfc) << 1);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 350 to 378
	value = ((uint32_t)(input[43] & 0x03) << 30) |
			((uint32_t)input[44] << 22) |
			((uint32_t)input[45] << 14) |
			((uint32_t)input[46] << 6) |
			((uint32_t)(input[47] & 0xe0) >> 2);
	output[12] = (double)(value >> 3);
}

static void unpack_13_29bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 29-bit signed
	// Skip 3 bits, read 377 bits of data.
	// Input must be at least 48 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 31
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 32 to 60
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xf8));
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 61 to 89
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5) |
			((uint32_t)(input[11] & 0xc0) >> 3);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 177 to 205
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)input[24] << 9) |
			((uint32_t)(input[25] & 0xfc) << 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 206 to 234
	value = ((uint32_t)(input[25] & 0x03) << 30) |
			((uint32_t)input[26] << 22) |
			((uint32_t)input[27] << 14) |
			((uint32_t)input[28] << 6) |
			((uint32_t)(input[29] & 0xe0) >> 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 235 to 263
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)input[31] << 11) |
			((uint32_t)input[32] << 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 264 to 292
	value = ((uint32_t)input[33] << 24) |
			((uint32_t)input[34] << 16) |
			((uint32_t)input[35] << 8) |
			((uint32_t)(input[36] & 0xf8));
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 293 to 321
	value = ((uint32_t)(input[36] & 0x07) << 29) |
			((uint32_t)input[37] << 21) |
			((uint32_t)input[38] << 13) |
			((uint32_t)input[39] << 5) |
			((uint32_t)(input[40] & 0xc0) >> 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 322 to 350
	value = ((uint32_t)(input[40] & 0x3f) << 26) |
			((uint32_t)input[41] << 18) |
			((uint32_t)input[42] << 10) |
			((uint32_t)(input[43] & 0xfe) << 2);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 351 to 379
	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] & 0xf0) >> 1);
	output[12] = (double)(value >> 3);
}

static void unpack_13_29bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 29-bit unsigned
	// Skip 3 bits, read 377 bits of data.
	// Input must be at least 48 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 31
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 32 to 60
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xf8));
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 61 to 89
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5) |
			((uint32_t)(input[11] & 0xc0) >> 3);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 177 to 205
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)input[24] << 9) |
			((uint32_t)(input[25] & 0xfc) << 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 206 to 234
	value = ((uint32_t)(input[25] & 0x03) << 30) |
			((uint32_t)input[26] << 22) |
			((uint32_t)input[27] << 14) |
			((uint32_t)input[28] << 6) |
			((uint32_t)(input[29] & 0xe0) >> 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 235 to 263
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)input[31] << 11) |
			((uint32_t)input[32] << 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 264 to 292
	value = ((uint32_t)input[33] << 24) |
			((uint32_t)input[34] << 16) |
			((uint32_t)input[35] << 8) |
			((uint32_t)(input[36] & 0xf8));
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 293 to 321
	value = ((uint32_t)(input[36] & 0x07) << 29) |
			((uint32_t)input[37] << 21) |
			((uint32_t)input[38] << 13) |
			((uint32_t)input[39] << 5) |
			((uint32_t)(input[40] & 0xc0) >> 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 322 to 350
	value = ((uint32_t)(input[40] & 0x3f) << 26) |
			((uint32_t)input[41] << 18) |
			((uint32_t)input[42] << 10) |
			((uint32_t)(input[43] & 0xfe) << 2);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 351 to 379
	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] & 0xf0) >> 1);
	output[12] = (double)(value >> 3);
}

static void unpack_13_29bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 29-bit signed
	// Skip 4 bits, read 377 bits of data.
	// Input must be at least 48 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 32
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0x80) >> 4);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 33 to 61
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)(input[7] & 0xfc) << 1);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 62 to 90
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xe0) >> 2);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 178 to 206
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)input[24] << 10) |
			((uint32_t)(input[25] & 0xfe) << 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 207 to 235
	value = ((uint32_t)(input[25] & 0x01) << 31) |
			((uint32_t)input[26] << 23) |
			((uint32_t)input[27] << 15) |
			((uint32_t)input[28] << 7) |
			((uint32_t)(input[29] & 0xf0) >> 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 236 to 264
	value = ((uint32_t)(input[29] & 0x0f) << 28) |
			((uint32_t)input[30] << 20) |
			((uint32_t)input[31] << 12) |
			((uint32_t)input[32] << 4) |
			((uint32_t)(input[33] & 0x80) >> 4);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 265 to 293
	value = ((uint32_t)(input[33] & 0x7f) << 25) |
			((uint32_t)input[34] << 17) |
			((uint32_t)input[35] << 9) |
			((uint32_t)(input[36] & 0xfc) << 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 294 to 322
	value = ((uint32_t)(input[36] & 0x03) << 30) |
			((uint32_t)input[37] << 22) |
			((uint32_t)input[38] << 14) |
			((uint32_t)input[39] << 6) |
			((uint32_t)(input[40] & 0xe0) >> 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 323 to 351
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)input[42] << 11) |
			((uint32_t)input[43] << 3);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 352 to 380
	value = ((uint32_t)input[44] << 24) |
			((uint32_t)input[45] << 16) |
			((uint32_t)input[46] << 8) |
			((uint32_t)(input[47] & 0xf8));
	output[12] = (double)(value >> 3);
}

static void unpack_13_29bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 29-bit unsigned
	// Skip 4 bits, read 377 bits of data.
	// Input must be at least 48 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 32
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0x80) >> 4);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 33 to 61
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)(input[7] & 0xfc) << 1);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 62 to 90
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xe0) >> 2);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 178 to 206
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)input[24] << 10) |
			((uint32_t)(input[25] & 0xfe) << 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 207 to 235
	value = ((uint32_t)(input[25] & 0x01) << 31) |
			((uint32_t)input[26] << 23) |
			((uint32_t)input[27] << 15) |
			((uint32_t)input[28] << 7) |
			((uint32_t)(input[29] & 0xf0) >> 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 236 to 264
	value = ((uint32_t)(input[29] & 0x0f) << 28) |
			((uint32_t)input[30] << 20) |
			((uint32_t)input[31] << 12) |
			((uint32_t)input[32] << 4) |
			((uint32_t)(input[33] & 0x80) >> 4);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 265 to 293
	value = ((uint32_t)(input[33] & 0x7f) << 25) |
			((uint32_t)input[34] << 17) |
			((uint32_t)input[35] << 9) |
			((uint32_t)(input[36] & 0xfc) << 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 294 to 322
	value = ((uint32_t)(input[36] & 0x03) << 30) |
			((uint32_t)input[37] << 22) |
			((uint32_t)input[38] << 14) |
			((uint32_t)input[39] << 6) |
			((uint32_t)(input[40] & 0xe0) >> 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 323 to 351
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)input[42] << 11) |
			((uint32_t)input[43] << 3);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 352 to 380
	value = ((uint32_t)input[44] << 24) |
			((uint32_t)input[45] << 16) |
			((uint32_t)input[46] << 8) |
			((uint32_t)(input[47] & 0xf8));
	output[12] = (double)(value >> 3);
}

static void unpack_13_29bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 29-bit signed
	// Skip 5 bits, read 377 bits of data.
	// Input must be at least 48 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 33
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xc0) >> 3);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 34 to 62
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)(input[7] & 0xfe) << 2);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 63 to 91
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xf0) >> 1);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 150 to 178
	value = ((uint32_t)(input[18] & 0x03) << 30) |
			((uint32_t)input[19] << 22) |
			((uint32_t)input[20] << 14) |
			((uint32_t)input[21] << 6) |
			((uint32_t)(input[22] & 0xe0) >> 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 179 to 207
	value = ((uint32_t)(input[22] & 0x1f) << 27) |
			((uint32_t)input[23] << 19) |
			((uint32_t)input[24] << 11) |
			((uint32_t)input[25] << 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 208 to 236
	value = ((uint32_t)input[26] << 24) |
			((uint32_t)input[27] << 16) |
			((uint32_t)input[28] << 8) |
			((uint32_t)(input[29] & 0xf8));
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 237 to 265
	value = ((uint32_t)(input[29] & 0x07) << 29) |
			((uint32_t)input[30] << 21) |
			((uint32_t)input[31] << 13) |
			((uint32_t)input[32] << 5) |
			((uint32_t)(input[33] & 0xc0) >> 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 266 to 294
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)input[35] << 10) |
			((uint32_t)(input[36] & 0xfe) << 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 295 to 323
	value = ((uint32_t)(input[36] & 0x01) << 31) |
			((uint32_t)input[37] << 23) |
			((uint32_t)input[38] << 15) |
			((uint32_t)input[39] << 7) |
			((uint32_t)(input[40] & 0xf0) >> 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 324 to 352
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)input[43] << 4) |
			((uint32_t)(input[44] & 0x80) >> 4);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 353 to 381
	value = ((uint32_t)(input[44] & 0x7f) << 25) |
			((uint32_t)input[45] << 17) |
			((uint32_t)input[46] << 9) |
			((uint32_t)(input[47] & 0xfc) << 1);
	output[12] = (double)(value >> 3);
}

static void unpack_13_29bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 29-bit unsigned
	// Skip 5 bits, read 377 bits of data.
	// Input must be at least 48 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 33
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xc0) >> 3);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 34 to 62
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)(input[7] & 0xfe) << 2);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 63 to 91
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xf0) >> 1);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 150 to 178
	value = ((uint32_t)(input[18] & 0x03) << 30) |
			((uint32_t)input[19] << 22) |
			((uint32_t)input[20] << 14) |
			((uint32_t)input[21] << 6) |
			((uint32_t)(input[22] & 0xe0) >> 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 179 to 207
	value = ((uint32_t)(input[22] & 0x1f) << 27) |
			((uint32_t)input[23] << 19) |
			((uint32_t)input[24] << 11) |
			((uint32_t)input[25] << 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 208 to 236
	value = ((uint32_t)input[26] << 24) |
			((uint32_t)input[27] << 16) |
			((uint32_t)input[28] << 8) |
			((uint32_t)(input[29] & 0xf8));
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 237 to 265
	value = ((uint32_t)(input[29] & 0x07) << 29) |
			((uint32_t)input[30] << 21) |
			((uint32_t)input[31] << 13) |
			((uint32_t)input[32] << 5) |
			((uint32_t)(input[33] & 0xc0) >> 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 266 to 294
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)input[35] << 10) |
			((uint32_t)(input[36] & 0xfe) << 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 295 to 323
	value = ((uint32_t)(input[36] & 0x01) << 31) |
			((uint32_t)input[37] << 23) |
			((uint32_t)input[38] << 15) |
			((uint32_t)input[39] << 7) |
			((uint32_t)(input[40] & 0xf0) >> 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 324 to 352
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)input[43] << 4) |
			((uint32_t)(input[44] & 0x80) >> 4);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 353 to 381
	value = ((uint32_t)(input[44] & 0x7f) << 25) |
			((uint32_t)input[45] << 17) |
			((uint32_t)input[46] << 9) |
			((uint32_t)(input[47] & 0xfc) << 1);
	output[12] = (double)(value >> 3);
}

static void unpack_13_29bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 29-bit signed
	// Skip 6 bits, read 377 bits of data.
	// Input must be at least 48 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 34
	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] & 0xe0) >> 2);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 35 to 63
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 64 to 92
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xf8));
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 93 to 121
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xc0) >> 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 151 to 179
	value = ((uint32_t)(input[18] & 0x01) << 31) |
			((uint32_t)input[19] << 23) |
			((uint32_t)input[20] << 15) |
			((uint32_t)input[21] << 7) |
			((uint32_t)(input[22] & 0xf0) >> 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 180 to 208
	value = ((uint32_t)(input[22] & 0x0f) << 28) |
			((uint32_t)input[23] << 20) |
			((uint32_t)input[24] << 12) |
			((uint32_t)input[25] << 4) |
			((uint32_t)(input[26] & 0x80) >> 4);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 209 to 237
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)input[28] << 9) |
			((uint32_t)(input[29] & 0xfc) << 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 238 to 266
	value = ((uint32_t)(input[29] & 0x03) << 30) |
			((uint32_t)input[30] << 22) |
			((uint32_t)input[31] << 14) |
			((uint32_t)input[32] << 6) |
			((uint32_t)(input[33] & 0xe0) >> 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 267 to 295
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)input[35] << 11) |
			((uint32_t)input[36] << 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 296 to 324
	value = ((uint32_t)input[37] << 24) |
			((uint32_t)input[38] << 16) |
			((uint32_t)input[39] << 8) |
			((uint32_t)(input[40] & 0xf8));
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 325 to 353
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5) |
			((uint32_t)(input[44] & 0xc0) >> 3);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 354 to 382
	value = ((uint32_t)(input[44] & 0x3f) << 26) |
			((uint32_t)input[45] << 18) |
			((uint32_t)input[46] << 10) |
			((uint32_t)(input[47] & 0xfe) << 2);
	output[12] = (double)(value >> 3);
}

static void unpack_13_29bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 29-bit unsigned
	// Skip 6 bits, read 377 bits of data.
	// Input must be at least 48 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 34
	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] & 0xe0) >> 2);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 35 to 63
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 64 to 92
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xf8));
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 93 to 121
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xc0) >> 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 151 to 179
	value = ((uint32_t)(input[18] & 0x01) << 31) |
			((uint32_t)input[19] << 23) |
			((uint32_t)input[20] << 15) |
			((uint32_t)input[21] << 7) |
			((uint32_t)(input[22] & 0xf0) >> 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 180 to 208
	value = ((uint32_t)(input[22] & 0x0f) << 28) |
			((uint32_t)input[23] << 20) |
			((uint32_t)input[24] << 12) |
			((uint32_t)input[25] << 4) |
			((uint32_t)(input[26] & 0x80) >> 4);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 209 to 237
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)input[28] << 9) |
			((uint32_t)(input[29] & 0xfc) << 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 238 to 266
	value = ((uint32_t)(input[29] & 0x03) << 30) |
			((uint32_t)input[30] << 22) |
			((uint32_t)input[31] << 14) |
			((uint32_t)input[32] << 6) |
			((uint32_t)(input[33] & 0xe0) >> 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 267 to 295
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)input[35] << 11) |
			((uint32_t)input[36] << 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 296 to 324
	value = ((uint32_t)input[37] << 24) |
			((uint32_t)input[38] << 16) |
			((uint32_t)input[39] << 8) |
			((uint32_t)(input[40] & 0xf8));
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 325 to 353
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5) |
			((uint32_t)(input[44] & 0xc0) >> 3);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 354 to 382
	value = ((uint32_t)(input[44] & 0x3f) << 26) |
			((uint32_t)input[45] << 18) |
			((uint32_t)input[46] << 10) |
			((uint32_t)(input[47] & 0xfe) << 2);
	output[12] = (double)(value >> 3);
}

static void unpack_13_29bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 29-bit signed
	// Skip 7 bits, read 377 bits of data.
	// Input must be at least 48 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 35
	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] & 0xf0) >> 1);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 36 to 64
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0x80) >> 4);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 65 to 93
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)(input[11] & 0xfc) << 1);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 94 to 122
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xe0) >> 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 181 to 209
	value = ((uint32_t)(input[22] & 0x07) << 29) |
			((uint32_t)input[23] << 21) |
			((uint32_t)input[24] << 13) |
			((uint32_t)input[25] << 5) |
			((uint32_t)(input[26] & 0xc0) >> 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 210 to 238
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)input[28] << 10) |
			((uint32_t)(input[29] & 0xfe) << 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 239 to 267
	value = ((uint32_t)(input[29] & 0x01) << 31) |
			((uint32_t)input[30] << 23) |
			((uint32_t)input[31] << 15) |
			((uint32_t)input[32] << 7) |
			((uint32_t)(input[33] & 0xf0) >> 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 268 to 296
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)input[35] << 12) |
			((uint32_t)input[36] << 4) |
			((uint32_t)(input[37] & 0x80) >> 4);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 297 to 325
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xfc) << 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 326 to 354
	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] & 0xe0) >> 2);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 355 to 383
	value = ((uint32_t)(input[44] & 0x1f) << 27) |
			((uint32_t)input[45] << 19) |
			((uint32_t)input[46] << 11) |
			((uint32_t)input[47] << 3);
	output[12] = (double)(value >> 3);
}

static void unpack_13_29bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 29-bit unsigned
	// Skip 7 bits, read 377 bits of data.
	// Input must be at least 48 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 35
	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] & 0xf0) >> 1);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 36 to 64
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0x80) >> 4);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 65 to 93
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)(input[11] & 0xfc) << 1);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 94 to 122
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xe0) >> 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 181 to 209
	value = ((uint32_t)(input[22] & 0x07) << 29) |
			((uint32_t)input[23] << 21) |
			((uint32_t)input[24] << 13) |
			((uint32_t)input[25] << 5) |
			((uint32_t)(input[26] & 0xc0) >> 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 210 to 238
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)input[28] << 10) |
			((uint32_t)(input[29] & 0xfe) << 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 239 to 267
	value = ((uint32_t)(input[29] & 0x01) << 31) |
			((uint32_t)input[30] << 23) |
			((uint32_t)input[31] << 15) |
			((uint32_t)input[32] << 7) |
			((uint32_t)(input[33] & 0xf0) >> 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 268 to 296
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)input[35] << 12) |
			((uint32_t)input[36] << 4) |
			((uint32_t)(input[37] & 0x80) >> 4);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 297 to 325
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xfc) << 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 326 to 354
	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] & 0xe0) >> 2);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 355 to 383
	value = ((uint32_t)(input[44] & 0x1f) << 27) |
			((uint32_t)input[45] << 19) |
			((uint32_t)input[46] << 11) |
			((uint32_t)input[47] << 3);
	output[12] = (double)(value >> 3);
}

static void unpack_14_29bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 29-bit signed
	// Skip 0 bits, read 406 bits of data.
	// Input must be at least 51 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 28
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xf8));
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 29 to 57
	value = ((uint32_t)(input[3] & 0x07) << 29) |
			((uint32_t)input[4] << 21) |
			((uint32_t)input[5] << 13) |
			((uint32_t)input[6] << 5) |
			((uint32_t)(input[7] & 0xc0) >> 3);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 58 to 86
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xfe) << 2);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 145 to 173
	value = ((uint32_t)(input[18] & 0x7f) << 25) |
			((uint32_t)input[19] << 17) |
			((uint32_t)input[20] << 9) |
			((uint32_t)(input[21] & 0xfc) << 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 174 to 202
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)input[24] << 6) |
			((uint32_t)(input[25] & 0xe0) >> 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 203 to 231
	value = ((uint32_t)(input[25] & 0x1f) << 27) |
			((uint32_t)input[26] << 19) |
			((uint32_t)input[27] << 11) |
			((uint32_t)input[28] << 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 232 to 260
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)input[31] << 8) |
			((uint32_t)(input[32] & 0xf8));
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 261 to 289
	value = ((uint32_t)(input[32] & 0x07) << 29) |
			((uint32_t)input[33] << 21) |
			((uint32_t)input[34] << 13) |
			((uint32_t)input[35] << 5) |
			((uint32_t)(input[36] & 0xc0) >> 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 290 to 318
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)input[38] << 10) |
			((uint32_t)(input[39] & 0xfe) << 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 319 to 347
	value = ((uint32_t)(input[39] & 0x01) << 31) |
			((uint32_t)input[40] << 23) |
			((uint32_t)input[41] << 15) |
			((uint32_t)input[42] << 7) |
			((uint32_t)(input[43] & 0xf0) >> 1);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 348 to 376
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)input[45] << 12) |
			((uint32_t)input[46] << 4) |
			((uint32_t)(input[47] & 0x80) >> 4);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 377 to 405
	value = ((uint32_t)(input[47] & 0x7f) << 25) |
			((uint32_t)input[48] << 17) |
			((uint32_t)input[49] << 9) |
			((uint32_t)(input[50] & 0xfc) << 1);
	output[13] = (double)(value >> 3);
}

static void unpack_14_29bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 29-bit unsigned
	// Skip 0 bits, read 406 bits of data.
	// Input must be at least 51 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 28
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xf8));
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 29 to 57
	value = ((uint32_t)(input[3] & 0x07) << 29) |
			((uint32_t)input[4] << 21) |
			((uint32_t)input[5] << 13) |
			((uint32_t)input[6] << 5) |
			((uint32_t)(input[7] & 0xc0) >> 3);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 58 to 86
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xfe) << 2);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 145 to 173
	value = ((uint32_t)(input[18] & 0x7f) << 25) |
			((uint32_t)input[19] << 17) |
			((uint32_t)input[20] << 9) |
			((uint32_t)(input[21] & 0xfc) << 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 174 to 202
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)input[24] << 6) |
			((uint32_t)(input[25] & 0xe0) >> 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 203 to 231
	value = ((uint32_t)(input[25] & 0x1f) << 27) |
			((uint32_t)input[26] << 19) |
			((uint32_t)input[27] << 11) |
			((uint32_t)input[28] << 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 232 to 260
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)input[31] << 8) |
			((uint32_t)(input[32] & 0xf8));
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 261 to 289
	value = ((uint32_t)(input[32] & 0x07) << 29) |
			((uint32_t)input[33] << 21) |
			((uint32_t)input[34] << 13) |
			((uint32_t)input[35] << 5) |
			((uint32_t)(input[36] & 0xc0) >> 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 290 to 318
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)input[38] << 10) |
			((uint32_t)(input[39] & 0xfe) << 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 319 to 347
	value = ((uint32_t)(input[39] & 0x01) << 31) |
			((uint32_t)input[40] << 23) |
			((uint32_t)input[41] << 15) |
			((uint32_t)input[42] << 7) |
			((uint32_t)(input[43] & 0xf0) >> 1);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 348 to 376
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)input[45] << 12) |
			((uint32_t)input[46] << 4) |
			((uint32_t)(input[47] & 0x80) >> 4);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 377 to 405
	value = ((uint32_t)(input[47] & 0x7f) << 25) |
			((uint32_t)input[48] << 17) |
			((uint32_t)input[49] << 9) |
			((uint32_t)(input[50] & 0xfc) << 1);
	output[13] = (double)(value >> 3);
}

static void unpack_14_29bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 29-bit signed
	// Skip 1 bits, read 406 bits of data.
	// Input must be at least 51 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 29
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)(input[3] & 0xfc) << 1);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 59 to 87
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)input[10] << 3);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 88 to 116
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xf8));
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 175 to 203
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)input[24] << 7) |
			((uint32_t)(input[25] & 0xf0) >> 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 204 to 232
	value = ((uint32_t)(input[25] & 0x0f) << 28) |
			((uint32_t)input[26] << 20) |
			((uint32_t)input[27] << 12) |
			((uint32_t)input[28] << 4) |
			((uint32_t)(input[29] & 0x80) >> 4);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 233 to 261
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)input[31] << 9) |
			((uint32_t)(input[32] & 0xfc) << 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 262 to 290
	value = ((uint32_t)(input[32] & 0x03) << 30) |
			((uint32_t)input[33] << 22) |
			((uint32_t)input[34] << 14) |
			((uint32_t)input[35] << 6) |
			((uint32_t)(input[36] & 0xe0) >> 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 291 to 319
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)input[38] << 11) |
			((uint32_t)input[39] << 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 320 to 348
	value = ((uint32_t)input[40] << 24) |
			((uint32_t)input[41] << 16) |
			((uint32_t)input[42] << 8) |
			((uint32_t)(input[43] & 0xf8));
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 349 to 377
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13) |
			((uint32_t)input[46] << 5) |
			((uint32_t)(input[47] & 0xc0) >> 3);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 378 to 406
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)(input[50] & 0xfe) << 2);
	output[13] = (double)(value >> 3);
}

static void unpack_14_29bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 29-bit unsigned
	// Skip 1 bits, read 406 bits of data.
	// Input must be at least 51 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 29
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)(input[3] & 0xfc) << 1);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 59 to 87
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)input[10] << 3);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 88 to 116
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xf8));
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 175 to 203
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)input[24] << 7) |
			((uint32_t)(input[25] & 0xf0) >> 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 204 to 232
	value = ((uint32_t)(input[25] & 0x0f) << 28) |
			((uint32_t)input[26] << 20) |
			((uint32_t)input[27] << 12) |
			((uint32_t)input[28] << 4) |
			((uint32_t)(input[29] & 0x80) >> 4);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 233 to 261
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)input[31] << 9) |
			((uint32_t)(input[32] & 0xfc) << 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 262 to 290
	value = ((uint32_t)(input[32] & 0x03) << 30) |
			((uint32_t)input[33] << 22) |
			((uint32_t)input[34] << 14) |
			((uint32_t)input[35] << 6) |
			((uint32_t)(input[36] & 0xe0) >> 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 291 to 319
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)input[38] << 11) |
			((uint32_t)input[39] << 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 320 to 348
	value = ((uint32_t)input[40] << 24) |
			((uint32_t)input[41] << 16) |
			((uint32_t)input[42] << 8) |
			((uint32_t)(input[43] & 0xf8));
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 349 to 377
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13) |
			((uint32_t)input[46] << 5) |
			((uint32_t)(input[47] & 0xc0) >> 3);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 378 to 406
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)(input[50] & 0xfe) << 2);
	output[13] = (double)(value >> 3);
}

static void unpack_14_29bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 29-bit signed
	// Skip 2 bits, read 406 bits of data.
	// Input must be at least 51 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 30
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)(input[3] & 0xfe) << 2);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 31 to 59
	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] & 0xf0) >> 1);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 60 to 88
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)input[10] << 4) |
			((uint32_t)(input[11] & 0x80) >> 4);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 89 to 117
	value = ((uint32_t)(input[11] & 0x7f) << 25) |
			((uint32_t)input[12] << 17) |
			((uint32_t)input[13] << 9) |
			((uint32_t)(input[14] & 0xfc) << 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 147 to 175
	value = ((uint32_t)(input[18] & 0x1f) << 27) |
			((uint32_t)input[19] << 19) |
			((uint32_t)input[20] << 11) |
			((uint32_t)input[21] << 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 176 to 204
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)input[24] << 8) |
			((uint32_t)(input[25] & 0xf8));
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 205 to 233
	value = ((uint32_t)(input[25] & 0x07) << 29) |
			((uint32_t)input[26] << 21) |
			((uint32_t)input[27] << 13) |
			((uint32_t)input[28] << 5) |
			((uint32_t)(input[29] & 0xc0) >> 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 234 to 262
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)input[31] << 10) |
			((uint32_t)(input[32] & 0xfe) << 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 263 to 291
	value = ((uint32_t)(input[32] & 0x01) << 31) |
			((uint32_t)input[33] << 23) |
			((uint32_t)input[34] << 15) |
			((uint32_t)input[35] << 7) |
			((uint32_t)(input[36] & 0xf0) >> 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 292 to 320
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)input[38] << 12) |
			((uint32_t)input[39] << 4) |
			((uint32_t)(input[40] & 0x80) >> 4);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 321 to 349
	value = ((uint32_t)(input[40] & 0x7f) << 25) |
			((uint32_t)input[41] << 17) |
			((uint32_t)input[42] << 9) |
			((uint32_t)(input[43] & 0xfc) << 1);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 350 to 378
	value = ((uint32_t)(input[43] & 0x03) << 30) |
			((uint32_t)input[44] << 22) |
			((uint32_t)input[45] << 14) |
			((uint32_t)input[46] << 6) |
			((uint32_t)(input[47] & 0xe0) >> 2);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 379 to 407
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)input[50] << 3);
	output[13] = (double)(value >> 3);
}

static void unpack_14_29bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 29-bit unsigned
	// Skip 2 bits, read 406 bits of data.
	// Input must be at least 51 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 30
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)(input[3] & 0xfe) << 2);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 31 to 59
	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] & 0xf0) >> 1);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 60 to 88
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)input[10] << 4) |
			((uint32_t)(input[11] & 0x80) >> 4);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 89 to 117
	value = ((uint32_t)(input[11] & 0x7f) << 25) |
			((uint32_t)input[12] << 17) |
			((uint32_t)input[13] << 9) |
			((uint32_t)(input[14] & 0xfc) << 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 147 to 175
	value = ((uint32_t)(input[18] & 0x1f) << 27) |
			((uint32_t)input[19] << 19) |
			((uint32_t)input[20] << 11) |
			((uint32_t)input[21] << 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 176 to 204
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)input[24] << 8) |
			((uint32_t)(input[25] & 0xf8));
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 205 to 233
	value = ((uint32_t)(input[25] & 0x07) << 29) |
			((uint32_t)input[26] << 21) |
			((uint32_t)input[27] << 13) |
			((uint32_t)input[28] << 5) |
			((uint32_t)(input[29] & 0xc0) >> 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 234 to 262
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)input[31] << 10) |
			((uint32_t)(input[32] & 0xfe) << 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 263 to 291
	value = ((uint32_t)(input[32] & 0x01) << 31) |
			((uint32_t)input[33] << 23) |
			((uint32_t)input[34] << 15) |
			((uint32_t)input[35] << 7) |
			((uint32_t)(input[36] & 0xf0) >> 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 292 to 320
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)input[38] << 12) |
			((uint32_t)input[39] << 4) |
			((uint32_t)(input[40] & 0x80) >> 4);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 321 to 349
	value = ((uint32_t)(input[40] & 0x7f) << 25) |
			((uint32_t)input[41] << 17) |
			((uint32_t)input[42] << 9) |
			((uint32_t)(input[43] & 0xfc) << 1);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 350 to 378
	value = ((uint32_t)(input[43] & 0x03) << 30) |
			((uint32_t)input[44] << 22) |
			((uint32_t)input[45] << 14) |
			((uint32_t)input[46] << 6) |
			((uint32_t)(input[47] & 0xe0) >> 2);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 379 to 407
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)input[50] << 3);
	output[13] = (double)(value >> 3);
}

static void unpack_14_29bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 29-bit signed
	// Skip 3 bits, read 406 bits of data.
	// Input must be at least 52 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 31
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 32 to 60
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xf8));
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 61 to 89
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5) |
			((uint32_t)(input[11] & 0xc0) >> 3);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 177 to 205
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)input[24] << 9) |
			((uint32_t)(input[25] & 0xfc) << 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 206 to 234
	value = ((uint32_t)(input[25] & 0x03) << 30) |
			((uint32_t)input[26] << 22) |
			((uint32_t)input[27] << 14) |
			((uint32_t)input[28] << 6) |
			((uint32_t)(input[29] & 0xe0) >> 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 235 to 263
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)input[31] << 11) |
			((uint32_t)input[32] << 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 264 to 292
	value = ((uint32_t)input[33] << 24) |
			((uint32_t)input[34] << 16) |
			((uint32_t)input[35] << 8) |
			((uint32_t)(input[36] & 0xf8));
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 293 to 321
	value = ((uint32_t)(input[36] & 0x07) << 29) |
			((uint32_t)input[37] << 21) |
			((uint32_t)input[38] << 13) |
			((uint32_t)input[39] << 5) |
			((uint32_t)(input[40] & 0xc0) >> 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 322 to 350
	value = ((uint32_t)(input[40] & 0x3f) << 26) |
			((uint32_t)input[41] << 18) |
			((uint32_t)input[42] << 10) |
			((uint32_t)(input[43] & 0xfe) << 2);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 351 to 379
	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] & 0xf0) >> 1);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 380 to 408
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)input[49] << 12) |
			((uint32_t)input[50] << 4) |
			((uint32_t)(input[51] & 0x80) >> 4);
	output[13] = (double)(value >> 3);
}

static void unpack_14_29bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 29-bit unsigned
	// Skip 3 bits, read 406 bits of data.
	// Input must be at least 52 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 31
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 32 to 60
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xf8));
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 61 to 89
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5) |
			((uint32_t)(input[11] & 0xc0) >> 3);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 177 to 205
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)input[24] << 9) |
			((uint32_t)(input[25] & 0xfc) << 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 206 to 234
	value = ((uint32_t)(input[25] & 0x03) << 30) |
			((uint32_t)input[26] << 22) |
			((uint32_t)input[27] << 14) |
			((uint32_t)input[28] << 6) |
			((uint32_t)(input[29] & 0xe0) >> 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 235 to 263
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)input[31] << 11) |
			((uint32_t)input[32] << 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 264 to 292
	value = ((uint32_t)input[33] << 24) |
			((uint32_t)input[34] << 16) |
			((uint32_t)input[35] << 8) |
			((uint32_t)(input[36] & 0xf8));
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 293 to 321
	value = ((uint32_t)(input[36] & 0x07) << 29) |
			((uint32_t)input[37] << 21) |
			((uint32_t)input[38] << 13) |
			((uint32_t)input[39] << 5) |
			((uint32_t)(input[40] & 0xc0) >> 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 322 to 350
	value = ((uint32_t)(input[40] & 0x3f) << 26) |
			((uint32_t)input[41] << 18) |
			((uint32_t)input[42] << 10) |
			((uint32_t)(input[43] & 0xfe) << 2);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 351 to 379
	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] & 0xf0) >> 1);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 380 to 408
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)input[49] << 12) |
			((uint32_t)input[50] << 4) |
			((uint32_t)(input[51] & 0x80) >> 4);
	output[13] = (double)(value >> 3);
}

static void unpack_14_29bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 29-bit signed
	// Skip 4 bits, read 406 bits of data.
	// Input must be at least 52 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 32
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0x80) >> 4);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 33 to 61
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)(input[7] & 0xfc) << 1);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 62 to 90
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xe0) >> 2);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 178 to 206
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)input[24] << 10) |
			((uint32_t)(input[25] & 0xfe) << 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 207 to 235
	value = ((uint32_t)(input[25] & 0x01) << 31) |
			((uint32_t)input[26] << 23) |
			((uint32_t)input[27] << 15) |
			((uint32_t)input[28] << 7) |
			((uint32_t)(input[29] & 0xf0) >> 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 236 to 264
	value = ((uint32_t)(input[29] & 0x0f) << 28) |
			((uint32_t)input[30] << 20) |
			((uint32_t)input[31] << 12) |
			((uint32_t)input[32] << 4) |
			((uint32_t)(input[33] & 0x80) >> 4);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 265 to 293
	value = ((uint32_t)(input[33] & 0x7f) << 25) |
			((uint32_t)input[34] << 17) |
			((uint32_t)input[35] << 9) |
			((uint32_t)(input[36] & 0xfc) << 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 294 to 322
	value = ((uint32_t)(input[36] & 0x03) << 30) |
			((uint32_t)input[37] << 22) |
			((uint32_t)input[38] << 14) |
			((uint32_t)input[39] << 6) |
			((uint32_t)(input[40] & 0xe0) >> 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 323 to 351
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)input[42] << 11) |
			((uint32_t)input[43] << 3);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 352 to 380
	value = ((uint32_t)input[44] << 24) |
			((uint32_t)input[45] << 16) |
			((uint32_t)input[46] << 8) |
			((uint32_t)(input[47] & 0xf8));
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 381 to 409
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13) |
			((uint32_t)input[50] << 5) |
			((uint32_t)(input[51] & 0xc0) >> 3);
	output[13] = (double)(value >> 3);
}

static void unpack_14_29bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 29-bit unsigned
	// Skip 4 bits, read 406 bits of data.
	// Input must be at least 52 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 32
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0x80) >> 4);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 33 to 61
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)(input[7] & 0xfc) << 1);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 62 to 90
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xe0) >> 2);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 178 to 206
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)input[24] << 10) |
			((uint32_t)(input[25] & 0xfe) << 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 207 to 235
	value = ((uint32_t)(input[25] & 0x01) << 31) |
			((uint32_t)input[26] << 23) |
			((uint32_t)input[27] << 15) |
			((uint32_t)input[28] << 7) |
			((uint32_t)(input[29] & 0xf0) >> 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 236 to 264
	value = ((uint32_t)(input[29] & 0x0f) << 28) |
			((uint32_t)input[30] << 20) |
			((uint32_t)input[31] << 12) |
			((uint32_t)input[32] << 4) |
			((uint32_t)(input[33] & 0x80) >> 4);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 265 to 293
	value = ((uint32_t)(input[33] & 0x7f) << 25) |
			((uint32_t)input[34] << 17) |
			((uint32_t)input[35] << 9) |
			((uint32_t)(input[36] & 0xfc) << 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 294 to 322
	value = ((uint32_t)(input[36] & 0x03) << 30) |
			((uint32_t)input[37] << 22) |
			((uint32_t)input[38] << 14) |
			((uint32_t)input[39] << 6) |
			((uint32_t)(input[40] & 0xe0) >> 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 323 to 351
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)input[42] << 11) |
			((uint32_t)input[43] << 3);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 352 to 380
	value = ((uint32_t)input[44] << 24) |
			((uint32_t)input[45] << 16) |
			((uint32_t)input[46] << 8) |
			((uint32_t)(input[47] & 0xf8));
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 381 to 409
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13) |
			((uint32_t)input[50] << 5) |
			((uint32_t)(input[51] & 0xc0) >> 3);
	output[13] = (double)(value >> 3);
}

static void unpack_14_29bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 29-bit signed
	// Skip 5 bits, read 406 bits of data.
	// Input must be at least 52 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 33
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xc0) >> 3);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 34 to 62
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)(input[7] & 0xfe) << 2);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 63 to 91
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xf0) >> 1);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 150 to 178
	value = ((uint32_t)(input[18] & 0x03) << 30) |
			((uint32_t)input[19] << 22) |
			((uint32_t)input[20] << 14) |
			((uint32_t)input[21] << 6) |
			((uint32_t)(input[22] & 0xe0) >> 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 179 to 207
	value = ((uint32_t)(input[22] & 0x1f) << 27) |
			((uint32_t)input[23] << 19) |
			((uint32_t)input[24] << 11) |
			((uint32_t)input[25] << 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 208 to 236
	value = ((uint32_t)input[26] << 24) |
			((uint32_t)input[27] << 16) |
			((uint32_t)input[28] << 8) |
			((uint32_t)(input[29] & 0xf8));
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 237 to 265
	value = ((uint32_t)(input[29] & 0x07) << 29) |
			((uint32_t)input[30] << 21) |
			((uint32_t)input[31] << 13) |
			((uint32_t)input[32] << 5) |
			((uint32_t)(input[33] & 0xc0) >> 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 266 to 294
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)input[35] << 10) |
			((uint32_t)(input[36] & 0xfe) << 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 295 to 323
	value = ((uint32_t)(input[36] & 0x01) << 31) |
			((uint32_t)input[37] << 23) |
			((uint32_t)input[38] << 15) |
			((uint32_t)input[39] << 7) |
			((uint32_t)(input[40] & 0xf0) >> 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 324 to 352
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)input[43] << 4) |
			((uint32_t)(input[44] & 0x80) >> 4);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 353 to 381
	value = ((uint32_t)(input[44] & 0x7f) << 25) |
			((uint32_t)input[45] << 17) |
			((uint32_t)input[46] << 9) |
			((uint32_t)(input[47] & 0xfc) << 1);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 382 to 410
	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] & 0xe0) >> 2);
	output[13] = (double)(value >> 3);
}

static void unpack_14_29bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 29-bit unsigned
	// Skip 5 bits, read 406 bits of data.
	// Input must be at least 52 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 33
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xc0) >> 3);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 34 to 62
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)(input[7] & 0xfe) << 2);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 63 to 91
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xf0) >> 1);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 150 to 178
	value = ((uint32_t)(input[18] & 0x03) << 30) |
			((uint32_t)input[19] << 22) |
			((uint32_t)input[20] << 14) |
			((uint32_t)input[21] << 6) |
			((uint32_t)(input[22] & 0xe0) >> 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 179 to 207
	value = ((uint32_t)(input[22] & 0x1f) << 27) |
			((uint32_t)input[23] << 19) |
			((uint32_t)input[24] << 11) |
			((uint32_t)input[25] << 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 208 to 236
	value = ((uint32_t)input[26] << 24) |
			((uint32_t)input[27] << 16) |
			((uint32_t)input[28] << 8) |
			((uint32_t)(input[29] & 0xf8));
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 237 to 265
	value = ((uint32_t)(input[29] & 0x07) << 29) |
			((uint32_t)input[30] << 21) |
			((uint32_t)input[31] << 13) |
			((uint32_t)input[32] << 5) |
			((uint32_t)(input[33] & 0xc0) >> 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 266 to 294
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)input[35] << 10) |
			((uint32_t)(input[36] & 0xfe) << 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 295 to 323
	value = ((uint32_t)(input[36] & 0x01) << 31) |
			((uint32_t)input[37] << 23) |
			((uint32_t)input[38] << 15) |
			((uint32_t)input[39] << 7) |
			((uint32_t)(input[40] & 0xf0) >> 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 324 to 352
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)input[43] << 4) |
			((uint32_t)(input[44] & 0x80) >> 4);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 353 to 381
	value = ((uint32_t)(input[44] & 0x7f) << 25) |
			((uint32_t)input[45] << 17) |
			((uint32_t)input[46] << 9) |
			((uint32_t)(input[47] & 0xfc) << 1);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 382 to 410
	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] & 0xe0) >> 2);
	output[13] = (double)(value >> 3);
}

static void unpack_14_29bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 29-bit signed
	// Skip 6 bits, read 406 bits of data.
	// Input must be at least 52 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 34
	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] & 0xe0) >> 2);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 35 to 63
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 64 to 92
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xf8));
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 93 to 121
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xc0) >> 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 151 to 179
	value = ((uint32_t)(input[18] & 0x01) << 31) |
			((uint32_t)input[19] << 23) |
			((uint32_t)input[20] << 15) |
			((uint32_t)input[21] << 7) |
			((uint32_t)(input[22] & 0xf0) >> 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 180 to 208
	value = ((uint32_t)(input[22] & 0x0f) << 28) |
			((uint32_t)input[23] << 20) |
			((uint32_t)input[24] << 12) |
			((uint32_t)input[25] << 4) |
			((uint32_t)(input[26] & 0x80) >> 4);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 209 to 237
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)input[28] << 9) |
			((uint32_t)(input[29] & 0xfc) << 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 238 to 266
	value = ((uint32_t)(input[29] & 0x03) << 30) |
			((uint32_t)input[30] << 22) |
			((uint32_t)input[31] << 14) |
			((uint32_t)input[32] << 6) |
			((uint32_t)(input[33] & 0xe0) >> 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 267 to 295
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)input[35] << 11) |
			((uint32_t)input[36] << 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 296 to 324
	value = ((uint32_t)input[37] << 24) |
			((uint32_t)input[38] << 16) |
			((uint32_t)input[39] << 8) |
			((uint32_t)(input[40] & 0xf8));
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 325 to 353
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5) |
			((uint32_t)(input[44] & 0xc0) >> 3);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 354 to 382
	value = ((uint32_t)(input[44] & 0x3f) << 26) |
			((uint32_t)input[45] << 18) |
			((uint32_t)input[46] << 10) |
			((uint32_t)(input[47] & 0xfe) << 2);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 383 to 411
	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] & 0xf0) >> 1);
	output[13] = (double)(value >> 3);
}

static void unpack_14_29bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 29-bit unsigned
	// Skip 6 bits, read 406 bits of data.
	// Input must be at least 52 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 34
	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] & 0xe0) >> 2);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 35 to 63
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 64 to 92
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xf8));
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 93 to 121
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xc0) >> 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 151 to 179
	value = ((uint32_t)(input[18] & 0x01) << 31) |
			((uint32_t)input[19] << 23) |
			((uint32_t)input[20] << 15) |
			((uint32_t)input[21] << 7) |
			((uint32_t)(input[22] & 0xf0) >> 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 180 to 208
	value = ((uint32_t)(input[22] & 0x0f) << 28) |
			((uint32_t)input[23] << 20) |
			((uint32_t)input[24] << 12) |
			((uint32_t)input[25] << 4) |
			((uint32_t)(input[26] & 0x80) >> 4);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 209 to 237
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)input[28] << 9) |
			((uint32_t)(input[29] & 0xfc) << 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 238 to 266
	value = ((uint32_t)(input[29] & 0x03) << 30) |
			((uint32_t)input[30] << 22) |
			((uint32_t)input[31] << 14) |
			((uint32_t)input[32] << 6) |
			((uint32_t)(input[33] & 0xe0) >> 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 267 to 295
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)input[35] << 11) |
			((uint32_t)input[36] << 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 296 to 324
	value = ((uint32_t)input[37] << 24) |
			((uint32_t)input[38] << 16) |
			((uint32_t)input[39] << 8) |
			((uint32_t)(input[40] & 0xf8));
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 325 to 353
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5) |
			((uint32_t)(input[44] & 0xc0) >> 3);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 354 to 382
	value = ((uint32_t)(input[44] & 0x3f) << 26) |
			((uint32_t)input[45] << 18) |
			((uint32_t)input[46] << 10) |
			((uint32_t)(input[47] & 0xfe) << 2);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 383 to 411
	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] & 0xf0) >> 1);
	output[13] = (double)(value >> 3);
}

static void unpack_14_29bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 29-bit signed
	// Skip 7 bits, read 406 bits of data.
	// Input must be at least 52 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 35
	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] & 0xf0) >> 1);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 36 to 64
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0x80) >> 4);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 65 to 93
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)(input[11] & 0xfc) << 1);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 94 to 122
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xe0) >> 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 181 to 209
	value = ((uint32_t)(input[22] & 0x07) << 29) |
			((uint32_t)input[23] << 21) |
			((uint32_t)input[24] << 13) |
			((uint32_t)input[25] << 5) |
			((uint32_t)(input[26] & 0xc0) >> 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 210 to 238
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)input[28] << 10) |
			((uint32_t)(input[29] & 0xfe) << 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 239 to 267
	value = ((uint32_t)(input[29] & 0x01) << 31) |
			((uint32_t)input[30] << 23) |
			((uint32_t)input[31] << 15) |
			((uint32_t)input[32] << 7) |
			((uint32_t)(input[33] & 0xf0) >> 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 268 to 296
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)input[35] << 12) |
			((uint32_t)input[36] << 4) |
			((uint32_t)(input[37] & 0x80) >> 4);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 297 to 325
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xfc) << 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 326 to 354
	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] & 0xe0) >> 2);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 355 to 383
	value = ((uint32_t)(input[44] & 0x1f) << 27) |
			((uint32_t)input[45] << 19) |
			((uint32_t)input[46] << 11) |
			((uint32_t)input[47] << 3);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 384 to 412
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)input[50] << 8) |
			((uint32_t)(input[51] & 0xf8));
	output[13] = (double)(value >> 3);
}

static void unpack_14_29bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 29-bit unsigned
	// Skip 7 bits, read 406 bits of data.
	// Input must be at least 52 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 35
	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] & 0xf0) >> 1);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 36 to 64
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0x80) >> 4);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 65 to 93
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)(input[11] & 0xfc) << 1);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 94 to 122
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xe0) >> 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 181 to 209
	value = ((uint32_t)(input[22] & 0x07) << 29) |
			((uint32_t)input[23] << 21) |
			((uint32_t)input[24] << 13) |
			((uint32_t)input[25] << 5) |
			((uint32_t)(input[26] & 0xc0) >> 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 210 to 238
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)input[28] << 10) |
			((uint32_t)(input[29] & 0xfe) << 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 239 to 267
	value = ((uint32_t)(input[29] & 0x01) << 31) |
			((uint32_t)input[30] << 23) |
			((uint32_t)input[31] << 15) |
			((uint32_t)input[32] << 7) |
			((uint32_t)(input[33] & 0xf0) >> 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 268 to 296
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)input[35] << 12) |
			((uint32_t)input[36] << 4) |
			((uint32_t)(input[37] & 0x80) >> 4);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 297 to 325
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xfc) << 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 326 to 354
	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] & 0xe0) >> 2);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 355 to 383
	value = ((uint32_t)(input[44] & 0x1f) << 27) |
			((uint32_t)input[45] << 19) |
			((uint32_t)input[46] << 11) |
			((uint32_t)input[47] << 3);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 384 to 412
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)input[50] << 8) |
			((uint32_t)(input[51] & 0xf8));
	output[13] = (double)(value >> 3);
}

static void unpack_15_29bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 29-bit signed
	// Skip 0 bits, read 435 bits of data.
	// Input must be at least 55 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 28
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xf8));
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 29 to 57
	value = ((uint32_t)(input[3] & 0x07) << 29) |
			((uint32_t)input[4] << 21) |
			((uint32_t)input[5] << 13) |
			((uint32_t)input[6] << 5) |
			((uint32_t)(input[7] & 0xc0) >> 3);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 58 to 86
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xfe) << 2);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 145 to 173
	value = ((uint32_t)(input[18] & 0x7f) << 25) |
			((uint32_t)input[19] << 17) |
			((uint32_t)input[20] << 9) |
			((uint32_t)(input[21] & 0xfc) << 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 174 to 202
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)input[24] << 6) |
			((uint32_t)(input[25] & 0xe0) >> 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 203 to 231
	value = ((uint32_t)(input[25] & 0x1f) << 27) |
			((uint32_t)input[26] << 19) |
			((uint32_t)input[27] << 11) |
			((uint32_t)input[28] << 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 232 to 260
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)input[31] << 8) |
			((uint32_t)(input[32] & 0xf8));
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 261 to 289
	value = ((uint32_t)(input[32] & 0x07) << 29) |
			((uint32_t)input[33] << 21) |
			((uint32_t)input[34] << 13) |
			((uint32_t)input[35] << 5) |
			((uint32_t)(input[36] & 0xc0) >> 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 290 to 318
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)input[38] << 10) |
			((uint32_t)(input[39] & 0xfe) << 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 319 to 347
	value = ((uint32_t)(input[39] & 0x01) << 31) |
			((uint32_t)input[40] << 23) |
			((uint32_t)input[41] << 15) |
			((uint32_t)input[42] << 7) |
			((uint32_t)(input[43] & 0xf0) >> 1);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 348 to 376
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)input[45] << 12) |
			((uint32_t)input[46] << 4) |
			((uint32_t)(input[47] & 0x80) >> 4);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 377 to 405
	value = ((uint32_t)(input[47] & 0x7f) << 25) |
			((uint32_t)input[48] << 17) |
			((uint32_t)input[49] << 9) |
			((uint32_t)(input[50] & 0xfc) << 1);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 406 to 434
	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] & 0xe0) >> 2);
	output[14] = (double)(value >> 3);
}

static void unpack_15_29bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 29-bit unsigned
	// Skip 0 bits, read 435 bits of data.
	// Input must be at least 55 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 28
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xf8));
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 29 to 57
	value = ((uint32_t)(input[3] & 0x07) << 29) |
			((uint32_t)input[4] << 21) |
			((uint32_t)input[5] << 13) |
			((uint32_t)input[6] << 5) |
			((uint32_t)(input[7] & 0xc0) >> 3);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 58 to 86
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xfe) << 2);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 145 to 173
	value = ((uint32_t)(input[18] & 0x7f) << 25) |
			((uint32_t)input[19] << 17) |
			((uint32_t)input[20] << 9) |
			((uint32_t)(input[21] & 0xfc) << 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 174 to 202
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)input[24] << 6) |
			((uint32_t)(input[25] & 0xe0) >> 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 203 to 231
	value = ((uint32_t)(input[25] & 0x1f) << 27) |
			((uint32_t)input[26] << 19) |
			((uint32_t)input[27] << 11) |
			((uint32_t)input[28] << 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 232 to 260
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)input[31] << 8) |
			((uint32_t)(input[32] & 0xf8));
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 261 to 289
	value = ((uint32_t)(input[32] & 0x07) << 29) |
			((uint32_t)input[33] << 21) |
			((uint32_t)input[34] << 13) |
			((uint32_t)input[35] << 5) |
			((uint32_t)(input[36] & 0xc0) >> 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 290 to 318
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)input[38] << 10) |
			((uint32_t)(input[39] & 0xfe) << 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 319 to 347
	value = ((uint32_t)(input[39] & 0x01) << 31) |
			((uint32_t)input[40] << 23) |
			((uint32_t)input[41] << 15) |
			((uint32_t)input[42] << 7) |
			((uint32_t)(input[43] & 0xf0) >> 1);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 348 to 376
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)input[45] << 12) |
			((uint32_t)input[46] << 4) |
			((uint32_t)(input[47] & 0x80) >> 4);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 377 to 405
	value = ((uint32_t)(input[47] & 0x7f) << 25) |
			((uint32_t)input[48] << 17) |
			((uint32_t)input[49] << 9) |
			((uint32_t)(input[50] & 0xfc) << 1);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 406 to 434
	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] & 0xe0) >> 2);
	output[14] = (double)(value >> 3);
}

static void unpack_15_29bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 29-bit signed
	// Skip 1 bits, read 435 bits of data.
	// Input must be at least 55 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 29
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)(input[3] & 0xfc) << 1);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 59 to 87
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)input[10] << 3);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 88 to 116
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xf8));
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 175 to 203
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)input[24] << 7) |
			((uint32_t)(input[25] & 0xf0) >> 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 204 to 232
	value = ((uint32_t)(input[25] & 0x0f) << 28) |
			((uint32_t)input[26] << 20) |
			((uint32_t)input[27] << 12) |
			((uint32_t)input[28] << 4) |
			((uint32_t)(input[29] & 0x80) >> 4);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 233 to 261
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)input[31] << 9) |
			((uint32_t)(input[32] & 0xfc) << 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 262 to 290
	value = ((uint32_t)(input[32] & 0x03) << 30) |
			((uint32_t)input[33] << 22) |
			((uint32_t)input[34] << 14) |
			((uint32_t)input[35] << 6) |
			((uint32_t)(input[36] & 0xe0) >> 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 291 to 319
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)input[38] << 11) |
			((uint32_t)input[39] << 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 320 to 348
	value = ((uint32_t)input[40] << 24) |
			((uint32_t)input[41] << 16) |
			((uint32_t)input[42] << 8) |
			((uint32_t)(input[43] & 0xf8));
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 349 to 377
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13) |
			((uint32_t)input[46] << 5) |
			((uint32_t)(input[47] & 0xc0) >> 3);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 378 to 406
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)(input[50] & 0xfe) << 2);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 407 to 435
	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] & 0xf0) >> 1);
	output[14] = (double)(value >> 3);
}

static void unpack_15_29bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 29-bit unsigned
	// Skip 1 bits, read 435 bits of data.
	// Input must be at least 55 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 29
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)(input[3] & 0xfc) << 1);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 59 to 87
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)input[10] << 3);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 88 to 116
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xf8));
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 175 to 203
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)input[24] << 7) |
			((uint32_t)(input[25] & 0xf0) >> 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 204 to 232
	value = ((uint32_t)(input[25] & 0x0f) << 28) |
			((uint32_t)input[26] << 20) |
			((uint32_t)input[27] << 12) |
			((uint32_t)input[28] << 4) |
			((uint32_t)(input[29] & 0x80) >> 4);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 233 to 261
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)input[31] << 9) |
			((uint32_t)(input[32] & 0xfc) << 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 262 to 290
	value = ((uint32_t)(input[32] & 0x03) << 30) |
			((uint32_t)input[33] << 22) |
			((uint32_t)input[34] << 14) |
			((uint32_t)input[35] << 6) |
			((uint32_t)(input[36] & 0xe0) >> 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 291 to 319
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)input[38] << 11) |
			((uint32_t)input[39] << 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 320 to 348
	value = ((uint32_t)input[40] << 24) |
			((uint32_t)input[41] << 16) |
			((uint32_t)input[42] << 8) |
			((uint32_t)(input[43] & 0xf8));
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 349 to 377
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13) |
			((uint32_t)input[46] << 5) |
			((uint32_t)(input[47] & 0xc0) >> 3);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 378 to 406
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)(input[50] & 0xfe) << 2);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 407 to 435
	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] & 0xf0) >> 1);
	output[14] = (double)(value >> 3);
}

static void unpack_15_29bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 29-bit signed
	// Skip 2 bits, read 435 bits of data.
	// Input must be at least 55 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 30
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)(input[3] & 0xfe) << 2);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 31 to 59
	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] & 0xf0) >> 1);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 60 to 88
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)input[10] << 4) |
			((uint32_t)(input[11] & 0x80) >> 4);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 89 to 117
	value = ((uint32_t)(input[11] & 0x7f) << 25) |
			((uint32_t)input[12] << 17) |
			((uint32_t)input[13] << 9) |
			((uint32_t)(input[14] & 0xfc) << 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 147 to 175
	value = ((uint32_t)(input[18] & 0x1f) << 27) |
			((uint32_t)input[19] << 19) |
			((uint32_t)input[20] << 11) |
			((uint32_t)input[21] << 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 176 to 204
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)input[24] << 8) |
			((uint32_t)(input[25] & 0xf8));
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 205 to 233
	value = ((uint32_t)(input[25] & 0x07) << 29) |
			((uint32_t)input[26] << 21) |
			((uint32_t)input[27] << 13) |
			((uint32_t)input[28] << 5) |
			((uint32_t)(input[29] & 0xc0) >> 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 234 to 262
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)input[31] << 10) |
			((uint32_t)(input[32] & 0xfe) << 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 263 to 291
	value = ((uint32_t)(input[32] & 0x01) << 31) |
			((uint32_t)input[33] << 23) |
			((uint32_t)input[34] << 15) |
			((uint32_t)input[35] << 7) |
			((uint32_t)(input[36] & 0xf0) >> 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 292 to 320
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)input[38] << 12) |
			((uint32_t)input[39] << 4) |
			((uint32_t)(input[40] & 0x80) >> 4);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 321 to 349
	value = ((uint32_t)(input[40] & 0x7f) << 25) |
			((uint32_t)input[41] << 17) |
			((uint32_t)input[42] << 9) |
			((uint32_t)(input[43] & 0xfc) << 1);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 350 to 378
	value = ((uint32_t)(input[43] & 0x03) << 30) |
			((uint32_t)input[44] << 22) |
			((uint32_t)input[45] << 14) |
			((uint32_t)input[46] << 6) |
			((uint32_t)(input[47] & 0xe0) >> 2);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 379 to 407
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)input[50] << 3);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 408 to 436
	value = ((uint32_t)input[51] << 24) |
			((uint32_t)input[52] << 16) |
			((uint32_t)input[53] << 8) |
			((uint32_t)(input[54] & 0xf8));
	output[14] = (double)(value >> 3);
}

static void unpack_15_29bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 29-bit unsigned
	// Skip 2 bits, read 435 bits of data.
	// Input must be at least 55 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 30
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)(input[3] & 0xfe) << 2);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 31 to 59
	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] & 0xf0) >> 1);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 60 to 88
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)input[10] << 4) |
			((uint32_t)(input[11] & 0x80) >> 4);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 89 to 117
	value = ((uint32_t)(input[11] & 0x7f) << 25) |
			((uint32_t)input[12] << 17) |
			((uint32_t)input[13] << 9) |
			((uint32_t)(input[14] & 0xfc) << 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 147 to 175
	value = ((uint32_t)(input[18] & 0x1f) << 27) |
			((uint32_t)input[19] << 19) |
			((uint32_t)input[20] << 11) |
			((uint32_t)input[21] << 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 176 to 204
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)input[24] << 8) |
			((uint32_t)(input[25] & 0xf8));
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 205 to 233
	value = ((uint32_t)(input[25] & 0x07) << 29) |
			((uint32_t)input[26] << 21) |
			((uint32_t)input[27] << 13) |
			((uint32_t)input[28] << 5) |
			((uint32_t)(input[29] & 0xc0) >> 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 234 to 262
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)input[31] << 10) |
			((uint32_t)(input[32] & 0xfe) << 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 263 to 291
	value = ((uint32_t)(input[32] & 0x01) << 31) |
			((uint32_t)input[33] << 23) |
			((uint32_t)input[34] << 15) |
			((uint32_t)input[35] << 7) |
			((uint32_t)(input[36] & 0xf0) >> 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 292 to 320
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)input[38] << 12) |
			((uint32_t)input[39] << 4) |
			((uint32_t)(input[40] & 0x80) >> 4);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 321 to 349
	value = ((uint32_t)(input[40] & 0x7f) << 25) |
			((uint32_t)input[41] << 17) |
			((uint32_t)input[42] << 9) |
			((uint32_t)(input[43] & 0xfc) << 1);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 350 to 378
	value = ((uint32_t)(input[43] & 0x03) << 30) |
			((uint32_t)input[44] << 22) |
			((uint32_t)input[45] << 14) |
			((uint32_t)input[46] << 6) |
			((uint32_t)(input[47] & 0xe0) >> 2);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 379 to 407
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)input[50] << 3);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 408 to 436
	value = ((uint32_t)input[51] << 24) |
			((uint32_t)input[52] << 16) |
			((uint32_t)input[53] << 8) |
			((uint32_t)(input[54] & 0xf8));
	output[14] = (double)(value >> 3);
}

static void unpack_15_29bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 29-bit signed
	// Skip 3 bits, read 435 bits of data.
	// Input must be at least 55 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 31
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 32 to 60
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xf8));
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 61 to 89
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5) |
			((uint32_t)(input[11] & 0xc0) >> 3);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 177 to 205
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)input[24] << 9) |
			((uint32_t)(input[25] & 0xfc) << 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 206 to 234
	value = ((uint32_t)(input[25] & 0x03) << 30) |
			((uint32_t)input[26] << 22) |
			((uint32_t)input[27] << 14) |
			((uint32_t)input[28] << 6) |
			((uint32_t)(input[29] & 0xe0) >> 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 235 to 263
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)input[31] << 11) |
			((uint32_t)input[32] << 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 264 to 292
	value = ((uint32_t)input[33] << 24) |
			((uint32_t)input[34] << 16) |
			((uint32_t)input[35] << 8) |
			((uint32_t)(input[36] & 0xf8));
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 293 to 321
	value = ((uint32_t)(input[36] & 0x07) << 29) |
			((uint32_t)input[37] << 21) |
			((uint32_t)input[38] << 13) |
			((uint32_t)input[39] << 5) |
			((uint32_t)(input[40] & 0xc0) >> 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 322 to 350
	value = ((uint32_t)(input[40] & 0x3f) << 26) |
			((uint32_t)input[41] << 18) |
			((uint32_t)input[42] << 10) |
			((uint32_t)(input[43] & 0xfe) << 2);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 351 to 379
	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] & 0xf0) >> 1);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 380 to 408
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)input[49] << 12) |
			((uint32_t)input[50] << 4) |
			((uint32_t)(input[51] & 0x80) >> 4);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 409 to 437
	value = ((uint32_t)(input[51] & 0x7f) << 25) |
			((uint32_t)input[52] << 17) |
			((uint32_t)input[53] << 9) |
			((uint32_t)(input[54] & 0xfc) << 1);
	output[14] = (double)(value >> 3);
}

static void unpack_15_29bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 29-bit unsigned
	// Skip 3 bits, read 435 bits of data.
	// Input must be at least 55 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 31
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 32 to 60
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xf8));
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 61 to 89
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5) |
			((uint32_t)(input[11] & 0xc0) >> 3);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 177 to 205
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)input[24] << 9) |
			((uint32_t)(input[25] & 0xfc) << 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 206 to 234
	value = ((uint32_t)(input[25] & 0x03) << 30) |
			((uint32_t)input[26] << 22) |
			((uint32_t)input[27] << 14) |
			((uint32_t)input[28] << 6) |
			((uint32_t)(input[29] & 0xe0) >> 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 235 to 263
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)input[31] << 11) |
			((uint32_t)input[32] << 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 264 to 292
	value = ((uint32_t)input[33] << 24) |
			((uint32_t)input[34] << 16) |
			((uint32_t)input[35] << 8) |
			((uint32_t)(input[36] & 0xf8));
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 293 to 321
	value = ((uint32_t)(input[36] & 0x07) << 29) |
			((uint32_t)input[37] << 21) |
			((uint32_t)input[38] << 13) |
			((uint32_t)input[39] << 5) |
			((uint32_t)(input[40] & 0xc0) >> 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 322 to 350
	value = ((uint32_t)(input[40] & 0x3f) << 26) |
			((uint32_t)input[41] << 18) |
			((uint32_t)input[42] << 10) |
			((uint32_t)(input[43] & 0xfe) << 2);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 351 to 379
	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] & 0xf0) >> 1);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 380 to 408
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)input[49] << 12) |
			((uint32_t)input[50] << 4) |
			((uint32_t)(input[51] & 0x80) >> 4);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 409 to 437
	value = ((uint32_t)(input[51] & 0x7f) << 25) |
			((uint32_t)input[52] << 17) |
			((uint32_t)input[53] << 9) |
			((uint32_t)(input[54] & 0xfc) << 1);
	output[14] = (double)(value >> 3);
}

static void unpack_15_29bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 29-bit signed
	// Skip 4 bits, read 435 bits of data.
	// Input must be at least 55 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 32
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0x80) >> 4);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 33 to 61
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)(input[7] & 0xfc) << 1);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 62 to 90
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xe0) >> 2);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 178 to 206
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)input[24] << 10) |
			((uint32_t)(input[25] & 0xfe) << 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 207 to 235
	value = ((uint32_t)(input[25] & 0x01) << 31) |
			((uint32_t)input[26] << 23) |
			((uint32_t)input[27] << 15) |
			((uint32_t)input[28] << 7) |
			((uint32_t)(input[29] & 0xf0) >> 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 236 to 264
	value = ((uint32_t)(input[29] & 0x0f) << 28) |
			((uint32_t)input[30] << 20) |
			((uint32_t)input[31] << 12) |
			((uint32_t)input[32] << 4) |
			((uint32_t)(input[33] & 0x80) >> 4);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 265 to 293
	value = ((uint32_t)(input[33] & 0x7f) << 25) |
			((uint32_t)input[34] << 17) |
			((uint32_t)input[35] << 9) |
			((uint32_t)(input[36] & 0xfc) << 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 294 to 322
	value = ((uint32_t)(input[36] & 0x03) << 30) |
			((uint32_t)input[37] << 22) |
			((uint32_t)input[38] << 14) |
			((uint32_t)input[39] << 6) |
			((uint32_t)(input[40] & 0xe0) >> 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 323 to 351
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)input[42] << 11) |
			((uint32_t)input[43] << 3);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 352 to 380
	value = ((uint32_t)input[44] << 24) |
			((uint32_t)input[45] << 16) |
			((uint32_t)input[46] << 8) |
			((uint32_t)(input[47] & 0xf8));
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 381 to 409
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13) |
			((uint32_t)input[50] << 5) |
			((uint32_t)(input[51] & 0xc0) >> 3);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 410 to 438
	value = ((uint32_t)(input[51] & 0x3f) << 26) |
			((uint32_t)input[52] << 18) |
			((uint32_t)input[53] << 10) |
			((uint32_t)(input[54] & 0xfe) << 2);
	output[14] = (double)(value >> 3);
}

static void unpack_15_29bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 29-bit unsigned
	// Skip 4 bits, read 435 bits of data.
	// Input must be at least 55 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 32
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0x80) >> 4);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 33 to 61
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)(input[7] & 0xfc) << 1);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 62 to 90
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xe0) >> 2);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 178 to 206
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)input[24] << 10) |
			((uint32_t)(input[25] & 0xfe) << 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 207 to 235
	value = ((uint32_t)(input[25] & 0x01) << 31) |
			((uint32_t)input[26] << 23) |
			((uint32_t)input[27] << 15) |
			((uint32_t)input[28] << 7) |
			((uint32_t)(input[29] & 0xf0) >> 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 236 to 264
	value = ((uint32_t)(input[29] & 0x0f) << 28) |
			((uint32_t)input[30] << 20) |
			((uint32_t)input[31] << 12) |
			((uint32_t)input[32] << 4) |
			((uint32_t)(input[33] & 0x80) >> 4);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 265 to 293
	value = ((uint32_t)(input[33] & 0x7f) << 25) |
			((uint32_t)input[34] << 17) |
			((uint32_t)input[35] << 9) |
			((uint32_t)(input[36] & 0xfc) << 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 294 to 322
	value = ((uint32_t)(input[36] & 0x03) << 30) |
			((uint32_t)input[37] << 22) |
			((uint32_t)input[38] << 14) |
			((uint32_t)input[39] << 6) |
			((uint32_t)(input[40] & 0xe0) >> 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 323 to 351
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)input[42] << 11) |
			((uint32_t)input[43] << 3);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 352 to 380
	value = ((uint32_t)input[44] << 24) |
			((uint32_t)input[45] << 16) |
			((uint32_t)input[46] << 8) |
			((uint32_t)(input[47] & 0xf8));
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 381 to 409
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13) |
			((uint32_t)input[50] << 5) |
			((uint32_t)(input[51] & 0xc0) >> 3);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 410 to 438
	value = ((uint32_t)(input[51] & 0x3f) << 26) |
			((uint32_t)input[52] << 18) |
			((uint32_t)input[53] << 10) |
			((uint32_t)(input[54] & 0xfe) << 2);
	output[14] = (double)(value >> 3);
}

static void unpack_15_29bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 29-bit signed
	// Skip 5 bits, read 435 bits of data.
	// Input must be at least 55 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 33
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xc0) >> 3);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 34 to 62
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)(input[7] & 0xfe) << 2);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 63 to 91
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xf0) >> 1);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 150 to 178
	value = ((uint32_t)(input[18] & 0x03) << 30) |
			((uint32_t)input[19] << 22) |
			((uint32_t)input[20] << 14) |
			((uint32_t)input[21] << 6) |
			((uint32_t)(input[22] & 0xe0) >> 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 179 to 207
	value = ((uint32_t)(input[22] & 0x1f) << 27) |
			((uint32_t)input[23] << 19) |
			((uint32_t)input[24] << 11) |
			((uint32_t)input[25] << 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 208 to 236
	value = ((uint32_t)input[26] << 24) |
			((uint32_t)input[27] << 16) |
			((uint32_t)input[28] << 8) |
			((uint32_t)(input[29] & 0xf8));
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 237 to 265
	value = ((uint32_t)(input[29] & 0x07) << 29) |
			((uint32_t)input[30] << 21) |
			((uint32_t)input[31] << 13) |
			((uint32_t)input[32] << 5) |
			((uint32_t)(input[33] & 0xc0) >> 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 266 to 294
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)input[35] << 10) |
			((uint32_t)(input[36] & 0xfe) << 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 295 to 323
	value = ((uint32_t)(input[36] & 0x01) << 31) |
			((uint32_t)input[37] << 23) |
			((uint32_t)input[38] << 15) |
			((uint32_t)input[39] << 7) |
			((uint32_t)(input[40] & 0xf0) >> 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 324 to 352
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)input[43] << 4) |
			((uint32_t)(input[44] & 0x80) >> 4);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 353 to 381
	value = ((uint32_t)(input[44] & 0x7f) << 25) |
			((uint32_t)input[45] << 17) |
			((uint32_t)input[46] << 9) |
			((uint32_t)(input[47] & 0xfc) << 1);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 382 to 410
	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] & 0xe0) >> 2);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 411 to 439
	value = ((uint32_t)(input[51] & 0x1f) << 27) |
			((uint32_t)input[52] << 19) |
			((uint32_t)input[53] << 11) |
			((uint32_t)input[54] << 3);
	output[14] = (double)(value >> 3);
}

static void unpack_15_29bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 29-bit unsigned
	// Skip 5 bits, read 435 bits of data.
	// Input must be at least 55 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 33
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xc0) >> 3);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 34 to 62
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)(input[7] & 0xfe) << 2);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 63 to 91
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xf0) >> 1);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 150 to 178
	value = ((uint32_t)(input[18] & 0x03) << 30) |
			((uint32_t)input[19] << 22) |
			((uint32_t)input[20] << 14) |
			((uint32_t)input[21] << 6) |
			((uint32_t)(input[22] & 0xe0) >> 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 179 to 207
	value = ((uint32_t)(input[22] & 0x1f) << 27) |
			((uint32_t)input[23] << 19) |
			((uint32_t)input[24] << 11) |
			((uint32_t)input[25] << 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 208 to 236
	value = ((uint32_t)input[26] << 24) |
			((uint32_t)input[27] << 16) |
			((uint32_t)input[28] << 8) |
			((uint32_t)(input[29] & 0xf8));
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 237 to 265
	value = ((uint32_t)(input[29] & 0x07) << 29) |
			((uint32_t)input[30] << 21) |
			((uint32_t)input[31] << 13) |
			((uint32_t)input[32] << 5) |
			((uint32_t)(input[33] & 0xc0) >> 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 266 to 294
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)input[35] << 10) |
			((uint32_t)(input[36] & 0xfe) << 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 295 to 323
	value = ((uint32_t)(input[36] & 0x01) << 31) |
			((uint32_t)input[37] << 23) |
			((uint32_t)input[38] << 15) |
			((uint32_t)input[39] << 7) |
			((uint32_t)(input[40] & 0xf0) >> 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 324 to 352
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)input[43] << 4) |
			((uint32_t)(input[44] & 0x80) >> 4);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 353 to 381
	value = ((uint32_t)(input[44] & 0x7f) << 25) |
			((uint32_t)input[45] << 17) |
			((uint32_t)input[46] << 9) |
			((uint32_t)(input[47] & 0xfc) << 1);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 382 to 410
	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] & 0xe0) >> 2);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 411 to 439
	value = ((uint32_t)(input[51] & 0x1f) << 27) |
			((uint32_t)input[52] << 19) |
			((uint32_t)input[53] << 11) |
			((uint32_t)input[54] << 3);
	output[14] = (double)(value >> 3);
}

static void unpack_15_29bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 29-bit signed
	// Skip 6 bits, read 435 bits of data.
	// Input must be at least 56 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 34
	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] & 0xe0) >> 2);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 35 to 63
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 64 to 92
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xf8));
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 93 to 121
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xc0) >> 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 151 to 179
	value = ((uint32_t)(input[18] & 0x01) << 31) |
			((uint32_t)input[19] << 23) |
			((uint32_t)input[20] << 15) |
			((uint32_t)input[21] << 7) |
			((uint32_t)(input[22] & 0xf0) >> 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 180 to 208
	value = ((uint32_t)(input[22] & 0x0f) << 28) |
			((uint32_t)input[23] << 20) |
			((uint32_t)input[24] << 12) |
			((uint32_t)input[25] << 4) |
			((uint32_t)(input[26] & 0x80) >> 4);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 209 to 237
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)input[28] << 9) |
			((uint32_t)(input[29] & 0xfc) << 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 238 to 266
	value = ((uint32_t)(input[29] & 0x03) << 30) |
			((uint32_t)input[30] << 22) |
			((uint32_t)input[31] << 14) |
			((uint32_t)input[32] << 6) |
			((uint32_t)(input[33] & 0xe0) >> 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 267 to 295
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)input[35] << 11) |
			((uint32_t)input[36] << 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 296 to 324
	value = ((uint32_t)input[37] << 24) |
			((uint32_t)input[38] << 16) |
			((uint32_t)input[39] << 8) |
			((uint32_t)(input[40] & 0xf8));
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 325 to 353
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5) |
			((uint32_t)(input[44] & 0xc0) >> 3);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 354 to 382
	value = ((uint32_t)(input[44] & 0x3f) << 26) |
			((uint32_t)input[45] << 18) |
			((uint32_t)input[46] << 10) |
			((uint32_t)(input[47] & 0xfe) << 2);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 383 to 411
	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] & 0xf0) >> 1);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 412 to 440
	value = ((uint32_t)(input[51] & 0x0f) << 28) |
			((uint32_t)input[52] << 20) |
			((uint32_t)input[53] << 12) |
			((uint32_t)input[54] << 4) |
			((uint32_t)(input[55] & 0x80) >> 4);
	output[14] = (double)(value >> 3);
}

static void unpack_15_29bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 29-bit unsigned
	// Skip 6 bits, read 435 bits of data.
	// Input must be at least 56 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 34
	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] & 0xe0) >> 2);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 35 to 63
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 64 to 92
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xf8));
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 93 to 121
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xc0) >> 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 151 to 179
	value = ((uint32_t)(input[18] & 0x01) << 31) |
			((uint32_t)input[19] << 23) |
			((uint32_t)input[20] << 15) |
			((uint32_t)input[21] << 7) |
			((uint32_t)(input[22] & 0xf0) >> 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 180 to 208
	value = ((uint32_t)(input[22] & 0x0f) << 28) |
			((uint32_t)input[23] << 20) |
			((uint32_t)input[24] << 12) |
			((uint32_t)input[25] << 4) |
			((uint32_t)(input[26] & 0x80) >> 4);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 209 to 237
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)input[28] << 9) |
			((uint32_t)(input[29] & 0xfc) << 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 238 to 266
	value = ((uint32_t)(input[29] & 0x03) << 30) |
			((uint32_t)input[30] << 22) |
			((uint32_t)input[31] << 14) |
			((uint32_t)input[32] << 6) |
			((uint32_t)(input[33] & 0xe0) >> 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 267 to 295
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)input[35] << 11) |
			((uint32_t)input[36] << 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 296 to 324
	value = ((uint32_t)input[37] << 24) |
			((uint32_t)input[38] << 16) |
			((uint32_t)input[39] << 8) |
			((uint32_t)(input[40] & 0xf8));
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 325 to 353
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5) |
			((uint32_t)(input[44] & 0xc0) >> 3);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 354 to 382
	value = ((uint32_t)(input[44] & 0x3f) << 26) |
			((uint32_t)input[45] << 18) |
			((uint32_t)input[46] << 10) |
			((uint32_t)(input[47] & 0xfe) << 2);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 383 to 411
	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] & 0xf0) >> 1);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 412 to 440
	value = ((uint32_t)(input[51] & 0x0f) << 28) |
			((uint32_t)input[52] << 20) |
			((uint32_t)input[53] << 12) |
			((uint32_t)input[54] << 4) |
			((uint32_t)(input[55] & 0x80) >> 4);
	output[14] = (double)(value >> 3);
}

static void unpack_15_29bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 29-bit signed
	// Skip 7 bits, read 435 bits of data.
	// Input must be at least 56 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 35
	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] & 0xf0) >> 1);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 36 to 64
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0x80) >> 4);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 65 to 93
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)(input[11] & 0xfc) << 1);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 94 to 122
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xe0) >> 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 181 to 209
	value = ((uint32_t)(input[22] & 0x07) << 29) |
			((uint32_t)input[23] << 21) |
			((uint32_t)input[24] << 13) |
			((uint32_t)input[25] << 5) |
			((uint32_t)(input[26] & 0xc0) >> 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 210 to 238
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)input[28] << 10) |
			((uint32_t)(input[29] & 0xfe) << 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 239 to 267
	value = ((uint32_t)(input[29] & 0x01) << 31) |
			((uint32_t)input[30] << 23) |
			((uint32_t)input[31] << 15) |
			((uint32_t)input[32] << 7) |
			((uint32_t)(input[33] & 0xf0) >> 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 268 to 296
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)input[35] << 12) |
			((uint32_t)input[36] << 4) |
			((uint32_t)(input[37] & 0x80) >> 4);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 297 to 325
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xfc) << 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 326 to 354
	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] & 0xe0) >> 2);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 355 to 383
	value = ((uint32_t)(input[44] & 0x1f) << 27) |
			((uint32_t)input[45] << 19) |
			((uint32_t)input[46] << 11) |
			((uint32_t)input[47] << 3);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 384 to 412
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)input[50] << 8) |
			((uint32_t)(input[51] & 0xf8));
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 413 to 441
	value = ((uint32_t)(input[51] & 0x07) << 29) |
			((uint32_t)input[52] << 21) |
			((uint32_t)input[53] << 13) |
			((uint32_t)input[54] << 5) |
			((uint32_t)(input[55] & 0xc0) >> 3);
	output[14] = (double)(value >> 3);
}

static void unpack_15_29bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 29-bit unsigned
	// Skip 7 bits, read 435 bits of data.
	// Input must be at least 56 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 35
	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] & 0xf0) >> 1);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 36 to 64
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0x80) >> 4);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 65 to 93
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)(input[11] & 0xfc) << 1);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 94 to 122
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xe0) >> 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 181 to 209
	value = ((uint32_t)(input[22] & 0x07) << 29) |
			((uint32_t)input[23] << 21) |
			((uint32_t)input[24] << 13) |
			((uint32_t)input[25] << 5) |
			((uint32_t)(input[26] & 0xc0) >> 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 210 to 238
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)input[28] << 10) |
			((uint32_t)(input[29] & 0xfe) << 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 239 to 267
	value = ((uint32_t)(input[29] & 0x01) << 31) |
			((uint32_t)input[30] << 23) |
			((uint32_t)input[31] << 15) |
			((uint32_t)input[32] << 7) |
			((uint32_t)(input[33] & 0xf0) >> 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 268 to 296
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)input[35] << 12) |
			((uint32_t)input[36] << 4) |
			((uint32_t)(input[37] & 0x80) >> 4);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 297 to 325
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xfc) << 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 326 to 354
	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] & 0xe0) >> 2);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 355 to 383
	value = ((uint32_t)(input[44] & 0x1f) << 27) |
			((uint32_t)input[45] << 19) |
			((uint32_t)input[46] << 11) |
			((uint32_t)input[47] << 3);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 384 to 412
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)input[50] << 8) |
			((uint32_t)(input[51] & 0xf8));
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 413 to 441
	value = ((uint32_t)(input[51] & 0x07) << 29) |
			((uint32_t)input[52] << 21) |
			((uint32_t)input[53] << 13) |
			((uint32_t)input[54] << 5) |
			((uint32_t)(input[55] & 0xc0) >> 3);
	output[14] = (double)(value >> 3);
}

static void unpack_16_29bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 29-bit signed
	// Skip 0 bits, read 464 bits of data.
	// Input must be at least 58 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 28
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xf8));
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 29 to 57
	value = ((uint32_t)(input[3] & 0x07) << 29) |
			((uint32_t)input[4] << 21) |
			((uint32_t)input[5] << 13) |
			((uint32_t)input[6] << 5) |
			((uint32_t)(input[7] & 0xc0) >> 3);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 58 to 86
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xfe) << 2);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 145 to 173
	value = ((uint32_t)(input[18] & 0x7f) << 25) |
			((uint32_t)input[19] << 17) |
			((uint32_t)input[20] << 9) |
			((uint32_t)(input[21] & 0xfc) << 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 174 to 202
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)input[24] << 6) |
			((uint32_t)(input[25] & 0xe0) >> 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 203 to 231
	value = ((uint32_t)(input[25] & 0x1f) << 27) |
			((uint32_t)input[26] << 19) |
			((uint32_t)input[27] << 11) |
			((uint32_t)input[28] << 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 232 to 260
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)input[31] << 8) |
			((uint32_t)(input[32] & 0xf8));
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 261 to 289
	value = ((uint32_t)(input[32] & 0x07) << 29) |
			((uint32_t)input[33] << 21) |
			((uint32_t)input[34] << 13) |
			((uint32_t)input[35] << 5) |
			((uint32_t)(input[36] & 0xc0) >> 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 290 to 318
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)input[38] << 10) |
			((uint32_t)(input[39] & 0xfe) << 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 319 to 347
	value = ((uint32_t)(input[39] & 0x01) << 31) |
			((uint32_t)input[40] << 23) |
			((uint32_t)input[41] << 15) |
			((uint32_t)input[42] << 7) |
			((uint32_t)(input[43] & 0xf0) >> 1);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 348 to 376
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)input[45] << 12) |
			((uint32_t)input[46] << 4) |
			((uint32_t)(input[47] & 0x80) >> 4);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 377 to 405
	value = ((uint32_t)(input[47] & 0x7f) << 25) |
			((uint32_t)input[48] << 17) |
			((uint32_t)input[49] << 9) |
			((uint32_t)(input[50] & 0xfc) << 1);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 406 to 434
	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] & 0xe0) >> 2);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 435 to 463
	value = ((uint32_t)(input[54] & 0x1f) << 27) |
			((uint32_t)input[55] << 19) |
			((uint32_t)input[56] << 11) |
			((uint32_t)input[57] << 3);
	output[15] = (double)(value >> 3);
}

static void unpack_16_29bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 29-bit unsigned
	// Skip 0 bits, read 464 bits of data.
	// Input must be at least 58 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 28
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xf8));
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 29 to 57
	value = ((uint32_t)(input[3] & 0x07) << 29) |
			((uint32_t)input[4] << 21) |
			((uint32_t)input[5] << 13) |
			((uint32_t)input[6] << 5) |
			((uint32_t)(input[7] & 0xc0) >> 3);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 58 to 86
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xfe) << 2);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 145 to 173
	value = ((uint32_t)(input[18] & 0x7f) << 25) |
			((uint32_t)input[19] << 17) |
			((uint32_t)input[20] << 9) |
			((uint32_t)(input[21] & 0xfc) << 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 174 to 202
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)input[24] << 6) |
			((uint32_t)(input[25] & 0xe0) >> 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 203 to 231
	value = ((uint32_t)(input[25] & 0x1f) << 27) |
			((uint32_t)input[26] << 19) |
			((uint32_t)input[27] << 11) |
			((uint32_t)input[28] << 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 232 to 260
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)input[31] << 8) |
			((uint32_t)(input[32] & 0xf8));
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 261 to 289
	value = ((uint32_t)(input[32] & 0x07) << 29) |
			((uint32_t)input[33] << 21) |
			((uint32_t)input[34] << 13) |
			((uint32_t)input[35] << 5) |
			((uint32_t)(input[36] & 0xc0) >> 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 290 to 318
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)input[38] << 10) |
			((uint32_t)(input[39] & 0xfe) << 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 319 to 347
	value = ((uint32_t)(input[39] & 0x01) << 31) |
			((uint32_t)input[40] << 23) |
			((uint32_t)input[41] << 15) |
			((uint32_t)input[42] << 7) |
			((uint32_t)(input[43] & 0xf0) >> 1);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 348 to 376
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)input[45] << 12) |
			((uint32_t)input[46] << 4) |
			((uint32_t)(input[47] & 0x80) >> 4);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 377 to 405
	value = ((uint32_t)(input[47] & 0x7f) << 25) |
			((uint32_t)input[48] << 17) |
			((uint32_t)input[49] << 9) |
			((uint32_t)(input[50] & 0xfc) << 1);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 406 to 434
	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] & 0xe0) >> 2);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 435 to 463
	value = ((uint32_t)(input[54] & 0x1f) << 27) |
			((uint32_t)input[55] << 19) |
			((uint32_t)input[56] << 11) |
			((uint32_t)input[57] << 3);
	output[15] = (double)(value >> 3);
}

static void unpack_16_29bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 29-bit signed
	// Skip 1 bits, read 464 bits of data.
	// Input must be at least 59 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 29
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)(input[3] & 0xfc) << 1);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 59 to 87
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)input[10] << 3);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 88 to 116
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xf8));
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 175 to 203
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)input[24] << 7) |
			((uint32_t)(input[25] & 0xf0) >> 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 204 to 232
	value = ((uint32_t)(input[25] & 0x0f) << 28) |
			((uint32_t)input[26] << 20) |
			((uint32_t)input[27] << 12) |
			((uint32_t)input[28] << 4) |
			((uint32_t)(input[29] & 0x80) >> 4);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 233 to 261
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)input[31] << 9) |
			((uint32_t)(input[32] & 0xfc) << 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 262 to 290
	value = ((uint32_t)(input[32] & 0x03) << 30) |
			((uint32_t)input[33] << 22) |
			((uint32_t)input[34] << 14) |
			((uint32_t)input[35] << 6) |
			((uint32_t)(input[36] & 0xe0) >> 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 291 to 319
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)input[38] << 11) |
			((uint32_t)input[39] << 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 320 to 348
	value = ((uint32_t)input[40] << 24) |
			((uint32_t)input[41] << 16) |
			((uint32_t)input[42] << 8) |
			((uint32_t)(input[43] & 0xf8));
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 349 to 377
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13) |
			((uint32_t)input[46] << 5) |
			((uint32_t)(input[47] & 0xc0) >> 3);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 378 to 406
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)(input[50] & 0xfe) << 2);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 407 to 435
	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] & 0xf0) >> 1);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 436 to 464
	value = ((uint32_t)(input[54] & 0x0f) << 28) |
			((uint32_t)input[55] << 20) |
			((uint32_t)input[56] << 12) |
			((uint32_t)input[57] << 4) |
			((uint32_t)(input[58] & 0x80) >> 4);
	output[15] = (double)(value >> 3);
}

static void unpack_16_29bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 29-bit unsigned
	// Skip 1 bits, read 464 bits of data.
	// Input must be at least 59 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 29
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)(input[3] & 0xfc) << 1);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 59 to 87
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)input[10] << 3);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 88 to 116
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xf8));
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 175 to 203
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)input[24] << 7) |
			((uint32_t)(input[25] & 0xf0) >> 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 204 to 232
	value = ((uint32_t)(input[25] & 0x0f) << 28) |
			((uint32_t)input[26] << 20) |
			((uint32_t)input[27] << 12) |
			((uint32_t)input[28] << 4) |
			((uint32_t)(input[29] & 0x80) >> 4);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 233 to 261
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)input[31] << 9) |
			((uint32_t)(input[32] & 0xfc) << 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 262 to 290
	value = ((uint32_t)(input[32] & 0x03) << 30) |
			((uint32_t)input[33] << 22) |
			((uint32_t)input[34] << 14) |
			((uint32_t)input[35] << 6) |
			((uint32_t)(input[36] & 0xe0) >> 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 291 to 319
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)input[38] << 11) |
			((uint32_t)input[39] << 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 320 to 348
	value = ((uint32_t)input[40] << 24) |
			((uint32_t)input[41] << 16) |
			((uint32_t)input[42] << 8) |
			((uint32_t)(input[43] & 0xf8));
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 349 to 377
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13) |
			((uint32_t)input[46] << 5) |
			((uint32_t)(input[47] & 0xc0) >> 3);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 378 to 406
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)(input[50] & 0xfe) << 2);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 407 to 435
	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] & 0xf0) >> 1);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 436 to 464
	value = ((uint32_t)(input[54] & 0x0f) << 28) |
			((uint32_t)input[55] << 20) |
			((uint32_t)input[56] << 12) |
			((uint32_t)input[57] << 4) |
			((uint32_t)(input[58] & 0x80) >> 4);
	output[15] = (double)(value >> 3);
}

static void unpack_16_29bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 29-bit signed
	// Skip 2 bits, read 464 bits of data.
	// Input must be at least 59 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 30
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)(input[3] & 0xfe) << 2);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 31 to 59
	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] & 0xf0) >> 1);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 60 to 88
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)input[10] << 4) |
			((uint32_t)(input[11] & 0x80) >> 4);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 89 to 117
	value = ((uint32_t)(input[11] & 0x7f) << 25) |
			((uint32_t)input[12] << 17) |
			((uint32_t)input[13] << 9) |
			((uint32_t)(input[14] & 0xfc) << 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 147 to 175
	value = ((uint32_t)(input[18] & 0x1f) << 27) |
			((uint32_t)input[19] << 19) |
			((uint32_t)input[20] << 11) |
			((uint32_t)input[21] << 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 176 to 204
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)input[24] << 8) |
			((uint32_t)(input[25] & 0xf8));
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 205 to 233
	value = ((uint32_t)(input[25] & 0x07) << 29) |
			((uint32_t)input[26] << 21) |
			((uint32_t)input[27] << 13) |
			((uint32_t)input[28] << 5) |
			((uint32_t)(input[29] & 0xc0) >> 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 234 to 262
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)input[31] << 10) |
			((uint32_t)(input[32] & 0xfe) << 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 263 to 291
	value = ((uint32_t)(input[32] & 0x01) << 31) |
			((uint32_t)input[33] << 23) |
			((uint32_t)input[34] << 15) |
			((uint32_t)input[35] << 7) |
			((uint32_t)(input[36] & 0xf0) >> 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 292 to 320
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)input[38] << 12) |
			((uint32_t)input[39] << 4) |
			((uint32_t)(input[40] & 0x80) >> 4);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 321 to 349
	value = ((uint32_t)(input[40] & 0x7f) << 25) |
			((uint32_t)input[41] << 17) |
			((uint32_t)input[42] << 9) |
			((uint32_t)(input[43] & 0xfc) << 1);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 350 to 378
	value = ((uint32_t)(input[43] & 0x03) << 30) |
			((uint32_t)input[44] << 22) |
			((uint32_t)input[45] << 14) |
			((uint32_t)input[46] << 6) |
			((uint32_t)(input[47] & 0xe0) >> 2);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 379 to 407
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)input[50] << 3);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 408 to 436
	value = ((uint32_t)input[51] << 24) |
			((uint32_t)input[52] << 16) |
			((uint32_t)input[53] << 8) |
			((uint32_t)(input[54] & 0xf8));
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 437 to 465
	value = ((uint32_t)(input[54] & 0x07) << 29) |
			((uint32_t)input[55] << 21) |
			((uint32_t)input[56] << 13) |
			((uint32_t)input[57] << 5) |
			((uint32_t)(input[58] & 0xc0) >> 3);
	output[15] = (double)(value >> 3);
}

static void unpack_16_29bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 29-bit unsigned
	// Skip 2 bits, read 464 bits of data.
	// Input must be at least 59 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 30
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)(input[3] & 0xfe) << 2);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 31 to 59
	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] & 0xf0) >> 1);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 60 to 88
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)input[10] << 4) |
			((uint32_t)(input[11] & 0x80) >> 4);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 89 to 117
	value = ((uint32_t)(input[11] & 0x7f) << 25) |
			((uint32_t)input[12] << 17) |
			((uint32_t)input[13] << 9) |
			((uint32_t)(input[14] & 0xfc) << 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 147 to 175
	value = ((uint32_t)(input[18] & 0x1f) << 27) |
			((uint32_t)input[19] << 19) |
			((uint32_t)input[20] << 11) |
			((uint32_t)input[21] << 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 176 to 204
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)input[24] << 8) |
			((uint32_t)(input[25] & 0xf8));
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 205 to 233
	value = ((uint32_t)(input[25] & 0x07) << 29) |
			((uint32_t)input[26] << 21) |
			((uint32_t)input[27] << 13) |
			((uint32_t)input[28] << 5) |
			((uint32_t)(input[29] & 0xc0) >> 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 234 to 262
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)input[31] << 10) |
			((uint32_t)(input[32] & 0xfe) << 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 263 to 291
	value = ((uint32_t)(input[32] & 0x01) << 31) |
			((uint32_t)input[33] << 23) |
			((uint32_t)input[34] << 15) |
			((uint32_t)input[35] << 7) |
			((uint32_t)(input[36] & 0xf0) >> 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 292 to 320
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)input[38] << 12) |
			((uint32_t)input[39] << 4) |
			((uint32_t)(input[40] & 0x80) >> 4);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 321 to 349
	value = ((uint32_t)(input[40] & 0x7f) << 25) |
			((uint32_t)input[41] << 17) |
			((uint32_t)input[42] << 9) |
			((uint32_t)(input[43] & 0xfc) << 1);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 350 to 378
	value = ((uint32_t)(input[43] & 0x03) << 30) |
			((uint32_t)input[44] << 22) |
			((uint32_t)input[45] << 14) |
			((uint32_t)input[46] << 6) |
			((uint32_t)(input[47] & 0xe0) >> 2);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 379 to 407
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)input[50] << 3);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 408 to 436
	value = ((uint32_t)input[51] << 24) |
			((uint32_t)input[52] << 16) |
			((uint32_t)input[53] << 8) |
			((uint32_t)(input[54] & 0xf8));
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 437 to 465
	value = ((uint32_t)(input[54] & 0x07) << 29) |
			((uint32_t)input[55] << 21) |
			((uint32_t)input[56] << 13) |
			((uint32_t)input[57] << 5) |
			((uint32_t)(input[58] & 0xc0) >> 3);
	output[15] = (double)(value >> 3);
}

static void unpack_16_29bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 29-bit signed
	// Skip 3 bits, read 464 bits of data.
	// Input must be at least 59 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 31
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 32 to 60
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xf8));
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 61 to 89
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5) |
			((uint32_t)(input[11] & 0xc0) >> 3);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 177 to 205
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)input[24] << 9) |
			((uint32_t)(input[25] & 0xfc) << 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 206 to 234
	value = ((uint32_t)(input[25] & 0x03) << 30) |
			((uint32_t)input[26] << 22) |
			((uint32_t)input[27] << 14) |
			((uint32_t)input[28] << 6) |
			((uint32_t)(input[29] & 0xe0) >> 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 235 to 263
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)input[31] << 11) |
			((uint32_t)input[32] << 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 264 to 292
	value = ((uint32_t)input[33] << 24) |
			((uint32_t)input[34] << 16) |
			((uint32_t)input[35] << 8) |
			((uint32_t)(input[36] & 0xf8));
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 293 to 321
	value = ((uint32_t)(input[36] & 0x07) << 29) |
			((uint32_t)input[37] << 21) |
			((uint32_t)input[38] << 13) |
			((uint32_t)input[39] << 5) |
			((uint32_t)(input[40] & 0xc0) >> 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 322 to 350
	value = ((uint32_t)(input[40] & 0x3f) << 26) |
			((uint32_t)input[41] << 18) |
			((uint32_t)input[42] << 10) |
			((uint32_t)(input[43] & 0xfe) << 2);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 351 to 379
	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] & 0xf0) >> 1);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 380 to 408
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)input[49] << 12) |
			((uint32_t)input[50] << 4) |
			((uint32_t)(input[51] & 0x80) >> 4);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 409 to 437
	value = ((uint32_t)(input[51] & 0x7f) << 25) |
			((uint32_t)input[52] << 17) |
			((uint32_t)input[53] << 9) |
			((uint32_t)(input[54] & 0xfc) << 1);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 438 to 466
	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] & 0xe0) >> 2);
	output[15] = (double)(value >> 3);
}

static void unpack_16_29bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 29-bit unsigned
	// Skip 3 bits, read 464 bits of data.
	// Input must be at least 59 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 31
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 32 to 60
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xf8));
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 61 to 89
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5) |
			((uint32_t)(input[11] & 0xc0) >> 3);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 177 to 205
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)input[24] << 9) |
			((uint32_t)(input[25] & 0xfc) << 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 206 to 234
	value = ((uint32_t)(input[25] & 0x03) << 30) |
			((uint32_t)input[26] << 22) |
			((uint32_t)input[27] << 14) |
			((uint32_t)input[28] << 6) |
			((uint32_t)(input[29] & 0xe0) >> 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 235 to 263
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)input[31] << 11) |
			((uint32_t)input[32] << 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 264 to 292
	value = ((uint32_t)input[33] << 24) |
			((uint32_t)input[34] << 16) |
			((uint32_t)input[35] << 8) |
			((uint32_t)(input[36] & 0xf8));
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 293 to 321
	value = ((uint32_t)(input[36] & 0x07) << 29) |
			((uint32_t)input[37] << 21) |
			((uint32_t)input[38] << 13) |
			((uint32_t)input[39] << 5) |
			((uint32_t)(input[40] & 0xc0) >> 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 322 to 350
	value = ((uint32_t)(input[40] & 0x3f) << 26) |
			((uint32_t)input[41] << 18) |
			((uint32_t)input[42] << 10) |
			((uint32_t)(input[43] & 0xfe) << 2);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 351 to 379
	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] & 0xf0) >> 1);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 380 to 408
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)input[49] << 12) |
			((uint32_t)input[50] << 4) |
			((uint32_t)(input[51] & 0x80) >> 4);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 409 to 437
	value = ((uint32_t)(input[51] & 0x7f) << 25) |
			((uint32_t)input[52] << 17) |
			((uint32_t)input[53] << 9) |
			((uint32_t)(input[54] & 0xfc) << 1);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 438 to 466
	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] & 0xe0) >> 2);
	output[15] = (double)(value >> 3);
}

static void unpack_16_29bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 29-bit signed
	// Skip 4 bits, read 464 bits of data.
	// Input must be at least 59 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 32
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0x80) >> 4);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 33 to 61
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)(input[7] & 0xfc) << 1);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 62 to 90
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xe0) >> 2);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 178 to 206
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)input[24] << 10) |
			((uint32_t)(input[25] & 0xfe) << 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 207 to 235
	value = ((uint32_t)(input[25] & 0x01) << 31) |
			((uint32_t)input[26] << 23) |
			((uint32_t)input[27] << 15) |
			((uint32_t)input[28] << 7) |
			((uint32_t)(input[29] & 0xf0) >> 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 236 to 264
	value = ((uint32_t)(input[29] & 0x0f) << 28) |
			((uint32_t)input[30] << 20) |
			((uint32_t)input[31] << 12) |
			((uint32_t)input[32] << 4) |
			((uint32_t)(input[33] & 0x80) >> 4);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 265 to 293
	value = ((uint32_t)(input[33] & 0x7f) << 25) |
			((uint32_t)input[34] << 17) |
			((uint32_t)input[35] << 9) |
			((uint32_t)(input[36] & 0xfc) << 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 294 to 322
	value = ((uint32_t)(input[36] & 0x03) << 30) |
			((uint32_t)input[37] << 22) |
			((uint32_t)input[38] << 14) |
			((uint32_t)input[39] << 6) |
			((uint32_t)(input[40] & 0xe0) >> 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 323 to 351
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)input[42] << 11) |
			((uint32_t)input[43] << 3);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 352 to 380
	value = ((uint32_t)input[44] << 24) |
			((uint32_t)input[45] << 16) |
			((uint32_t)input[46] << 8) |
			((uint32_t)(input[47] & 0xf8));
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 381 to 409
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13) |
			((uint32_t)input[50] << 5) |
			((uint32_t)(input[51] & 0xc0) >> 3);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 410 to 438
	value = ((uint32_t)(input[51] & 0x3f) << 26) |
			((uint32_t)input[52] << 18) |
			((uint32_t)input[53] << 10) |
			((uint32_t)(input[54] & 0xfe) << 2);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 439 to 467
	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] & 0xf0) >> 1);
	output[15] = (double)(value >> 3);
}

static void unpack_16_29bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 29-bit unsigned
	// Skip 4 bits, read 464 bits of data.
	// Input must be at least 59 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 32
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0x80) >> 4);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 33 to 61
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)(input[7] & 0xfc) << 1);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 62 to 90
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xe0) >> 2);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 178 to 206
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)input[24] << 10) |
			((uint32_t)(input[25] & 0xfe) << 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 207 to 235
	value = ((uint32_t)(input[25] & 0x01) << 31) |
			((uint32_t)input[26] << 23) |
			((uint32_t)input[27] << 15) |
			((uint32_t)input[28] << 7) |
			((uint32_t)(input[29] & 0xf0) >> 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 236 to 264
	value = ((uint32_t)(input[29] & 0x0f) << 28) |
			((uint32_t)input[30] << 20) |
			((uint32_t)input[31] << 12) |
			((uint32_t)input[32] << 4) |
			((uint32_t)(input[33] & 0x80) >> 4);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 265 to 293
	value = ((uint32_t)(input[33] & 0x7f) << 25) |
			((uint32_t)input[34] << 17) |
			((uint32_t)input[35] << 9) |
			((uint32_t)(input[36] & 0xfc) << 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 294 to 322
	value = ((uint32_t)(input[36] & 0x03) << 30) |
			((uint32_t)input[37] << 22) |
			((uint32_t)input[38] << 14) |
			((uint32_t)input[39] << 6) |
			((uint32_t)(input[40] & 0xe0) >> 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 323 to 351
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)input[42] << 11) |
			((uint32_t)input[43] << 3);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 352 to 380
	value = ((uint32_t)input[44] << 24) |
			((uint32_t)input[45] << 16) |
			((uint32_t)input[46] << 8) |
			((uint32_t)(input[47] & 0xf8));
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 381 to 409
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13) |
			((uint32_t)input[50] << 5) |
			((uint32_t)(input[51] & 0xc0) >> 3);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 410 to 438
	value = ((uint32_t)(input[51] & 0x3f) << 26) |
			((uint32_t)input[52] << 18) |
			((uint32_t)input[53] << 10) |
			((uint32_t)(input[54] & 0xfe) << 2);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 439 to 467
	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] & 0xf0) >> 1);
	output[15] = (double)(value >> 3);
}

static void unpack_16_29bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 29-bit signed
	// Skip 5 bits, read 464 bits of data.
	// Input must be at least 59 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 33
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xc0) >> 3);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 34 to 62
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)(input[7] & 0xfe) << 2);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 63 to 91
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xf0) >> 1);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 150 to 178
	value = ((uint32_t)(input[18] & 0x03) << 30) |
			((uint32_t)input[19] << 22) |
			((uint32_t)input[20] << 14) |
			((uint32_t)input[21] << 6) |
			((uint32_t)(input[22] & 0xe0) >> 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 179 to 207
	value = ((uint32_t)(input[22] & 0x1f) << 27) |
			((uint32_t)input[23] << 19) |
			((uint32_t)input[24] << 11) |
			((uint32_t)input[25] << 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 208 to 236
	value = ((uint32_t)input[26] << 24) |
			((uint32_t)input[27] << 16) |
			((uint32_t)input[28] << 8) |
			((uint32_t)(input[29] & 0xf8));
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 237 to 265
	value = ((uint32_t)(input[29] & 0x07) << 29) |
			((uint32_t)input[30] << 21) |
			((uint32_t)input[31] << 13) |
			((uint32_t)input[32] << 5) |
			((uint32_t)(input[33] & 0xc0) >> 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 266 to 294
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)input[35] << 10) |
			((uint32_t)(input[36] & 0xfe) << 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 295 to 323
	value = ((uint32_t)(input[36] & 0x01) << 31) |
			((uint32_t)input[37] << 23) |
			((uint32_t)input[38] << 15) |
			((uint32_t)input[39] << 7) |
			((uint32_t)(input[40] & 0xf0) >> 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 324 to 352
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)input[43] << 4) |
			((uint32_t)(input[44] & 0x80) >> 4);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 353 to 381
	value = ((uint32_t)(input[44] & 0x7f) << 25) |
			((uint32_t)input[45] << 17) |
			((uint32_t)input[46] << 9) |
			((uint32_t)(input[47] & 0xfc) << 1);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 382 to 410
	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] & 0xe0) >> 2);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 411 to 439
	value = ((uint32_t)(input[51] & 0x1f) << 27) |
			((uint32_t)input[52] << 19) |
			((uint32_t)input[53] << 11) |
			((uint32_t)input[54] << 3);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 440 to 468
	value = ((uint32_t)input[55] << 24) |
			((uint32_t)input[56] << 16) |
			((uint32_t)input[57] << 8) |
			((uint32_t)(input[58] & 0xf8));
	output[15] = (double)(value >> 3);
}

static void unpack_16_29bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 29-bit unsigned
	// Skip 5 bits, read 464 bits of data.
	// Input must be at least 59 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 33
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xc0) >> 3);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 34 to 62
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)(input[7] & 0xfe) << 2);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 63 to 91
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xf0) >> 1);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 150 to 178
	value = ((uint32_t)(input[18] & 0x03) << 30) |
			((uint32_t)input[19] << 22) |
			((uint32_t)input[20] << 14) |
			((uint32_t)input[21] << 6) |
			((uint32_t)(input[22] & 0xe0) >> 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 179 to 207
	value = ((uint32_t)(input[22] & 0x1f) << 27) |
			((uint32_t)input[23] << 19) |
			((uint32_t)input[24] << 11) |
			((uint32_t)input[25] << 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 208 to 236
	value = ((uint32_t)input[26] << 24) |
			((uint32_t)input[27] << 16) |
			((uint32_t)input[28] << 8) |
			((uint32_t)(input[29] & 0xf8));
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 237 to 265
	value = ((uint32_t)(input[29] & 0x07) << 29) |
			((uint32_t)input[30] << 21) |
			((uint32_t)input[31] << 13) |
			((uint32_t)input[32] << 5) |
			((uint32_t)(input[33] & 0xc0) >> 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 266 to 294
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)input[35] << 10) |
			((uint32_t)(input[36] & 0xfe) << 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 295 to 323
	value = ((uint32_t)(input[36] & 0x01) << 31) |
			((uint32_t)input[37] << 23) |
			((uint32_t)input[38] << 15) |
			((uint32_t)input[39] << 7) |
			((uint32_t)(input[40] & 0xf0) >> 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 324 to 352
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)input[43] << 4) |
			((uint32_t)(input[44] & 0x80) >> 4);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 353 to 381
	value = ((uint32_t)(input[44] & 0x7f) << 25) |
			((uint32_t)input[45] << 17) |
			((uint32_t)input[46] << 9) |
			((uint32_t)(input[47] & 0xfc) << 1);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 382 to 410
	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] & 0xe0) >> 2);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 411 to 439
	value = ((uint32_t)(input[51] & 0x1f) << 27) |
			((uint32_t)input[52] << 19) |
			((uint32_t)input[53] << 11) |
			((uint32_t)input[54] << 3);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 440 to 468
	value = ((uint32_t)input[55] << 24) |
			((uint32_t)input[56] << 16) |
			((uint32_t)input[57] << 8) |
			((uint32_t)(input[58] & 0xf8));
	output[15] = (double)(value >> 3);
}

static void unpack_16_29bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 29-bit signed
	// Skip 6 bits, read 464 bits of data.
	// Input must be at least 59 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 34
	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] & 0xe0) >> 2);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 35 to 63
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 64 to 92
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xf8));
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 93 to 121
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xc0) >> 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 151 to 179
	value = ((uint32_t)(input[18] & 0x01) << 31) |
			((uint32_t)input[19] << 23) |
			((uint32_t)input[20] << 15) |
			((uint32_t)input[21] << 7) |
			((uint32_t)(input[22] & 0xf0) >> 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 180 to 208
	value = ((uint32_t)(input[22] & 0x0f) << 28) |
			((uint32_t)input[23] << 20) |
			((uint32_t)input[24] << 12) |
			((uint32_t)input[25] << 4) |
			((uint32_t)(input[26] & 0x80) >> 4);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 209 to 237
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)input[28] << 9) |
			((uint32_t)(input[29] & 0xfc) << 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 238 to 266
	value = ((uint32_t)(input[29] & 0x03) << 30) |
			((uint32_t)input[30] << 22) |
			((uint32_t)input[31] << 14) |
			((uint32_t)input[32] << 6) |
			((uint32_t)(input[33] & 0xe0) >> 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 267 to 295
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)input[35] << 11) |
			((uint32_t)input[36] << 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 296 to 324
	value = ((uint32_t)input[37] << 24) |
			((uint32_t)input[38] << 16) |
			((uint32_t)input[39] << 8) |
			((uint32_t)(input[40] & 0xf8));
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 325 to 353
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5) |
			((uint32_t)(input[44] & 0xc0) >> 3);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 354 to 382
	value = ((uint32_t)(input[44] & 0x3f) << 26) |
			((uint32_t)input[45] << 18) |
			((uint32_t)input[46] << 10) |
			((uint32_t)(input[47] & 0xfe) << 2);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 383 to 411
	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] & 0xf0) >> 1);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 412 to 440
	value = ((uint32_t)(input[51] & 0x0f) << 28) |
			((uint32_t)input[52] << 20) |
			((uint32_t)input[53] << 12) |
			((uint32_t)input[54] << 4) |
			((uint32_t)(input[55] & 0x80) >> 4);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 441 to 469
	value = ((uint32_t)(input[55] & 0x7f) << 25) |
			((uint32_t)input[56] << 17) |
			((uint32_t)input[57] << 9) |
			((uint32_t)(input[58] & 0xfc) << 1);
	output[15] = (double)(value >> 3);
}

static void unpack_16_29bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 29-bit unsigned
	// Skip 6 bits, read 464 bits of data.
	// Input must be at least 59 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 34
	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] & 0xe0) >> 2);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 35 to 63
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 64 to 92
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xf8));
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 93 to 121
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xc0) >> 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 151 to 179
	value = ((uint32_t)(input[18] & 0x01) << 31) |
			((uint32_t)input[19] << 23) |
			((uint32_t)input[20] << 15) |
			((uint32_t)input[21] << 7) |
			((uint32_t)(input[22] & 0xf0) >> 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 180 to 208
	value = ((uint32_t)(input[22] & 0x0f) << 28) |
			((uint32_t)input[23] << 20) |
			((uint32_t)input[24] << 12) |
			((uint32_t)input[25] << 4) |
			((uint32_t)(input[26] & 0x80) >> 4);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 209 to 237
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)input[28] << 9) |
			((uint32_t)(input[29] & 0xfc) << 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 238 to 266
	value = ((uint32_t)(input[29] & 0x03) << 30) |
			((uint32_t)input[30] << 22) |
			((uint32_t)input[31] << 14) |
			((uint32_t)input[32] << 6) |
			((uint32_t)(input[33] & 0xe0) >> 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 267 to 295
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)input[35] << 11) |
			((uint32_t)input[36] << 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 296 to 324
	value = ((uint32_t)input[37] << 24) |
			((uint32_t)input[38] << 16) |
			((uint32_t)input[39] << 8) |
			((uint32_t)(input[40] & 0xf8));
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 325 to 353
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5) |
			((uint32_t)(input[44] & 0xc0) >> 3);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 354 to 382
	value = ((uint32_t)(input[44] & 0x3f) << 26) |
			((uint32_t)input[45] << 18) |
			((uint32_t)input[46] << 10) |
			((uint32_t)(input[47] & 0xfe) << 2);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 383 to 411
	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] & 0xf0) >> 1);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 412 to 440
	value = ((uint32_t)(input[51] & 0x0f) << 28) |
			((uint32_t)input[52] << 20) |
			((uint32_t)input[53] << 12) |
			((uint32_t)input[54] << 4) |
			((uint32_t)(input[55] & 0x80) >> 4);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 441 to 469
	value = ((uint32_t)(input[55] & 0x7f) << 25) |
			((uint32_t)input[56] << 17) |
			((uint32_t)input[57] << 9) |
			((uint32_t)(input[58] & 0xfc) << 1);
	output[15] = (double)(value >> 3);
}

static void unpack_16_29bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 29-bit signed
	// Skip 7 bits, read 464 bits of data.
	// Input must be at least 59 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 35
	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] & 0xf0) >> 1);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 36 to 64
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0x80) >> 4);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 65 to 93
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)(input[11] & 0xfc) << 1);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 94 to 122
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xe0) >> 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 181 to 209
	value = ((uint32_t)(input[22] & 0x07) << 29) |
			((uint32_t)input[23] << 21) |
			((uint32_t)input[24] << 13) |
			((uint32_t)input[25] << 5) |
			((uint32_t)(input[26] & 0xc0) >> 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 210 to 238
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)input[28] << 10) |
			((uint32_t)(input[29] & 0xfe) << 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 239 to 267
	value = ((uint32_t)(input[29] & 0x01) << 31) |
			((uint32_t)input[30] << 23) |
			((uint32_t)input[31] << 15) |
			((uint32_t)input[32] << 7) |
			((uint32_t)(input[33] & 0xf0) >> 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 268 to 296
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)input[35] << 12) |
			((uint32_t)input[36] << 4) |
			((uint32_t)(input[37] & 0x80) >> 4);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 297 to 325
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xfc) << 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 326 to 354
	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] & 0xe0) >> 2);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 355 to 383
	value = ((uint32_t)(input[44] & 0x1f) << 27) |
			((uint32_t)input[45] << 19) |
			((uint32_t)input[46] << 11) |
			((uint32_t)input[47] << 3);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 384 to 412
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)input[50] << 8) |
			((uint32_t)(input[51] & 0xf8));
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 413 to 441
	value = ((uint32_t)(input[51] & 0x07) << 29) |
			((uint32_t)input[52] << 21) |
			((uint32_t)input[53] << 13) |
			((uint32_t)input[54] << 5) |
			((uint32_t)(input[55] & 0xc0) >> 3);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 442 to 470
	value = ((uint32_t)(input[55] & 0x3f) << 26) |
			((uint32_t)input[56] << 18) |
			((uint32_t)input[57] << 10) |
			((uint32_t)(input[58] & 0xfe) << 2);
	output[15] = (double)(value >> 3);
}

static void unpack_16_29bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 29-bit unsigned
	// Skip 7 bits, read 464 bits of data.
	// Input must be at least 59 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 35
	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] & 0xf0) >> 1);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 36 to 64
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0x80) >> 4);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 65 to 93
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)(input[11] & 0xfc) << 1);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 94 to 122
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xe0) >> 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 181 to 209
	value = ((uint32_t)(input[22] & 0x07) << 29) |
			((uint32_t)input[23] << 21) |
			((uint32_t)input[24] << 13) |
			((uint32_t)input[25] << 5) |
			((uint32_t)(input[26] & 0xc0) >> 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 210 to 238
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)input[28] << 10) |
			((uint32_t)(input[29] & 0xfe) << 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 239 to 267
	value = ((uint32_t)(input[29] & 0x01) << 31) |
			((uint32_t)input[30] << 23) |
			((uint32_t)input[31] << 15) |
			((uint32_t)input[32] << 7) |
			((uint32_t)(input[33] & 0xf0) >> 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 268 to 296
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)input[35] << 12) |
			((uint32_t)input[36] << 4) |
			((uint32_t)(input[37] & 0x80) >> 4);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 297 to 325
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xfc) << 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 326 to 354
	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] & 0xe0) >> 2);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 355 to 383
	value = ((uint32_t)(input[44] & 0x1f) << 27) |
			((uint32_t)input[45] << 19) |
			((uint32_t)input[46] << 11) |
			((uint32_t)input[47] << 3);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 384 to 412
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)input[50] << 8) |
			((uint32_t)(input[51] & 0xf8));
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 413 to 441
	value = ((uint32_t)(input[51] & 0x07) << 29) |
			((uint32_t)input[52] << 21) |
			((uint32_t)input[53] << 13) |
			((uint32_t)input[54] << 5) |
			((uint32_t)(input[55] & 0xc0) >> 3);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 442 to 470
	value = ((uint32_t)(input[55] & 0x3f) << 26) |
			((uint32_t)input[56] << 18) |
			((uint32_t)input[57] << 10) |
			((uint32_t)(input[58] & 0xfe) << 2);
	output[15] = (double)(value >> 3);
}

static void unpack_17_29bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 29-bit signed
	// Skip 0 bits, read 493 bits of data.
	// Input must be at least 62 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 28
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xf8));
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 29 to 57
	value = ((uint32_t)(input[3] & 0x07) << 29) |
			((uint32_t)input[4] << 21) |
			((uint32_t)input[5] << 13) |
			((uint32_t)input[6] << 5) |
			((uint32_t)(input[7] & 0xc0) >> 3);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 58 to 86
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xfe) << 2);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 145 to 173
	value = ((uint32_t)(input[18] & 0x7f) << 25) |
			((uint32_t)input[19] << 17) |
			((uint32_t)input[20] << 9) |
			((uint32_t)(input[21] & 0xfc) << 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 174 to 202
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)input[24] << 6) |
			((uint32_t)(input[25] & 0xe0) >> 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 203 to 231
	value = ((uint32_t)(input[25] & 0x1f) << 27) |
			((uint32_t)input[26] << 19) |
			((uint32_t)input[27] << 11) |
			((uint32_t)input[28] << 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 232 to 260
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)input[31] << 8) |
			((uint32_t)(input[32] & 0xf8));
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 261 to 289
	value = ((uint32_t)(input[32] & 0x07) << 29) |
			((uint32_t)input[33] << 21) |
			((uint32_t)input[34] << 13) |
			((uint32_t)input[35] << 5) |
			((uint32_t)(input[36] & 0xc0) >> 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 290 to 318
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)input[38] << 10) |
			((uint32_t)(input[39] & 0xfe) << 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 319 to 347
	value = ((uint32_t)(input[39] & 0x01) << 31) |
			((uint32_t)input[40] << 23) |
			((uint32_t)input[41] << 15) |
			((uint32_t)input[42] << 7) |
			((uint32_t)(input[43] & 0xf0) >> 1);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 348 to 376
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)input[45] << 12) |
			((uint32_t)input[46] << 4) |
			((uint32_t)(input[47] & 0x80) >> 4);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 377 to 405
	value = ((uint32_t)(input[47] & 0x7f) << 25) |
			((uint32_t)input[48] << 17) |
			((uint32_t)input[49] << 9) |
			((uint32_t)(input[50] & 0xfc) << 1);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 406 to 434
	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] & 0xe0) >> 2);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 435 to 463
	value = ((uint32_t)(input[54] & 0x1f) << 27) |
			((uint32_t)input[55] << 19) |
			((uint32_t)input[56] << 11) |
			((uint32_t)input[57] << 3);
	output[15] = (double)(value >> 3);

	// read output[16]: from bit 464 to 492
	value = ((uint32_t)input[58] << 24) |
			((uint32_t)input[59] << 16) |
			((uint32_t)input[60] << 8) |
			((uint32_t)(input[61] & 0xf8));
	output[16] = (double)(value >> 3);
}

static void unpack_17_29bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 29-bit unsigned
	// Skip 0 bits, read 493 bits of data.
	// Input must be at least 62 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 28
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)input[2] << 8) |
			((uint32_t)(input[3] & 0xf8));
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 29 to 57
	value = ((uint32_t)(input[3] & 0x07) << 29) |
			((uint32_t)input[4] << 21) |
			((uint32_t)input[5] << 13) |
			((uint32_t)input[6] << 5) |
			((uint32_t)(input[7] & 0xc0) >> 3);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 58 to 86
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)input[9] << 10) |
			((uint32_t)(input[10] & 0xfe) << 2);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 87 to 115
	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] & 0xf0) >> 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 116 to 144
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)input[16] << 12) |
			((uint32_t)input[17] << 4) |
			((uint32_t)(input[18] & 0x80) >> 4);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 145 to 173
	value = ((uint32_t)(input[18] & 0x7f) << 25) |
			((uint32_t)input[19] << 17) |
			((uint32_t)input[20] << 9) |
			((uint32_t)(input[21] & 0xfc) << 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 174 to 202
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)input[24] << 6) |
			((uint32_t)(input[25] & 0xe0) >> 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 203 to 231
	value = ((uint32_t)(input[25] & 0x1f) << 27) |
			((uint32_t)input[26] << 19) |
			((uint32_t)input[27] << 11) |
			((uint32_t)input[28] << 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 232 to 260
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)input[31] << 8) |
			((uint32_t)(input[32] & 0xf8));
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 261 to 289
	value = ((uint32_t)(input[32] & 0x07) << 29) |
			((uint32_t)input[33] << 21) |
			((uint32_t)input[34] << 13) |
			((uint32_t)input[35] << 5) |
			((uint32_t)(input[36] & 0xc0) >> 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 290 to 318
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)input[38] << 10) |
			((uint32_t)(input[39] & 0xfe) << 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 319 to 347
	value = ((uint32_t)(input[39] & 0x01) << 31) |
			((uint32_t)input[40] << 23) |
			((uint32_t)input[41] << 15) |
			((uint32_t)input[42] << 7) |
			((uint32_t)(input[43] & 0xf0) >> 1);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 348 to 376
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)input[45] << 12) |
			((uint32_t)input[46] << 4) |
			((uint32_t)(input[47] & 0x80) >> 4);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 377 to 405
	value = ((uint32_t)(input[47] & 0x7f) << 25) |
			((uint32_t)input[48] << 17) |
			((uint32_t)input[49] << 9) |
			((uint32_t)(input[50] & 0xfc) << 1);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 406 to 434
	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] & 0xe0) >> 2);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 435 to 463
	value = ((uint32_t)(input[54] & 0x1f) << 27) |
			((uint32_t)input[55] << 19) |
			((uint32_t)input[56] << 11) |
			((uint32_t)input[57] << 3);
	output[15] = (double)(value >> 3);

	// read output[16]: from bit 464 to 492
	value = ((uint32_t)input[58] << 24) |
			((uint32_t)input[59] << 16) |
			((uint32_t)input[60] << 8) |
			((uint32_t)(input[61] & 0xf8));
	output[16] = (double)(value >> 3);
}

static void unpack_17_29bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 29-bit signed
	// Skip 1 bits, read 493 bits of data.
	// Input must be at least 62 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 29
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)(input[3] & 0xfc) << 1);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 59 to 87
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)input[10] << 3);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 88 to 116
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xf8));
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 175 to 203
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)input[24] << 7) |
			((uint32_t)(input[25] & 0xf0) >> 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 204 to 232
	value = ((uint32_t)(input[25] & 0x0f) << 28) |
			((uint32_t)input[26] << 20) |
			((uint32_t)input[27] << 12) |
			((uint32_t)input[28] << 4) |
			((uint32_t)(input[29] & 0x80) >> 4);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 233 to 261
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)input[31] << 9) |
			((uint32_t)(input[32] & 0xfc) << 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 262 to 290
	value = ((uint32_t)(input[32] & 0x03) << 30) |
			((uint32_t)input[33] << 22) |
			((uint32_t)input[34] << 14) |
			((uint32_t)input[35] << 6) |
			((uint32_t)(input[36] & 0xe0) >> 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 291 to 319
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)input[38] << 11) |
			((uint32_t)input[39] << 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 320 to 348
	value = ((uint32_t)input[40] << 24) |
			((uint32_t)input[41] << 16) |
			((uint32_t)input[42] << 8) |
			((uint32_t)(input[43] & 0xf8));
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 349 to 377
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13) |
			((uint32_t)input[46] << 5) |
			((uint32_t)(input[47] & 0xc0) >> 3);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 378 to 406
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)(input[50] & 0xfe) << 2);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 407 to 435
	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] & 0xf0) >> 1);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 436 to 464
	value = ((uint32_t)(input[54] & 0x0f) << 28) |
			((uint32_t)input[55] << 20) |
			((uint32_t)input[56] << 12) |
			((uint32_t)input[57] << 4) |
			((uint32_t)(input[58] & 0x80) >> 4);
	output[15] = (double)(value >> 3);

	// read output[16]: from bit 465 to 493
	value = ((uint32_t)(input[58] & 0x7f) << 25) |
			((uint32_t)input[59] << 17) |
			((uint32_t)input[60] << 9) |
			((uint32_t)(input[61] & 0xfc) << 1);
	output[16] = (double)(value >> 3);
}

static void unpack_17_29bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 29-bit unsigned
	// Skip 1 bits, read 493 bits of data.
	// Input must be at least 62 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 29
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)input[2] << 9) |
			((uint32_t)(input[3] & 0xfc) << 1);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 30 to 58
	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] & 0xe0) >> 2);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 59 to 87
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)input[9] << 11) |
			((uint32_t)input[10] << 3);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 88 to 116
	value = ((uint32_t)input[11] << 24) |
			((uint32_t)input[12] << 16) |
			((uint32_t)input[13] << 8) |
			((uint32_t)(input[14] & 0xf8));
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 117 to 145
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13) |
			((uint32_t)input[17] << 5) |
			((uint32_t)(input[18] & 0xc0) >> 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 146 to 174
	value = ((uint32_t)(input[18] & 0x3f) << 26) |
			((uint32_t)input[19] << 18) |
			((uint32_t)input[20] << 10) |
			((uint32_t)(input[21] & 0xfe) << 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 175 to 203
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)input[24] << 7) |
			((uint32_t)(input[25] & 0xf0) >> 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 204 to 232
	value = ((uint32_t)(input[25] & 0x0f) << 28) |
			((uint32_t)input[26] << 20) |
			((uint32_t)input[27] << 12) |
			((uint32_t)input[28] << 4) |
			((uint32_t)(input[29] & 0x80) >> 4);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 233 to 261
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)input[31] << 9) |
			((uint32_t)(input[32] & 0xfc) << 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 262 to 290
	value = ((uint32_t)(input[32] & 0x03) << 30) |
			((uint32_t)input[33] << 22) |
			((uint32_t)input[34] << 14) |
			((uint32_t)input[35] << 6) |
			((uint32_t)(input[36] & 0xe0) >> 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 291 to 319
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)input[38] << 11) |
			((uint32_t)input[39] << 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 320 to 348
	value = ((uint32_t)input[40] << 24) |
			((uint32_t)input[41] << 16) |
			((uint32_t)input[42] << 8) |
			((uint32_t)(input[43] & 0xf8));
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 349 to 377
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13) |
			((uint32_t)input[46] << 5) |
			((uint32_t)(input[47] & 0xc0) >> 3);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 378 to 406
	value = ((uint32_t)(input[47] & 0x3f) << 26) |
			((uint32_t)input[48] << 18) |
			((uint32_t)input[49] << 10) |
			((uint32_t)(input[50] & 0xfe) << 2);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 407 to 435
	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] & 0xf0) >> 1);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 436 to 464
	value = ((uint32_t)(input[54] & 0x0f) << 28) |
			((uint32_t)input[55] << 20) |
			((uint32_t)input[56] << 12) |
			((uint32_t)input[57] << 4) |
			((uint32_t)(input[58] & 0x80) >> 4);
	output[15] = (double)(value >> 3);

	// read output[16]: from bit 465 to 493
	value = ((uint32_t)(input[58] & 0x7f) << 25) |
			((uint32_t)input[59] << 17) |
			((uint32_t)input[60] << 9) |
			((uint32_t)(input[61] & 0xfc) << 1);
	output[16] = (double)(value >> 3);
}

static void unpack_17_29bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 29-bit signed
	// Skip 2 bits, read 493 bits of data.
	// Input must be at least 62 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 30
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)(input[3] & 0xfe) << 2);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 31 to 59
	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] & 0xf0) >> 1);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 60 to 88
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)input[10] << 4) |
			((uint32_t)(input[11] & 0x80) >> 4);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 89 to 117
	value = ((uint32_t)(input[11] & 0x7f) << 25) |
			((uint32_t)input[12] << 17) |
			((uint32_t)input[13] << 9) |
			((uint32_t)(input[14] & 0xfc) << 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 147 to 175
	value = ((uint32_t)(input[18] & 0x1f) << 27) |
			((uint32_t)input[19] << 19) |
			((uint32_t)input[20] << 11) |
			((uint32_t)input[21] << 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 176 to 204
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)input[24] << 8) |
			((uint32_t)(input[25] & 0xf8));
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 205 to 233
	value = ((uint32_t)(input[25] & 0x07) << 29) |
			((uint32_t)input[26] << 21) |
			((uint32_t)input[27] << 13) |
			((uint32_t)input[28] << 5) |
			((uint32_t)(input[29] & 0xc0) >> 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 234 to 262
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)input[31] << 10) |
			((uint32_t)(input[32] & 0xfe) << 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 263 to 291
	value = ((uint32_t)(input[32] & 0x01) << 31) |
			((uint32_t)input[33] << 23) |
			((uint32_t)input[34] << 15) |
			((uint32_t)input[35] << 7) |
			((uint32_t)(input[36] & 0xf0) >> 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 292 to 320
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)input[38] << 12) |
			((uint32_t)input[39] << 4) |
			((uint32_t)(input[40] & 0x80) >> 4);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 321 to 349
	value = ((uint32_t)(input[40] & 0x7f) << 25) |
			((uint32_t)input[41] << 17) |
			((uint32_t)input[42] << 9) |
			((uint32_t)(input[43] & 0xfc) << 1);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 350 to 378
	value = ((uint32_t)(input[43] & 0x03) << 30) |
			((uint32_t)input[44] << 22) |
			((uint32_t)input[45] << 14) |
			((uint32_t)input[46] << 6) |
			((uint32_t)(input[47] & 0xe0) >> 2);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 379 to 407
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)input[50] << 3);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 408 to 436
	value = ((uint32_t)input[51] << 24) |
			((uint32_t)input[52] << 16) |
			((uint32_t)input[53] << 8) |
			((uint32_t)(input[54] & 0xf8));
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 437 to 465
	value = ((uint32_t)(input[54] & 0x07) << 29) |
			((uint32_t)input[55] << 21) |
			((uint32_t)input[56] << 13) |
			((uint32_t)input[57] << 5) |
			((uint32_t)(input[58] & 0xc0) >> 3);
	output[15] = (double)(value >> 3);

	// read output[16]: from bit 466 to 494
	value = ((uint32_t)(input[58] & 0x3f) << 26) |
			((uint32_t)input[59] << 18) |
			((uint32_t)input[60] << 10) |
			((uint32_t)(input[61] & 0xfe) << 2);
	output[16] = (double)(value >> 3);
}

static void unpack_17_29bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 29-bit unsigned
	// Skip 2 bits, read 493 bits of data.
	// Input must be at least 62 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 30
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)input[2] << 10) |
			((uint32_t)(input[3] & 0xfe) << 2);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 31 to 59
	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] & 0xf0) >> 1);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 60 to 88
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)input[9] << 12) |
			((uint32_t)input[10] << 4) |
			((uint32_t)(input[11] & 0x80) >> 4);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 89 to 117
	value = ((uint32_t)(input[11] & 0x7f) << 25) |
			((uint32_t)input[12] << 17) |
			((uint32_t)input[13] << 9) |
			((uint32_t)(input[14] & 0xfc) << 1);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 118 to 146
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)input[17] << 6) |
			((uint32_t)(input[18] & 0xe0) >> 2);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 147 to 175
	value = ((uint32_t)(input[18] & 0x1f) << 27) |
			((uint32_t)input[19] << 19) |
			((uint32_t)input[20] << 11) |
			((uint32_t)input[21] << 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 176 to 204
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)input[24] << 8) |
			((uint32_t)(input[25] & 0xf8));
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 205 to 233
	value = ((uint32_t)(input[25] & 0x07) << 29) |
			((uint32_t)input[26] << 21) |
			((uint32_t)input[27] << 13) |
			((uint32_t)input[28] << 5) |
			((uint32_t)(input[29] & 0xc0) >> 3);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 234 to 262
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)input[31] << 10) |
			((uint32_t)(input[32] & 0xfe) << 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 263 to 291
	value = ((uint32_t)(input[32] & 0x01) << 31) |
			((uint32_t)input[33] << 23) |
			((uint32_t)input[34] << 15) |
			((uint32_t)input[35] << 7) |
			((uint32_t)(input[36] & 0xf0) >> 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 292 to 320
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)input[38] << 12) |
			((uint32_t)input[39] << 4) |
			((uint32_t)(input[40] & 0x80) >> 4);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 321 to 349
	value = ((uint32_t)(input[40] & 0x7f) << 25) |
			((uint32_t)input[41] << 17) |
			((uint32_t)input[42] << 9) |
			((uint32_t)(input[43] & 0xfc) << 1);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 350 to 378
	value = ((uint32_t)(input[43] & 0x03) << 30) |
			((uint32_t)input[44] << 22) |
			((uint32_t)input[45] << 14) |
			((uint32_t)input[46] << 6) |
			((uint32_t)(input[47] & 0xe0) >> 2);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 379 to 407
	value = ((uint32_t)(input[47] & 0x1f) << 27) |
			((uint32_t)input[48] << 19) |
			((uint32_t)input[49] << 11) |
			((uint32_t)input[50] << 3);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 408 to 436
	value = ((uint32_t)input[51] << 24) |
			((uint32_t)input[52] << 16) |
			((uint32_t)input[53] << 8) |
			((uint32_t)(input[54] & 0xf8));
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 437 to 465
	value = ((uint32_t)(input[54] & 0x07) << 29) |
			((uint32_t)input[55] << 21) |
			((uint32_t)input[56] << 13) |
			((uint32_t)input[57] << 5) |
			((uint32_t)(input[58] & 0xc0) >> 3);
	output[15] = (double)(value >> 3);

	// read output[16]: from bit 466 to 494
	value = ((uint32_t)(input[58] & 0x3f) << 26) |
			((uint32_t)input[59] << 18) |
			((uint32_t)input[60] << 10) |
			((uint32_t)(input[61] & 0xfe) << 2);
	output[16] = (double)(value >> 3);
}

static void unpack_17_29bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 29-bit signed
	// Skip 3 bits, read 493 bits of data.
	// Input must be at least 62 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 31
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 32 to 60
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xf8));
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 61 to 89
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5) |
			((uint32_t)(input[11] & 0xc0) >> 3);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 177 to 205
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)input[24] << 9) |
			((uint32_t)(input[25] & 0xfc) << 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 206 to 234
	value = ((uint32_t)(input[25] & 0x03) << 30) |
			((uint32_t)input[26] << 22) |
			((uint32_t)input[27] << 14) |
			((uint32_t)input[28] << 6) |
			((uint32_t)(input[29] & 0xe0) >> 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 235 to 263
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)input[31] << 11) |
			((uint32_t)input[32] << 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 264 to 292
	value = ((uint32_t)input[33] << 24) |
			((uint32_t)input[34] << 16) |
			((uint32_t)input[35] << 8) |
			((uint32_t)(input[36] & 0xf8));
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 293 to 321
	value = ((uint32_t)(input[36] & 0x07) << 29) |
			((uint32_t)input[37] << 21) |
			((uint32_t)input[38] << 13) |
			((uint32_t)input[39] << 5) |
			((uint32_t)(input[40] & 0xc0) >> 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 322 to 350
	value = ((uint32_t)(input[40] & 0x3f) << 26) |
			((uint32_t)input[41] << 18) |
			((uint32_t)input[42] << 10) |
			((uint32_t)(input[43] & 0xfe) << 2);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 351 to 379
	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] & 0xf0) >> 1);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 380 to 408
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)input[49] << 12) |
			((uint32_t)input[50] << 4) |
			((uint32_t)(input[51] & 0x80) >> 4);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 409 to 437
	value = ((uint32_t)(input[51] & 0x7f) << 25) |
			((uint32_t)input[52] << 17) |
			((uint32_t)input[53] << 9) |
			((uint32_t)(input[54] & 0xfc) << 1);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 438 to 466
	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] & 0xe0) >> 2);
	output[15] = (double)(value >> 3);

	// read output[16]: from bit 467 to 495
	value = ((uint32_t)(input[58] & 0x1f) << 27) |
			((uint32_t)input[59] << 19) |
			((uint32_t)input[60] << 11) |
			((uint32_t)input[61] << 3);
	output[16] = (double)(value >> 3);
}

static void unpack_17_29bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 29-bit unsigned
	// Skip 3 bits, read 493 bits of data.
	// Input must be at least 62 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 31
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)input[2] << 11) |
			((uint32_t)input[3] << 3);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 32 to 60
	value = ((uint32_t)input[4] << 24) |
			((uint32_t)input[5] << 16) |
			((uint32_t)input[6] << 8) |
			((uint32_t)(input[7] & 0xf8));
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 61 to 89
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13) |
			((uint32_t)input[10] << 5) |
			((uint32_t)(input[11] & 0xc0) >> 3);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 90 to 118
	value = ((uint32_t)(input[11] & 0x3f) << 26) |
			((uint32_t)input[12] << 18) |
			((uint32_t)input[13] << 10) |
			((uint32_t)(input[14] & 0xfe) << 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 119 to 147
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)input[17] << 7) |
			((uint32_t)(input[18] & 0xf0) >> 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 148 to 176
	value = ((uint32_t)(input[18] & 0x0f) << 28) |
			((uint32_t)input[19] << 20) |
			((uint32_t)input[20] << 12) |
			((uint32_t)input[21] << 4) |
			((uint32_t)(input[22] & 0x80) >> 4);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 177 to 205
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)input[24] << 9) |
			((uint32_t)(input[25] & 0xfc) << 1);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 206 to 234
	value = ((uint32_t)(input[25] & 0x03) << 30) |
			((uint32_t)input[26] << 22) |
			((uint32_t)input[27] << 14) |
			((uint32_t)input[28] << 6) |
			((uint32_t)(input[29] & 0xe0) >> 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 235 to 263
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)input[31] << 11) |
			((uint32_t)input[32] << 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 264 to 292
	value = ((uint32_t)input[33] << 24) |
			((uint32_t)input[34] << 16) |
			((uint32_t)input[35] << 8) |
			((uint32_t)(input[36] & 0xf8));
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 293 to 321
	value = ((uint32_t)(input[36] & 0x07) << 29) |
			((uint32_t)input[37] << 21) |
			((uint32_t)input[38] << 13) |
			((uint32_t)input[39] << 5) |
			((uint32_t)(input[40] & 0xc0) >> 3);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 322 to 350
	value = ((uint32_t)(input[40] & 0x3f) << 26) |
			((uint32_t)input[41] << 18) |
			((uint32_t)input[42] << 10) |
			((uint32_t)(input[43] & 0xfe) << 2);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 351 to 379
	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] & 0xf0) >> 1);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 380 to 408
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)input[49] << 12) |
			((uint32_t)input[50] << 4) |
			((uint32_t)(input[51] & 0x80) >> 4);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 409 to 437
	value = ((uint32_t)(input[51] & 0x7f) << 25) |
			((uint32_t)input[52] << 17) |
			((uint32_t)input[53] << 9) |
			((uint32_t)(input[54] & 0xfc) << 1);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 438 to 466
	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] & 0xe0) >> 2);
	output[15] = (double)(value >> 3);

	// read output[16]: from bit 467 to 495
	value = ((uint32_t)(input[58] & 0x1f) << 27) |
			((uint32_t)input[59] << 19) |
			((uint32_t)input[60] << 11) |
			((uint32_t)input[61] << 3);
	output[16] = (double)(value >> 3);
}

static void unpack_17_29bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 29-bit signed
	// Skip 4 bits, read 493 bits of data.
	// Input must be at least 63 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 32
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0x80) >> 4);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 33 to 61
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)(input[7] & 0xfc) << 1);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 62 to 90
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xe0) >> 2);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 178 to 206
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)input[24] << 10) |
			((uint32_t)(input[25] & 0xfe) << 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 207 to 235
	value = ((uint32_t)(input[25] & 0x01) << 31) |
			((uint32_t)input[26] << 23) |
			((uint32_t)input[27] << 15) |
			((uint32_t)input[28] << 7) |
			((uint32_t)(input[29] & 0xf0) >> 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 236 to 264
	value = ((uint32_t)(input[29] & 0x0f) << 28) |
			((uint32_t)input[30] << 20) |
			((uint32_t)input[31] << 12) |
			((uint32_t)input[32] << 4) |
			((uint32_t)(input[33] & 0x80) >> 4);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 265 to 293
	value = ((uint32_t)(input[33] & 0x7f) << 25) |
			((uint32_t)input[34] << 17) |
			((uint32_t)input[35] << 9) |
			((uint32_t)(input[36] & 0xfc) << 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 294 to 322
	value = ((uint32_t)(input[36] & 0x03) << 30) |
			((uint32_t)input[37] << 22) |
			((uint32_t)input[38] << 14) |
			((uint32_t)input[39] << 6) |
			((uint32_t)(input[40] & 0xe0) >> 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 323 to 351
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)input[42] << 11) |
			((uint32_t)input[43] << 3);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 352 to 380
	value = ((uint32_t)input[44] << 24) |
			((uint32_t)input[45] << 16) |
			((uint32_t)input[46] << 8) |
			((uint32_t)(input[47] & 0xf8));
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 381 to 409
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13) |
			((uint32_t)input[50] << 5) |
			((uint32_t)(input[51] & 0xc0) >> 3);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 410 to 438
	value = ((uint32_t)(input[51] & 0x3f) << 26) |
			((uint32_t)input[52] << 18) |
			((uint32_t)input[53] << 10) |
			((uint32_t)(input[54] & 0xfe) << 2);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 439 to 467
	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] & 0xf0) >> 1);
	output[15] = (double)(value >> 3);

	// read output[16]: from bit 468 to 496
	value = ((uint32_t)(input[58] & 0x0f) << 28) |
			((uint32_t)input[59] << 20) |
			((uint32_t)input[60] << 12) |
			((uint32_t)input[61] << 4) |
			((uint32_t)(input[62] & 0x80) >> 4);
	output[16] = (double)(value >> 3);
}

static void unpack_17_29bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 29-bit unsigned
	// Skip 4 bits, read 493 bits of data.
	// Input must be at least 63 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 32
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)input[2] << 12) |
			((uint32_t)input[3] << 4) |
			((uint32_t)(input[4] & 0x80) >> 4);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 33 to 61
	value = ((uint32_t)(input[4] & 0x7f) << 25) |
			((uint32_t)input[5] << 17) |
			((uint32_t)input[6] << 9) |
			((uint32_t)(input[7] & 0xfc) << 1);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 62 to 90
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)input[10] << 6) |
			((uint32_t)(input[11] & 0xe0) >> 2);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 91 to 119
	value = ((uint32_t)(input[11] & 0x1f) << 27) |
			((uint32_t)input[12] << 19) |
			((uint32_t)input[13] << 11) |
			((uint32_t)input[14] << 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 120 to 148
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)input[17] << 8) |
			((uint32_t)(input[18] & 0xf8));
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 149 to 177
	value = ((uint32_t)(input[18] & 0x07) << 29) |
			((uint32_t)input[19] << 21) |
			((uint32_t)input[20] << 13) |
			((uint32_t)input[21] << 5) |
			((uint32_t)(input[22] & 0xc0) >> 3);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 178 to 206
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)input[24] << 10) |
			((uint32_t)(input[25] & 0xfe) << 2);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 207 to 235
	value = ((uint32_t)(input[25] & 0x01) << 31) |
			((uint32_t)input[26] << 23) |
			((uint32_t)input[27] << 15) |
			((uint32_t)input[28] << 7) |
			((uint32_t)(input[29] & 0xf0) >> 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 236 to 264
	value = ((uint32_t)(input[29] & 0x0f) << 28) |
			((uint32_t)input[30] << 20) |
			((uint32_t)input[31] << 12) |
			((uint32_t)input[32] << 4) |
			((uint32_t)(input[33] & 0x80) >> 4);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 265 to 293
	value = ((uint32_t)(input[33] & 0x7f) << 25) |
			((uint32_t)input[34] << 17) |
			((uint32_t)input[35] << 9) |
			((uint32_t)(input[36] & 0xfc) << 1);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 294 to 322
	value = ((uint32_t)(input[36] & 0x03) << 30) |
			((uint32_t)input[37] << 22) |
			((uint32_t)input[38] << 14) |
			((uint32_t)input[39] << 6) |
			((uint32_t)(input[40] & 0xe0) >> 2);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 323 to 351
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)input[42] << 11) |
			((uint32_t)input[43] << 3);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 352 to 380
	value = ((uint32_t)input[44] << 24) |
			((uint32_t)input[45] << 16) |
			((uint32_t)input[46] << 8) |
			((uint32_t)(input[47] & 0xf8));
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 381 to 409
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13) |
			((uint32_t)input[50] << 5) |
			((uint32_t)(input[51] & 0xc0) >> 3);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 410 to 438
	value = ((uint32_t)(input[51] & 0x3f) << 26) |
			((uint32_t)input[52] << 18) |
			((uint32_t)input[53] << 10) |
			((uint32_t)(input[54] & 0xfe) << 2);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 439 to 467
	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] & 0xf0) >> 1);
	output[15] = (double)(value >> 3);

	// read output[16]: from bit 468 to 496
	value = ((uint32_t)(input[58] & 0x0f) << 28) |
			((uint32_t)input[59] << 20) |
			((uint32_t)input[60] << 12) |
			((uint32_t)input[61] << 4) |
			((uint32_t)(input[62] & 0x80) >> 4);
	output[16] = (double)(value >> 3);
}

static void unpack_17_29bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 29-bit signed
	// Skip 5 bits, read 493 bits of data.
	// Input must be at least 63 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 33
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xc0) >> 3);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 34 to 62
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)(input[7] & 0xfe) << 2);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 63 to 91
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xf0) >> 1);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 150 to 178
	value = ((uint32_t)(input[18] & 0x03) << 30) |
			((uint32_t)input[19] << 22) |
			((uint32_t)input[20] << 14) |
			((uint32_t)input[21] << 6) |
			((uint32_t)(input[22] & 0xe0) >> 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 179 to 207
	value = ((uint32_t)(input[22] & 0x1f) << 27) |
			((uint32_t)input[23] << 19) |
			((uint32_t)input[24] << 11) |
			((uint32_t)input[25] << 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 208 to 236
	value = ((uint32_t)input[26] << 24) |
			((uint32_t)input[27] << 16) |
			((uint32_t)input[28] << 8) |
			((uint32_t)(input[29] & 0xf8));
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 237 to 265
	value = ((uint32_t)(input[29] & 0x07) << 29) |
			((uint32_t)input[30] << 21) |
			((uint32_t)input[31] << 13) |
			((uint32_t)input[32] << 5) |
			((uint32_t)(input[33] & 0xc0) >> 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 266 to 294
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)input[35] << 10) |
			((uint32_t)(input[36] & 0xfe) << 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 295 to 323
	value = ((uint32_t)(input[36] & 0x01) << 31) |
			((uint32_t)input[37] << 23) |
			((uint32_t)input[38] << 15) |
			((uint32_t)input[39] << 7) |
			((uint32_t)(input[40] & 0xf0) >> 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 324 to 352
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)input[43] << 4) |
			((uint32_t)(input[44] & 0x80) >> 4);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 353 to 381
	value = ((uint32_t)(input[44] & 0x7f) << 25) |
			((uint32_t)input[45] << 17) |
			((uint32_t)input[46] << 9) |
			((uint32_t)(input[47] & 0xfc) << 1);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 382 to 410
	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] & 0xe0) >> 2);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 411 to 439
	value = ((uint32_t)(input[51] & 0x1f) << 27) |
			((uint32_t)input[52] << 19) |
			((uint32_t)input[53] << 11) |
			((uint32_t)input[54] << 3);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 440 to 468
	value = ((uint32_t)input[55] << 24) |
			((uint32_t)input[56] << 16) |
			((uint32_t)input[57] << 8) |
			((uint32_t)(input[58] & 0xf8));
	output[15] = (double)(value >> 3);

	// read output[16]: from bit 469 to 497
	value = ((uint32_t)(input[58] & 0x07) << 29) |
			((uint32_t)input[59] << 21) |
			((uint32_t)input[60] << 13) |
			((uint32_t)input[61] << 5) |
			((uint32_t)(input[62] & 0xc0) >> 3);
	output[16] = (double)(value >> 3);
}

static void unpack_17_29bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 29-bit unsigned
	// Skip 5 bits, read 493 bits of data.
	// Input must be at least 63 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 33
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13) |
			((uint32_t)input[3] << 5) |
			((uint32_t)(input[4] & 0xc0) >> 3);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 34 to 62
	value = ((uint32_t)(input[4] & 0x3f) << 26) |
			((uint32_t)input[5] << 18) |
			((uint32_t)input[6] << 10) |
			((uint32_t)(input[7] & 0xfe) << 2);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 63 to 91
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)input[10] << 7) |
			((uint32_t)(input[11] & 0xf0) >> 1);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 92 to 120
	value = ((uint32_t)(input[11] & 0x0f) << 28) |
			((uint32_t)input[12] << 20) |
			((uint32_t)input[13] << 12) |
			((uint32_t)input[14] << 4) |
			((uint32_t)(input[15] & 0x80) >> 4);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 121 to 149
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)input[17] << 9) |
			((uint32_t)(input[18] & 0xfc) << 1);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 150 to 178
	value = ((uint32_t)(input[18] & 0x03) << 30) |
			((uint32_t)input[19] << 22) |
			((uint32_t)input[20] << 14) |
			((uint32_t)input[21] << 6) |
			((uint32_t)(input[22] & 0xe0) >> 2);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 179 to 207
	value = ((uint32_t)(input[22] & 0x1f) << 27) |
			((uint32_t)input[23] << 19) |
			((uint32_t)input[24] << 11) |
			((uint32_t)input[25] << 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 208 to 236
	value = ((uint32_t)input[26] << 24) |
			((uint32_t)input[27] << 16) |
			((uint32_t)input[28] << 8) |
			((uint32_t)(input[29] & 0xf8));
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 237 to 265
	value = ((uint32_t)(input[29] & 0x07) << 29) |
			((uint32_t)input[30] << 21) |
			((uint32_t)input[31] << 13) |
			((uint32_t)input[32] << 5) |
			((uint32_t)(input[33] & 0xc0) >> 3);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 266 to 294
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)input[35] << 10) |
			((uint32_t)(input[36] & 0xfe) << 2);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 295 to 323
	value = ((uint32_t)(input[36] & 0x01) << 31) |
			((uint32_t)input[37] << 23) |
			((uint32_t)input[38] << 15) |
			((uint32_t)input[39] << 7) |
			((uint32_t)(input[40] & 0xf0) >> 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 324 to 352
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)input[42] << 12) |
			((uint32_t)input[43] << 4) |
			((uint32_t)(input[44] & 0x80) >> 4);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 353 to 381
	value = ((uint32_t)(input[44] & 0x7f) << 25) |
			((uint32_t)input[45] << 17) |
			((uint32_t)input[46] << 9) |
			((uint32_t)(input[47] & 0xfc) << 1);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 382 to 410
	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] & 0xe0) >> 2);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 411 to 439
	value = ((uint32_t)(input[51] & 0x1f) << 27) |
			((uint32_t)input[52] << 19) |
			((uint32_t)input[53] << 11) |
			((uint32_t)input[54] << 3);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 440 to 468
	value = ((uint32_t)input[55] << 24) |
			((uint32_t)input[56] << 16) |
			((uint32_t)input[57] << 8) |
			((uint32_t)(input[58] & 0xf8));
	output[15] = (double)(value >> 3);

	// read output[16]: from bit 469 to 497
	value = ((uint32_t)(input[58] & 0x07) << 29) |
			((uint32_t)input[59] << 21) |
			((uint32_t)input[60] << 13) |
			((uint32_t)input[61] << 5) |
			((uint32_t)(input[62] & 0xc0) >> 3);
	output[16] = (double)(value >> 3);
}

static void unpack_17_29bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 29-bit signed
	// Skip 6 bits, read 493 bits of data.
	// Input must be at least 63 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 34
	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] & 0xe0) >> 2);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 35 to 63
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 64 to 92
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xf8));
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 93 to 121
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xc0) >> 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 151 to 179
	value = ((uint32_t)(input[18] & 0x01) << 31) |
			((uint32_t)input[19] << 23) |
			((uint32_t)input[20] << 15) |
			((uint32_t)input[21] << 7) |
			((uint32_t)(input[22] & 0xf0) >> 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 180 to 208
	value = ((uint32_t)(input[22] & 0x0f) << 28) |
			((uint32_t)input[23] << 20) |
			((uint32_t)input[24] << 12) |
			((uint32_t)input[25] << 4) |
			((uint32_t)(input[26] & 0x80) >> 4);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 209 to 237
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)input[28] << 9) |
			((uint32_t)(input[29] & 0xfc) << 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 238 to 266
	value = ((uint32_t)(input[29] & 0x03) << 30) |
			((uint32_t)input[30] << 22) |
			((uint32_t)input[31] << 14) |
			((uint32_t)input[32] << 6) |
			((uint32_t)(input[33] & 0xe0) >> 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 267 to 295
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)input[35] << 11) |
			((uint32_t)input[36] << 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 296 to 324
	value = ((uint32_t)input[37] << 24) |
			((uint32_t)input[38] << 16) |
			((uint32_t)input[39] << 8) |
			((uint32_t)(input[40] & 0xf8));
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 325 to 353
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5) |
			((uint32_t)(input[44] & 0xc0) >> 3);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 354 to 382
	value = ((uint32_t)(input[44] & 0x3f) << 26) |
			((uint32_t)input[45] << 18) |
			((uint32_t)input[46] << 10) |
			((uint32_t)(input[47] & 0xfe) << 2);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 383 to 411
	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] & 0xf0) >> 1);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 412 to 440
	value = ((uint32_t)(input[51] & 0x0f) << 28) |
			((uint32_t)input[52] << 20) |
			((uint32_t)input[53] << 12) |
			((uint32_t)input[54] << 4) |
			((uint32_t)(input[55] & 0x80) >> 4);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 441 to 469
	value = ((uint32_t)(input[55] & 0x7f) << 25) |
			((uint32_t)input[56] << 17) |
			((uint32_t)input[57] << 9) |
			((uint32_t)(input[58] & 0xfc) << 1);
	output[15] = (double)(value >> 3);

	// read output[16]: from bit 470 to 498
	value = ((uint32_t)(input[58] & 0x03) << 30) |
			((uint32_t)input[59] << 22) |
			((uint32_t)input[60] << 14) |
			((uint32_t)input[61] << 6) |
			((uint32_t)(input[62] & 0xe0) >> 2);
	output[16] = (double)(value >> 3);
}

static void unpack_17_29bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 29-bit unsigned
	// Skip 6 bits, read 493 bits of data.
	// Input must be at least 63 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 34
	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] & 0xe0) >> 2);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 35 to 63
	value = ((uint32_t)(input[4] & 0x1f) << 27) |
			((uint32_t)input[5] << 19) |
			((uint32_t)input[6] << 11) |
			((uint32_t)input[7] << 3);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 64 to 92
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)input[10] << 8) |
			((uint32_t)(input[11] & 0xf8));
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 93 to 121
	value = ((uint32_t)(input[11] & 0x07) << 29) |
			((uint32_t)input[12] << 21) |
			((uint32_t)input[13] << 13) |
			((uint32_t)input[14] << 5) |
			((uint32_t)(input[15] & 0xc0) >> 3);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 122 to 150
	value = ((uint32_t)(input[15] & 0x3f) << 26) |
			((uint32_t)input[16] << 18) |
			((uint32_t)input[17] << 10) |
			((uint32_t)(input[18] & 0xfe) << 2);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 151 to 179
	value = ((uint32_t)(input[18] & 0x01) << 31) |
			((uint32_t)input[19] << 23) |
			((uint32_t)input[20] << 15) |
			((uint32_t)input[21] << 7) |
			((uint32_t)(input[22] & 0xf0) >> 1);
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 180 to 208
	value = ((uint32_t)(input[22] & 0x0f) << 28) |
			((uint32_t)input[23] << 20) |
			((uint32_t)input[24] << 12) |
			((uint32_t)input[25] << 4) |
			((uint32_t)(input[26] & 0x80) >> 4);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 209 to 237
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)input[28] << 9) |
			((uint32_t)(input[29] & 0xfc) << 1);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 238 to 266
	value = ((uint32_t)(input[29] & 0x03) << 30) |
			((uint32_t)input[30] << 22) |
			((uint32_t)input[31] << 14) |
			((uint32_t)input[32] << 6) |
			((uint32_t)(input[33] & 0xe0) >> 2);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 267 to 295
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)input[35] << 11) |
			((uint32_t)input[36] << 3);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 296 to 324
	value = ((uint32_t)input[37] << 24) |
			((uint32_t)input[38] << 16) |
			((uint32_t)input[39] << 8) |
			((uint32_t)(input[40] & 0xf8));
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 325 to 353
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13) |
			((uint32_t)input[43] << 5) |
			((uint32_t)(input[44] & 0xc0) >> 3);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 354 to 382
	value = ((uint32_t)(input[44] & 0x3f) << 26) |
			((uint32_t)input[45] << 18) |
			((uint32_t)input[46] << 10) |
			((uint32_t)(input[47] & 0xfe) << 2);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 383 to 411
	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] & 0xf0) >> 1);
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 412 to 440
	value = ((uint32_t)(input[51] & 0x0f) << 28) |
			((uint32_t)input[52] << 20) |
			((uint32_t)input[53] << 12) |
			((uint32_t)input[54] << 4) |
			((uint32_t)(input[55] & 0x80) >> 4);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 441 to 469
	value = ((uint32_t)(input[55] & 0x7f) << 25) |
			((uint32_t)input[56] << 17) |
			((uint32_t)input[57] << 9) |
			((uint32_t)(input[58] & 0xfc) << 1);
	output[15] = (double)(value >> 3);

	// read output[16]: from bit 470 to 498
	value = ((uint32_t)(input[58] & 0x03) << 30) |
			((uint32_t)input[59] << 22) |
			((uint32_t)input[60] << 14) |
			((uint32_t)input[61] << 6) |
			((uint32_t)(input[62] & 0xe0) >> 2);
	output[16] = (double)(value >> 3);
}

static void unpack_17_29bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 29-bit signed
	// Skip 7 bits, read 493 bits of data.
	// Input must be at least 63 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 35
	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] & 0xf0) >> 1);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 36 to 64
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0x80) >> 4);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 65 to 93
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)(input[11] & 0xfc) << 1);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 94 to 122
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xe0) >> 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 181 to 209
	value = ((uint32_t)(input[22] & 0x07) << 29) |
			((uint32_t)input[23] << 21) |
			((uint32_t)input[24] << 13) |
			((uint32_t)input[25] << 5) |
			((uint32_t)(input[26] & 0xc0) >> 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 210 to 238
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)input[28] << 10) |
			((uint32_t)(input[29] & 0xfe) << 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 239 to 267
	value = ((uint32_t)(input[29] & 0x01) << 31) |
			((uint32_t)input[30] << 23) |
			((uint32_t)input[31] << 15) |
			((uint32_t)input[32] << 7) |
			((uint32_t)(input[33] & 0xf0) >> 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 268 to 296
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)input[35] << 12) |
			((uint32_t)input[36] << 4) |
			((uint32_t)(input[37] & 0x80) >> 4);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 297 to 325
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xfc) << 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 326 to 354
	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] & 0xe0) >> 2);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 355 to 383
	value = ((uint32_t)(input[44] & 0x1f) << 27) |
			((uint32_t)input[45] << 19) |
			((uint32_t)input[46] << 11) |
			((uint32_t)input[47] << 3);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 384 to 412
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)input[50] << 8) |
			((uint32_t)(input[51] & 0xf8));
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 413 to 441
	value = ((uint32_t)(input[51] & 0x07) << 29) |
			((uint32_t)input[52] << 21) |
			((uint32_t)input[53] << 13) |
			((uint32_t)input[54] << 5) |
			((uint32_t)(input[55] & 0xc0) >> 3);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 442 to 470
	value = ((uint32_t)(input[55] & 0x3f) << 26) |
			((uint32_t)input[56] << 18) |
			((uint32_t)input[57] << 10) |
			((uint32_t)(input[58] & 0xfe) << 2);
	output[15] = (double)(value >> 3);

	// read output[16]: from bit 471 to 499
	value = ((uint32_t)(input[58] & 0x01) << 31) |
			((uint32_t)input[59] << 23) |
			((uint32_t)input[60] << 15) |
			((uint32_t)input[61] << 7) |
			((uint32_t)(input[62] & 0xf0) >> 1);
	output[16] = (double)(value >> 3);
}

static void unpack_17_29bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 29-bit unsigned
	// Skip 7 bits, read 493 bits of data.
	// Input must be at least 63 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 35
	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] & 0xf0) >> 1);
	output[0] = (double)(value >> 3);

	// read output[1]: from bit 36 to 64
	value = ((uint32_t)(input[4] & 0x0f) << 28) |
			((uint32_t)input[5] << 20) |
			((uint32_t)input[6] << 12) |
			((uint32_t)input[7] << 4) |
			((uint32_t)(input[8] & 0x80) >> 4);
	output[1] = (double)(value >> 3);

	// read output[2]: from bit 65 to 93
	value = ((uint32_t)(input[8] & 0x7f) << 25) |
			((uint32_t)input[9] << 17) |
			((uint32_t)input[10] << 9) |
			((uint32_t)(input[11] & 0xfc) << 1);
	output[2] = (double)(value >> 3);

	// read output[3]: from bit 94 to 122
	value = ((uint32_t)(input[11] & 0x03) << 30) |
			((uint32_t)input[12] << 22) |
			((uint32_t)input[13] << 14) |
			((uint32_t)input[14] << 6) |
			((uint32_t)(input[15] & 0xe0) >> 2);
	output[3] = (double)(value >> 3);

	// read output[4]: from bit 123 to 151
	value = ((uint32_t)(input[15] & 0x1f) << 27) |
			((uint32_t)input[16] << 19) |
			((uint32_t)input[17] << 11) |
			((uint32_t)input[18] << 3);
	output[4] = (double)(value >> 3);

	// read output[5]: from bit 152 to 180
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)input[21] << 8) |
			((uint32_t)(input[22] & 0xf8));
	output[5] = (double)(value >> 3);

	// read output[6]: from bit 181 to 209
	value = ((uint32_t)(input[22] & 0x07) << 29) |
			((uint32_t)input[23] << 21) |
			((uint32_t)input[24] << 13) |
			((uint32_t)input[25] << 5) |
			((uint32_t)(input[26] & 0xc0) >> 3);
	output[6] = (double)(value >> 3);

	// read output[7]: from bit 210 to 238
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)input[28] << 10) |
			((uint32_t)(input[29] & 0xfe) << 2);
	output[7] = (double)(value >> 3);

	// read output[8]: from bit 239 to 267
	value = ((uint32_t)(input[29] & 0x01) << 31) |
			((uint32_t)input[30] << 23) |
			((uint32_t)input[31] << 15) |
			((uint32_t)input[32] << 7) |
			((uint32_t)(input[33] & 0xf0) >> 1);
	output[8] = (double)(value >> 3);

	// read output[9]: from bit 268 to 296
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)input[35] << 12) |
			((uint32_t)input[36] << 4) |
			((uint32_t)(input[37] & 0x80) >> 4);
	output[9] = (double)(value >> 3);

	// read output[10]: from bit 297 to 325
	value = ((uint32_t)(input[37] & 0x7f) << 25) |
			((uint32_t)input[38] << 17) |
			((uint32_t)input[39] << 9) |
			((uint32_t)(input[40] & 0xfc) << 1);
	output[10] = (double)(value >> 3);

	// read output[11]: from bit 326 to 354
	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] & 0xe0) >> 2);
	output[11] = (double)(value >> 3);

	// read output[12]: from bit 355 to 383
	value = ((uint32_t)(input[44] & 0x1f) << 27) |
			((uint32_t)input[45] << 19) |
			((uint32_t)input[46] << 11) |
			((uint32_t)input[47] << 3);
	output[12] = (double)(value >> 3);

	// read output[13]: from bit 384 to 412
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)input[50] << 8) |
			((uint32_t)(input[51] & 0xf8));
	output[13] = (double)(value >> 3);

	// read output[14]: from bit 413 to 441
	value = ((uint32_t)(input[51] & 0x07) << 29) |
			((uint32_t)input[52] << 21) |
			((uint32_t)input[53] << 13) |
			((uint32_t)input[54] << 5) |
			((uint32_t)(input[55] & 0xc0) >> 3);
	output[14] = (double)(value >> 3);

	// read output[15]: from bit 442 to 470
	value = ((uint32_t)(input[55] & 0x3f) << 26) |
			((uint32_t)input[56] << 18) |
			((uint32_t)input[57] << 10) |
			((uint32_t)(input[58] & 0xfe) << 2);
	output[15] = (double)(value >> 3);

	// read output[16]: from bit 471 to 499
	value = ((uint32_t)(input[58] & 0x01) << 31) |
			((uint32_t)input[59] << 23) |
			((uint32_t)input[60] << 15) |
			((uint32_t)input[61] << 7) |
			((uint32_t)(input[62] & 0xf0) >> 1);
	output[16] = (double)(value >> 3);
}


unpack_func_t unpack_29bit[UNPACK_29BIT_MAX_COUNT][8][2] = {
	{
		{
			unpack_1_29bit_unsigned_0off,
			unpack_1_29bit_signed_0off,
		},
		{
			unpack_1_29bit_unsigned_1off,
			unpack_1_29bit_signed_1off,
		},
		{
			unpack_1_29bit_unsigned_2off,
			unpack_1_29bit_signed_2off,
		},
		{
			unpack_1_29bit_unsigned_3off,
			unpack_1_29bit_signed_3off,
		},
		{
			unpack_1_29bit_unsigned_4off,
			unpack_1_29bit_signed_4off,
		},
		{
			unpack_1_29bit_unsigned_5off,
			unpack_1_29bit_signed_5off,
		},
		{
			unpack_1_29bit_unsigned_6off,
			unpack_1_29bit_signed_6off,
		},
		{
			unpack_1_29bit_unsigned_7off,
			unpack_1_29bit_signed_7off,
		},
	},
	{
		{
			unpack_2_29bit_unsigned_0off,
			unpack_2_29bit_signed_0off,
		},
		{
			unpack_2_29bit_unsigned_1off,
			unpack_2_29bit_signed_1off,
		},
		{
			unpack_2_29bit_unsigned_2off,
			unpack_2_29bit_signed_2off,
		},
		{
			unpack_2_29bit_unsigned_3off,
			unpack_2_29bit_signed_3off,
		},
		{
			unpack_2_29bit_unsigned_4off,
			unpack_2_29bit_signed_4off,
		},
		{
			unpack_2_29bit_unsigned_5off,
			unpack_2_29bit_signed_5off,
		},
		{
			unpack_2_29bit_unsigned_6off,
			unpack_2_29bit_signed_6off,
		},
		{
			unpack_2_29bit_unsigned_7off,
			unpack_2_29bit_signed_7off,
		},
	},
	{
		{
			unpack_3_29bit_unsigned_0off,
			unpack_3_29bit_signed_0off,
		},
		{
			unpack_3_29bit_unsigned_1off,
			unpack_3_29bit_signed_1off,
		},
		{
			unpack_3_29bit_unsigned_2off,
			unpack_3_29bit_signed_2off,
		},
		{
			unpack_3_29bit_unsigned_3off,
			unpack_3_29bit_signed_3off,
		},
		{
			unpack_3_29bit_unsigned_4off,
			unpack_3_29bit_signed_4off,
		},
		{
			unpack_3_29bit_unsigned_5off,
			unpack_3_29bit_signed_5off,
		},
		{
			unpack_3_29bit_unsigned_6off,
			unpack_3_29bit_signed_6off,
		},
		{
			unpack_3_29bit_unsigned_7off,
			unpack_3_29bit_signed_7off,
		},
	},
	{
		{
			unpack_4_29bit_unsigned_0off,
			unpack_4_29bit_signed_0off,
		},
		{
			unpack_4_29bit_unsigned_1off,
			unpack_4_29bit_signed_1off,
		},
		{
			unpack_4_29bit_unsigned_2off,
			unpack_4_29bit_signed_2off,
		},
		{
			unpack_4_29bit_unsigned_3off,
			unpack_4_29bit_signed_3off,
		},
		{
			unpack_4_29bit_unsigned_4off,
			unpack_4_29bit_signed_4off,
		},
		{
			unpack_4_29bit_unsigned_5off,
			unpack_4_29bit_signed_5off,
		},
		{
			unpack_4_29bit_unsigned_6off,
			unpack_4_29bit_signed_6off,
		},
		{
			unpack_4_29bit_unsigned_7off,
			unpack_4_29bit_signed_7off,
		},
	},
	{
		{
			unpack_5_29bit_unsigned_0off,
			unpack_5_29bit_signed_0off,
		},
		{
			unpack_5_29bit_unsigned_1off,
			unpack_5_29bit_signed_1off,
		},
		{
			unpack_5_29bit_unsigned_2off,
			unpack_5_29bit_signed_2off,
		},
		{
			unpack_5_29bit_unsigned_3off,
			unpack_5_29bit_signed_3off,
		},
		{
			unpack_5_29bit_unsigned_4off,
			unpack_5_29bit_signed_4off,
		},
		{
			unpack_5_29bit_unsigned_5off,
			unpack_5_29bit_signed_5off,
		},
		{
			unpack_5_29bit_unsigned_6off,
			unpack_5_29bit_signed_6off,
		},
		{
			unpack_5_29bit_unsigned_7off,
			unpack_5_29bit_signed_7off,
		},
	},
	{
		{
			unpack_6_29bit_unsigned_0off,
			unpack_6_29bit_signed_0off,
		},
		{
			unpack_6_29bit_unsigned_1off,
			unpack_6_29bit_signed_1off,
		},
		{
			unpack_6_29bit_unsigned_2off,
			unpack_6_29bit_signed_2off,
		},
		{
			unpack_6_29bit_unsigned_3off,
			unpack_6_29bit_signed_3off,
		},
		{
			unpack_6_29bit_unsigned_4off,
			unpack_6_29bit_signed_4off,
		},
		{
			unpack_6_29bit_unsigned_5off,
			unpack_6_29bit_signed_5off,
		},
		{
			unpack_6_29bit_unsigned_6off,
			unpack_6_29bit_signed_6off,
		},
		{
			unpack_6_29bit_unsigned_7off,
			unpack_6_29bit_signed_7off,
		},
	},
	{
		{
			unpack_7_29bit_unsigned_0off,
			unpack_7_29bit_signed_0off,
		},
		{
			unpack_7_29bit_unsigned_1off,
			unpack_7_29bit_signed_1off,
		},
		{
			unpack_7_29bit_unsigned_2off,
			unpack_7_29bit_signed_2off,
		},
		{
			unpack_7_29bit_unsigned_3off,
			unpack_7_29bit_signed_3off,
		},
		{
			unpack_7_29bit_unsigned_4off,
			unpack_7_29bit_signed_4off,
		},
		{
			unpack_7_29bit_unsigned_5off,
			unpack_7_29bit_signed_5off,
		},
		{
			unpack_7_29bit_unsigned_6off,
			unpack_7_29bit_signed_6off,
		},
		{
			unpack_7_29bit_unsigned_7off,
			unpack_7_29bit_signed_7off,
		},
	},
	{
		{
			unpack_8_29bit_unsigned_0off,
			unpack_8_29bit_signed_0off,
		},
		{
			unpack_8_29bit_unsigned_1off,
			unpack_8_29bit_signed_1off,
		},
		{
			unpack_8_29bit_unsigned_2off,
			unpack_8_29bit_signed_2off,
		},
		{
			unpack_8_29bit_unsigned_3off,
			unpack_8_29bit_signed_3off,
		},
		{
			unpack_8_29bit_unsigned_4off,
			unpack_8_29bit_signed_4off,
		},
		{
			unpack_8_29bit_unsigned_5off,
			unpack_8_29bit_signed_5off,
		},
		{
			unpack_8_29bit_unsigned_6off,
			unpack_8_29bit_signed_6off,
		},
		{
			unpack_8_29bit_unsigned_7off,
			unpack_8_29bit_signed_7off,
		},
	},
	{
		{
			unpack_9_29bit_unsigned_0off,
			unpack_9_29bit_signed_0off,
		},
		{
			unpack_9_29bit_unsigned_1off,
			unpack_9_29bit_signed_1off,
		},
		{
			unpack_9_29bit_unsigned_2off,
			unpack_9_29bit_signed_2off,
		},
		{
			unpack_9_29bit_unsigned_3off,
			unpack_9_29bit_signed_3off,
		},
		{
			unpack_9_29bit_unsigned_4off,
			unpack_9_29bit_signed_4off,
		},
		{
			unpack_9_29bit_unsigned_5off,
			unpack_9_29bit_signed_5off,
		},
		{
			unpack_9_29bit_unsigned_6off,
			unpack_9_29bit_signed_6off,
		},
		{
			unpack_9_29bit_unsigned_7off,
			unpack_9_29bit_signed_7off,
		},
	},
	{
		{
			unpack_10_29bit_unsigned_0off,
			unpack_10_29bit_signed_0off,
		},
		{
			unpack_10_29bit_unsigned_1off,
			unpack_10_29bit_signed_1off,
		},
		{
			unpack_10_29bit_unsigned_2off,
			unpack_10_29bit_signed_2off,
		},
		{
			unpack_10_29bit_unsigned_3off,
			unpack_10_29bit_signed_3off,
		},
		{
			unpack_10_29bit_unsigned_4off,
			unpack_10_29bit_signed_4off,
		},
		{
			unpack_10_29bit_unsigned_5off,
			unpack_10_29bit_signed_5off,
		},
		{
			unpack_10_29bit_unsigned_6off,
			unpack_10_29bit_signed_6off,
		},
		{
			unpack_10_29bit_unsigned_7off,
			unpack_10_29bit_signed_7off,
		},
	},
	{
		{
			unpack_11_29bit_unsigned_0off,
			unpack_11_29bit_signed_0off,
		},
		{
			unpack_11_29bit_unsigned_1off,
			unpack_11_29bit_signed_1off,
		},
		{
			unpack_11_29bit_unsigned_2off,
			unpack_11_29bit_signed_2off,
		},
		{
			unpack_11_29bit_unsigned_3off,
			unpack_11_29bit_signed_3off,
		},
		{
			unpack_11_29bit_unsigned_4off,
			unpack_11_29bit_signed_4off,
		},
		{
			unpack_11_29bit_unsigned_5off,
			unpack_11_29bit_signed_5off,
		},
		{
			unpack_11_29bit_unsigned_6off,
			unpack_11_29bit_signed_6off,
		},
		{
			unpack_11_29bit_unsigned_7off,
			unpack_11_29bit_signed_7off,
		},
	},
	{
		{
			unpack_12_29bit_unsigned_0off,
			unpack_12_29bit_signed_0off,
		},
		{
			unpack_12_29bit_unsigned_1off,
			unpack_12_29bit_signed_1off,
		},
		{
			unpack_12_29bit_unsigned_2off,
			unpack_12_29bit_signed_2off,
		},
		{
			unpack_12_29bit_unsigned_3off,
			unpack_12_29bit_signed_3off,
		},
		{
			unpack_12_29bit_unsigned_4off,
			unpack_12_29bit_signed_4off,
		},
		{
			unpack_12_29bit_unsigned_5off,
			unpack_12_29bit_signed_5off,
		},
		{
			unpack_12_29bit_unsigned_6off,
			unpack_12_29bit_signed_6off,
		},
		{
			unpack_12_29bit_unsigned_7off,
			unpack_12_29bit_signed_7off,
		},
	},
	{
		{
			unpack_13_29bit_unsigned_0off,
			unpack_13_29bit_signed_0off,
		},
		{
			unpack_13_29bit_unsigned_1off,
			unpack_13_29bit_signed_1off,
		},
		{
			unpack_13_29bit_unsigned_2off,
			unpack_13_29bit_signed_2off,
		},
		{
			unpack_13_29bit_unsigned_3off,
			unpack_13_29bit_signed_3off,
		},
		{
			unpack_13_29bit_unsigned_4off,
			unpack_13_29bit_signed_4off,
		},
		{
			unpack_13_29bit_unsigned_5off,
			unpack_13_29bit_signed_5off,
		},
		{
			unpack_13_29bit_unsigned_6off,
			unpack_13_29bit_signed_6off,
		},
		{
			unpack_13_29bit_unsigned_7off,
			unpack_13_29bit_signed_7off,
		},
	},
	{
		{
			unpack_14_29bit_unsigned_0off,
			unpack_14_29bit_signed_0off,
		},
		{
			unpack_14_29bit_unsigned_1off,
			unpack_14_29bit_signed_1off,
		},
		{
			unpack_14_29bit_unsigned_2off,
			unpack_14_29bit_signed_2off,
		},
		{
			unpack_14_29bit_unsigned_3off,
			unpack_14_29bit_signed_3off,
		},
		{
			unpack_14_29bit_unsigned_4off,
			unpack_14_29bit_signed_4off,
		},
		{
			unpack_14_29bit_unsigned_5off,
			unpack_14_29bit_signed_5off,
		},
		{
			unpack_14_29bit_unsigned_6off,
			unpack_14_29bit_signed_6off,
		},
		{
			unpack_14_29bit_unsigned_7off,
			unpack_14_29bit_signed_7off,
		},
	},
	{
		{
			unpack_15_29bit_unsigned_0off,
			unpack_15_29bit_signed_0off,
		},
		{
			unpack_15_29bit_unsigned_1off,
			unpack_15_29bit_signed_1off,
		},
		{
			unpack_15_29bit_unsigned_2off,
			unpack_15_29bit_signed_2off,
		},
		{
			unpack_15_29bit_unsigned_3off,
			unpack_15_29bit_signed_3off,
		},
		{
			unpack_15_29bit_unsigned_4off,
			unpack_15_29bit_signed_4off,
		},
		{
			unpack_15_29bit_unsigned_5off,
			unpack_15_29bit_signed_5off,
		},
		{
			unpack_15_29bit_unsigned_6off,
			unpack_15_29bit_signed_6off,
		},
		{
			unpack_15_29bit_unsigned_7off,
			unpack_15_29bit_signed_7off,
		},
	},
	{
		{
			unpack_16_29bit_unsigned_0off,
			unpack_16_29bit_signed_0off,
		},
		{
			unpack_16_29bit_unsigned_1off,
			unpack_16_29bit_signed_1off,
		},
		{
			unpack_16_29bit_unsigned_2off,
			unpack_16_29bit_signed_2off,
		},
		{
			unpack_16_29bit_unsigned_3off,
			unpack_16_29bit_signed_3off,
		},
		{
			unpack_16_29bit_unsigned_4off,
			unpack_16_29bit_signed_4off,
		},
		{
			unpack_16_29bit_unsigned_5off,
			unpack_16_29bit_signed_5off,
		},
		{
			unpack_16_29bit_unsigned_6off,
			unpack_16_29bit_signed_6off,
		},
		{
			unpack_16_29bit_unsigned_7off,
			unpack_16_29bit_signed_7off,
		},
	},
	{
		{
			unpack_17_29bit_unsigned_0off,
			unpack_17_29bit_signed_0off,
		},
		{
			unpack_17_29bit_unsigned_1off,
			unpack_17_29bit_signed_1off,
		},
		{
			unpack_17_29bit_unsigned_2off,
			unpack_17_29bit_signed_2off,
		},
		{
			unpack_17_29bit_unsigned_3off,
			unpack_17_29bit_signed_3off,
		},
		{
			unpack_17_29bit_unsigned_4off,
			unpack_17_29bit_signed_4off,
		},
		{
			unpack_17_29bit_unsigned_5off,
			unpack_17_29bit_signed_5off,
		},
		{
			unpack_17_29bit_unsigned_6off,
			unpack_17_29bit_signed_6off,
		},
		{
			unpack_17_29bit_unsigned_7off,
			unpack_17_29bit_signed_7off,
		},
	},
};
