// AUTOGENERATED FILE. DO NOT MODIFY.

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

#include "unpack19.h"



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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

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

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

	uint32_t value;

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

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

	int32_t value;

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

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

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

	uint32_t value;

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

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

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

	int32_t value;

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

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

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

	uint32_t value;

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

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

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

	int32_t value;

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

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

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

	uint32_t value;

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

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

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

	int32_t value;

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

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

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

	uint32_t value;

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

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

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

	int32_t value;

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

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

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

	uint32_t value;

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

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

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

	int32_t value;

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

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

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

	uint32_t value;

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

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

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

	int32_t value;

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

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

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

	uint32_t value;

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

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

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

	int32_t value;

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

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

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

	uint32_t value;

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

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

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

	int32_t value;

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

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

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

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

	uint32_t value;

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

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

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

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

	int32_t value;

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

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

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);
}

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

	int32_t value;

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

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

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

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

	uint32_t value;

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

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

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

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

	int32_t value;

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

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

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

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

	uint32_t value;

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

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

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

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

	int32_t value;

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

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

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

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

	uint32_t value;

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

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

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

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

	int32_t value;

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

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

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);
}

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

	int32_t value;

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

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

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

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

	uint32_t value;

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

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

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

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

	int32_t value;

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

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

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

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

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

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

	uint32_t value;

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

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

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

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

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

	int32_t value;

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

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

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

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

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

	uint32_t value;

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

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

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

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

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

	int32_t value;

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

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

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

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

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

	uint32_t value;

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

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

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

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

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

	int32_t value;

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

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

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

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

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

	uint32_t value;

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

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

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

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

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

	int32_t value;

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

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

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

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

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

	uint32_t value;

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

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

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

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

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

	int32_t value;

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

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

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

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

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

	uint32_t value;

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

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

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

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

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

	int32_t value;

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

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

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

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

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

	uint32_t value;

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

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

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

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

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

	int32_t value;

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

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

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

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

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

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

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

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

	int32_t value;

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

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

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

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

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

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

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);
}

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);
}

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);
}

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);
}

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

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

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

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

	uint32_t value;

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

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

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

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

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

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

	int32_t value;

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

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

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

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

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

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

	uint32_t value;

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

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

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

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

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

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

	int32_t value;

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

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

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

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

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

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

	uint32_t value;

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

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

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

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

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

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

	int32_t value;

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

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

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

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

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

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

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

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

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

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

	int32_t value;

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

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

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

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

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

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

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

	uint32_t value;

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

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

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

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

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

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

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

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

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

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

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

	int32_t value;

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

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

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

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);
}

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

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

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

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

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

	int32_t value;

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

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

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

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

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

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

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

	uint32_t value;

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

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

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

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

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

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

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

	int32_t value;

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

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

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

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

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

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

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

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

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);
}

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

	int32_t value;

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

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

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

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

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

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);
}

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

	uint32_t value;

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

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

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

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

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

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

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

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

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

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

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

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

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

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

	int32_t value;

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

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

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

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

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

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

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

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

	uint32_t value;

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

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

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

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

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

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

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

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

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

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

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

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

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

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

	int32_t value;

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

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

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

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

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

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

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

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

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

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

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

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

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

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

	int32_t value;

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

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

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

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

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

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

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

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

	uint32_t value;

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

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

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

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

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

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

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

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

	int32_t value;

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

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

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

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

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

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

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

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

	uint32_t value;

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

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

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

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

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

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

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

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

	int32_t value;

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

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

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

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

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

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);
}

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

	uint32_t value;

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

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

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

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

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

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

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

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

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

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

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

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

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

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

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

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

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

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

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

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);
}

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

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

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

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

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

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

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

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

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

	int32_t value;

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

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

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

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

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

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

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

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

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

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

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

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

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

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

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

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

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

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

	int32_t value;

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

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

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

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

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

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

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

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

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

	uint32_t value;

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

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

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

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

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

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

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

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

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

	int32_t value;

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

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

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

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

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

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

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

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

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

	uint32_t value;

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

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

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

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

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

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

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

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

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

	int32_t value;

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

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

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

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

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

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

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

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

	uint32_t value;

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

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

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

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

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

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

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

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

	int32_t value;

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

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

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

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

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

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

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

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

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

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

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

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

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

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

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

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

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

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);
}

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

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

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

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

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);
}

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

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

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

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

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);
}

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

	int32_t value;

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

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

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

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

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

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

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);
}

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

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

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

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);
}

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

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

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

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

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);
}

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

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

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

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

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

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

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

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

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

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

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

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

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

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

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

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

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);
}

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

	int32_t value;

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

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

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

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

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

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

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

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

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);
}

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

	uint32_t value;

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

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

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

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

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

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

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

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

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);
}

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

	int32_t value;

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

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

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

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

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

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

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

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

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

	uint32_t value;

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

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

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

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

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

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

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

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

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

	int32_t value;

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

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

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

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

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

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

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

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

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

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

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

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

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

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

	int32_t value;

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

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

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

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

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

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

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

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

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

	uint32_t value;

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

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

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

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

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

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

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

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

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

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

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

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

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

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

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

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

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

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

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

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

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

	int32_t value;

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

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

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

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

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

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

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

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

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

	uint32_t value;

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

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

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

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

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

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

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

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

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

	int32_t value;

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

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

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

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

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

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

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

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

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

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

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

	uint32_t value;

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

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

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

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

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

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

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

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

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

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

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

	int32_t value;

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

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

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

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

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

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

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

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

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

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

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

	uint32_t value;

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

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

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

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

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

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

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

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

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

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

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

	int32_t value;

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

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

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

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

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

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);
}

static void unpack_10_19bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 19-bit unsigned
	// Skip 6 bits, read 190 bits of data.
	// Input must be at least 25 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);
}

static void unpack_10_19bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 19-bit signed
	// Skip 7 bits, read 190 bits of data.
	// Input must be at least 25 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);
}

static void unpack_10_19bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 10 values into output
	// Values are 19-bit unsigned
	// Skip 7 bits, read 190 bits of data.
	// Input must be at least 25 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);
}

static void unpack_11_19bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 19-bit signed
	// Skip 0 bits, read 209 bits of data.
	// Input must be at least 27 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);
}

static void unpack_11_19bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 19-bit unsigned
	// Skip 0 bits, read 209 bits of data.
	// Input must be at least 27 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);
}

static void unpack_11_19bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 19-bit signed
	// Skip 1 bits, read 209 bits of data.
	// Input must be at least 27 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);
}

static void unpack_11_19bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 19-bit unsigned
	// Skip 1 bits, read 209 bits of data.
	// Input must be at least 27 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);
}

static void unpack_11_19bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 19-bit signed
	// Skip 2 bits, read 209 bits of data.
	// Input must be at least 27 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);
}

static void unpack_11_19bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 19-bit unsigned
	// Skip 2 bits, read 209 bits of data.
	// Input must be at least 27 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);
}

static void unpack_11_19bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 19-bit signed
	// Skip 3 bits, read 209 bits of data.
	// Input must be at least 27 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);
}

static void unpack_11_19bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 19-bit unsigned
	// Skip 3 bits, read 209 bits of data.
	// Input must be at least 27 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);
}

static void unpack_11_19bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 19-bit signed
	// Skip 4 bits, read 209 bits of data.
	// Input must be at least 27 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);
}

static void unpack_11_19bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 19-bit unsigned
	// Skip 4 bits, read 209 bits of data.
	// Input must be at least 27 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);
}

static void unpack_11_19bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 19-bit signed
	// Skip 5 bits, read 209 bits of data.
	// Input must be at least 27 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);
}

static void unpack_11_19bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 19-bit unsigned
	// Skip 5 bits, read 209 bits of data.
	// Input must be at least 27 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);
}

static void unpack_11_19bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 19-bit signed
	// Skip 6 bits, read 209 bits of data.
	// Input must be at least 27 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);
}

static void unpack_11_19bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 19-bit unsigned
	// Skip 6 bits, read 209 bits of data.
	// Input must be at least 27 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);
}

static void unpack_11_19bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 19-bit signed
	// Skip 7 bits, read 209 bits of data.
	// Input must be at least 27 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);
}

static void unpack_11_19bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 11 values into output
	// Values are 19-bit unsigned
	// Skip 7 bits, read 209 bits of data.
	// Input must be at least 27 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);
}

static void unpack_12_19bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 19-bit signed
	// Skip 0 bits, read 228 bits of data.
	// Input must be at least 29 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);
}

static void unpack_12_19bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 19-bit unsigned
	// Skip 0 bits, read 228 bits of data.
	// Input must be at least 29 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);
}

static void unpack_12_19bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 19-bit signed
	// Skip 1 bits, read 228 bits of data.
	// Input must be at least 29 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);
}

static void unpack_12_19bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 19-bit unsigned
	// Skip 1 bits, read 228 bits of data.
	// Input must be at least 29 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);
}

static void unpack_12_19bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 19-bit signed
	// Skip 2 bits, read 228 bits of data.
	// Input must be at least 29 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);
}

static void unpack_12_19bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 19-bit unsigned
	// Skip 2 bits, read 228 bits of data.
	// Input must be at least 29 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);
}

static void unpack_12_19bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 19-bit signed
	// Skip 3 bits, read 228 bits of data.
	// Input must be at least 29 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);
}

static void unpack_12_19bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 19-bit unsigned
	// Skip 3 bits, read 228 bits of data.
	// Input must be at least 29 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);
}

static void unpack_12_19bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 19-bit signed
	// Skip 4 bits, read 228 bits of data.
	// Input must be at least 29 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);
}

static void unpack_12_19bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 19-bit unsigned
	// Skip 4 bits, read 228 bits of data.
	// Input must be at least 29 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);
}

static void unpack_12_19bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 19-bit signed
	// Skip 5 bits, read 228 bits of data.
	// Input must be at least 30 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);
}

static void unpack_12_19bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 19-bit unsigned
	// Skip 5 bits, read 228 bits of data.
	// Input must be at least 30 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);
}

static void unpack_12_19bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 19-bit signed
	// Skip 6 bits, read 228 bits of data.
	// Input must be at least 30 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);
}

static void unpack_12_19bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 19-bit unsigned
	// Skip 6 bits, read 228 bits of data.
	// Input must be at least 30 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);
}

static void unpack_12_19bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 19-bit signed
	// Skip 7 bits, read 228 bits of data.
	// Input must be at least 30 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);
}

static void unpack_12_19bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 12 values into output
	// Values are 19-bit unsigned
	// Skip 7 bits, read 228 bits of data.
	// Input must be at least 30 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);
}

static void unpack_13_19bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 19-bit signed
	// Skip 0 bits, read 247 bits of data.
	// Input must be at least 31 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);
}

static void unpack_13_19bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 19-bit unsigned
	// Skip 0 bits, read 247 bits of data.
	// Input must be at least 31 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);
}

static void unpack_13_19bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 19-bit signed
	// Skip 1 bits, read 247 bits of data.
	// Input must be at least 31 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);
}

static void unpack_13_19bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 19-bit unsigned
	// Skip 1 bits, read 247 bits of data.
	// Input must be at least 31 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);
}

static void unpack_13_19bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 19-bit signed
	// Skip 2 bits, read 247 bits of data.
	// Input must be at least 32 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);
}

static void unpack_13_19bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 19-bit unsigned
	// Skip 2 bits, read 247 bits of data.
	// Input must be at least 32 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);
}

static void unpack_13_19bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 19-bit signed
	// Skip 3 bits, read 247 bits of data.
	// Input must be at least 32 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);
}

static void unpack_13_19bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 19-bit unsigned
	// Skip 3 bits, read 247 bits of data.
	// Input must be at least 32 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);
}

static void unpack_13_19bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 19-bit signed
	// Skip 4 bits, read 247 bits of data.
	// Input must be at least 32 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);
}

static void unpack_13_19bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 19-bit unsigned
	// Skip 4 bits, read 247 bits of data.
	// Input must be at least 32 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);
}

static void unpack_13_19bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 19-bit signed
	// Skip 5 bits, read 247 bits of data.
	// Input must be at least 32 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);
}

static void unpack_13_19bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 19-bit unsigned
	// Skip 5 bits, read 247 bits of data.
	// Input must be at least 32 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);
}

static void unpack_13_19bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 19-bit signed
	// Skip 6 bits, read 247 bits of data.
	// Input must be at least 32 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);
}

static void unpack_13_19bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 19-bit unsigned
	// Skip 6 bits, read 247 bits of data.
	// Input must be at least 32 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);
}

static void unpack_13_19bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 19-bit signed
	// Skip 7 bits, read 247 bits of data.
	// Input must be at least 32 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);
}

static void unpack_13_19bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 13 values into output
	// Values are 19-bit unsigned
	// Skip 7 bits, read 247 bits of data.
	// Input must be at least 32 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);
}

static void unpack_14_19bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 19-bit signed
	// Skip 0 bits, read 266 bits of data.
	// Input must be at least 34 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);
}

static void unpack_14_19bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 19-bit unsigned
	// Skip 0 bits, read 266 bits of data.
	// Input must be at least 34 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);
}

static void unpack_14_19bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 19-bit signed
	// Skip 1 bits, read 266 bits of data.
	// Input must be at least 34 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);
}

static void unpack_14_19bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 19-bit unsigned
	// Skip 1 bits, read 266 bits of data.
	// Input must be at least 34 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);
}

static void unpack_14_19bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 19-bit signed
	// Skip 2 bits, read 266 bits of data.
	// Input must be at least 34 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);
}

static void unpack_14_19bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 19-bit unsigned
	// Skip 2 bits, read 266 bits of data.
	// Input must be at least 34 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);
}

static void unpack_14_19bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 19-bit signed
	// Skip 3 bits, read 266 bits of data.
	// Input must be at least 34 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);
}

static void unpack_14_19bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 19-bit unsigned
	// Skip 3 bits, read 266 bits of data.
	// Input must be at least 34 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);
}

static void unpack_14_19bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 19-bit signed
	// Skip 4 bits, read 266 bits of data.
	// Input must be at least 34 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);
}

static void unpack_14_19bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 19-bit unsigned
	// Skip 4 bits, read 266 bits of data.
	// Input must be at least 34 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);
}

static void unpack_14_19bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 19-bit signed
	// Skip 5 bits, read 266 bits of data.
	// Input must be at least 34 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);
}

static void unpack_14_19bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 19-bit unsigned
	// Skip 5 bits, read 266 bits of data.
	// Input must be at least 34 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);
}

static void unpack_14_19bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 19-bit signed
	// Skip 6 bits, read 266 bits of data.
	// Input must be at least 34 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);
}

static void unpack_14_19bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 19-bit unsigned
	// Skip 6 bits, read 266 bits of data.
	// Input must be at least 34 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);
}

static void unpack_14_19bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 19-bit signed
	// Skip 7 bits, read 266 bits of data.
	// Input must be at least 35 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);
}

static void unpack_14_19bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 14 values into output
	// Values are 19-bit unsigned
	// Skip 7 bits, read 266 bits of data.
	// Input must be at least 35 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);
}

static void unpack_15_19bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 19-bit signed
	// Skip 0 bits, read 285 bits of data.
	// Input must be at least 36 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);
}

static void unpack_15_19bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 19-bit unsigned
	// Skip 0 bits, read 285 bits of data.
	// Input must be at least 36 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);
}

static void unpack_15_19bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 19-bit signed
	// Skip 1 bits, read 285 bits of data.
	// Input must be at least 36 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);
}

static void unpack_15_19bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 19-bit unsigned
	// Skip 1 bits, read 285 bits of data.
	// Input must be at least 36 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);
}

static void unpack_15_19bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 19-bit signed
	// Skip 2 bits, read 285 bits of data.
	// Input must be at least 36 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);
}

static void unpack_15_19bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 19-bit unsigned
	// Skip 2 bits, read 285 bits of data.
	// Input must be at least 36 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);
}

static void unpack_15_19bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 19-bit signed
	// Skip 3 bits, read 285 bits of data.
	// Input must be at least 36 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);
}

static void unpack_15_19bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 19-bit unsigned
	// Skip 3 bits, read 285 bits of data.
	// Input must be at least 36 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);
}

static void unpack_15_19bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 19-bit signed
	// Skip 4 bits, read 285 bits of data.
	// Input must be at least 37 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);
}

static void unpack_15_19bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 19-bit unsigned
	// Skip 4 bits, read 285 bits of data.
	// Input must be at least 37 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);
}

static void unpack_15_19bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 19-bit signed
	// Skip 5 bits, read 285 bits of data.
	// Input must be at least 37 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);
}

static void unpack_15_19bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 19-bit unsigned
	// Skip 5 bits, read 285 bits of data.
	// Input must be at least 37 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);
}

static void unpack_15_19bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 19-bit signed
	// Skip 6 bits, read 285 bits of data.
	// Input must be at least 37 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);
}

static void unpack_15_19bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 19-bit unsigned
	// Skip 6 bits, read 285 bits of data.
	// Input must be at least 37 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);
}

static void unpack_15_19bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 19-bit signed
	// Skip 7 bits, read 285 bits of data.
	// Input must be at least 37 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);
}

static void unpack_15_19bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 15 values into output
	// Values are 19-bit unsigned
	// Skip 7 bits, read 285 bits of data.
	// Input must be at least 37 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);
}

static void unpack_16_19bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 19-bit signed
	// Skip 0 bits, read 304 bits of data.
	// Input must be at least 38 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 285 to 303
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13);
	output[15] = (double)(value >> 13);
}

static void unpack_16_19bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 19-bit unsigned
	// Skip 0 bits, read 304 bits of data.
	// Input must be at least 38 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 285 to 303
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13);
	output[15] = (double)(value >> 13);
}

static void unpack_16_19bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 19-bit signed
	// Skip 1 bits, read 304 bits of data.
	// Input must be at least 39 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 286 to 304
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)(input[38] & 0x80) << 6);
	output[15] = (double)(value >> 13);
}

static void unpack_16_19bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 19-bit unsigned
	// Skip 1 bits, read 304 bits of data.
	// Input must be at least 39 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 286 to 304
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)(input[38] & 0x80) << 6);
	output[15] = (double)(value >> 13);
}

static void unpack_16_19bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 19-bit signed
	// Skip 2 bits, read 304 bits of data.
	// Input must be at least 39 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 287 to 305
	value = ((uint32_t)(input[35] & 0x01) << 31) |
			((uint32_t)input[36] << 23) |
			((uint32_t)input[37] << 15) |
			((uint32_t)(input[38] & 0xc0) << 7);
	output[15] = (double)(value >> 13);
}

static void unpack_16_19bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 19-bit unsigned
	// Skip 2 bits, read 304 bits of data.
	// Input must be at least 39 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 287 to 305
	value = ((uint32_t)(input[35] & 0x01) << 31) |
			((uint32_t)input[36] << 23) |
			((uint32_t)input[37] << 15) |
			((uint32_t)(input[38] & 0xc0) << 7);
	output[15] = (double)(value >> 13);
}

static void unpack_16_19bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 19-bit signed
	// Skip 3 bits, read 304 bits of data.
	// Input must be at least 39 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 288 to 306
	value = ((uint32_t)input[36] << 24) |
			((uint32_t)input[37] << 16) |
			((uint32_t)(input[38] & 0xe0) << 8);
	output[15] = (double)(value >> 13);
}

static void unpack_16_19bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 19-bit unsigned
	// Skip 3 bits, read 304 bits of data.
	// Input must be at least 39 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 288 to 306
	value = ((uint32_t)input[36] << 24) |
			((uint32_t)input[37] << 16) |
			((uint32_t)(input[38] & 0xe0) << 8);
	output[15] = (double)(value >> 13);
}

static void unpack_16_19bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 19-bit signed
	// Skip 4 bits, read 304 bits of data.
	// Input must be at least 39 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 289 to 307
	value = ((uint32_t)(input[36] & 0x7f) << 25) |
			((uint32_t)input[37] << 17) |
			((uint32_t)(input[38] & 0xf0) << 9);
	output[15] = (double)(value >> 13);
}

static void unpack_16_19bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 19-bit unsigned
	// Skip 4 bits, read 304 bits of data.
	// Input must be at least 39 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 289 to 307
	value = ((uint32_t)(input[36] & 0x7f) << 25) |
			((uint32_t)input[37] << 17) |
			((uint32_t)(input[38] & 0xf0) << 9);
	output[15] = (double)(value >> 13);
}

static void unpack_16_19bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 19-bit signed
	// Skip 5 bits, read 304 bits of data.
	// Input must be at least 39 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 290 to 308
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)(input[38] & 0xf8) << 10);
	output[15] = (double)(value >> 13);
}

static void unpack_16_19bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 19-bit unsigned
	// Skip 5 bits, read 304 bits of data.
	// Input must be at least 39 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 290 to 308
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)(input[38] & 0xf8) << 10);
	output[15] = (double)(value >> 13);
}

static void unpack_16_19bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 19-bit signed
	// Skip 6 bits, read 304 bits of data.
	// Input must be at least 39 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 291 to 309
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)(input[38] & 0xfc) << 11);
	output[15] = (double)(value >> 13);
}

static void unpack_16_19bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 19-bit unsigned
	// Skip 6 bits, read 304 bits of data.
	// Input must be at least 39 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 291 to 309
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)(input[38] & 0xfc) << 11);
	output[15] = (double)(value >> 13);
}

static void unpack_16_19bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 19-bit signed
	// Skip 7 bits, read 304 bits of data.
	// Input must be at least 39 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 292 to 310
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)(input[38] & 0xfe) << 12);
	output[15] = (double)(value >> 13);
}

static void unpack_16_19bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 16 values into output
	// Values are 19-bit unsigned
	// Skip 7 bits, read 304 bits of data.
	// Input must be at least 39 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 292 to 310
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)(input[38] & 0xfe) << 12);
	output[15] = (double)(value >> 13);
}

static void unpack_17_19bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 19-bit signed
	// Skip 0 bits, read 323 bits of data.
	// Input must be at least 41 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 285 to 303
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 304 to 322
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)(input[40] & 0xe0) << 8);
	output[16] = (double)(value >> 13);
}

static void unpack_17_19bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 19-bit unsigned
	// Skip 0 bits, read 323 bits of data.
	// Input must be at least 41 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 285 to 303
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 304 to 322
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)(input[40] & 0xe0) << 8);
	output[16] = (double)(value >> 13);
}

static void unpack_17_19bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 19-bit signed
	// Skip 1 bits, read 323 bits of data.
	// Input must be at least 41 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 286 to 304
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)(input[38] & 0x80) << 6);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 305 to 323
	value = ((uint32_t)(input[38] & 0x7f) << 25) |
			((uint32_t)input[39] << 17) |
			((uint32_t)(input[40] & 0xf0) << 9);
	output[16] = (double)(value >> 13);
}

static void unpack_17_19bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 19-bit unsigned
	// Skip 1 bits, read 323 bits of data.
	// Input must be at least 41 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 286 to 304
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)(input[38] & 0x80) << 6);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 305 to 323
	value = ((uint32_t)(input[38] & 0x7f) << 25) |
			((uint32_t)input[39] << 17) |
			((uint32_t)(input[40] & 0xf0) << 9);
	output[16] = (double)(value >> 13);
}

static void unpack_17_19bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 19-bit signed
	// Skip 2 bits, read 323 bits of data.
	// Input must be at least 41 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 287 to 305
	value = ((uint32_t)(input[35] & 0x01) << 31) |
			((uint32_t)input[36] << 23) |
			((uint32_t)input[37] << 15) |
			((uint32_t)(input[38] & 0xc0) << 7);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 306 to 324
	value = ((uint32_t)(input[38] & 0x3f) << 26) |
			((uint32_t)input[39] << 18) |
			((uint32_t)(input[40] & 0xf8) << 10);
	output[16] = (double)(value >> 13);
}

static void unpack_17_19bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 19-bit unsigned
	// Skip 2 bits, read 323 bits of data.
	// Input must be at least 41 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 287 to 305
	value = ((uint32_t)(input[35] & 0x01) << 31) |
			((uint32_t)input[36] << 23) |
			((uint32_t)input[37] << 15) |
			((uint32_t)(input[38] & 0xc0) << 7);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 306 to 324
	value = ((uint32_t)(input[38] & 0x3f) << 26) |
			((uint32_t)input[39] << 18) |
			((uint32_t)(input[40] & 0xf8) << 10);
	output[16] = (double)(value >> 13);
}

static void unpack_17_19bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 19-bit signed
	// Skip 3 bits, read 323 bits of data.
	// Input must be at least 41 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 288 to 306
	value = ((uint32_t)input[36] << 24) |
			((uint32_t)input[37] << 16) |
			((uint32_t)(input[38] & 0xe0) << 8);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 307 to 325
	value = ((uint32_t)(input[38] & 0x1f) << 27) |
			((uint32_t)input[39] << 19) |
			((uint32_t)(input[40] & 0xfc) << 11);
	output[16] = (double)(value >> 13);
}

static void unpack_17_19bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 19-bit unsigned
	// Skip 3 bits, read 323 bits of data.
	// Input must be at least 41 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 288 to 306
	value = ((uint32_t)input[36] << 24) |
			((uint32_t)input[37] << 16) |
			((uint32_t)(input[38] & 0xe0) << 8);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 307 to 325
	value = ((uint32_t)(input[38] & 0x1f) << 27) |
			((uint32_t)input[39] << 19) |
			((uint32_t)(input[40] & 0xfc) << 11);
	output[16] = (double)(value >> 13);
}

static void unpack_17_19bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 19-bit signed
	// Skip 4 bits, read 323 bits of data.
	// Input must be at least 41 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 289 to 307
	value = ((uint32_t)(input[36] & 0x7f) << 25) |
			((uint32_t)input[37] << 17) |
			((uint32_t)(input[38] & 0xf0) << 9);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 308 to 326
	value = ((uint32_t)(input[38] & 0x0f) << 28) |
			((uint32_t)input[39] << 20) |
			((uint32_t)(input[40] & 0xfe) << 12);
	output[16] = (double)(value >> 13);
}

static void unpack_17_19bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 19-bit unsigned
	// Skip 4 bits, read 323 bits of data.
	// Input must be at least 41 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 289 to 307
	value = ((uint32_t)(input[36] & 0x7f) << 25) |
			((uint32_t)input[37] << 17) |
			((uint32_t)(input[38] & 0xf0) << 9);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 308 to 326
	value = ((uint32_t)(input[38] & 0x0f) << 28) |
			((uint32_t)input[39] << 20) |
			((uint32_t)(input[40] & 0xfe) << 12);
	output[16] = (double)(value >> 13);
}

static void unpack_17_19bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 19-bit signed
	// Skip 5 bits, read 323 bits of data.
	// Input must be at least 41 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 290 to 308
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)(input[38] & 0xf8) << 10);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 309 to 327
	value = ((uint32_t)(input[38] & 0x07) << 29) |
			((uint32_t)input[39] << 21) |
			((uint32_t)input[40] << 13);
	output[16] = (double)(value >> 13);
}

static void unpack_17_19bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 19-bit unsigned
	// Skip 5 bits, read 323 bits of data.
	// Input must be at least 41 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 290 to 308
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)(input[38] & 0xf8) << 10);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 309 to 327
	value = ((uint32_t)(input[38] & 0x07) << 29) |
			((uint32_t)input[39] << 21) |
			((uint32_t)input[40] << 13);
	output[16] = (double)(value >> 13);
}

static void unpack_17_19bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 19-bit signed
	// Skip 6 bits, read 323 bits of data.
	// Input must be at least 42 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 291 to 309
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)(input[38] & 0xfc) << 11);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 310 to 328
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)(input[41] & 0x80) << 6);
	output[16] = (double)(value >> 13);
}

static void unpack_17_19bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 19-bit unsigned
	// Skip 6 bits, read 323 bits of data.
	// Input must be at least 42 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 291 to 309
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)(input[38] & 0xfc) << 11);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 310 to 328
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)(input[41] & 0x80) << 6);
	output[16] = (double)(value >> 13);
}

static void unpack_17_19bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 19-bit signed
	// Skip 7 bits, read 323 bits of data.
	// Input must be at least 42 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 292 to 310
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)(input[38] & 0xfe) << 12);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 311 to 329
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)(input[41] & 0xc0) << 7);
	output[16] = (double)(value >> 13);
}

static void unpack_17_19bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 17 values into output
	// Values are 19-bit unsigned
	// Skip 7 bits, read 323 bits of data.
	// Input must be at least 42 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 292 to 310
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)(input[38] & 0xfe) << 12);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 311 to 329
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)(input[41] & 0xc0) << 7);
	output[16] = (double)(value >> 13);
}

static void unpack_18_19bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 19-bit signed
	// Skip 0 bits, read 342 bits of data.
	// Input must be at least 43 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 285 to 303
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 304 to 322
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)(input[40] & 0xe0) << 8);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 323 to 341
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)(input[42] & 0xfc) << 11);
	output[17] = (double)(value >> 13);
}

static void unpack_18_19bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 19-bit unsigned
	// Skip 0 bits, read 342 bits of data.
	// Input must be at least 43 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 285 to 303
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 304 to 322
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)(input[40] & 0xe0) << 8);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 323 to 341
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)(input[42] & 0xfc) << 11);
	output[17] = (double)(value >> 13);
}

static void unpack_18_19bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 19-bit signed
	// Skip 1 bits, read 342 bits of data.
	// Input must be at least 43 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 286 to 304
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)(input[38] & 0x80) << 6);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 305 to 323
	value = ((uint32_t)(input[38] & 0x7f) << 25) |
			((uint32_t)input[39] << 17) |
			((uint32_t)(input[40] & 0xf0) << 9);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 324 to 342
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)(input[42] & 0xfe) << 12);
	output[17] = (double)(value >> 13);
}

static void unpack_18_19bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 19-bit unsigned
	// Skip 1 bits, read 342 bits of data.
	// Input must be at least 43 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 286 to 304
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)(input[38] & 0x80) << 6);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 305 to 323
	value = ((uint32_t)(input[38] & 0x7f) << 25) |
			((uint32_t)input[39] << 17) |
			((uint32_t)(input[40] & 0xf0) << 9);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 324 to 342
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)(input[42] & 0xfe) << 12);
	output[17] = (double)(value >> 13);
}

static void unpack_18_19bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 19-bit signed
	// Skip 2 bits, read 342 bits of data.
	// Input must be at least 43 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 287 to 305
	value = ((uint32_t)(input[35] & 0x01) << 31) |
			((uint32_t)input[36] << 23) |
			((uint32_t)input[37] << 15) |
			((uint32_t)(input[38] & 0xc0) << 7);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 306 to 324
	value = ((uint32_t)(input[38] & 0x3f) << 26) |
			((uint32_t)input[39] << 18) |
			((uint32_t)(input[40] & 0xf8) << 10);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 325 to 343
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13);
	output[17] = (double)(value >> 13);
}

static void unpack_18_19bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 19-bit unsigned
	// Skip 2 bits, read 342 bits of data.
	// Input must be at least 43 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 287 to 305
	value = ((uint32_t)(input[35] & 0x01) << 31) |
			((uint32_t)input[36] << 23) |
			((uint32_t)input[37] << 15) |
			((uint32_t)(input[38] & 0xc0) << 7);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 306 to 324
	value = ((uint32_t)(input[38] & 0x3f) << 26) |
			((uint32_t)input[39] << 18) |
			((uint32_t)(input[40] & 0xf8) << 10);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 325 to 343
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13);
	output[17] = (double)(value >> 13);
}

static void unpack_18_19bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 19-bit signed
	// Skip 3 bits, read 342 bits of data.
	// Input must be at least 44 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 288 to 306
	value = ((uint32_t)input[36] << 24) |
			((uint32_t)input[37] << 16) |
			((uint32_t)(input[38] & 0xe0) << 8);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 307 to 325
	value = ((uint32_t)(input[38] & 0x1f) << 27) |
			((uint32_t)input[39] << 19) |
			((uint32_t)(input[40] & 0xfc) << 11);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 326 to 344
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)(input[43] & 0x80) << 6);
	output[17] = (double)(value >> 13);
}

static void unpack_18_19bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 19-bit unsigned
	// Skip 3 bits, read 342 bits of data.
	// Input must be at least 44 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 288 to 306
	value = ((uint32_t)input[36] << 24) |
			((uint32_t)input[37] << 16) |
			((uint32_t)(input[38] & 0xe0) << 8);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 307 to 325
	value = ((uint32_t)(input[38] & 0x1f) << 27) |
			((uint32_t)input[39] << 19) |
			((uint32_t)(input[40] & 0xfc) << 11);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 326 to 344
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)(input[43] & 0x80) << 6);
	output[17] = (double)(value >> 13);
}

static void unpack_18_19bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 19-bit signed
	// Skip 4 bits, read 342 bits of data.
	// Input must be at least 44 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 289 to 307
	value = ((uint32_t)(input[36] & 0x7f) << 25) |
			((uint32_t)input[37] << 17) |
			((uint32_t)(input[38] & 0xf0) << 9);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 308 to 326
	value = ((uint32_t)(input[38] & 0x0f) << 28) |
			((uint32_t)input[39] << 20) |
			((uint32_t)(input[40] & 0xfe) << 12);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 327 to 345
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)(input[43] & 0xc0) << 7);
	output[17] = (double)(value >> 13);
}

static void unpack_18_19bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 19-bit unsigned
	// Skip 4 bits, read 342 bits of data.
	// Input must be at least 44 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 289 to 307
	value = ((uint32_t)(input[36] & 0x7f) << 25) |
			((uint32_t)input[37] << 17) |
			((uint32_t)(input[38] & 0xf0) << 9);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 308 to 326
	value = ((uint32_t)(input[38] & 0x0f) << 28) |
			((uint32_t)input[39] << 20) |
			((uint32_t)(input[40] & 0xfe) << 12);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 327 to 345
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)(input[43] & 0xc0) << 7);
	output[17] = (double)(value >> 13);
}

static void unpack_18_19bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 19-bit signed
	// Skip 5 bits, read 342 bits of data.
	// Input must be at least 44 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 290 to 308
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)(input[38] & 0xf8) << 10);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 309 to 327
	value = ((uint32_t)(input[38] & 0x07) << 29) |
			((uint32_t)input[39] << 21) |
			((uint32_t)input[40] << 13);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 328 to 346
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)(input[43] & 0xe0) << 8);
	output[17] = (double)(value >> 13);
}

static void unpack_18_19bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 19-bit unsigned
	// Skip 5 bits, read 342 bits of data.
	// Input must be at least 44 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 290 to 308
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)(input[38] & 0xf8) << 10);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 309 to 327
	value = ((uint32_t)(input[38] & 0x07) << 29) |
			((uint32_t)input[39] << 21) |
			((uint32_t)input[40] << 13);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 328 to 346
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)(input[43] & 0xe0) << 8);
	output[17] = (double)(value >> 13);
}

static void unpack_18_19bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 19-bit signed
	// Skip 6 bits, read 342 bits of data.
	// Input must be at least 44 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 291 to 309
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)(input[38] & 0xfc) << 11);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 310 to 328
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)(input[41] & 0x80) << 6);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 329 to 347
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)(input[43] & 0xf0) << 9);
	output[17] = (double)(value >> 13);
}

static void unpack_18_19bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 19-bit unsigned
	// Skip 6 bits, read 342 bits of data.
	// Input must be at least 44 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 291 to 309
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)(input[38] & 0xfc) << 11);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 310 to 328
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)(input[41] & 0x80) << 6);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 329 to 347
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)(input[43] & 0xf0) << 9);
	output[17] = (double)(value >> 13);
}

static void unpack_18_19bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 19-bit signed
	// Skip 7 bits, read 342 bits of data.
	// Input must be at least 44 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 292 to 310
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)(input[38] & 0xfe) << 12);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 311 to 329
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)(input[41] & 0xc0) << 7);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 330 to 348
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)(input[43] & 0xf8) << 10);
	output[17] = (double)(value >> 13);
}

static void unpack_18_19bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 18 values into output
	// Values are 19-bit unsigned
	// Skip 7 bits, read 342 bits of data.
	// Input must be at least 44 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 292 to 310
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)(input[38] & 0xfe) << 12);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 311 to 329
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)(input[41] & 0xc0) << 7);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 330 to 348
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)(input[43] & 0xf8) << 10);
	output[17] = (double)(value >> 13);
}

static void unpack_19_19bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 19 values into output
	// Values are 19-bit signed
	// Skip 0 bits, read 361 bits of data.
	// Input must be at least 46 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 285 to 303
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 304 to 322
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)(input[40] & 0xe0) << 8);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 323 to 341
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)(input[42] & 0xfc) << 11);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 342 to 360
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)(input[45] & 0x80) << 6);
	output[18] = (double)(value >> 13);
}

static void unpack_19_19bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 19 values into output
	// Values are 19-bit unsigned
	// Skip 0 bits, read 361 bits of data.
	// Input must be at least 46 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 285 to 303
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 304 to 322
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)(input[40] & 0xe0) << 8);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 323 to 341
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)(input[42] & 0xfc) << 11);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 342 to 360
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)(input[45] & 0x80) << 6);
	output[18] = (double)(value >> 13);
}

static void unpack_19_19bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 19 values into output
	// Values are 19-bit signed
	// Skip 1 bits, read 361 bits of data.
	// Input must be at least 46 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 286 to 304
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)(input[38] & 0x80) << 6);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 305 to 323
	value = ((uint32_t)(input[38] & 0x7f) << 25) |
			((uint32_t)input[39] << 17) |
			((uint32_t)(input[40] & 0xf0) << 9);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 324 to 342
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)(input[42] & 0xfe) << 12);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 343 to 361
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)(input[45] & 0xc0) << 7);
	output[18] = (double)(value >> 13);
}

static void unpack_19_19bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 19 values into output
	// Values are 19-bit unsigned
	// Skip 1 bits, read 361 bits of data.
	// Input must be at least 46 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 286 to 304
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)(input[38] & 0x80) << 6);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 305 to 323
	value = ((uint32_t)(input[38] & 0x7f) << 25) |
			((uint32_t)input[39] << 17) |
			((uint32_t)(input[40] & 0xf0) << 9);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 324 to 342
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)(input[42] & 0xfe) << 12);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 343 to 361
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)(input[45] & 0xc0) << 7);
	output[18] = (double)(value >> 13);
}

static void unpack_19_19bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 19 values into output
	// Values are 19-bit signed
	// Skip 2 bits, read 361 bits of data.
	// Input must be at least 46 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 287 to 305
	value = ((uint32_t)(input[35] & 0x01) << 31) |
			((uint32_t)input[36] << 23) |
			((uint32_t)input[37] << 15) |
			((uint32_t)(input[38] & 0xc0) << 7);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 306 to 324
	value = ((uint32_t)(input[38] & 0x3f) << 26) |
			((uint32_t)input[39] << 18) |
			((uint32_t)(input[40] & 0xf8) << 10);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 325 to 343
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 344 to 362
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)(input[45] & 0xe0) << 8);
	output[18] = (double)(value >> 13);
}

static void unpack_19_19bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 19 values into output
	// Values are 19-bit unsigned
	// Skip 2 bits, read 361 bits of data.
	// Input must be at least 46 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 287 to 305
	value = ((uint32_t)(input[35] & 0x01) << 31) |
			((uint32_t)input[36] << 23) |
			((uint32_t)input[37] << 15) |
			((uint32_t)(input[38] & 0xc0) << 7);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 306 to 324
	value = ((uint32_t)(input[38] & 0x3f) << 26) |
			((uint32_t)input[39] << 18) |
			((uint32_t)(input[40] & 0xf8) << 10);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 325 to 343
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 344 to 362
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)(input[45] & 0xe0) << 8);
	output[18] = (double)(value >> 13);
}

static void unpack_19_19bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 19 values into output
	// Values are 19-bit signed
	// Skip 3 bits, read 361 bits of data.
	// Input must be at least 46 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 288 to 306
	value = ((uint32_t)input[36] << 24) |
			((uint32_t)input[37] << 16) |
			((uint32_t)(input[38] & 0xe0) << 8);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 307 to 325
	value = ((uint32_t)(input[38] & 0x1f) << 27) |
			((uint32_t)input[39] << 19) |
			((uint32_t)(input[40] & 0xfc) << 11);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 326 to 344
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)(input[43] & 0x80) << 6);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 345 to 363
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)(input[45] & 0xf0) << 9);
	output[18] = (double)(value >> 13);
}

static void unpack_19_19bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 19 values into output
	// Values are 19-bit unsigned
	// Skip 3 bits, read 361 bits of data.
	// Input must be at least 46 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 288 to 306
	value = ((uint32_t)input[36] << 24) |
			((uint32_t)input[37] << 16) |
			((uint32_t)(input[38] & 0xe0) << 8);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 307 to 325
	value = ((uint32_t)(input[38] & 0x1f) << 27) |
			((uint32_t)input[39] << 19) |
			((uint32_t)(input[40] & 0xfc) << 11);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 326 to 344
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)(input[43] & 0x80) << 6);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 345 to 363
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)(input[45] & 0xf0) << 9);
	output[18] = (double)(value >> 13);
}

static void unpack_19_19bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 19 values into output
	// Values are 19-bit signed
	// Skip 4 bits, read 361 bits of data.
	// Input must be at least 46 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 289 to 307
	value = ((uint32_t)(input[36] & 0x7f) << 25) |
			((uint32_t)input[37] << 17) |
			((uint32_t)(input[38] & 0xf0) << 9);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 308 to 326
	value = ((uint32_t)(input[38] & 0x0f) << 28) |
			((uint32_t)input[39] << 20) |
			((uint32_t)(input[40] & 0xfe) << 12);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 327 to 345
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)(input[43] & 0xc0) << 7);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 346 to 364
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)(input[45] & 0xf8) << 10);
	output[18] = (double)(value >> 13);
}

static void unpack_19_19bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 19 values into output
	// Values are 19-bit unsigned
	// Skip 4 bits, read 361 bits of data.
	// Input must be at least 46 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 289 to 307
	value = ((uint32_t)(input[36] & 0x7f) << 25) |
			((uint32_t)input[37] << 17) |
			((uint32_t)(input[38] & 0xf0) << 9);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 308 to 326
	value = ((uint32_t)(input[38] & 0x0f) << 28) |
			((uint32_t)input[39] << 20) |
			((uint32_t)(input[40] & 0xfe) << 12);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 327 to 345
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)(input[43] & 0xc0) << 7);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 346 to 364
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)(input[45] & 0xf8) << 10);
	output[18] = (double)(value >> 13);
}

static void unpack_19_19bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 19 values into output
	// Values are 19-bit signed
	// Skip 5 bits, read 361 bits of data.
	// Input must be at least 46 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 290 to 308
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)(input[38] & 0xf8) << 10);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 309 to 327
	value = ((uint32_t)(input[38] & 0x07) << 29) |
			((uint32_t)input[39] << 21) |
			((uint32_t)input[40] << 13);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 328 to 346
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)(input[43] & 0xe0) << 8);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 347 to 365
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)(input[45] & 0xfc) << 11);
	output[18] = (double)(value >> 13);
}

static void unpack_19_19bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 19 values into output
	// Values are 19-bit unsigned
	// Skip 5 bits, read 361 bits of data.
	// Input must be at least 46 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 290 to 308
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)(input[38] & 0xf8) << 10);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 309 to 327
	value = ((uint32_t)(input[38] & 0x07) << 29) |
			((uint32_t)input[39] << 21) |
			((uint32_t)input[40] << 13);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 328 to 346
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)(input[43] & 0xe0) << 8);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 347 to 365
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)(input[45] & 0xfc) << 11);
	output[18] = (double)(value >> 13);
}

static void unpack_19_19bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 19 values into output
	// Values are 19-bit signed
	// Skip 6 bits, read 361 bits of data.
	// Input must be at least 46 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 291 to 309
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)(input[38] & 0xfc) << 11);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 310 to 328
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)(input[41] & 0x80) << 6);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 329 to 347
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)(input[43] & 0xf0) << 9);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 348 to 366
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)(input[45] & 0xfe) << 12);
	output[18] = (double)(value >> 13);
}

static void unpack_19_19bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 19 values into output
	// Values are 19-bit unsigned
	// Skip 6 bits, read 361 bits of data.
	// Input must be at least 46 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 291 to 309
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)(input[38] & 0xfc) << 11);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 310 to 328
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)(input[41] & 0x80) << 6);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 329 to 347
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)(input[43] & 0xf0) << 9);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 348 to 366
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)(input[45] & 0xfe) << 12);
	output[18] = (double)(value >> 13);
}

static void unpack_19_19bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 19 values into output
	// Values are 19-bit signed
	// Skip 7 bits, read 361 bits of data.
	// Input must be at least 46 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 292 to 310
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)(input[38] & 0xfe) << 12);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 311 to 329
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)(input[41] & 0xc0) << 7);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 330 to 348
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)(input[43] & 0xf8) << 10);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 349 to 367
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13);
	output[18] = (double)(value >> 13);
}

static void unpack_19_19bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 19 values into output
	// Values are 19-bit unsigned
	// Skip 7 bits, read 361 bits of data.
	// Input must be at least 46 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 292 to 310
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)(input[38] & 0xfe) << 12);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 311 to 329
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)(input[41] & 0xc0) << 7);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 330 to 348
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)(input[43] & 0xf8) << 10);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 349 to 367
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13);
	output[18] = (double)(value >> 13);
}

static void unpack_20_19bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 20 values into output
	// Values are 19-bit signed
	// Skip 0 bits, read 380 bits of data.
	// Input must be at least 48 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 285 to 303
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 304 to 322
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)(input[40] & 0xe0) << 8);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 323 to 341
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)(input[42] & 0xfc) << 11);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 342 to 360
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)(input[45] & 0x80) << 6);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 361 to 379
	value = ((uint32_t)(input[45] & 0x7f) << 25) |
			((uint32_t)input[46] << 17) |
			((uint32_t)(input[47] & 0xf0) << 9);
	output[19] = (double)(value >> 13);
}

static void unpack_20_19bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 20 values into output
	// Values are 19-bit unsigned
	// Skip 0 bits, read 380 bits of data.
	// Input must be at least 48 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 285 to 303
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 304 to 322
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)(input[40] & 0xe0) << 8);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 323 to 341
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)(input[42] & 0xfc) << 11);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 342 to 360
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)(input[45] & 0x80) << 6);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 361 to 379
	value = ((uint32_t)(input[45] & 0x7f) << 25) |
			((uint32_t)input[46] << 17) |
			((uint32_t)(input[47] & 0xf0) << 9);
	output[19] = (double)(value >> 13);
}

static void unpack_20_19bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 20 values into output
	// Values are 19-bit signed
	// Skip 1 bits, read 380 bits of data.
	// Input must be at least 48 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 286 to 304
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)(input[38] & 0x80) << 6);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 305 to 323
	value = ((uint32_t)(input[38] & 0x7f) << 25) |
			((uint32_t)input[39] << 17) |
			((uint32_t)(input[40] & 0xf0) << 9);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 324 to 342
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)(input[42] & 0xfe) << 12);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 343 to 361
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)(input[45] & 0xc0) << 7);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 362 to 380
	value = ((uint32_t)(input[45] & 0x3f) << 26) |
			((uint32_t)input[46] << 18) |
			((uint32_t)(input[47] & 0xf8) << 10);
	output[19] = (double)(value >> 13);
}

static void unpack_20_19bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 20 values into output
	// Values are 19-bit unsigned
	// Skip 1 bits, read 380 bits of data.
	// Input must be at least 48 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 286 to 304
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)(input[38] & 0x80) << 6);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 305 to 323
	value = ((uint32_t)(input[38] & 0x7f) << 25) |
			((uint32_t)input[39] << 17) |
			((uint32_t)(input[40] & 0xf0) << 9);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 324 to 342
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)(input[42] & 0xfe) << 12);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 343 to 361
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)(input[45] & 0xc0) << 7);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 362 to 380
	value = ((uint32_t)(input[45] & 0x3f) << 26) |
			((uint32_t)input[46] << 18) |
			((uint32_t)(input[47] & 0xf8) << 10);
	output[19] = (double)(value >> 13);
}

static void unpack_20_19bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 20 values into output
	// Values are 19-bit signed
	// Skip 2 bits, read 380 bits of data.
	// Input must be at least 48 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 287 to 305
	value = ((uint32_t)(input[35] & 0x01) << 31) |
			((uint32_t)input[36] << 23) |
			((uint32_t)input[37] << 15) |
			((uint32_t)(input[38] & 0xc0) << 7);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 306 to 324
	value = ((uint32_t)(input[38] & 0x3f) << 26) |
			((uint32_t)input[39] << 18) |
			((uint32_t)(input[40] & 0xf8) << 10);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 325 to 343
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 344 to 362
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)(input[45] & 0xe0) << 8);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 363 to 381
	value = ((uint32_t)(input[45] & 0x1f) << 27) |
			((uint32_t)input[46] << 19) |
			((uint32_t)(input[47] & 0xfc) << 11);
	output[19] = (double)(value >> 13);
}

static void unpack_20_19bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 20 values into output
	// Values are 19-bit unsigned
	// Skip 2 bits, read 380 bits of data.
	// Input must be at least 48 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 287 to 305
	value = ((uint32_t)(input[35] & 0x01) << 31) |
			((uint32_t)input[36] << 23) |
			((uint32_t)input[37] << 15) |
			((uint32_t)(input[38] & 0xc0) << 7);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 306 to 324
	value = ((uint32_t)(input[38] & 0x3f) << 26) |
			((uint32_t)input[39] << 18) |
			((uint32_t)(input[40] & 0xf8) << 10);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 325 to 343
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 344 to 362
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)(input[45] & 0xe0) << 8);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 363 to 381
	value = ((uint32_t)(input[45] & 0x1f) << 27) |
			((uint32_t)input[46] << 19) |
			((uint32_t)(input[47] & 0xfc) << 11);
	output[19] = (double)(value >> 13);
}

static void unpack_20_19bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 20 values into output
	// Values are 19-bit signed
	// Skip 3 bits, read 380 bits of data.
	// Input must be at least 48 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 288 to 306
	value = ((uint32_t)input[36] << 24) |
			((uint32_t)input[37] << 16) |
			((uint32_t)(input[38] & 0xe0) << 8);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 307 to 325
	value = ((uint32_t)(input[38] & 0x1f) << 27) |
			((uint32_t)input[39] << 19) |
			((uint32_t)(input[40] & 0xfc) << 11);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 326 to 344
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)(input[43] & 0x80) << 6);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 345 to 363
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)(input[45] & 0xf0) << 9);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 364 to 382
	value = ((uint32_t)(input[45] & 0x0f) << 28) |
			((uint32_t)input[46] << 20) |
			((uint32_t)(input[47] & 0xfe) << 12);
	output[19] = (double)(value >> 13);
}

static void unpack_20_19bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 20 values into output
	// Values are 19-bit unsigned
	// Skip 3 bits, read 380 bits of data.
	// Input must be at least 48 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 288 to 306
	value = ((uint32_t)input[36] << 24) |
			((uint32_t)input[37] << 16) |
			((uint32_t)(input[38] & 0xe0) << 8);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 307 to 325
	value = ((uint32_t)(input[38] & 0x1f) << 27) |
			((uint32_t)input[39] << 19) |
			((uint32_t)(input[40] & 0xfc) << 11);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 326 to 344
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)(input[43] & 0x80) << 6);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 345 to 363
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)(input[45] & 0xf0) << 9);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 364 to 382
	value = ((uint32_t)(input[45] & 0x0f) << 28) |
			((uint32_t)input[46] << 20) |
			((uint32_t)(input[47] & 0xfe) << 12);
	output[19] = (double)(value >> 13);
}

static void unpack_20_19bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 20 values into output
	// Values are 19-bit signed
	// Skip 4 bits, read 380 bits of data.
	// Input must be at least 48 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 289 to 307
	value = ((uint32_t)(input[36] & 0x7f) << 25) |
			((uint32_t)input[37] << 17) |
			((uint32_t)(input[38] & 0xf0) << 9);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 308 to 326
	value = ((uint32_t)(input[38] & 0x0f) << 28) |
			((uint32_t)input[39] << 20) |
			((uint32_t)(input[40] & 0xfe) << 12);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 327 to 345
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)(input[43] & 0xc0) << 7);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 346 to 364
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)(input[45] & 0xf8) << 10);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 365 to 383
	value = ((uint32_t)(input[45] & 0x07) << 29) |
			((uint32_t)input[46] << 21) |
			((uint32_t)input[47] << 13);
	output[19] = (double)(value >> 13);
}

static void unpack_20_19bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 20 values into output
	// Values are 19-bit unsigned
	// Skip 4 bits, read 380 bits of data.
	// Input must be at least 48 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 289 to 307
	value = ((uint32_t)(input[36] & 0x7f) << 25) |
			((uint32_t)input[37] << 17) |
			((uint32_t)(input[38] & 0xf0) << 9);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 308 to 326
	value = ((uint32_t)(input[38] & 0x0f) << 28) |
			((uint32_t)input[39] << 20) |
			((uint32_t)(input[40] & 0xfe) << 12);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 327 to 345
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)(input[43] & 0xc0) << 7);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 346 to 364
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)(input[45] & 0xf8) << 10);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 365 to 383
	value = ((uint32_t)(input[45] & 0x07) << 29) |
			((uint32_t)input[46] << 21) |
			((uint32_t)input[47] << 13);
	output[19] = (double)(value >> 13);
}

static void unpack_20_19bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 20 values into output
	// Values are 19-bit signed
	// Skip 5 bits, read 380 bits of data.
	// Input must be at least 49 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 290 to 308
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)(input[38] & 0xf8) << 10);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 309 to 327
	value = ((uint32_t)(input[38] & 0x07) << 29) |
			((uint32_t)input[39] << 21) |
			((uint32_t)input[40] << 13);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 328 to 346
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)(input[43] & 0xe0) << 8);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 347 to 365
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)(input[45] & 0xfc) << 11);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 366 to 384
	value = ((uint32_t)(input[45] & 0x03) << 30) |
			((uint32_t)input[46] << 22) |
			((uint32_t)input[47] << 14) |
			((uint32_t)(input[48] & 0x80) << 6);
	output[19] = (double)(value >> 13);
}

static void unpack_20_19bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 20 values into output
	// Values are 19-bit unsigned
	// Skip 5 bits, read 380 bits of data.
	// Input must be at least 49 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 290 to 308
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)(input[38] & 0xf8) << 10);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 309 to 327
	value = ((uint32_t)(input[38] & 0x07) << 29) |
			((uint32_t)input[39] << 21) |
			((uint32_t)input[40] << 13);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 328 to 346
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)(input[43] & 0xe0) << 8);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 347 to 365
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)(input[45] & 0xfc) << 11);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 366 to 384
	value = ((uint32_t)(input[45] & 0x03) << 30) |
			((uint32_t)input[46] << 22) |
			((uint32_t)input[47] << 14) |
			((uint32_t)(input[48] & 0x80) << 6);
	output[19] = (double)(value >> 13);
}

static void unpack_20_19bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 20 values into output
	// Values are 19-bit signed
	// Skip 6 bits, read 380 bits of data.
	// Input must be at least 49 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 291 to 309
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)(input[38] & 0xfc) << 11);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 310 to 328
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)(input[41] & 0x80) << 6);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 329 to 347
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)(input[43] & 0xf0) << 9);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 348 to 366
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)(input[45] & 0xfe) << 12);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 367 to 385
	value = ((uint32_t)(input[45] & 0x01) << 31) |
			((uint32_t)input[46] << 23) |
			((uint32_t)input[47] << 15) |
			((uint32_t)(input[48] & 0xc0) << 7);
	output[19] = (double)(value >> 13);
}

static void unpack_20_19bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 20 values into output
	// Values are 19-bit unsigned
	// Skip 6 bits, read 380 bits of data.
	// Input must be at least 49 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 291 to 309
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)(input[38] & 0xfc) << 11);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 310 to 328
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)(input[41] & 0x80) << 6);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 329 to 347
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)(input[43] & 0xf0) << 9);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 348 to 366
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)(input[45] & 0xfe) << 12);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 367 to 385
	value = ((uint32_t)(input[45] & 0x01) << 31) |
			((uint32_t)input[46] << 23) |
			((uint32_t)input[47] << 15) |
			((uint32_t)(input[48] & 0xc0) << 7);
	output[19] = (double)(value >> 13);
}

static void unpack_20_19bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 20 values into output
	// Values are 19-bit signed
	// Skip 7 bits, read 380 bits of data.
	// Input must be at least 49 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 292 to 310
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)(input[38] & 0xfe) << 12);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 311 to 329
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)(input[41] & 0xc0) << 7);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 330 to 348
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)(input[43] & 0xf8) << 10);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 349 to 367
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 368 to 386
	value = ((uint32_t)input[46] << 24) |
			((uint32_t)input[47] << 16) |
			((uint32_t)(input[48] & 0xe0) << 8);
	output[19] = (double)(value >> 13);
}

static void unpack_20_19bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 20 values into output
	// Values are 19-bit unsigned
	// Skip 7 bits, read 380 bits of data.
	// Input must be at least 49 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 292 to 310
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)(input[38] & 0xfe) << 12);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 311 to 329
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)(input[41] & 0xc0) << 7);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 330 to 348
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)(input[43] & 0xf8) << 10);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 349 to 367
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 368 to 386
	value = ((uint32_t)input[46] << 24) |
			((uint32_t)input[47] << 16) |
			((uint32_t)(input[48] & 0xe0) << 8);
	output[19] = (double)(value >> 13);
}

static void unpack_21_19bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 21 values into output
	// Values are 19-bit signed
	// Skip 0 bits, read 399 bits of data.
	// Input must be at least 50 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 285 to 303
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 304 to 322
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)(input[40] & 0xe0) << 8);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 323 to 341
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)(input[42] & 0xfc) << 11);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 342 to 360
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)(input[45] & 0x80) << 6);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 361 to 379
	value = ((uint32_t)(input[45] & 0x7f) << 25) |
			((uint32_t)input[46] << 17) |
			((uint32_t)(input[47] & 0xf0) << 9);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 380 to 398
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)(input[49] & 0xfe) << 12);
	output[20] = (double)(value >> 13);
}

static void unpack_21_19bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 21 values into output
	// Values are 19-bit unsigned
	// Skip 0 bits, read 399 bits of data.
	// Input must be at least 50 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 285 to 303
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 304 to 322
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)(input[40] & 0xe0) << 8);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 323 to 341
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)(input[42] & 0xfc) << 11);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 342 to 360
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)(input[45] & 0x80) << 6);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 361 to 379
	value = ((uint32_t)(input[45] & 0x7f) << 25) |
			((uint32_t)input[46] << 17) |
			((uint32_t)(input[47] & 0xf0) << 9);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 380 to 398
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)(input[49] & 0xfe) << 12);
	output[20] = (double)(value >> 13);
}

static void unpack_21_19bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 21 values into output
	// Values are 19-bit signed
	// Skip 1 bits, read 399 bits of data.
	// Input must be at least 50 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 286 to 304
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)(input[38] & 0x80) << 6);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 305 to 323
	value = ((uint32_t)(input[38] & 0x7f) << 25) |
			((uint32_t)input[39] << 17) |
			((uint32_t)(input[40] & 0xf0) << 9);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 324 to 342
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)(input[42] & 0xfe) << 12);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 343 to 361
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)(input[45] & 0xc0) << 7);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 362 to 380
	value = ((uint32_t)(input[45] & 0x3f) << 26) |
			((uint32_t)input[46] << 18) |
			((uint32_t)(input[47] & 0xf8) << 10);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 381 to 399
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13);
	output[20] = (double)(value >> 13);
}

static void unpack_21_19bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 21 values into output
	// Values are 19-bit unsigned
	// Skip 1 bits, read 399 bits of data.
	// Input must be at least 50 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 286 to 304
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)(input[38] & 0x80) << 6);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 305 to 323
	value = ((uint32_t)(input[38] & 0x7f) << 25) |
			((uint32_t)input[39] << 17) |
			((uint32_t)(input[40] & 0xf0) << 9);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 324 to 342
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)(input[42] & 0xfe) << 12);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 343 to 361
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)(input[45] & 0xc0) << 7);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 362 to 380
	value = ((uint32_t)(input[45] & 0x3f) << 26) |
			((uint32_t)input[46] << 18) |
			((uint32_t)(input[47] & 0xf8) << 10);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 381 to 399
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13);
	output[20] = (double)(value >> 13);
}

static void unpack_21_19bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 21 values into output
	// Values are 19-bit signed
	// Skip 2 bits, read 399 bits of data.
	// Input must be at least 51 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 287 to 305
	value = ((uint32_t)(input[35] & 0x01) << 31) |
			((uint32_t)input[36] << 23) |
			((uint32_t)input[37] << 15) |
			((uint32_t)(input[38] & 0xc0) << 7);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 306 to 324
	value = ((uint32_t)(input[38] & 0x3f) << 26) |
			((uint32_t)input[39] << 18) |
			((uint32_t)(input[40] & 0xf8) << 10);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 325 to 343
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 344 to 362
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)(input[45] & 0xe0) << 8);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 363 to 381
	value = ((uint32_t)(input[45] & 0x1f) << 27) |
			((uint32_t)input[46] << 19) |
			((uint32_t)(input[47] & 0xfc) << 11);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 382 to 400
	value = ((uint32_t)(input[47] & 0x03) << 30) |
			((uint32_t)input[48] << 22) |
			((uint32_t)input[49] << 14) |
			((uint32_t)(input[50] & 0x80) << 6);
	output[20] = (double)(value >> 13);
}

static void unpack_21_19bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 21 values into output
	// Values are 19-bit unsigned
	// Skip 2 bits, read 399 bits of data.
	// Input must be at least 51 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 287 to 305
	value = ((uint32_t)(input[35] & 0x01) << 31) |
			((uint32_t)input[36] << 23) |
			((uint32_t)input[37] << 15) |
			((uint32_t)(input[38] & 0xc0) << 7);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 306 to 324
	value = ((uint32_t)(input[38] & 0x3f) << 26) |
			((uint32_t)input[39] << 18) |
			((uint32_t)(input[40] & 0xf8) << 10);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 325 to 343
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 344 to 362
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)(input[45] & 0xe0) << 8);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 363 to 381
	value = ((uint32_t)(input[45] & 0x1f) << 27) |
			((uint32_t)input[46] << 19) |
			((uint32_t)(input[47] & 0xfc) << 11);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 382 to 400
	value = ((uint32_t)(input[47] & 0x03) << 30) |
			((uint32_t)input[48] << 22) |
			((uint32_t)input[49] << 14) |
			((uint32_t)(input[50] & 0x80) << 6);
	output[20] = (double)(value >> 13);
}

static void unpack_21_19bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 21 values into output
	// Values are 19-bit signed
	// Skip 3 bits, read 399 bits of data.
	// Input must be at least 51 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 288 to 306
	value = ((uint32_t)input[36] << 24) |
			((uint32_t)input[37] << 16) |
			((uint32_t)(input[38] & 0xe0) << 8);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 307 to 325
	value = ((uint32_t)(input[38] & 0x1f) << 27) |
			((uint32_t)input[39] << 19) |
			((uint32_t)(input[40] & 0xfc) << 11);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 326 to 344
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)(input[43] & 0x80) << 6);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 345 to 363
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)(input[45] & 0xf0) << 9);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 364 to 382
	value = ((uint32_t)(input[45] & 0x0f) << 28) |
			((uint32_t)input[46] << 20) |
			((uint32_t)(input[47] & 0xfe) << 12);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 383 to 401
	value = ((uint32_t)(input[47] & 0x01) << 31) |
			((uint32_t)input[48] << 23) |
			((uint32_t)input[49] << 15) |
			((uint32_t)(input[50] & 0xc0) << 7);
	output[20] = (double)(value >> 13);
}

static void unpack_21_19bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 21 values into output
	// Values are 19-bit unsigned
	// Skip 3 bits, read 399 bits of data.
	// Input must be at least 51 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 288 to 306
	value = ((uint32_t)input[36] << 24) |
			((uint32_t)input[37] << 16) |
			((uint32_t)(input[38] & 0xe0) << 8);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 307 to 325
	value = ((uint32_t)(input[38] & 0x1f) << 27) |
			((uint32_t)input[39] << 19) |
			((uint32_t)(input[40] & 0xfc) << 11);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 326 to 344
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)(input[43] & 0x80) << 6);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 345 to 363
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)(input[45] & 0xf0) << 9);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 364 to 382
	value = ((uint32_t)(input[45] & 0x0f) << 28) |
			((uint32_t)input[46] << 20) |
			((uint32_t)(input[47] & 0xfe) << 12);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 383 to 401
	value = ((uint32_t)(input[47] & 0x01) << 31) |
			((uint32_t)input[48] << 23) |
			((uint32_t)input[49] << 15) |
			((uint32_t)(input[50] & 0xc0) << 7);
	output[20] = (double)(value >> 13);
}

static void unpack_21_19bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 21 values into output
	// Values are 19-bit signed
	// Skip 4 bits, read 399 bits of data.
	// Input must be at least 51 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 289 to 307
	value = ((uint32_t)(input[36] & 0x7f) << 25) |
			((uint32_t)input[37] << 17) |
			((uint32_t)(input[38] & 0xf0) << 9);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 308 to 326
	value = ((uint32_t)(input[38] & 0x0f) << 28) |
			((uint32_t)input[39] << 20) |
			((uint32_t)(input[40] & 0xfe) << 12);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 327 to 345
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)(input[43] & 0xc0) << 7);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 346 to 364
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)(input[45] & 0xf8) << 10);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 365 to 383
	value = ((uint32_t)(input[45] & 0x07) << 29) |
			((uint32_t)input[46] << 21) |
			((uint32_t)input[47] << 13);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 384 to 402
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)(input[50] & 0xe0) << 8);
	output[20] = (double)(value >> 13);
}

static void unpack_21_19bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 21 values into output
	// Values are 19-bit unsigned
	// Skip 4 bits, read 399 bits of data.
	// Input must be at least 51 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 289 to 307
	value = ((uint32_t)(input[36] & 0x7f) << 25) |
			((uint32_t)input[37] << 17) |
			((uint32_t)(input[38] & 0xf0) << 9);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 308 to 326
	value = ((uint32_t)(input[38] & 0x0f) << 28) |
			((uint32_t)input[39] << 20) |
			((uint32_t)(input[40] & 0xfe) << 12);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 327 to 345
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)(input[43] & 0xc0) << 7);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 346 to 364
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)(input[45] & 0xf8) << 10);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 365 to 383
	value = ((uint32_t)(input[45] & 0x07) << 29) |
			((uint32_t)input[46] << 21) |
			((uint32_t)input[47] << 13);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 384 to 402
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)(input[50] & 0xe0) << 8);
	output[20] = (double)(value >> 13);
}

static void unpack_21_19bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 21 values into output
	// Values are 19-bit signed
	// Skip 5 bits, read 399 bits of data.
	// Input must be at least 51 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 290 to 308
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)(input[38] & 0xf8) << 10);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 309 to 327
	value = ((uint32_t)(input[38] & 0x07) << 29) |
			((uint32_t)input[39] << 21) |
			((uint32_t)input[40] << 13);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 328 to 346
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)(input[43] & 0xe0) << 8);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 347 to 365
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)(input[45] & 0xfc) << 11);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 366 to 384
	value = ((uint32_t)(input[45] & 0x03) << 30) |
			((uint32_t)input[46] << 22) |
			((uint32_t)input[47] << 14) |
			((uint32_t)(input[48] & 0x80) << 6);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 385 to 403
	value = ((uint32_t)(input[48] & 0x7f) << 25) |
			((uint32_t)input[49] << 17) |
			((uint32_t)(input[50] & 0xf0) << 9);
	output[20] = (double)(value >> 13);
}

static void unpack_21_19bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 21 values into output
	// Values are 19-bit unsigned
	// Skip 5 bits, read 399 bits of data.
	// Input must be at least 51 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 290 to 308
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)(input[38] & 0xf8) << 10);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 309 to 327
	value = ((uint32_t)(input[38] & 0x07) << 29) |
			((uint32_t)input[39] << 21) |
			((uint32_t)input[40] << 13);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 328 to 346
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)(input[43] & 0xe0) << 8);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 347 to 365
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)(input[45] & 0xfc) << 11);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 366 to 384
	value = ((uint32_t)(input[45] & 0x03) << 30) |
			((uint32_t)input[46] << 22) |
			((uint32_t)input[47] << 14) |
			((uint32_t)(input[48] & 0x80) << 6);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 385 to 403
	value = ((uint32_t)(input[48] & 0x7f) << 25) |
			((uint32_t)input[49] << 17) |
			((uint32_t)(input[50] & 0xf0) << 9);
	output[20] = (double)(value >> 13);
}

static void unpack_21_19bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 21 values into output
	// Values are 19-bit signed
	// Skip 6 bits, read 399 bits of data.
	// Input must be at least 51 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 291 to 309
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)(input[38] & 0xfc) << 11);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 310 to 328
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)(input[41] & 0x80) << 6);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 329 to 347
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)(input[43] & 0xf0) << 9);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 348 to 366
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)(input[45] & 0xfe) << 12);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 367 to 385
	value = ((uint32_t)(input[45] & 0x01) << 31) |
			((uint32_t)input[46] << 23) |
			((uint32_t)input[47] << 15) |
			((uint32_t)(input[48] & 0xc0) << 7);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 386 to 404
	value = ((uint32_t)(input[48] & 0x3f) << 26) |
			((uint32_t)input[49] << 18) |
			((uint32_t)(input[50] & 0xf8) << 10);
	output[20] = (double)(value >> 13);
}

static void unpack_21_19bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 21 values into output
	// Values are 19-bit unsigned
	// Skip 6 bits, read 399 bits of data.
	// Input must be at least 51 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 291 to 309
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)(input[38] & 0xfc) << 11);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 310 to 328
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)(input[41] & 0x80) << 6);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 329 to 347
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)(input[43] & 0xf0) << 9);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 348 to 366
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)(input[45] & 0xfe) << 12);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 367 to 385
	value = ((uint32_t)(input[45] & 0x01) << 31) |
			((uint32_t)input[46] << 23) |
			((uint32_t)input[47] << 15) |
			((uint32_t)(input[48] & 0xc0) << 7);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 386 to 404
	value = ((uint32_t)(input[48] & 0x3f) << 26) |
			((uint32_t)input[49] << 18) |
			((uint32_t)(input[50] & 0xf8) << 10);
	output[20] = (double)(value >> 13);
}

static void unpack_21_19bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 21 values into output
	// Values are 19-bit signed
	// Skip 7 bits, read 399 bits of data.
	// Input must be at least 51 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 292 to 310
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)(input[38] & 0xfe) << 12);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 311 to 329
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)(input[41] & 0xc0) << 7);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 330 to 348
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)(input[43] & 0xf8) << 10);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 349 to 367
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 368 to 386
	value = ((uint32_t)input[46] << 24) |
			((uint32_t)input[47] << 16) |
			((uint32_t)(input[48] & 0xe0) << 8);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 387 to 405
	value = ((uint32_t)(input[48] & 0x1f) << 27) |
			((uint32_t)input[49] << 19) |
			((uint32_t)(input[50] & 0xfc) << 11);
	output[20] = (double)(value >> 13);
}

static void unpack_21_19bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 21 values into output
	// Values are 19-bit unsigned
	// Skip 7 bits, read 399 bits of data.
	// Input must be at least 51 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 292 to 310
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)(input[38] & 0xfe) << 12);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 311 to 329
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)(input[41] & 0xc0) << 7);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 330 to 348
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)(input[43] & 0xf8) << 10);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 349 to 367
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 368 to 386
	value = ((uint32_t)input[46] << 24) |
			((uint32_t)input[47] << 16) |
			((uint32_t)(input[48] & 0xe0) << 8);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 387 to 405
	value = ((uint32_t)(input[48] & 0x1f) << 27) |
			((uint32_t)input[49] << 19) |
			((uint32_t)(input[50] & 0xfc) << 11);
	output[20] = (double)(value >> 13);
}

static void unpack_22_19bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 22 values into output
	// Values are 19-bit signed
	// Skip 0 bits, read 418 bits of data.
	// Input must be at least 53 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 285 to 303
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 304 to 322
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)(input[40] & 0xe0) << 8);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 323 to 341
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)(input[42] & 0xfc) << 11);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 342 to 360
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)(input[45] & 0x80) << 6);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 361 to 379
	value = ((uint32_t)(input[45] & 0x7f) << 25) |
			((uint32_t)input[46] << 17) |
			((uint32_t)(input[47] & 0xf0) << 9);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 380 to 398
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)(input[49] & 0xfe) << 12);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 399 to 417
	value = ((uint32_t)(input[49] & 0x01) << 31) |
			((uint32_t)input[50] << 23) |
			((uint32_t)input[51] << 15) |
			((uint32_t)(input[52] & 0xc0) << 7);
	output[21] = (double)(value >> 13);
}

static void unpack_22_19bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 22 values into output
	// Values are 19-bit unsigned
	// Skip 0 bits, read 418 bits of data.
	// Input must be at least 53 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 285 to 303
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 304 to 322
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)(input[40] & 0xe0) << 8);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 323 to 341
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)(input[42] & 0xfc) << 11);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 342 to 360
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)(input[45] & 0x80) << 6);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 361 to 379
	value = ((uint32_t)(input[45] & 0x7f) << 25) |
			((uint32_t)input[46] << 17) |
			((uint32_t)(input[47] & 0xf0) << 9);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 380 to 398
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)(input[49] & 0xfe) << 12);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 399 to 417
	value = ((uint32_t)(input[49] & 0x01) << 31) |
			((uint32_t)input[50] << 23) |
			((uint32_t)input[51] << 15) |
			((uint32_t)(input[52] & 0xc0) << 7);
	output[21] = (double)(value >> 13);
}

static void unpack_22_19bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 22 values into output
	// Values are 19-bit signed
	// Skip 1 bits, read 418 bits of data.
	// Input must be at least 53 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 286 to 304
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)(input[38] & 0x80) << 6);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 305 to 323
	value = ((uint32_t)(input[38] & 0x7f) << 25) |
			((uint32_t)input[39] << 17) |
			((uint32_t)(input[40] & 0xf0) << 9);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 324 to 342
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)(input[42] & 0xfe) << 12);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 343 to 361
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)(input[45] & 0xc0) << 7);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 362 to 380
	value = ((uint32_t)(input[45] & 0x3f) << 26) |
			((uint32_t)input[46] << 18) |
			((uint32_t)(input[47] & 0xf8) << 10);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 381 to 399
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 400 to 418
	value = ((uint32_t)input[50] << 24) |
			((uint32_t)input[51] << 16) |
			((uint32_t)(input[52] & 0xe0) << 8);
	output[21] = (double)(value >> 13);
}

static void unpack_22_19bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 22 values into output
	// Values are 19-bit unsigned
	// Skip 1 bits, read 418 bits of data.
	// Input must be at least 53 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 286 to 304
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)(input[38] & 0x80) << 6);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 305 to 323
	value = ((uint32_t)(input[38] & 0x7f) << 25) |
			((uint32_t)input[39] << 17) |
			((uint32_t)(input[40] & 0xf0) << 9);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 324 to 342
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)(input[42] & 0xfe) << 12);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 343 to 361
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)(input[45] & 0xc0) << 7);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 362 to 380
	value = ((uint32_t)(input[45] & 0x3f) << 26) |
			((uint32_t)input[46] << 18) |
			((uint32_t)(input[47] & 0xf8) << 10);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 381 to 399
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 400 to 418
	value = ((uint32_t)input[50] << 24) |
			((uint32_t)input[51] << 16) |
			((uint32_t)(input[52] & 0xe0) << 8);
	output[21] = (double)(value >> 13);
}

static void unpack_22_19bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 22 values into output
	// Values are 19-bit signed
	// Skip 2 bits, read 418 bits of data.
	// Input must be at least 53 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 287 to 305
	value = ((uint32_t)(input[35] & 0x01) << 31) |
			((uint32_t)input[36] << 23) |
			((uint32_t)input[37] << 15) |
			((uint32_t)(input[38] & 0xc0) << 7);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 306 to 324
	value = ((uint32_t)(input[38] & 0x3f) << 26) |
			((uint32_t)input[39] << 18) |
			((uint32_t)(input[40] & 0xf8) << 10);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 325 to 343
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 344 to 362
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)(input[45] & 0xe0) << 8);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 363 to 381
	value = ((uint32_t)(input[45] & 0x1f) << 27) |
			((uint32_t)input[46] << 19) |
			((uint32_t)(input[47] & 0xfc) << 11);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 382 to 400
	value = ((uint32_t)(input[47] & 0x03) << 30) |
			((uint32_t)input[48] << 22) |
			((uint32_t)input[49] << 14) |
			((uint32_t)(input[50] & 0x80) << 6);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 401 to 419
	value = ((uint32_t)(input[50] & 0x7f) << 25) |
			((uint32_t)input[51] << 17) |
			((uint32_t)(input[52] & 0xf0) << 9);
	output[21] = (double)(value >> 13);
}

static void unpack_22_19bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 22 values into output
	// Values are 19-bit unsigned
	// Skip 2 bits, read 418 bits of data.
	// Input must be at least 53 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 287 to 305
	value = ((uint32_t)(input[35] & 0x01) << 31) |
			((uint32_t)input[36] << 23) |
			((uint32_t)input[37] << 15) |
			((uint32_t)(input[38] & 0xc0) << 7);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 306 to 324
	value = ((uint32_t)(input[38] & 0x3f) << 26) |
			((uint32_t)input[39] << 18) |
			((uint32_t)(input[40] & 0xf8) << 10);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 325 to 343
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 344 to 362
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)(input[45] & 0xe0) << 8);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 363 to 381
	value = ((uint32_t)(input[45] & 0x1f) << 27) |
			((uint32_t)input[46] << 19) |
			((uint32_t)(input[47] & 0xfc) << 11);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 382 to 400
	value = ((uint32_t)(input[47] & 0x03) << 30) |
			((uint32_t)input[48] << 22) |
			((uint32_t)input[49] << 14) |
			((uint32_t)(input[50] & 0x80) << 6);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 401 to 419
	value = ((uint32_t)(input[50] & 0x7f) << 25) |
			((uint32_t)input[51] << 17) |
			((uint32_t)(input[52] & 0xf0) << 9);
	output[21] = (double)(value >> 13);
}

static void unpack_22_19bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 22 values into output
	// Values are 19-bit signed
	// Skip 3 bits, read 418 bits of data.
	// Input must be at least 53 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 288 to 306
	value = ((uint32_t)input[36] << 24) |
			((uint32_t)input[37] << 16) |
			((uint32_t)(input[38] & 0xe0) << 8);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 307 to 325
	value = ((uint32_t)(input[38] & 0x1f) << 27) |
			((uint32_t)input[39] << 19) |
			((uint32_t)(input[40] & 0xfc) << 11);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 326 to 344
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)(input[43] & 0x80) << 6);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 345 to 363
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)(input[45] & 0xf0) << 9);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 364 to 382
	value = ((uint32_t)(input[45] & 0x0f) << 28) |
			((uint32_t)input[46] << 20) |
			((uint32_t)(input[47] & 0xfe) << 12);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 383 to 401
	value = ((uint32_t)(input[47] & 0x01) << 31) |
			((uint32_t)input[48] << 23) |
			((uint32_t)input[49] << 15) |
			((uint32_t)(input[50] & 0xc0) << 7);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 402 to 420
	value = ((uint32_t)(input[50] & 0x3f) << 26) |
			((uint32_t)input[51] << 18) |
			((uint32_t)(input[52] & 0xf8) << 10);
	output[21] = (double)(value >> 13);
}

static void unpack_22_19bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 22 values into output
	// Values are 19-bit unsigned
	// Skip 3 bits, read 418 bits of data.
	// Input must be at least 53 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 288 to 306
	value = ((uint32_t)input[36] << 24) |
			((uint32_t)input[37] << 16) |
			((uint32_t)(input[38] & 0xe0) << 8);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 307 to 325
	value = ((uint32_t)(input[38] & 0x1f) << 27) |
			((uint32_t)input[39] << 19) |
			((uint32_t)(input[40] & 0xfc) << 11);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 326 to 344
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)(input[43] & 0x80) << 6);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 345 to 363
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)(input[45] & 0xf0) << 9);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 364 to 382
	value = ((uint32_t)(input[45] & 0x0f) << 28) |
			((uint32_t)input[46] << 20) |
			((uint32_t)(input[47] & 0xfe) << 12);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 383 to 401
	value = ((uint32_t)(input[47] & 0x01) << 31) |
			((uint32_t)input[48] << 23) |
			((uint32_t)input[49] << 15) |
			((uint32_t)(input[50] & 0xc0) << 7);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 402 to 420
	value = ((uint32_t)(input[50] & 0x3f) << 26) |
			((uint32_t)input[51] << 18) |
			((uint32_t)(input[52] & 0xf8) << 10);
	output[21] = (double)(value >> 13);
}

static void unpack_22_19bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 22 values into output
	// Values are 19-bit signed
	// Skip 4 bits, read 418 bits of data.
	// Input must be at least 53 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 289 to 307
	value = ((uint32_t)(input[36] & 0x7f) << 25) |
			((uint32_t)input[37] << 17) |
			((uint32_t)(input[38] & 0xf0) << 9);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 308 to 326
	value = ((uint32_t)(input[38] & 0x0f) << 28) |
			((uint32_t)input[39] << 20) |
			((uint32_t)(input[40] & 0xfe) << 12);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 327 to 345
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)(input[43] & 0xc0) << 7);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 346 to 364
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)(input[45] & 0xf8) << 10);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 365 to 383
	value = ((uint32_t)(input[45] & 0x07) << 29) |
			((uint32_t)input[46] << 21) |
			((uint32_t)input[47] << 13);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 384 to 402
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)(input[50] & 0xe0) << 8);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 403 to 421
	value = ((uint32_t)(input[50] & 0x1f) << 27) |
			((uint32_t)input[51] << 19) |
			((uint32_t)(input[52] & 0xfc) << 11);
	output[21] = (double)(value >> 13);
}

static void unpack_22_19bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 22 values into output
	// Values are 19-bit unsigned
	// Skip 4 bits, read 418 bits of data.
	// Input must be at least 53 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 289 to 307
	value = ((uint32_t)(input[36] & 0x7f) << 25) |
			((uint32_t)input[37] << 17) |
			((uint32_t)(input[38] & 0xf0) << 9);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 308 to 326
	value = ((uint32_t)(input[38] & 0x0f) << 28) |
			((uint32_t)input[39] << 20) |
			((uint32_t)(input[40] & 0xfe) << 12);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 327 to 345
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)(input[43] & 0xc0) << 7);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 346 to 364
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)(input[45] & 0xf8) << 10);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 365 to 383
	value = ((uint32_t)(input[45] & 0x07) << 29) |
			((uint32_t)input[46] << 21) |
			((uint32_t)input[47] << 13);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 384 to 402
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)(input[50] & 0xe0) << 8);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 403 to 421
	value = ((uint32_t)(input[50] & 0x1f) << 27) |
			((uint32_t)input[51] << 19) |
			((uint32_t)(input[52] & 0xfc) << 11);
	output[21] = (double)(value >> 13);
}

static void unpack_22_19bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 22 values into output
	// Values are 19-bit signed
	// Skip 5 bits, read 418 bits of data.
	// Input must be at least 53 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 290 to 308
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)(input[38] & 0xf8) << 10);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 309 to 327
	value = ((uint32_t)(input[38] & 0x07) << 29) |
			((uint32_t)input[39] << 21) |
			((uint32_t)input[40] << 13);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 328 to 346
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)(input[43] & 0xe0) << 8);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 347 to 365
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)(input[45] & 0xfc) << 11);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 366 to 384
	value = ((uint32_t)(input[45] & 0x03) << 30) |
			((uint32_t)input[46] << 22) |
			((uint32_t)input[47] << 14) |
			((uint32_t)(input[48] & 0x80) << 6);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 385 to 403
	value = ((uint32_t)(input[48] & 0x7f) << 25) |
			((uint32_t)input[49] << 17) |
			((uint32_t)(input[50] & 0xf0) << 9);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 404 to 422
	value = ((uint32_t)(input[50] & 0x0f) << 28) |
			((uint32_t)input[51] << 20) |
			((uint32_t)(input[52] & 0xfe) << 12);
	output[21] = (double)(value >> 13);
}

static void unpack_22_19bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 22 values into output
	// Values are 19-bit unsigned
	// Skip 5 bits, read 418 bits of data.
	// Input must be at least 53 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 290 to 308
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)(input[38] & 0xf8) << 10);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 309 to 327
	value = ((uint32_t)(input[38] & 0x07) << 29) |
			((uint32_t)input[39] << 21) |
			((uint32_t)input[40] << 13);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 328 to 346
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)(input[43] & 0xe0) << 8);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 347 to 365
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)(input[45] & 0xfc) << 11);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 366 to 384
	value = ((uint32_t)(input[45] & 0x03) << 30) |
			((uint32_t)input[46] << 22) |
			((uint32_t)input[47] << 14) |
			((uint32_t)(input[48] & 0x80) << 6);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 385 to 403
	value = ((uint32_t)(input[48] & 0x7f) << 25) |
			((uint32_t)input[49] << 17) |
			((uint32_t)(input[50] & 0xf0) << 9);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 404 to 422
	value = ((uint32_t)(input[50] & 0x0f) << 28) |
			((uint32_t)input[51] << 20) |
			((uint32_t)(input[52] & 0xfe) << 12);
	output[21] = (double)(value >> 13);
}

static void unpack_22_19bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 22 values into output
	// Values are 19-bit signed
	// Skip 6 bits, read 418 bits of data.
	// Input must be at least 53 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 291 to 309
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)(input[38] & 0xfc) << 11);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 310 to 328
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)(input[41] & 0x80) << 6);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 329 to 347
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)(input[43] & 0xf0) << 9);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 348 to 366
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)(input[45] & 0xfe) << 12);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 367 to 385
	value = ((uint32_t)(input[45] & 0x01) << 31) |
			((uint32_t)input[46] << 23) |
			((uint32_t)input[47] << 15) |
			((uint32_t)(input[48] & 0xc0) << 7);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 386 to 404
	value = ((uint32_t)(input[48] & 0x3f) << 26) |
			((uint32_t)input[49] << 18) |
			((uint32_t)(input[50] & 0xf8) << 10);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 405 to 423
	value = ((uint32_t)(input[50] & 0x07) << 29) |
			((uint32_t)input[51] << 21) |
			((uint32_t)input[52] << 13);
	output[21] = (double)(value >> 13);
}

static void unpack_22_19bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 22 values into output
	// Values are 19-bit unsigned
	// Skip 6 bits, read 418 bits of data.
	// Input must be at least 53 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 291 to 309
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)(input[38] & 0xfc) << 11);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 310 to 328
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)(input[41] & 0x80) << 6);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 329 to 347
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)(input[43] & 0xf0) << 9);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 348 to 366
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)(input[45] & 0xfe) << 12);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 367 to 385
	value = ((uint32_t)(input[45] & 0x01) << 31) |
			((uint32_t)input[46] << 23) |
			((uint32_t)input[47] << 15) |
			((uint32_t)(input[48] & 0xc0) << 7);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 386 to 404
	value = ((uint32_t)(input[48] & 0x3f) << 26) |
			((uint32_t)input[49] << 18) |
			((uint32_t)(input[50] & 0xf8) << 10);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 405 to 423
	value = ((uint32_t)(input[50] & 0x07) << 29) |
			((uint32_t)input[51] << 21) |
			((uint32_t)input[52] << 13);
	output[21] = (double)(value >> 13);
}

static void unpack_22_19bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 22 values into output
	// Values are 19-bit signed
	// Skip 7 bits, read 418 bits of data.
	// Input must be at least 54 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 292 to 310
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)(input[38] & 0xfe) << 12);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 311 to 329
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)(input[41] & 0xc0) << 7);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 330 to 348
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)(input[43] & 0xf8) << 10);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 349 to 367
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 368 to 386
	value = ((uint32_t)input[46] << 24) |
			((uint32_t)input[47] << 16) |
			((uint32_t)(input[48] & 0xe0) << 8);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 387 to 405
	value = ((uint32_t)(input[48] & 0x1f) << 27) |
			((uint32_t)input[49] << 19) |
			((uint32_t)(input[50] & 0xfc) << 11);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 406 to 424
	value = ((uint32_t)(input[50] & 0x03) << 30) |
			((uint32_t)input[51] << 22) |
			((uint32_t)input[52] << 14) |
			((uint32_t)(input[53] & 0x80) << 6);
	output[21] = (double)(value >> 13);
}

static void unpack_22_19bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 22 values into output
	// Values are 19-bit unsigned
	// Skip 7 bits, read 418 bits of data.
	// Input must be at least 54 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 292 to 310
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)(input[38] & 0xfe) << 12);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 311 to 329
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)(input[41] & 0xc0) << 7);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 330 to 348
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)(input[43] & 0xf8) << 10);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 349 to 367
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 368 to 386
	value = ((uint32_t)input[46] << 24) |
			((uint32_t)input[47] << 16) |
			((uint32_t)(input[48] & 0xe0) << 8);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 387 to 405
	value = ((uint32_t)(input[48] & 0x1f) << 27) |
			((uint32_t)input[49] << 19) |
			((uint32_t)(input[50] & 0xfc) << 11);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 406 to 424
	value = ((uint32_t)(input[50] & 0x03) << 30) |
			((uint32_t)input[51] << 22) |
			((uint32_t)input[52] << 14) |
			((uint32_t)(input[53] & 0x80) << 6);
	output[21] = (double)(value >> 13);
}

static void unpack_23_19bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 23 values into output
	// Values are 19-bit signed
	// Skip 0 bits, read 437 bits of data.
	// Input must be at least 55 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 285 to 303
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 304 to 322
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)(input[40] & 0xe0) << 8);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 323 to 341
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)(input[42] & 0xfc) << 11);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 342 to 360
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)(input[45] & 0x80) << 6);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 361 to 379
	value = ((uint32_t)(input[45] & 0x7f) << 25) |
			((uint32_t)input[46] << 17) |
			((uint32_t)(input[47] & 0xf0) << 9);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 380 to 398
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)(input[49] & 0xfe) << 12);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 399 to 417
	value = ((uint32_t)(input[49] & 0x01) << 31) |
			((uint32_t)input[50] << 23) |
			((uint32_t)input[51] << 15) |
			((uint32_t)(input[52] & 0xc0) << 7);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 418 to 436
	value = ((uint32_t)(input[52] & 0x3f) << 26) |
			((uint32_t)input[53] << 18) |
			((uint32_t)(input[54] & 0xf8) << 10);
	output[22] = (double)(value >> 13);
}

static void unpack_23_19bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 23 values into output
	// Values are 19-bit unsigned
	// Skip 0 bits, read 437 bits of data.
	// Input must be at least 55 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 285 to 303
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 304 to 322
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)(input[40] & 0xe0) << 8);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 323 to 341
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)(input[42] & 0xfc) << 11);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 342 to 360
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)(input[45] & 0x80) << 6);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 361 to 379
	value = ((uint32_t)(input[45] & 0x7f) << 25) |
			((uint32_t)input[46] << 17) |
			((uint32_t)(input[47] & 0xf0) << 9);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 380 to 398
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)(input[49] & 0xfe) << 12);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 399 to 417
	value = ((uint32_t)(input[49] & 0x01) << 31) |
			((uint32_t)input[50] << 23) |
			((uint32_t)input[51] << 15) |
			((uint32_t)(input[52] & 0xc0) << 7);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 418 to 436
	value = ((uint32_t)(input[52] & 0x3f) << 26) |
			((uint32_t)input[53] << 18) |
			((uint32_t)(input[54] & 0xf8) << 10);
	output[22] = (double)(value >> 13);
}

static void unpack_23_19bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 23 values into output
	// Values are 19-bit signed
	// Skip 1 bits, read 437 bits of data.
	// Input must be at least 55 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 286 to 304
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)(input[38] & 0x80) << 6);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 305 to 323
	value = ((uint32_t)(input[38] & 0x7f) << 25) |
			((uint32_t)input[39] << 17) |
			((uint32_t)(input[40] & 0xf0) << 9);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 324 to 342
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)(input[42] & 0xfe) << 12);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 343 to 361
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)(input[45] & 0xc0) << 7);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 362 to 380
	value = ((uint32_t)(input[45] & 0x3f) << 26) |
			((uint32_t)input[46] << 18) |
			((uint32_t)(input[47] & 0xf8) << 10);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 381 to 399
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 400 to 418
	value = ((uint32_t)input[50] << 24) |
			((uint32_t)input[51] << 16) |
			((uint32_t)(input[52] & 0xe0) << 8);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 419 to 437
	value = ((uint32_t)(input[52] & 0x1f) << 27) |
			((uint32_t)input[53] << 19) |
			((uint32_t)(input[54] & 0xfc) << 11);
	output[22] = (double)(value >> 13);
}

static void unpack_23_19bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 23 values into output
	// Values are 19-bit unsigned
	// Skip 1 bits, read 437 bits of data.
	// Input must be at least 55 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 286 to 304
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)(input[38] & 0x80) << 6);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 305 to 323
	value = ((uint32_t)(input[38] & 0x7f) << 25) |
			((uint32_t)input[39] << 17) |
			((uint32_t)(input[40] & 0xf0) << 9);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 324 to 342
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)(input[42] & 0xfe) << 12);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 343 to 361
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)(input[45] & 0xc0) << 7);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 362 to 380
	value = ((uint32_t)(input[45] & 0x3f) << 26) |
			((uint32_t)input[46] << 18) |
			((uint32_t)(input[47] & 0xf8) << 10);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 381 to 399
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 400 to 418
	value = ((uint32_t)input[50] << 24) |
			((uint32_t)input[51] << 16) |
			((uint32_t)(input[52] & 0xe0) << 8);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 419 to 437
	value = ((uint32_t)(input[52] & 0x1f) << 27) |
			((uint32_t)input[53] << 19) |
			((uint32_t)(input[54] & 0xfc) << 11);
	output[22] = (double)(value >> 13);
}

static void unpack_23_19bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 23 values into output
	// Values are 19-bit signed
	// Skip 2 bits, read 437 bits of data.
	// Input must be at least 55 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 287 to 305
	value = ((uint32_t)(input[35] & 0x01) << 31) |
			((uint32_t)input[36] << 23) |
			((uint32_t)input[37] << 15) |
			((uint32_t)(input[38] & 0xc0) << 7);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 306 to 324
	value = ((uint32_t)(input[38] & 0x3f) << 26) |
			((uint32_t)input[39] << 18) |
			((uint32_t)(input[40] & 0xf8) << 10);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 325 to 343
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 344 to 362
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)(input[45] & 0xe0) << 8);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 363 to 381
	value = ((uint32_t)(input[45] & 0x1f) << 27) |
			((uint32_t)input[46] << 19) |
			((uint32_t)(input[47] & 0xfc) << 11);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 382 to 400
	value = ((uint32_t)(input[47] & 0x03) << 30) |
			((uint32_t)input[48] << 22) |
			((uint32_t)input[49] << 14) |
			((uint32_t)(input[50] & 0x80) << 6);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 401 to 419
	value = ((uint32_t)(input[50] & 0x7f) << 25) |
			((uint32_t)input[51] << 17) |
			((uint32_t)(input[52] & 0xf0) << 9);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 420 to 438
	value = ((uint32_t)(input[52] & 0x0f) << 28) |
			((uint32_t)input[53] << 20) |
			((uint32_t)(input[54] & 0xfe) << 12);
	output[22] = (double)(value >> 13);
}

static void unpack_23_19bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 23 values into output
	// Values are 19-bit unsigned
	// Skip 2 bits, read 437 bits of data.
	// Input must be at least 55 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 287 to 305
	value = ((uint32_t)(input[35] & 0x01) << 31) |
			((uint32_t)input[36] << 23) |
			((uint32_t)input[37] << 15) |
			((uint32_t)(input[38] & 0xc0) << 7);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 306 to 324
	value = ((uint32_t)(input[38] & 0x3f) << 26) |
			((uint32_t)input[39] << 18) |
			((uint32_t)(input[40] & 0xf8) << 10);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 325 to 343
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 344 to 362
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)(input[45] & 0xe0) << 8);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 363 to 381
	value = ((uint32_t)(input[45] & 0x1f) << 27) |
			((uint32_t)input[46] << 19) |
			((uint32_t)(input[47] & 0xfc) << 11);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 382 to 400
	value = ((uint32_t)(input[47] & 0x03) << 30) |
			((uint32_t)input[48] << 22) |
			((uint32_t)input[49] << 14) |
			((uint32_t)(input[50] & 0x80) << 6);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 401 to 419
	value = ((uint32_t)(input[50] & 0x7f) << 25) |
			((uint32_t)input[51] << 17) |
			((uint32_t)(input[52] & 0xf0) << 9);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 420 to 438
	value = ((uint32_t)(input[52] & 0x0f) << 28) |
			((uint32_t)input[53] << 20) |
			((uint32_t)(input[54] & 0xfe) << 12);
	output[22] = (double)(value >> 13);
}

static void unpack_23_19bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 23 values into output
	// Values are 19-bit signed
	// Skip 3 bits, read 437 bits of data.
	// Input must be at least 55 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 288 to 306
	value = ((uint32_t)input[36] << 24) |
			((uint32_t)input[37] << 16) |
			((uint32_t)(input[38] & 0xe0) << 8);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 307 to 325
	value = ((uint32_t)(input[38] & 0x1f) << 27) |
			((uint32_t)input[39] << 19) |
			((uint32_t)(input[40] & 0xfc) << 11);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 326 to 344
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)(input[43] & 0x80) << 6);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 345 to 363
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)(input[45] & 0xf0) << 9);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 364 to 382
	value = ((uint32_t)(input[45] & 0x0f) << 28) |
			((uint32_t)input[46] << 20) |
			((uint32_t)(input[47] & 0xfe) << 12);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 383 to 401
	value = ((uint32_t)(input[47] & 0x01) << 31) |
			((uint32_t)input[48] << 23) |
			((uint32_t)input[49] << 15) |
			((uint32_t)(input[50] & 0xc0) << 7);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 402 to 420
	value = ((uint32_t)(input[50] & 0x3f) << 26) |
			((uint32_t)input[51] << 18) |
			((uint32_t)(input[52] & 0xf8) << 10);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 421 to 439
	value = ((uint32_t)(input[52] & 0x07) << 29) |
			((uint32_t)input[53] << 21) |
			((uint32_t)input[54] << 13);
	output[22] = (double)(value >> 13);
}

static void unpack_23_19bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 23 values into output
	// Values are 19-bit unsigned
	// Skip 3 bits, read 437 bits of data.
	// Input must be at least 55 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 288 to 306
	value = ((uint32_t)input[36] << 24) |
			((uint32_t)input[37] << 16) |
			((uint32_t)(input[38] & 0xe0) << 8);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 307 to 325
	value = ((uint32_t)(input[38] & 0x1f) << 27) |
			((uint32_t)input[39] << 19) |
			((uint32_t)(input[40] & 0xfc) << 11);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 326 to 344
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)(input[43] & 0x80) << 6);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 345 to 363
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)(input[45] & 0xf0) << 9);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 364 to 382
	value = ((uint32_t)(input[45] & 0x0f) << 28) |
			((uint32_t)input[46] << 20) |
			((uint32_t)(input[47] & 0xfe) << 12);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 383 to 401
	value = ((uint32_t)(input[47] & 0x01) << 31) |
			((uint32_t)input[48] << 23) |
			((uint32_t)input[49] << 15) |
			((uint32_t)(input[50] & 0xc0) << 7);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 402 to 420
	value = ((uint32_t)(input[50] & 0x3f) << 26) |
			((uint32_t)input[51] << 18) |
			((uint32_t)(input[52] & 0xf8) << 10);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 421 to 439
	value = ((uint32_t)(input[52] & 0x07) << 29) |
			((uint32_t)input[53] << 21) |
			((uint32_t)input[54] << 13);
	output[22] = (double)(value >> 13);
}

static void unpack_23_19bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 23 values into output
	// Values are 19-bit signed
	// Skip 4 bits, read 437 bits of data.
	// Input must be at least 56 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 289 to 307
	value = ((uint32_t)(input[36] & 0x7f) << 25) |
			((uint32_t)input[37] << 17) |
			((uint32_t)(input[38] & 0xf0) << 9);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 308 to 326
	value = ((uint32_t)(input[38] & 0x0f) << 28) |
			((uint32_t)input[39] << 20) |
			((uint32_t)(input[40] & 0xfe) << 12);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 327 to 345
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)(input[43] & 0xc0) << 7);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 346 to 364
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)(input[45] & 0xf8) << 10);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 365 to 383
	value = ((uint32_t)(input[45] & 0x07) << 29) |
			((uint32_t)input[46] << 21) |
			((uint32_t)input[47] << 13);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 384 to 402
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)(input[50] & 0xe0) << 8);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 403 to 421
	value = ((uint32_t)(input[50] & 0x1f) << 27) |
			((uint32_t)input[51] << 19) |
			((uint32_t)(input[52] & 0xfc) << 11);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 422 to 440
	value = ((uint32_t)(input[52] & 0x03) << 30) |
			((uint32_t)input[53] << 22) |
			((uint32_t)input[54] << 14) |
			((uint32_t)(input[55] & 0x80) << 6);
	output[22] = (double)(value >> 13);
}

static void unpack_23_19bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 23 values into output
	// Values are 19-bit unsigned
	// Skip 4 bits, read 437 bits of data.
	// Input must be at least 56 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 289 to 307
	value = ((uint32_t)(input[36] & 0x7f) << 25) |
			((uint32_t)input[37] << 17) |
			((uint32_t)(input[38] & 0xf0) << 9);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 308 to 326
	value = ((uint32_t)(input[38] & 0x0f) << 28) |
			((uint32_t)input[39] << 20) |
			((uint32_t)(input[40] & 0xfe) << 12);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 327 to 345
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)(input[43] & 0xc0) << 7);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 346 to 364
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)(input[45] & 0xf8) << 10);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 365 to 383
	value = ((uint32_t)(input[45] & 0x07) << 29) |
			((uint32_t)input[46] << 21) |
			((uint32_t)input[47] << 13);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 384 to 402
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)(input[50] & 0xe0) << 8);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 403 to 421
	value = ((uint32_t)(input[50] & 0x1f) << 27) |
			((uint32_t)input[51] << 19) |
			((uint32_t)(input[52] & 0xfc) << 11);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 422 to 440
	value = ((uint32_t)(input[52] & 0x03) << 30) |
			((uint32_t)input[53] << 22) |
			((uint32_t)input[54] << 14) |
			((uint32_t)(input[55] & 0x80) << 6);
	output[22] = (double)(value >> 13);
}

static void unpack_23_19bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 23 values into output
	// Values are 19-bit signed
	// Skip 5 bits, read 437 bits of data.
	// Input must be at least 56 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 290 to 308
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)(input[38] & 0xf8) << 10);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 309 to 327
	value = ((uint32_t)(input[38] & 0x07) << 29) |
			((uint32_t)input[39] << 21) |
			((uint32_t)input[40] << 13);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 328 to 346
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)(input[43] & 0xe0) << 8);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 347 to 365
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)(input[45] & 0xfc) << 11);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 366 to 384
	value = ((uint32_t)(input[45] & 0x03) << 30) |
			((uint32_t)input[46] << 22) |
			((uint32_t)input[47] << 14) |
			((uint32_t)(input[48] & 0x80) << 6);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 385 to 403
	value = ((uint32_t)(input[48] & 0x7f) << 25) |
			((uint32_t)input[49] << 17) |
			((uint32_t)(input[50] & 0xf0) << 9);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 404 to 422
	value = ((uint32_t)(input[50] & 0x0f) << 28) |
			((uint32_t)input[51] << 20) |
			((uint32_t)(input[52] & 0xfe) << 12);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 423 to 441
	value = ((uint32_t)(input[52] & 0x01) << 31) |
			((uint32_t)input[53] << 23) |
			((uint32_t)input[54] << 15) |
			((uint32_t)(input[55] & 0xc0) << 7);
	output[22] = (double)(value >> 13);
}

static void unpack_23_19bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 23 values into output
	// Values are 19-bit unsigned
	// Skip 5 bits, read 437 bits of data.
	// Input must be at least 56 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 290 to 308
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)(input[38] & 0xf8) << 10);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 309 to 327
	value = ((uint32_t)(input[38] & 0x07) << 29) |
			((uint32_t)input[39] << 21) |
			((uint32_t)input[40] << 13);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 328 to 346
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)(input[43] & 0xe0) << 8);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 347 to 365
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)(input[45] & 0xfc) << 11);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 366 to 384
	value = ((uint32_t)(input[45] & 0x03) << 30) |
			((uint32_t)input[46] << 22) |
			((uint32_t)input[47] << 14) |
			((uint32_t)(input[48] & 0x80) << 6);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 385 to 403
	value = ((uint32_t)(input[48] & 0x7f) << 25) |
			((uint32_t)input[49] << 17) |
			((uint32_t)(input[50] & 0xf0) << 9);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 404 to 422
	value = ((uint32_t)(input[50] & 0x0f) << 28) |
			((uint32_t)input[51] << 20) |
			((uint32_t)(input[52] & 0xfe) << 12);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 423 to 441
	value = ((uint32_t)(input[52] & 0x01) << 31) |
			((uint32_t)input[53] << 23) |
			((uint32_t)input[54] << 15) |
			((uint32_t)(input[55] & 0xc0) << 7);
	output[22] = (double)(value >> 13);
}

static void unpack_23_19bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 23 values into output
	// Values are 19-bit signed
	// Skip 6 bits, read 437 bits of data.
	// Input must be at least 56 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 291 to 309
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)(input[38] & 0xfc) << 11);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 310 to 328
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)(input[41] & 0x80) << 6);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 329 to 347
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)(input[43] & 0xf0) << 9);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 348 to 366
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)(input[45] & 0xfe) << 12);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 367 to 385
	value = ((uint32_t)(input[45] & 0x01) << 31) |
			((uint32_t)input[46] << 23) |
			((uint32_t)input[47] << 15) |
			((uint32_t)(input[48] & 0xc0) << 7);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 386 to 404
	value = ((uint32_t)(input[48] & 0x3f) << 26) |
			((uint32_t)input[49] << 18) |
			((uint32_t)(input[50] & 0xf8) << 10);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 405 to 423
	value = ((uint32_t)(input[50] & 0x07) << 29) |
			((uint32_t)input[51] << 21) |
			((uint32_t)input[52] << 13);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 424 to 442
	value = ((uint32_t)input[53] << 24) |
			((uint32_t)input[54] << 16) |
			((uint32_t)(input[55] & 0xe0) << 8);
	output[22] = (double)(value >> 13);
}

static void unpack_23_19bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 23 values into output
	// Values are 19-bit unsigned
	// Skip 6 bits, read 437 bits of data.
	// Input must be at least 56 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 291 to 309
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)(input[38] & 0xfc) << 11);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 310 to 328
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)(input[41] & 0x80) << 6);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 329 to 347
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)(input[43] & 0xf0) << 9);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 348 to 366
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)(input[45] & 0xfe) << 12);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 367 to 385
	value = ((uint32_t)(input[45] & 0x01) << 31) |
			((uint32_t)input[46] << 23) |
			((uint32_t)input[47] << 15) |
			((uint32_t)(input[48] & 0xc0) << 7);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 386 to 404
	value = ((uint32_t)(input[48] & 0x3f) << 26) |
			((uint32_t)input[49] << 18) |
			((uint32_t)(input[50] & 0xf8) << 10);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 405 to 423
	value = ((uint32_t)(input[50] & 0x07) << 29) |
			((uint32_t)input[51] << 21) |
			((uint32_t)input[52] << 13);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 424 to 442
	value = ((uint32_t)input[53] << 24) |
			((uint32_t)input[54] << 16) |
			((uint32_t)(input[55] & 0xe0) << 8);
	output[22] = (double)(value >> 13);
}

static void unpack_23_19bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 23 values into output
	// Values are 19-bit signed
	// Skip 7 bits, read 437 bits of data.
	// Input must be at least 56 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 292 to 310
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)(input[38] & 0xfe) << 12);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 311 to 329
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)(input[41] & 0xc0) << 7);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 330 to 348
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)(input[43] & 0xf8) << 10);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 349 to 367
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 368 to 386
	value = ((uint32_t)input[46] << 24) |
			((uint32_t)input[47] << 16) |
			((uint32_t)(input[48] & 0xe0) << 8);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 387 to 405
	value = ((uint32_t)(input[48] & 0x1f) << 27) |
			((uint32_t)input[49] << 19) |
			((uint32_t)(input[50] & 0xfc) << 11);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 406 to 424
	value = ((uint32_t)(input[50] & 0x03) << 30) |
			((uint32_t)input[51] << 22) |
			((uint32_t)input[52] << 14) |
			((uint32_t)(input[53] & 0x80) << 6);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 425 to 443
	value = ((uint32_t)(input[53] & 0x7f) << 25) |
			((uint32_t)input[54] << 17) |
			((uint32_t)(input[55] & 0xf0) << 9);
	output[22] = (double)(value >> 13);
}

static void unpack_23_19bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 23 values into output
	// Values are 19-bit unsigned
	// Skip 7 bits, read 437 bits of data.
	// Input must be at least 56 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 292 to 310
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)(input[38] & 0xfe) << 12);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 311 to 329
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)(input[41] & 0xc0) << 7);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 330 to 348
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)(input[43] & 0xf8) << 10);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 349 to 367
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 368 to 386
	value = ((uint32_t)input[46] << 24) |
			((uint32_t)input[47] << 16) |
			((uint32_t)(input[48] & 0xe0) << 8);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 387 to 405
	value = ((uint32_t)(input[48] & 0x1f) << 27) |
			((uint32_t)input[49] << 19) |
			((uint32_t)(input[50] & 0xfc) << 11);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 406 to 424
	value = ((uint32_t)(input[50] & 0x03) << 30) |
			((uint32_t)input[51] << 22) |
			((uint32_t)input[52] << 14) |
			((uint32_t)(input[53] & 0x80) << 6);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 425 to 443
	value = ((uint32_t)(input[53] & 0x7f) << 25) |
			((uint32_t)input[54] << 17) |
			((uint32_t)(input[55] & 0xf0) << 9);
	output[22] = (double)(value >> 13);
}

static void unpack_24_19bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 24 values into output
	// Values are 19-bit signed
	// Skip 0 bits, read 456 bits of data.
	// Input must be at least 57 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 285 to 303
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 304 to 322
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)(input[40] & 0xe0) << 8);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 323 to 341
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)(input[42] & 0xfc) << 11);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 342 to 360
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)(input[45] & 0x80) << 6);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 361 to 379
	value = ((uint32_t)(input[45] & 0x7f) << 25) |
			((uint32_t)input[46] << 17) |
			((uint32_t)(input[47] & 0xf0) << 9);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 380 to 398
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)(input[49] & 0xfe) << 12);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 399 to 417
	value = ((uint32_t)(input[49] & 0x01) << 31) |
			((uint32_t)input[50] << 23) |
			((uint32_t)input[51] << 15) |
			((uint32_t)(input[52] & 0xc0) << 7);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 418 to 436
	value = ((uint32_t)(input[52] & 0x3f) << 26) |
			((uint32_t)input[53] << 18) |
			((uint32_t)(input[54] & 0xf8) << 10);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 437 to 455
	value = ((uint32_t)(input[54] & 0x07) << 29) |
			((uint32_t)input[55] << 21) |
			((uint32_t)input[56] << 13);
	output[23] = (double)(value >> 13);
}

static void unpack_24_19bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 24 values into output
	// Values are 19-bit unsigned
	// Skip 0 bits, read 456 bits of data.
	// Input must be at least 57 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 285 to 303
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 304 to 322
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)(input[40] & 0xe0) << 8);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 323 to 341
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)(input[42] & 0xfc) << 11);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 342 to 360
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)(input[45] & 0x80) << 6);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 361 to 379
	value = ((uint32_t)(input[45] & 0x7f) << 25) |
			((uint32_t)input[46] << 17) |
			((uint32_t)(input[47] & 0xf0) << 9);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 380 to 398
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)(input[49] & 0xfe) << 12);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 399 to 417
	value = ((uint32_t)(input[49] & 0x01) << 31) |
			((uint32_t)input[50] << 23) |
			((uint32_t)input[51] << 15) |
			((uint32_t)(input[52] & 0xc0) << 7);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 418 to 436
	value = ((uint32_t)(input[52] & 0x3f) << 26) |
			((uint32_t)input[53] << 18) |
			((uint32_t)(input[54] & 0xf8) << 10);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 437 to 455
	value = ((uint32_t)(input[54] & 0x07) << 29) |
			((uint32_t)input[55] << 21) |
			((uint32_t)input[56] << 13);
	output[23] = (double)(value >> 13);
}

static void unpack_24_19bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 24 values into output
	// Values are 19-bit signed
	// Skip 1 bits, read 456 bits of data.
	// Input must be at least 58 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 286 to 304
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)(input[38] & 0x80) << 6);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 305 to 323
	value = ((uint32_t)(input[38] & 0x7f) << 25) |
			((uint32_t)input[39] << 17) |
			((uint32_t)(input[40] & 0xf0) << 9);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 324 to 342
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)(input[42] & 0xfe) << 12);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 343 to 361
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)(input[45] & 0xc0) << 7);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 362 to 380
	value = ((uint32_t)(input[45] & 0x3f) << 26) |
			((uint32_t)input[46] << 18) |
			((uint32_t)(input[47] & 0xf8) << 10);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 381 to 399
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 400 to 418
	value = ((uint32_t)input[50] << 24) |
			((uint32_t)input[51] << 16) |
			((uint32_t)(input[52] & 0xe0) << 8);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 419 to 437
	value = ((uint32_t)(input[52] & 0x1f) << 27) |
			((uint32_t)input[53] << 19) |
			((uint32_t)(input[54] & 0xfc) << 11);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 438 to 456
	value = ((uint32_t)(input[54] & 0x03) << 30) |
			((uint32_t)input[55] << 22) |
			((uint32_t)input[56] << 14) |
			((uint32_t)(input[57] & 0x80) << 6);
	output[23] = (double)(value >> 13);
}

static void unpack_24_19bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 24 values into output
	// Values are 19-bit unsigned
	// Skip 1 bits, read 456 bits of data.
	// Input must be at least 58 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 286 to 304
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)(input[38] & 0x80) << 6);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 305 to 323
	value = ((uint32_t)(input[38] & 0x7f) << 25) |
			((uint32_t)input[39] << 17) |
			((uint32_t)(input[40] & 0xf0) << 9);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 324 to 342
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)(input[42] & 0xfe) << 12);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 343 to 361
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)(input[45] & 0xc0) << 7);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 362 to 380
	value = ((uint32_t)(input[45] & 0x3f) << 26) |
			((uint32_t)input[46] << 18) |
			((uint32_t)(input[47] & 0xf8) << 10);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 381 to 399
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 400 to 418
	value = ((uint32_t)input[50] << 24) |
			((uint32_t)input[51] << 16) |
			((uint32_t)(input[52] & 0xe0) << 8);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 419 to 437
	value = ((uint32_t)(input[52] & 0x1f) << 27) |
			((uint32_t)input[53] << 19) |
			((uint32_t)(input[54] & 0xfc) << 11);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 438 to 456
	value = ((uint32_t)(input[54] & 0x03) << 30) |
			((uint32_t)input[55] << 22) |
			((uint32_t)input[56] << 14) |
			((uint32_t)(input[57] & 0x80) << 6);
	output[23] = (double)(value >> 13);
}

static void unpack_24_19bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 24 values into output
	// Values are 19-bit signed
	// Skip 2 bits, read 456 bits of data.
	// Input must be at least 58 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 287 to 305
	value = ((uint32_t)(input[35] & 0x01) << 31) |
			((uint32_t)input[36] << 23) |
			((uint32_t)input[37] << 15) |
			((uint32_t)(input[38] & 0xc0) << 7);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 306 to 324
	value = ((uint32_t)(input[38] & 0x3f) << 26) |
			((uint32_t)input[39] << 18) |
			((uint32_t)(input[40] & 0xf8) << 10);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 325 to 343
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 344 to 362
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)(input[45] & 0xe0) << 8);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 363 to 381
	value = ((uint32_t)(input[45] & 0x1f) << 27) |
			((uint32_t)input[46] << 19) |
			((uint32_t)(input[47] & 0xfc) << 11);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 382 to 400
	value = ((uint32_t)(input[47] & 0x03) << 30) |
			((uint32_t)input[48] << 22) |
			((uint32_t)input[49] << 14) |
			((uint32_t)(input[50] & 0x80) << 6);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 401 to 419
	value = ((uint32_t)(input[50] & 0x7f) << 25) |
			((uint32_t)input[51] << 17) |
			((uint32_t)(input[52] & 0xf0) << 9);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 420 to 438
	value = ((uint32_t)(input[52] & 0x0f) << 28) |
			((uint32_t)input[53] << 20) |
			((uint32_t)(input[54] & 0xfe) << 12);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 439 to 457
	value = ((uint32_t)(input[54] & 0x01) << 31) |
			((uint32_t)input[55] << 23) |
			((uint32_t)input[56] << 15) |
			((uint32_t)(input[57] & 0xc0) << 7);
	output[23] = (double)(value >> 13);
}

static void unpack_24_19bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 24 values into output
	// Values are 19-bit unsigned
	// Skip 2 bits, read 456 bits of data.
	// Input must be at least 58 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 287 to 305
	value = ((uint32_t)(input[35] & 0x01) << 31) |
			((uint32_t)input[36] << 23) |
			((uint32_t)input[37] << 15) |
			((uint32_t)(input[38] & 0xc0) << 7);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 306 to 324
	value = ((uint32_t)(input[38] & 0x3f) << 26) |
			((uint32_t)input[39] << 18) |
			((uint32_t)(input[40] & 0xf8) << 10);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 325 to 343
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 344 to 362
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)(input[45] & 0xe0) << 8);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 363 to 381
	value = ((uint32_t)(input[45] & 0x1f) << 27) |
			((uint32_t)input[46] << 19) |
			((uint32_t)(input[47] & 0xfc) << 11);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 382 to 400
	value = ((uint32_t)(input[47] & 0x03) << 30) |
			((uint32_t)input[48] << 22) |
			((uint32_t)input[49] << 14) |
			((uint32_t)(input[50] & 0x80) << 6);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 401 to 419
	value = ((uint32_t)(input[50] & 0x7f) << 25) |
			((uint32_t)input[51] << 17) |
			((uint32_t)(input[52] & 0xf0) << 9);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 420 to 438
	value = ((uint32_t)(input[52] & 0x0f) << 28) |
			((uint32_t)input[53] << 20) |
			((uint32_t)(input[54] & 0xfe) << 12);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 439 to 457
	value = ((uint32_t)(input[54] & 0x01) << 31) |
			((uint32_t)input[55] << 23) |
			((uint32_t)input[56] << 15) |
			((uint32_t)(input[57] & 0xc0) << 7);
	output[23] = (double)(value >> 13);
}

static void unpack_24_19bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 24 values into output
	// Values are 19-bit signed
	// Skip 3 bits, read 456 bits of data.
	// Input must be at least 58 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 288 to 306
	value = ((uint32_t)input[36] << 24) |
			((uint32_t)input[37] << 16) |
			((uint32_t)(input[38] & 0xe0) << 8);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 307 to 325
	value = ((uint32_t)(input[38] & 0x1f) << 27) |
			((uint32_t)input[39] << 19) |
			((uint32_t)(input[40] & 0xfc) << 11);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 326 to 344
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)(input[43] & 0x80) << 6);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 345 to 363
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)(input[45] & 0xf0) << 9);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 364 to 382
	value = ((uint32_t)(input[45] & 0x0f) << 28) |
			((uint32_t)input[46] << 20) |
			((uint32_t)(input[47] & 0xfe) << 12);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 383 to 401
	value = ((uint32_t)(input[47] & 0x01) << 31) |
			((uint32_t)input[48] << 23) |
			((uint32_t)input[49] << 15) |
			((uint32_t)(input[50] & 0xc0) << 7);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 402 to 420
	value = ((uint32_t)(input[50] & 0x3f) << 26) |
			((uint32_t)input[51] << 18) |
			((uint32_t)(input[52] & 0xf8) << 10);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 421 to 439
	value = ((uint32_t)(input[52] & 0x07) << 29) |
			((uint32_t)input[53] << 21) |
			((uint32_t)input[54] << 13);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 440 to 458
	value = ((uint32_t)input[55] << 24) |
			((uint32_t)input[56] << 16) |
			((uint32_t)(input[57] & 0xe0) << 8);
	output[23] = (double)(value >> 13);
}

static void unpack_24_19bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 24 values into output
	// Values are 19-bit unsigned
	// Skip 3 bits, read 456 bits of data.
	// Input must be at least 58 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 288 to 306
	value = ((uint32_t)input[36] << 24) |
			((uint32_t)input[37] << 16) |
			((uint32_t)(input[38] & 0xe0) << 8);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 307 to 325
	value = ((uint32_t)(input[38] & 0x1f) << 27) |
			((uint32_t)input[39] << 19) |
			((uint32_t)(input[40] & 0xfc) << 11);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 326 to 344
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)(input[43] & 0x80) << 6);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 345 to 363
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)(input[45] & 0xf0) << 9);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 364 to 382
	value = ((uint32_t)(input[45] & 0x0f) << 28) |
			((uint32_t)input[46] << 20) |
			((uint32_t)(input[47] & 0xfe) << 12);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 383 to 401
	value = ((uint32_t)(input[47] & 0x01) << 31) |
			((uint32_t)input[48] << 23) |
			((uint32_t)input[49] << 15) |
			((uint32_t)(input[50] & 0xc0) << 7);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 402 to 420
	value = ((uint32_t)(input[50] & 0x3f) << 26) |
			((uint32_t)input[51] << 18) |
			((uint32_t)(input[52] & 0xf8) << 10);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 421 to 439
	value = ((uint32_t)(input[52] & 0x07) << 29) |
			((uint32_t)input[53] << 21) |
			((uint32_t)input[54] << 13);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 440 to 458
	value = ((uint32_t)input[55] << 24) |
			((uint32_t)input[56] << 16) |
			((uint32_t)(input[57] & 0xe0) << 8);
	output[23] = (double)(value >> 13);
}

static void unpack_24_19bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 24 values into output
	// Values are 19-bit signed
	// Skip 4 bits, read 456 bits of data.
	// Input must be at least 58 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 289 to 307
	value = ((uint32_t)(input[36] & 0x7f) << 25) |
			((uint32_t)input[37] << 17) |
			((uint32_t)(input[38] & 0xf0) << 9);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 308 to 326
	value = ((uint32_t)(input[38] & 0x0f) << 28) |
			((uint32_t)input[39] << 20) |
			((uint32_t)(input[40] & 0xfe) << 12);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 327 to 345
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)(input[43] & 0xc0) << 7);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 346 to 364
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)(input[45] & 0xf8) << 10);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 365 to 383
	value = ((uint32_t)(input[45] & 0x07) << 29) |
			((uint32_t)input[46] << 21) |
			((uint32_t)input[47] << 13);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 384 to 402
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)(input[50] & 0xe0) << 8);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 403 to 421
	value = ((uint32_t)(input[50] & 0x1f) << 27) |
			((uint32_t)input[51] << 19) |
			((uint32_t)(input[52] & 0xfc) << 11);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 422 to 440
	value = ((uint32_t)(input[52] & 0x03) << 30) |
			((uint32_t)input[53] << 22) |
			((uint32_t)input[54] << 14) |
			((uint32_t)(input[55] & 0x80) << 6);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 441 to 459
	value = ((uint32_t)(input[55] & 0x7f) << 25) |
			((uint32_t)input[56] << 17) |
			((uint32_t)(input[57] & 0xf0) << 9);
	output[23] = (double)(value >> 13);
}

static void unpack_24_19bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 24 values into output
	// Values are 19-bit unsigned
	// Skip 4 bits, read 456 bits of data.
	// Input must be at least 58 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 289 to 307
	value = ((uint32_t)(input[36] & 0x7f) << 25) |
			((uint32_t)input[37] << 17) |
			((uint32_t)(input[38] & 0xf0) << 9);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 308 to 326
	value = ((uint32_t)(input[38] & 0x0f) << 28) |
			((uint32_t)input[39] << 20) |
			((uint32_t)(input[40] & 0xfe) << 12);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 327 to 345
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)(input[43] & 0xc0) << 7);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 346 to 364
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)(input[45] & 0xf8) << 10);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 365 to 383
	value = ((uint32_t)(input[45] & 0x07) << 29) |
			((uint32_t)input[46] << 21) |
			((uint32_t)input[47] << 13);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 384 to 402
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)(input[50] & 0xe0) << 8);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 403 to 421
	value = ((uint32_t)(input[50] & 0x1f) << 27) |
			((uint32_t)input[51] << 19) |
			((uint32_t)(input[52] & 0xfc) << 11);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 422 to 440
	value = ((uint32_t)(input[52] & 0x03) << 30) |
			((uint32_t)input[53] << 22) |
			((uint32_t)input[54] << 14) |
			((uint32_t)(input[55] & 0x80) << 6);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 441 to 459
	value = ((uint32_t)(input[55] & 0x7f) << 25) |
			((uint32_t)input[56] << 17) |
			((uint32_t)(input[57] & 0xf0) << 9);
	output[23] = (double)(value >> 13);
}

static void unpack_24_19bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 24 values into output
	// Values are 19-bit signed
	// Skip 5 bits, read 456 bits of data.
	// Input must be at least 58 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 290 to 308
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)(input[38] & 0xf8) << 10);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 309 to 327
	value = ((uint32_t)(input[38] & 0x07) << 29) |
			((uint32_t)input[39] << 21) |
			((uint32_t)input[40] << 13);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 328 to 346
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)(input[43] & 0xe0) << 8);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 347 to 365
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)(input[45] & 0xfc) << 11);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 366 to 384
	value = ((uint32_t)(input[45] & 0x03) << 30) |
			((uint32_t)input[46] << 22) |
			((uint32_t)input[47] << 14) |
			((uint32_t)(input[48] & 0x80) << 6);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 385 to 403
	value = ((uint32_t)(input[48] & 0x7f) << 25) |
			((uint32_t)input[49] << 17) |
			((uint32_t)(input[50] & 0xf0) << 9);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 404 to 422
	value = ((uint32_t)(input[50] & 0x0f) << 28) |
			((uint32_t)input[51] << 20) |
			((uint32_t)(input[52] & 0xfe) << 12);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 423 to 441
	value = ((uint32_t)(input[52] & 0x01) << 31) |
			((uint32_t)input[53] << 23) |
			((uint32_t)input[54] << 15) |
			((uint32_t)(input[55] & 0xc0) << 7);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 442 to 460
	value = ((uint32_t)(input[55] & 0x3f) << 26) |
			((uint32_t)input[56] << 18) |
			((uint32_t)(input[57] & 0xf8) << 10);
	output[23] = (double)(value >> 13);
}

static void unpack_24_19bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 24 values into output
	// Values are 19-bit unsigned
	// Skip 5 bits, read 456 bits of data.
	// Input must be at least 58 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 290 to 308
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)(input[38] & 0xf8) << 10);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 309 to 327
	value = ((uint32_t)(input[38] & 0x07) << 29) |
			((uint32_t)input[39] << 21) |
			((uint32_t)input[40] << 13);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 328 to 346
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)(input[43] & 0xe0) << 8);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 347 to 365
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)(input[45] & 0xfc) << 11);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 366 to 384
	value = ((uint32_t)(input[45] & 0x03) << 30) |
			((uint32_t)input[46] << 22) |
			((uint32_t)input[47] << 14) |
			((uint32_t)(input[48] & 0x80) << 6);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 385 to 403
	value = ((uint32_t)(input[48] & 0x7f) << 25) |
			((uint32_t)input[49] << 17) |
			((uint32_t)(input[50] & 0xf0) << 9);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 404 to 422
	value = ((uint32_t)(input[50] & 0x0f) << 28) |
			((uint32_t)input[51] << 20) |
			((uint32_t)(input[52] & 0xfe) << 12);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 423 to 441
	value = ((uint32_t)(input[52] & 0x01) << 31) |
			((uint32_t)input[53] << 23) |
			((uint32_t)input[54] << 15) |
			((uint32_t)(input[55] & 0xc0) << 7);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 442 to 460
	value = ((uint32_t)(input[55] & 0x3f) << 26) |
			((uint32_t)input[56] << 18) |
			((uint32_t)(input[57] & 0xf8) << 10);
	output[23] = (double)(value >> 13);
}

static void unpack_24_19bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 24 values into output
	// Values are 19-bit signed
	// Skip 6 bits, read 456 bits of data.
	// Input must be at least 58 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 291 to 309
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)(input[38] & 0xfc) << 11);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 310 to 328
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)(input[41] & 0x80) << 6);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 329 to 347
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)(input[43] & 0xf0) << 9);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 348 to 366
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)(input[45] & 0xfe) << 12);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 367 to 385
	value = ((uint32_t)(input[45] & 0x01) << 31) |
			((uint32_t)input[46] << 23) |
			((uint32_t)input[47] << 15) |
			((uint32_t)(input[48] & 0xc0) << 7);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 386 to 404
	value = ((uint32_t)(input[48] & 0x3f) << 26) |
			((uint32_t)input[49] << 18) |
			((uint32_t)(input[50] & 0xf8) << 10);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 405 to 423
	value = ((uint32_t)(input[50] & 0x07) << 29) |
			((uint32_t)input[51] << 21) |
			((uint32_t)input[52] << 13);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 424 to 442
	value = ((uint32_t)input[53] << 24) |
			((uint32_t)input[54] << 16) |
			((uint32_t)(input[55] & 0xe0) << 8);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 443 to 461
	value = ((uint32_t)(input[55] & 0x1f) << 27) |
			((uint32_t)input[56] << 19) |
			((uint32_t)(input[57] & 0xfc) << 11);
	output[23] = (double)(value >> 13);
}

static void unpack_24_19bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 24 values into output
	// Values are 19-bit unsigned
	// Skip 6 bits, read 456 bits of data.
	// Input must be at least 58 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 291 to 309
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)(input[38] & 0xfc) << 11);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 310 to 328
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)(input[41] & 0x80) << 6);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 329 to 347
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)(input[43] & 0xf0) << 9);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 348 to 366
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)(input[45] & 0xfe) << 12);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 367 to 385
	value = ((uint32_t)(input[45] & 0x01) << 31) |
			((uint32_t)input[46] << 23) |
			((uint32_t)input[47] << 15) |
			((uint32_t)(input[48] & 0xc0) << 7);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 386 to 404
	value = ((uint32_t)(input[48] & 0x3f) << 26) |
			((uint32_t)input[49] << 18) |
			((uint32_t)(input[50] & 0xf8) << 10);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 405 to 423
	value = ((uint32_t)(input[50] & 0x07) << 29) |
			((uint32_t)input[51] << 21) |
			((uint32_t)input[52] << 13);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 424 to 442
	value = ((uint32_t)input[53] << 24) |
			((uint32_t)input[54] << 16) |
			((uint32_t)(input[55] & 0xe0) << 8);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 443 to 461
	value = ((uint32_t)(input[55] & 0x1f) << 27) |
			((uint32_t)input[56] << 19) |
			((uint32_t)(input[57] & 0xfc) << 11);
	output[23] = (double)(value >> 13);
}

static void unpack_24_19bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 24 values into output
	// Values are 19-bit signed
	// Skip 7 bits, read 456 bits of data.
	// Input must be at least 58 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 292 to 310
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)(input[38] & 0xfe) << 12);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 311 to 329
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)(input[41] & 0xc0) << 7);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 330 to 348
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)(input[43] & 0xf8) << 10);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 349 to 367
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 368 to 386
	value = ((uint32_t)input[46] << 24) |
			((uint32_t)input[47] << 16) |
			((uint32_t)(input[48] & 0xe0) << 8);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 387 to 405
	value = ((uint32_t)(input[48] & 0x1f) << 27) |
			((uint32_t)input[49] << 19) |
			((uint32_t)(input[50] & 0xfc) << 11);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 406 to 424
	value = ((uint32_t)(input[50] & 0x03) << 30) |
			((uint32_t)input[51] << 22) |
			((uint32_t)input[52] << 14) |
			((uint32_t)(input[53] & 0x80) << 6);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 425 to 443
	value = ((uint32_t)(input[53] & 0x7f) << 25) |
			((uint32_t)input[54] << 17) |
			((uint32_t)(input[55] & 0xf0) << 9);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 444 to 462
	value = ((uint32_t)(input[55] & 0x0f) << 28) |
			((uint32_t)input[56] << 20) |
			((uint32_t)(input[57] & 0xfe) << 12);
	output[23] = (double)(value >> 13);
}

static void unpack_24_19bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 24 values into output
	// Values are 19-bit unsigned
	// Skip 7 bits, read 456 bits of data.
	// Input must be at least 58 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 292 to 310
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)(input[38] & 0xfe) << 12);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 311 to 329
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)(input[41] & 0xc0) << 7);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 330 to 348
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)(input[43] & 0xf8) << 10);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 349 to 367
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 368 to 386
	value = ((uint32_t)input[46] << 24) |
			((uint32_t)input[47] << 16) |
			((uint32_t)(input[48] & 0xe0) << 8);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 387 to 405
	value = ((uint32_t)(input[48] & 0x1f) << 27) |
			((uint32_t)input[49] << 19) |
			((uint32_t)(input[50] & 0xfc) << 11);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 406 to 424
	value = ((uint32_t)(input[50] & 0x03) << 30) |
			((uint32_t)input[51] << 22) |
			((uint32_t)input[52] << 14) |
			((uint32_t)(input[53] & 0x80) << 6);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 425 to 443
	value = ((uint32_t)(input[53] & 0x7f) << 25) |
			((uint32_t)input[54] << 17) |
			((uint32_t)(input[55] & 0xf0) << 9);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 444 to 462
	value = ((uint32_t)(input[55] & 0x0f) << 28) |
			((uint32_t)input[56] << 20) |
			((uint32_t)(input[57] & 0xfe) << 12);
	output[23] = (double)(value >> 13);
}

static void unpack_25_19bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 25 values into output
	// Values are 19-bit signed
	// Skip 0 bits, read 475 bits of data.
	// Input must be at least 60 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 285 to 303
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 304 to 322
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)(input[40] & 0xe0) << 8);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 323 to 341
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)(input[42] & 0xfc) << 11);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 342 to 360
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)(input[45] & 0x80) << 6);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 361 to 379
	value = ((uint32_t)(input[45] & 0x7f) << 25) |
			((uint32_t)input[46] << 17) |
			((uint32_t)(input[47] & 0xf0) << 9);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 380 to 398
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)(input[49] & 0xfe) << 12);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 399 to 417
	value = ((uint32_t)(input[49] & 0x01) << 31) |
			((uint32_t)input[50] << 23) |
			((uint32_t)input[51] << 15) |
			((uint32_t)(input[52] & 0xc0) << 7);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 418 to 436
	value = ((uint32_t)(input[52] & 0x3f) << 26) |
			((uint32_t)input[53] << 18) |
			((uint32_t)(input[54] & 0xf8) << 10);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 437 to 455
	value = ((uint32_t)(input[54] & 0x07) << 29) |
			((uint32_t)input[55] << 21) |
			((uint32_t)input[56] << 13);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 456 to 474
	value = ((uint32_t)input[57] << 24) |
			((uint32_t)input[58] << 16) |
			((uint32_t)(input[59] & 0xe0) << 8);
	output[24] = (double)(value >> 13);
}

static void unpack_25_19bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 25 values into output
	// Values are 19-bit unsigned
	// Skip 0 bits, read 475 bits of data.
	// Input must be at least 60 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 285 to 303
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 304 to 322
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)(input[40] & 0xe0) << 8);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 323 to 341
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)(input[42] & 0xfc) << 11);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 342 to 360
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)(input[45] & 0x80) << 6);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 361 to 379
	value = ((uint32_t)(input[45] & 0x7f) << 25) |
			((uint32_t)input[46] << 17) |
			((uint32_t)(input[47] & 0xf0) << 9);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 380 to 398
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)(input[49] & 0xfe) << 12);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 399 to 417
	value = ((uint32_t)(input[49] & 0x01) << 31) |
			((uint32_t)input[50] << 23) |
			((uint32_t)input[51] << 15) |
			((uint32_t)(input[52] & 0xc0) << 7);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 418 to 436
	value = ((uint32_t)(input[52] & 0x3f) << 26) |
			((uint32_t)input[53] << 18) |
			((uint32_t)(input[54] & 0xf8) << 10);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 437 to 455
	value = ((uint32_t)(input[54] & 0x07) << 29) |
			((uint32_t)input[55] << 21) |
			((uint32_t)input[56] << 13);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 456 to 474
	value = ((uint32_t)input[57] << 24) |
			((uint32_t)input[58] << 16) |
			((uint32_t)(input[59] & 0xe0) << 8);
	output[24] = (double)(value >> 13);
}

static void unpack_25_19bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 25 values into output
	// Values are 19-bit signed
	// Skip 1 bits, read 475 bits of data.
	// Input must be at least 60 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 286 to 304
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)(input[38] & 0x80) << 6);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 305 to 323
	value = ((uint32_t)(input[38] & 0x7f) << 25) |
			((uint32_t)input[39] << 17) |
			((uint32_t)(input[40] & 0xf0) << 9);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 324 to 342
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)(input[42] & 0xfe) << 12);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 343 to 361
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)(input[45] & 0xc0) << 7);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 362 to 380
	value = ((uint32_t)(input[45] & 0x3f) << 26) |
			((uint32_t)input[46] << 18) |
			((uint32_t)(input[47] & 0xf8) << 10);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 381 to 399
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 400 to 418
	value = ((uint32_t)input[50] << 24) |
			((uint32_t)input[51] << 16) |
			((uint32_t)(input[52] & 0xe0) << 8);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 419 to 437
	value = ((uint32_t)(input[52] & 0x1f) << 27) |
			((uint32_t)input[53] << 19) |
			((uint32_t)(input[54] & 0xfc) << 11);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 438 to 456
	value = ((uint32_t)(input[54] & 0x03) << 30) |
			((uint32_t)input[55] << 22) |
			((uint32_t)input[56] << 14) |
			((uint32_t)(input[57] & 0x80) << 6);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 457 to 475
	value = ((uint32_t)(input[57] & 0x7f) << 25) |
			((uint32_t)input[58] << 17) |
			((uint32_t)(input[59] & 0xf0) << 9);
	output[24] = (double)(value >> 13);
}

static void unpack_25_19bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 25 values into output
	// Values are 19-bit unsigned
	// Skip 1 bits, read 475 bits of data.
	// Input must be at least 60 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 286 to 304
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)(input[38] & 0x80) << 6);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 305 to 323
	value = ((uint32_t)(input[38] & 0x7f) << 25) |
			((uint32_t)input[39] << 17) |
			((uint32_t)(input[40] & 0xf0) << 9);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 324 to 342
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)(input[42] & 0xfe) << 12);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 343 to 361
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)(input[45] & 0xc0) << 7);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 362 to 380
	value = ((uint32_t)(input[45] & 0x3f) << 26) |
			((uint32_t)input[46] << 18) |
			((uint32_t)(input[47] & 0xf8) << 10);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 381 to 399
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 400 to 418
	value = ((uint32_t)input[50] << 24) |
			((uint32_t)input[51] << 16) |
			((uint32_t)(input[52] & 0xe0) << 8);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 419 to 437
	value = ((uint32_t)(input[52] & 0x1f) << 27) |
			((uint32_t)input[53] << 19) |
			((uint32_t)(input[54] & 0xfc) << 11);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 438 to 456
	value = ((uint32_t)(input[54] & 0x03) << 30) |
			((uint32_t)input[55] << 22) |
			((uint32_t)input[56] << 14) |
			((uint32_t)(input[57] & 0x80) << 6);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 457 to 475
	value = ((uint32_t)(input[57] & 0x7f) << 25) |
			((uint32_t)input[58] << 17) |
			((uint32_t)(input[59] & 0xf0) << 9);
	output[24] = (double)(value >> 13);
}

static void unpack_25_19bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 25 values into output
	// Values are 19-bit signed
	// Skip 2 bits, read 475 bits of data.
	// Input must be at least 60 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 287 to 305
	value = ((uint32_t)(input[35] & 0x01) << 31) |
			((uint32_t)input[36] << 23) |
			((uint32_t)input[37] << 15) |
			((uint32_t)(input[38] & 0xc0) << 7);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 306 to 324
	value = ((uint32_t)(input[38] & 0x3f) << 26) |
			((uint32_t)input[39] << 18) |
			((uint32_t)(input[40] & 0xf8) << 10);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 325 to 343
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 344 to 362
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)(input[45] & 0xe0) << 8);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 363 to 381
	value = ((uint32_t)(input[45] & 0x1f) << 27) |
			((uint32_t)input[46] << 19) |
			((uint32_t)(input[47] & 0xfc) << 11);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 382 to 400
	value = ((uint32_t)(input[47] & 0x03) << 30) |
			((uint32_t)input[48] << 22) |
			((uint32_t)input[49] << 14) |
			((uint32_t)(input[50] & 0x80) << 6);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 401 to 419
	value = ((uint32_t)(input[50] & 0x7f) << 25) |
			((uint32_t)input[51] << 17) |
			((uint32_t)(input[52] & 0xf0) << 9);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 420 to 438
	value = ((uint32_t)(input[52] & 0x0f) << 28) |
			((uint32_t)input[53] << 20) |
			((uint32_t)(input[54] & 0xfe) << 12);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 439 to 457
	value = ((uint32_t)(input[54] & 0x01) << 31) |
			((uint32_t)input[55] << 23) |
			((uint32_t)input[56] << 15) |
			((uint32_t)(input[57] & 0xc0) << 7);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 458 to 476
	value = ((uint32_t)(input[57] & 0x3f) << 26) |
			((uint32_t)input[58] << 18) |
			((uint32_t)(input[59] & 0xf8) << 10);
	output[24] = (double)(value >> 13);
}

static void unpack_25_19bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 25 values into output
	// Values are 19-bit unsigned
	// Skip 2 bits, read 475 bits of data.
	// Input must be at least 60 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 287 to 305
	value = ((uint32_t)(input[35] & 0x01) << 31) |
			((uint32_t)input[36] << 23) |
			((uint32_t)input[37] << 15) |
			((uint32_t)(input[38] & 0xc0) << 7);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 306 to 324
	value = ((uint32_t)(input[38] & 0x3f) << 26) |
			((uint32_t)input[39] << 18) |
			((uint32_t)(input[40] & 0xf8) << 10);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 325 to 343
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 344 to 362
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)(input[45] & 0xe0) << 8);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 363 to 381
	value = ((uint32_t)(input[45] & 0x1f) << 27) |
			((uint32_t)input[46] << 19) |
			((uint32_t)(input[47] & 0xfc) << 11);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 382 to 400
	value = ((uint32_t)(input[47] & 0x03) << 30) |
			((uint32_t)input[48] << 22) |
			((uint32_t)input[49] << 14) |
			((uint32_t)(input[50] & 0x80) << 6);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 401 to 419
	value = ((uint32_t)(input[50] & 0x7f) << 25) |
			((uint32_t)input[51] << 17) |
			((uint32_t)(input[52] & 0xf0) << 9);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 420 to 438
	value = ((uint32_t)(input[52] & 0x0f) << 28) |
			((uint32_t)input[53] << 20) |
			((uint32_t)(input[54] & 0xfe) << 12);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 439 to 457
	value = ((uint32_t)(input[54] & 0x01) << 31) |
			((uint32_t)input[55] << 23) |
			((uint32_t)input[56] << 15) |
			((uint32_t)(input[57] & 0xc0) << 7);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 458 to 476
	value = ((uint32_t)(input[57] & 0x3f) << 26) |
			((uint32_t)input[58] << 18) |
			((uint32_t)(input[59] & 0xf8) << 10);
	output[24] = (double)(value >> 13);
}

static void unpack_25_19bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 25 values into output
	// Values are 19-bit signed
	// Skip 3 bits, read 475 bits of data.
	// Input must be at least 60 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 288 to 306
	value = ((uint32_t)input[36] << 24) |
			((uint32_t)input[37] << 16) |
			((uint32_t)(input[38] & 0xe0) << 8);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 307 to 325
	value = ((uint32_t)(input[38] & 0x1f) << 27) |
			((uint32_t)input[39] << 19) |
			((uint32_t)(input[40] & 0xfc) << 11);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 326 to 344
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)(input[43] & 0x80) << 6);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 345 to 363
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)(input[45] & 0xf0) << 9);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 364 to 382
	value = ((uint32_t)(input[45] & 0x0f) << 28) |
			((uint32_t)input[46] << 20) |
			((uint32_t)(input[47] & 0xfe) << 12);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 383 to 401
	value = ((uint32_t)(input[47] & 0x01) << 31) |
			((uint32_t)input[48] << 23) |
			((uint32_t)input[49] << 15) |
			((uint32_t)(input[50] & 0xc0) << 7);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 402 to 420
	value = ((uint32_t)(input[50] & 0x3f) << 26) |
			((uint32_t)input[51] << 18) |
			((uint32_t)(input[52] & 0xf8) << 10);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 421 to 439
	value = ((uint32_t)(input[52] & 0x07) << 29) |
			((uint32_t)input[53] << 21) |
			((uint32_t)input[54] << 13);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 440 to 458
	value = ((uint32_t)input[55] << 24) |
			((uint32_t)input[56] << 16) |
			((uint32_t)(input[57] & 0xe0) << 8);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 459 to 477
	value = ((uint32_t)(input[57] & 0x1f) << 27) |
			((uint32_t)input[58] << 19) |
			((uint32_t)(input[59] & 0xfc) << 11);
	output[24] = (double)(value >> 13);
}

static void unpack_25_19bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 25 values into output
	// Values are 19-bit unsigned
	// Skip 3 bits, read 475 bits of data.
	// Input must be at least 60 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 288 to 306
	value = ((uint32_t)input[36] << 24) |
			((uint32_t)input[37] << 16) |
			((uint32_t)(input[38] & 0xe0) << 8);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 307 to 325
	value = ((uint32_t)(input[38] & 0x1f) << 27) |
			((uint32_t)input[39] << 19) |
			((uint32_t)(input[40] & 0xfc) << 11);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 326 to 344
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)(input[43] & 0x80) << 6);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 345 to 363
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)(input[45] & 0xf0) << 9);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 364 to 382
	value = ((uint32_t)(input[45] & 0x0f) << 28) |
			((uint32_t)input[46] << 20) |
			((uint32_t)(input[47] & 0xfe) << 12);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 383 to 401
	value = ((uint32_t)(input[47] & 0x01) << 31) |
			((uint32_t)input[48] << 23) |
			((uint32_t)input[49] << 15) |
			((uint32_t)(input[50] & 0xc0) << 7);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 402 to 420
	value = ((uint32_t)(input[50] & 0x3f) << 26) |
			((uint32_t)input[51] << 18) |
			((uint32_t)(input[52] & 0xf8) << 10);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 421 to 439
	value = ((uint32_t)(input[52] & 0x07) << 29) |
			((uint32_t)input[53] << 21) |
			((uint32_t)input[54] << 13);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 440 to 458
	value = ((uint32_t)input[55] << 24) |
			((uint32_t)input[56] << 16) |
			((uint32_t)(input[57] & 0xe0) << 8);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 459 to 477
	value = ((uint32_t)(input[57] & 0x1f) << 27) |
			((uint32_t)input[58] << 19) |
			((uint32_t)(input[59] & 0xfc) << 11);
	output[24] = (double)(value >> 13);
}

static void unpack_25_19bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 25 values into output
	// Values are 19-bit signed
	// Skip 4 bits, read 475 bits of data.
	// Input must be at least 60 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 289 to 307
	value = ((uint32_t)(input[36] & 0x7f) << 25) |
			((uint32_t)input[37] << 17) |
			((uint32_t)(input[38] & 0xf0) << 9);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 308 to 326
	value = ((uint32_t)(input[38] & 0x0f) << 28) |
			((uint32_t)input[39] << 20) |
			((uint32_t)(input[40] & 0xfe) << 12);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 327 to 345
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)(input[43] & 0xc0) << 7);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 346 to 364
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)(input[45] & 0xf8) << 10);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 365 to 383
	value = ((uint32_t)(input[45] & 0x07) << 29) |
			((uint32_t)input[46] << 21) |
			((uint32_t)input[47] << 13);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 384 to 402
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)(input[50] & 0xe0) << 8);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 403 to 421
	value = ((uint32_t)(input[50] & 0x1f) << 27) |
			((uint32_t)input[51] << 19) |
			((uint32_t)(input[52] & 0xfc) << 11);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 422 to 440
	value = ((uint32_t)(input[52] & 0x03) << 30) |
			((uint32_t)input[53] << 22) |
			((uint32_t)input[54] << 14) |
			((uint32_t)(input[55] & 0x80) << 6);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 441 to 459
	value = ((uint32_t)(input[55] & 0x7f) << 25) |
			((uint32_t)input[56] << 17) |
			((uint32_t)(input[57] & 0xf0) << 9);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 460 to 478
	value = ((uint32_t)(input[57] & 0x0f) << 28) |
			((uint32_t)input[58] << 20) |
			((uint32_t)(input[59] & 0xfe) << 12);
	output[24] = (double)(value >> 13);
}

static void unpack_25_19bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 25 values into output
	// Values are 19-bit unsigned
	// Skip 4 bits, read 475 bits of data.
	// Input must be at least 60 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 289 to 307
	value = ((uint32_t)(input[36] & 0x7f) << 25) |
			((uint32_t)input[37] << 17) |
			((uint32_t)(input[38] & 0xf0) << 9);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 308 to 326
	value = ((uint32_t)(input[38] & 0x0f) << 28) |
			((uint32_t)input[39] << 20) |
			((uint32_t)(input[40] & 0xfe) << 12);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 327 to 345
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)(input[43] & 0xc0) << 7);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 346 to 364
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)(input[45] & 0xf8) << 10);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 365 to 383
	value = ((uint32_t)(input[45] & 0x07) << 29) |
			((uint32_t)input[46] << 21) |
			((uint32_t)input[47] << 13);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 384 to 402
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)(input[50] & 0xe0) << 8);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 403 to 421
	value = ((uint32_t)(input[50] & 0x1f) << 27) |
			((uint32_t)input[51] << 19) |
			((uint32_t)(input[52] & 0xfc) << 11);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 422 to 440
	value = ((uint32_t)(input[52] & 0x03) << 30) |
			((uint32_t)input[53] << 22) |
			((uint32_t)input[54] << 14) |
			((uint32_t)(input[55] & 0x80) << 6);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 441 to 459
	value = ((uint32_t)(input[55] & 0x7f) << 25) |
			((uint32_t)input[56] << 17) |
			((uint32_t)(input[57] & 0xf0) << 9);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 460 to 478
	value = ((uint32_t)(input[57] & 0x0f) << 28) |
			((uint32_t)input[58] << 20) |
			((uint32_t)(input[59] & 0xfe) << 12);
	output[24] = (double)(value >> 13);
}

static void unpack_25_19bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 25 values into output
	// Values are 19-bit signed
	// Skip 5 bits, read 475 bits of data.
	// Input must be at least 60 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 290 to 308
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)(input[38] & 0xf8) << 10);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 309 to 327
	value = ((uint32_t)(input[38] & 0x07) << 29) |
			((uint32_t)input[39] << 21) |
			((uint32_t)input[40] << 13);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 328 to 346
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)(input[43] & 0xe0) << 8);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 347 to 365
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)(input[45] & 0xfc) << 11);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 366 to 384
	value = ((uint32_t)(input[45] & 0x03) << 30) |
			((uint32_t)input[46] << 22) |
			((uint32_t)input[47] << 14) |
			((uint32_t)(input[48] & 0x80) << 6);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 385 to 403
	value = ((uint32_t)(input[48] & 0x7f) << 25) |
			((uint32_t)input[49] << 17) |
			((uint32_t)(input[50] & 0xf0) << 9);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 404 to 422
	value = ((uint32_t)(input[50] & 0x0f) << 28) |
			((uint32_t)input[51] << 20) |
			((uint32_t)(input[52] & 0xfe) << 12);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 423 to 441
	value = ((uint32_t)(input[52] & 0x01) << 31) |
			((uint32_t)input[53] << 23) |
			((uint32_t)input[54] << 15) |
			((uint32_t)(input[55] & 0xc0) << 7);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 442 to 460
	value = ((uint32_t)(input[55] & 0x3f) << 26) |
			((uint32_t)input[56] << 18) |
			((uint32_t)(input[57] & 0xf8) << 10);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 461 to 479
	value = ((uint32_t)(input[57] & 0x07) << 29) |
			((uint32_t)input[58] << 21) |
			((uint32_t)input[59] << 13);
	output[24] = (double)(value >> 13);
}

static void unpack_25_19bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 25 values into output
	// Values are 19-bit unsigned
	// Skip 5 bits, read 475 bits of data.
	// Input must be at least 60 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 290 to 308
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)(input[38] & 0xf8) << 10);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 309 to 327
	value = ((uint32_t)(input[38] & 0x07) << 29) |
			((uint32_t)input[39] << 21) |
			((uint32_t)input[40] << 13);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 328 to 346
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)(input[43] & 0xe0) << 8);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 347 to 365
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)(input[45] & 0xfc) << 11);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 366 to 384
	value = ((uint32_t)(input[45] & 0x03) << 30) |
			((uint32_t)input[46] << 22) |
			((uint32_t)input[47] << 14) |
			((uint32_t)(input[48] & 0x80) << 6);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 385 to 403
	value = ((uint32_t)(input[48] & 0x7f) << 25) |
			((uint32_t)input[49] << 17) |
			((uint32_t)(input[50] & 0xf0) << 9);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 404 to 422
	value = ((uint32_t)(input[50] & 0x0f) << 28) |
			((uint32_t)input[51] << 20) |
			((uint32_t)(input[52] & 0xfe) << 12);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 423 to 441
	value = ((uint32_t)(input[52] & 0x01) << 31) |
			((uint32_t)input[53] << 23) |
			((uint32_t)input[54] << 15) |
			((uint32_t)(input[55] & 0xc0) << 7);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 442 to 460
	value = ((uint32_t)(input[55] & 0x3f) << 26) |
			((uint32_t)input[56] << 18) |
			((uint32_t)(input[57] & 0xf8) << 10);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 461 to 479
	value = ((uint32_t)(input[57] & 0x07) << 29) |
			((uint32_t)input[58] << 21) |
			((uint32_t)input[59] << 13);
	output[24] = (double)(value >> 13);
}

static void unpack_25_19bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 25 values into output
	// Values are 19-bit signed
	// Skip 6 bits, read 475 bits of data.
	// Input must be at least 61 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 291 to 309
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)(input[38] & 0xfc) << 11);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 310 to 328
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)(input[41] & 0x80) << 6);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 329 to 347
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)(input[43] & 0xf0) << 9);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 348 to 366
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)(input[45] & 0xfe) << 12);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 367 to 385
	value = ((uint32_t)(input[45] & 0x01) << 31) |
			((uint32_t)input[46] << 23) |
			((uint32_t)input[47] << 15) |
			((uint32_t)(input[48] & 0xc0) << 7);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 386 to 404
	value = ((uint32_t)(input[48] & 0x3f) << 26) |
			((uint32_t)input[49] << 18) |
			((uint32_t)(input[50] & 0xf8) << 10);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 405 to 423
	value = ((uint32_t)(input[50] & 0x07) << 29) |
			((uint32_t)input[51] << 21) |
			((uint32_t)input[52] << 13);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 424 to 442
	value = ((uint32_t)input[53] << 24) |
			((uint32_t)input[54] << 16) |
			((uint32_t)(input[55] & 0xe0) << 8);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 443 to 461
	value = ((uint32_t)(input[55] & 0x1f) << 27) |
			((uint32_t)input[56] << 19) |
			((uint32_t)(input[57] & 0xfc) << 11);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 462 to 480
	value = ((uint32_t)(input[57] & 0x03) << 30) |
			((uint32_t)input[58] << 22) |
			((uint32_t)input[59] << 14) |
			((uint32_t)(input[60] & 0x80) << 6);
	output[24] = (double)(value >> 13);
}

static void unpack_25_19bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 25 values into output
	// Values are 19-bit unsigned
	// Skip 6 bits, read 475 bits of data.
	// Input must be at least 61 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 291 to 309
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)(input[38] & 0xfc) << 11);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 310 to 328
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)(input[41] & 0x80) << 6);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 329 to 347
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)(input[43] & 0xf0) << 9);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 348 to 366
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)(input[45] & 0xfe) << 12);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 367 to 385
	value = ((uint32_t)(input[45] & 0x01) << 31) |
			((uint32_t)input[46] << 23) |
			((uint32_t)input[47] << 15) |
			((uint32_t)(input[48] & 0xc0) << 7);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 386 to 404
	value = ((uint32_t)(input[48] & 0x3f) << 26) |
			((uint32_t)input[49] << 18) |
			((uint32_t)(input[50] & 0xf8) << 10);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 405 to 423
	value = ((uint32_t)(input[50] & 0x07) << 29) |
			((uint32_t)input[51] << 21) |
			((uint32_t)input[52] << 13);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 424 to 442
	value = ((uint32_t)input[53] << 24) |
			((uint32_t)input[54] << 16) |
			((uint32_t)(input[55] & 0xe0) << 8);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 443 to 461
	value = ((uint32_t)(input[55] & 0x1f) << 27) |
			((uint32_t)input[56] << 19) |
			((uint32_t)(input[57] & 0xfc) << 11);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 462 to 480
	value = ((uint32_t)(input[57] & 0x03) << 30) |
			((uint32_t)input[58] << 22) |
			((uint32_t)input[59] << 14) |
			((uint32_t)(input[60] & 0x80) << 6);
	output[24] = (double)(value >> 13);
}

static void unpack_25_19bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 25 values into output
	// Values are 19-bit signed
	// Skip 7 bits, read 475 bits of data.
	// Input must be at least 61 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 292 to 310
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)(input[38] & 0xfe) << 12);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 311 to 329
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)(input[41] & 0xc0) << 7);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 330 to 348
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)(input[43] & 0xf8) << 10);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 349 to 367
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 368 to 386
	value = ((uint32_t)input[46] << 24) |
			((uint32_t)input[47] << 16) |
			((uint32_t)(input[48] & 0xe0) << 8);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 387 to 405
	value = ((uint32_t)(input[48] & 0x1f) << 27) |
			((uint32_t)input[49] << 19) |
			((uint32_t)(input[50] & 0xfc) << 11);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 406 to 424
	value = ((uint32_t)(input[50] & 0x03) << 30) |
			((uint32_t)input[51] << 22) |
			((uint32_t)input[52] << 14) |
			((uint32_t)(input[53] & 0x80) << 6);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 425 to 443
	value = ((uint32_t)(input[53] & 0x7f) << 25) |
			((uint32_t)input[54] << 17) |
			((uint32_t)(input[55] & 0xf0) << 9);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 444 to 462
	value = ((uint32_t)(input[55] & 0x0f) << 28) |
			((uint32_t)input[56] << 20) |
			((uint32_t)(input[57] & 0xfe) << 12);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 463 to 481
	value = ((uint32_t)(input[57] & 0x01) << 31) |
			((uint32_t)input[58] << 23) |
			((uint32_t)input[59] << 15) |
			((uint32_t)(input[60] & 0xc0) << 7);
	output[24] = (double)(value >> 13);
}

static void unpack_25_19bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 25 values into output
	// Values are 19-bit unsigned
	// Skip 7 bits, read 475 bits of data.
	// Input must be at least 61 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 292 to 310
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)(input[38] & 0xfe) << 12);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 311 to 329
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)(input[41] & 0xc0) << 7);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 330 to 348
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)(input[43] & 0xf8) << 10);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 349 to 367
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 368 to 386
	value = ((uint32_t)input[46] << 24) |
			((uint32_t)input[47] << 16) |
			((uint32_t)(input[48] & 0xe0) << 8);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 387 to 405
	value = ((uint32_t)(input[48] & 0x1f) << 27) |
			((uint32_t)input[49] << 19) |
			((uint32_t)(input[50] & 0xfc) << 11);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 406 to 424
	value = ((uint32_t)(input[50] & 0x03) << 30) |
			((uint32_t)input[51] << 22) |
			((uint32_t)input[52] << 14) |
			((uint32_t)(input[53] & 0x80) << 6);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 425 to 443
	value = ((uint32_t)(input[53] & 0x7f) << 25) |
			((uint32_t)input[54] << 17) |
			((uint32_t)(input[55] & 0xf0) << 9);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 444 to 462
	value = ((uint32_t)(input[55] & 0x0f) << 28) |
			((uint32_t)input[56] << 20) |
			((uint32_t)(input[57] & 0xfe) << 12);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 463 to 481
	value = ((uint32_t)(input[57] & 0x01) << 31) |
			((uint32_t)input[58] << 23) |
			((uint32_t)input[59] << 15) |
			((uint32_t)(input[60] & 0xc0) << 7);
	output[24] = (double)(value >> 13);
}

static void unpack_26_19bit_signed_0off(const uint8_t * input, double * output) {
	// Unpack 26 values into output
	// Values are 19-bit signed
	// Skip 0 bits, read 494 bits of data.
	// Input must be at least 62 bytes long

	int32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 285 to 303
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 304 to 322
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)(input[40] & 0xe0) << 8);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 323 to 341
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)(input[42] & 0xfc) << 11);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 342 to 360
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)(input[45] & 0x80) << 6);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 361 to 379
	value = ((uint32_t)(input[45] & 0x7f) << 25) |
			((uint32_t)input[46] << 17) |
			((uint32_t)(input[47] & 0xf0) << 9);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 380 to 398
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)(input[49] & 0xfe) << 12);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 399 to 417
	value = ((uint32_t)(input[49] & 0x01) << 31) |
			((uint32_t)input[50] << 23) |
			((uint32_t)input[51] << 15) |
			((uint32_t)(input[52] & 0xc0) << 7);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 418 to 436
	value = ((uint32_t)(input[52] & 0x3f) << 26) |
			((uint32_t)input[53] << 18) |
			((uint32_t)(input[54] & 0xf8) << 10);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 437 to 455
	value = ((uint32_t)(input[54] & 0x07) << 29) |
			((uint32_t)input[55] << 21) |
			((uint32_t)input[56] << 13);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 456 to 474
	value = ((uint32_t)input[57] << 24) |
			((uint32_t)input[58] << 16) |
			((uint32_t)(input[59] & 0xe0) << 8);
	output[24] = (double)(value >> 13);

	// read output[25]: from bit 475 to 493
	value = ((uint32_t)(input[59] & 0x1f) << 27) |
			((uint32_t)input[60] << 19) |
			((uint32_t)(input[61] & 0xfc) << 11);
	output[25] = (double)(value >> 13);
}

static void unpack_26_19bit_unsigned_0off(const uint8_t * input, double * output) {
	// Unpack 26 values into output
	// Values are 19-bit unsigned
	// Skip 0 bits, read 494 bits of data.
	// Input must be at least 62 bytes long

	uint32_t value;

	// read output[0]: from bit 0 to 18
	value = ((uint32_t)input[0] << 24) |
			((uint32_t)input[1] << 16) |
			((uint32_t)(input[2] & 0xe0) << 8);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 19 to 37
	value = ((uint32_t)(input[2] & 0x1f) << 27) |
			((uint32_t)input[3] << 19) |
			((uint32_t)(input[4] & 0xfc) << 11);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 38 to 56
	value = ((uint32_t)(input[4] & 0x03) << 30) |
			((uint32_t)input[5] << 22) |
			((uint32_t)input[6] << 14) |
			((uint32_t)(input[7] & 0x80) << 6);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 57 to 75
	value = ((uint32_t)(input[7] & 0x7f) << 25) |
			((uint32_t)input[8] << 17) |
			((uint32_t)(input[9] & 0xf0) << 9);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 76 to 94
	value = ((uint32_t)(input[9] & 0x0f) << 28) |
			((uint32_t)input[10] << 20) |
			((uint32_t)(input[11] & 0xfe) << 12);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 95 to 113
	value = ((uint32_t)(input[11] & 0x01) << 31) |
			((uint32_t)input[12] << 23) |
			((uint32_t)input[13] << 15) |
			((uint32_t)(input[14] & 0xc0) << 7);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 114 to 132
	value = ((uint32_t)(input[14] & 0x3f) << 26) |
			((uint32_t)input[15] << 18) |
			((uint32_t)(input[16] & 0xf8) << 10);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 133 to 151
	value = ((uint32_t)(input[16] & 0x07) << 29) |
			((uint32_t)input[17] << 21) |
			((uint32_t)input[18] << 13);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 152 to 170
	value = ((uint32_t)input[19] << 24) |
			((uint32_t)input[20] << 16) |
			((uint32_t)(input[21] & 0xe0) << 8);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 171 to 189
	value = ((uint32_t)(input[21] & 0x1f) << 27) |
			((uint32_t)input[22] << 19) |
			((uint32_t)(input[23] & 0xfc) << 11);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 190 to 208
	value = ((uint32_t)(input[23] & 0x03) << 30) |
			((uint32_t)input[24] << 22) |
			((uint32_t)input[25] << 14) |
			((uint32_t)(input[26] & 0x80) << 6);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 209 to 227
	value = ((uint32_t)(input[26] & 0x7f) << 25) |
			((uint32_t)input[27] << 17) |
			((uint32_t)(input[28] & 0xf0) << 9);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 228 to 246
	value = ((uint32_t)(input[28] & 0x0f) << 28) |
			((uint32_t)input[29] << 20) |
			((uint32_t)(input[30] & 0xfe) << 12);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 247 to 265
	value = ((uint32_t)(input[30] & 0x01) << 31) |
			((uint32_t)input[31] << 23) |
			((uint32_t)input[32] << 15) |
			((uint32_t)(input[33] & 0xc0) << 7);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 266 to 284
	value = ((uint32_t)(input[33] & 0x3f) << 26) |
			((uint32_t)input[34] << 18) |
			((uint32_t)(input[35] & 0xf8) << 10);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 285 to 303
	value = ((uint32_t)(input[35] & 0x07) << 29) |
			((uint32_t)input[36] << 21) |
			((uint32_t)input[37] << 13);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 304 to 322
	value = ((uint32_t)input[38] << 24) |
			((uint32_t)input[39] << 16) |
			((uint32_t)(input[40] & 0xe0) << 8);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 323 to 341
	value = ((uint32_t)(input[40] & 0x1f) << 27) |
			((uint32_t)input[41] << 19) |
			((uint32_t)(input[42] & 0xfc) << 11);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 342 to 360
	value = ((uint32_t)(input[42] & 0x03) << 30) |
			((uint32_t)input[43] << 22) |
			((uint32_t)input[44] << 14) |
			((uint32_t)(input[45] & 0x80) << 6);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 361 to 379
	value = ((uint32_t)(input[45] & 0x7f) << 25) |
			((uint32_t)input[46] << 17) |
			((uint32_t)(input[47] & 0xf0) << 9);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 380 to 398
	value = ((uint32_t)(input[47] & 0x0f) << 28) |
			((uint32_t)input[48] << 20) |
			((uint32_t)(input[49] & 0xfe) << 12);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 399 to 417
	value = ((uint32_t)(input[49] & 0x01) << 31) |
			((uint32_t)input[50] << 23) |
			((uint32_t)input[51] << 15) |
			((uint32_t)(input[52] & 0xc0) << 7);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 418 to 436
	value = ((uint32_t)(input[52] & 0x3f) << 26) |
			((uint32_t)input[53] << 18) |
			((uint32_t)(input[54] & 0xf8) << 10);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 437 to 455
	value = ((uint32_t)(input[54] & 0x07) << 29) |
			((uint32_t)input[55] << 21) |
			((uint32_t)input[56] << 13);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 456 to 474
	value = ((uint32_t)input[57] << 24) |
			((uint32_t)input[58] << 16) |
			((uint32_t)(input[59] & 0xe0) << 8);
	output[24] = (double)(value >> 13);

	// read output[25]: from bit 475 to 493
	value = ((uint32_t)(input[59] & 0x1f) << 27) |
			((uint32_t)input[60] << 19) |
			((uint32_t)(input[61] & 0xfc) << 11);
	output[25] = (double)(value >> 13);
}

static void unpack_26_19bit_signed_1off(const uint8_t * input, double * output) {
	// Unpack 26 values into output
	// Values are 19-bit signed
	// Skip 1 bits, read 494 bits of data.
	// Input must be at least 62 bytes long

	int32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 286 to 304
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)(input[38] & 0x80) << 6);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 305 to 323
	value = ((uint32_t)(input[38] & 0x7f) << 25) |
			((uint32_t)input[39] << 17) |
			((uint32_t)(input[40] & 0xf0) << 9);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 324 to 342
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)(input[42] & 0xfe) << 12);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 343 to 361
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)(input[45] & 0xc0) << 7);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 362 to 380
	value = ((uint32_t)(input[45] & 0x3f) << 26) |
			((uint32_t)input[46] << 18) |
			((uint32_t)(input[47] & 0xf8) << 10);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 381 to 399
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 400 to 418
	value = ((uint32_t)input[50] << 24) |
			((uint32_t)input[51] << 16) |
			((uint32_t)(input[52] & 0xe0) << 8);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 419 to 437
	value = ((uint32_t)(input[52] & 0x1f) << 27) |
			((uint32_t)input[53] << 19) |
			((uint32_t)(input[54] & 0xfc) << 11);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 438 to 456
	value = ((uint32_t)(input[54] & 0x03) << 30) |
			((uint32_t)input[55] << 22) |
			((uint32_t)input[56] << 14) |
			((uint32_t)(input[57] & 0x80) << 6);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 457 to 475
	value = ((uint32_t)(input[57] & 0x7f) << 25) |
			((uint32_t)input[58] << 17) |
			((uint32_t)(input[59] & 0xf0) << 9);
	output[24] = (double)(value >> 13);

	// read output[25]: from bit 476 to 494
	value = ((uint32_t)(input[59] & 0x0f) << 28) |
			((uint32_t)input[60] << 20) |
			((uint32_t)(input[61] & 0xfe) << 12);
	output[25] = (double)(value >> 13);
}

static void unpack_26_19bit_unsigned_1off(const uint8_t * input, double * output) {
	// Unpack 26 values into output
	// Values are 19-bit unsigned
	// Skip 1 bits, read 494 bits of data.
	// Input must be at least 62 bytes long

	uint32_t value;

	// read output[0]: from bit 1 to 19
	value = ((uint32_t)(input[0] & 0x7f) << 25) |
			((uint32_t)input[1] << 17) |
			((uint32_t)(input[2] & 0xf0) << 9);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 20 to 38
	value = ((uint32_t)(input[2] & 0x0f) << 28) |
			((uint32_t)input[3] << 20) |
			((uint32_t)(input[4] & 0xfe) << 12);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 39 to 57
	value = ((uint32_t)(input[4] & 0x01) << 31) |
			((uint32_t)input[5] << 23) |
			((uint32_t)input[6] << 15) |
			((uint32_t)(input[7] & 0xc0) << 7);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 58 to 76
	value = ((uint32_t)(input[7] & 0x3f) << 26) |
			((uint32_t)input[8] << 18) |
			((uint32_t)(input[9] & 0xf8) << 10);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 77 to 95
	value = ((uint32_t)(input[9] & 0x07) << 29) |
			((uint32_t)input[10] << 21) |
			((uint32_t)input[11] << 13);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 96 to 114
	value = ((uint32_t)input[12] << 24) |
			((uint32_t)input[13] << 16) |
			((uint32_t)(input[14] & 0xe0) << 8);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 115 to 133
	value = ((uint32_t)(input[14] & 0x1f) << 27) |
			((uint32_t)input[15] << 19) |
			((uint32_t)(input[16] & 0xfc) << 11);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 134 to 152
	value = ((uint32_t)(input[16] & 0x03) << 30) |
			((uint32_t)input[17] << 22) |
			((uint32_t)input[18] << 14) |
			((uint32_t)(input[19] & 0x80) << 6);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 153 to 171
	value = ((uint32_t)(input[19] & 0x7f) << 25) |
			((uint32_t)input[20] << 17) |
			((uint32_t)(input[21] & 0xf0) << 9);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 172 to 190
	value = ((uint32_t)(input[21] & 0x0f) << 28) |
			((uint32_t)input[22] << 20) |
			((uint32_t)(input[23] & 0xfe) << 12);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 191 to 209
	value = ((uint32_t)(input[23] & 0x01) << 31) |
			((uint32_t)input[24] << 23) |
			((uint32_t)input[25] << 15) |
			((uint32_t)(input[26] & 0xc0) << 7);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 210 to 228
	value = ((uint32_t)(input[26] & 0x3f) << 26) |
			((uint32_t)input[27] << 18) |
			((uint32_t)(input[28] & 0xf8) << 10);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 229 to 247
	value = ((uint32_t)(input[28] & 0x07) << 29) |
			((uint32_t)input[29] << 21) |
			((uint32_t)input[30] << 13);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 248 to 266
	value = ((uint32_t)input[31] << 24) |
			((uint32_t)input[32] << 16) |
			((uint32_t)(input[33] & 0xe0) << 8);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 267 to 285
	value = ((uint32_t)(input[33] & 0x1f) << 27) |
			((uint32_t)input[34] << 19) |
			((uint32_t)(input[35] & 0xfc) << 11);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 286 to 304
	value = ((uint32_t)(input[35] & 0x03) << 30) |
			((uint32_t)input[36] << 22) |
			((uint32_t)input[37] << 14) |
			((uint32_t)(input[38] & 0x80) << 6);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 305 to 323
	value = ((uint32_t)(input[38] & 0x7f) << 25) |
			((uint32_t)input[39] << 17) |
			((uint32_t)(input[40] & 0xf0) << 9);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 324 to 342
	value = ((uint32_t)(input[40] & 0x0f) << 28) |
			((uint32_t)input[41] << 20) |
			((uint32_t)(input[42] & 0xfe) << 12);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 343 to 361
	value = ((uint32_t)(input[42] & 0x01) << 31) |
			((uint32_t)input[43] << 23) |
			((uint32_t)input[44] << 15) |
			((uint32_t)(input[45] & 0xc0) << 7);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 362 to 380
	value = ((uint32_t)(input[45] & 0x3f) << 26) |
			((uint32_t)input[46] << 18) |
			((uint32_t)(input[47] & 0xf8) << 10);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 381 to 399
	value = ((uint32_t)(input[47] & 0x07) << 29) |
			((uint32_t)input[48] << 21) |
			((uint32_t)input[49] << 13);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 400 to 418
	value = ((uint32_t)input[50] << 24) |
			((uint32_t)input[51] << 16) |
			((uint32_t)(input[52] & 0xe0) << 8);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 419 to 437
	value = ((uint32_t)(input[52] & 0x1f) << 27) |
			((uint32_t)input[53] << 19) |
			((uint32_t)(input[54] & 0xfc) << 11);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 438 to 456
	value = ((uint32_t)(input[54] & 0x03) << 30) |
			((uint32_t)input[55] << 22) |
			((uint32_t)input[56] << 14) |
			((uint32_t)(input[57] & 0x80) << 6);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 457 to 475
	value = ((uint32_t)(input[57] & 0x7f) << 25) |
			((uint32_t)input[58] << 17) |
			((uint32_t)(input[59] & 0xf0) << 9);
	output[24] = (double)(value >> 13);

	// read output[25]: from bit 476 to 494
	value = ((uint32_t)(input[59] & 0x0f) << 28) |
			((uint32_t)input[60] << 20) |
			((uint32_t)(input[61] & 0xfe) << 12);
	output[25] = (double)(value >> 13);
}

static void unpack_26_19bit_signed_2off(const uint8_t * input, double * output) {
	// Unpack 26 values into output
	// Values are 19-bit signed
	// Skip 2 bits, read 494 bits of data.
	// Input must be at least 62 bytes long

	int32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 287 to 305
	value = ((uint32_t)(input[35] & 0x01) << 31) |
			((uint32_t)input[36] << 23) |
			((uint32_t)input[37] << 15) |
			((uint32_t)(input[38] & 0xc0) << 7);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 306 to 324
	value = ((uint32_t)(input[38] & 0x3f) << 26) |
			((uint32_t)input[39] << 18) |
			((uint32_t)(input[40] & 0xf8) << 10);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 325 to 343
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 344 to 362
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)(input[45] & 0xe0) << 8);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 363 to 381
	value = ((uint32_t)(input[45] & 0x1f) << 27) |
			((uint32_t)input[46] << 19) |
			((uint32_t)(input[47] & 0xfc) << 11);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 382 to 400
	value = ((uint32_t)(input[47] & 0x03) << 30) |
			((uint32_t)input[48] << 22) |
			((uint32_t)input[49] << 14) |
			((uint32_t)(input[50] & 0x80) << 6);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 401 to 419
	value = ((uint32_t)(input[50] & 0x7f) << 25) |
			((uint32_t)input[51] << 17) |
			((uint32_t)(input[52] & 0xf0) << 9);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 420 to 438
	value = ((uint32_t)(input[52] & 0x0f) << 28) |
			((uint32_t)input[53] << 20) |
			((uint32_t)(input[54] & 0xfe) << 12);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 439 to 457
	value = ((uint32_t)(input[54] & 0x01) << 31) |
			((uint32_t)input[55] << 23) |
			((uint32_t)input[56] << 15) |
			((uint32_t)(input[57] & 0xc0) << 7);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 458 to 476
	value = ((uint32_t)(input[57] & 0x3f) << 26) |
			((uint32_t)input[58] << 18) |
			((uint32_t)(input[59] & 0xf8) << 10);
	output[24] = (double)(value >> 13);

	// read output[25]: from bit 477 to 495
	value = ((uint32_t)(input[59] & 0x07) << 29) |
			((uint32_t)input[60] << 21) |
			((uint32_t)input[61] << 13);
	output[25] = (double)(value >> 13);
}

static void unpack_26_19bit_unsigned_2off(const uint8_t * input, double * output) {
	// Unpack 26 values into output
	// Values are 19-bit unsigned
	// Skip 2 bits, read 494 bits of data.
	// Input must be at least 62 bytes long

	uint32_t value;

	// read output[0]: from bit 2 to 20
	value = ((uint32_t)(input[0] & 0x3f) << 26) |
			((uint32_t)input[1] << 18) |
			((uint32_t)(input[2] & 0xf8) << 10);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 21 to 39
	value = ((uint32_t)(input[2] & 0x07) << 29) |
			((uint32_t)input[3] << 21) |
			((uint32_t)input[4] << 13);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 40 to 58
	value = ((uint32_t)input[5] << 24) |
			((uint32_t)input[6] << 16) |
			((uint32_t)(input[7] & 0xe0) << 8);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 59 to 77
	value = ((uint32_t)(input[7] & 0x1f) << 27) |
			((uint32_t)input[8] << 19) |
			((uint32_t)(input[9] & 0xfc) << 11);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 78 to 96
	value = ((uint32_t)(input[9] & 0x03) << 30) |
			((uint32_t)input[10] << 22) |
			((uint32_t)input[11] << 14) |
			((uint32_t)(input[12] & 0x80) << 6);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 97 to 115
	value = ((uint32_t)(input[12] & 0x7f) << 25) |
			((uint32_t)input[13] << 17) |
			((uint32_t)(input[14] & 0xf0) << 9);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 116 to 134
	value = ((uint32_t)(input[14] & 0x0f) << 28) |
			((uint32_t)input[15] << 20) |
			((uint32_t)(input[16] & 0xfe) << 12);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 135 to 153
	value = ((uint32_t)(input[16] & 0x01) << 31) |
			((uint32_t)input[17] << 23) |
			((uint32_t)input[18] << 15) |
			((uint32_t)(input[19] & 0xc0) << 7);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 154 to 172
	value = ((uint32_t)(input[19] & 0x3f) << 26) |
			((uint32_t)input[20] << 18) |
			((uint32_t)(input[21] & 0xf8) << 10);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 173 to 191
	value = ((uint32_t)(input[21] & 0x07) << 29) |
			((uint32_t)input[22] << 21) |
			((uint32_t)input[23] << 13);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 192 to 210
	value = ((uint32_t)input[24] << 24) |
			((uint32_t)input[25] << 16) |
			((uint32_t)(input[26] & 0xe0) << 8);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 211 to 229
	value = ((uint32_t)(input[26] & 0x1f) << 27) |
			((uint32_t)input[27] << 19) |
			((uint32_t)(input[28] & 0xfc) << 11);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 230 to 248
	value = ((uint32_t)(input[28] & 0x03) << 30) |
			((uint32_t)input[29] << 22) |
			((uint32_t)input[30] << 14) |
			((uint32_t)(input[31] & 0x80) << 6);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 249 to 267
	value = ((uint32_t)(input[31] & 0x7f) << 25) |
			((uint32_t)input[32] << 17) |
			((uint32_t)(input[33] & 0xf0) << 9);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 268 to 286
	value = ((uint32_t)(input[33] & 0x0f) << 28) |
			((uint32_t)input[34] << 20) |
			((uint32_t)(input[35] & 0xfe) << 12);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 287 to 305
	value = ((uint32_t)(input[35] & 0x01) << 31) |
			((uint32_t)input[36] << 23) |
			((uint32_t)input[37] << 15) |
			((uint32_t)(input[38] & 0xc0) << 7);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 306 to 324
	value = ((uint32_t)(input[38] & 0x3f) << 26) |
			((uint32_t)input[39] << 18) |
			((uint32_t)(input[40] & 0xf8) << 10);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 325 to 343
	value = ((uint32_t)(input[40] & 0x07) << 29) |
			((uint32_t)input[41] << 21) |
			((uint32_t)input[42] << 13);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 344 to 362
	value = ((uint32_t)input[43] << 24) |
			((uint32_t)input[44] << 16) |
			((uint32_t)(input[45] & 0xe0) << 8);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 363 to 381
	value = ((uint32_t)(input[45] & 0x1f) << 27) |
			((uint32_t)input[46] << 19) |
			((uint32_t)(input[47] & 0xfc) << 11);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 382 to 400
	value = ((uint32_t)(input[47] & 0x03) << 30) |
			((uint32_t)input[48] << 22) |
			((uint32_t)input[49] << 14) |
			((uint32_t)(input[50] & 0x80) << 6);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 401 to 419
	value = ((uint32_t)(input[50] & 0x7f) << 25) |
			((uint32_t)input[51] << 17) |
			((uint32_t)(input[52] & 0xf0) << 9);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 420 to 438
	value = ((uint32_t)(input[52] & 0x0f) << 28) |
			((uint32_t)input[53] << 20) |
			((uint32_t)(input[54] & 0xfe) << 12);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 439 to 457
	value = ((uint32_t)(input[54] & 0x01) << 31) |
			((uint32_t)input[55] << 23) |
			((uint32_t)input[56] << 15) |
			((uint32_t)(input[57] & 0xc0) << 7);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 458 to 476
	value = ((uint32_t)(input[57] & 0x3f) << 26) |
			((uint32_t)input[58] << 18) |
			((uint32_t)(input[59] & 0xf8) << 10);
	output[24] = (double)(value >> 13);

	// read output[25]: from bit 477 to 495
	value = ((uint32_t)(input[59] & 0x07) << 29) |
			((uint32_t)input[60] << 21) |
			((uint32_t)input[61] << 13);
	output[25] = (double)(value >> 13);
}

static void unpack_26_19bit_signed_3off(const uint8_t * input, double * output) {
	// Unpack 26 values into output
	// Values are 19-bit signed
	// Skip 3 bits, read 494 bits of data.
	// Input must be at least 63 bytes long

	int32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 288 to 306
	value = ((uint32_t)input[36] << 24) |
			((uint32_t)input[37] << 16) |
			((uint32_t)(input[38] & 0xe0) << 8);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 307 to 325
	value = ((uint32_t)(input[38] & 0x1f) << 27) |
			((uint32_t)input[39] << 19) |
			((uint32_t)(input[40] & 0xfc) << 11);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 326 to 344
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)(input[43] & 0x80) << 6);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 345 to 363
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)(input[45] & 0xf0) << 9);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 364 to 382
	value = ((uint32_t)(input[45] & 0x0f) << 28) |
			((uint32_t)input[46] << 20) |
			((uint32_t)(input[47] & 0xfe) << 12);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 383 to 401
	value = ((uint32_t)(input[47] & 0x01) << 31) |
			((uint32_t)input[48] << 23) |
			((uint32_t)input[49] << 15) |
			((uint32_t)(input[50] & 0xc0) << 7);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 402 to 420
	value = ((uint32_t)(input[50] & 0x3f) << 26) |
			((uint32_t)input[51] << 18) |
			((uint32_t)(input[52] & 0xf8) << 10);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 421 to 439
	value = ((uint32_t)(input[52] & 0x07) << 29) |
			((uint32_t)input[53] << 21) |
			((uint32_t)input[54] << 13);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 440 to 458
	value = ((uint32_t)input[55] << 24) |
			((uint32_t)input[56] << 16) |
			((uint32_t)(input[57] & 0xe0) << 8);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 459 to 477
	value = ((uint32_t)(input[57] & 0x1f) << 27) |
			((uint32_t)input[58] << 19) |
			((uint32_t)(input[59] & 0xfc) << 11);
	output[24] = (double)(value >> 13);

	// read output[25]: from bit 478 to 496
	value = ((uint32_t)(input[59] & 0x03) << 30) |
			((uint32_t)input[60] << 22) |
			((uint32_t)input[61] << 14) |
			((uint32_t)(input[62] & 0x80) << 6);
	output[25] = (double)(value >> 13);
}

static void unpack_26_19bit_unsigned_3off(const uint8_t * input, double * output) {
	// Unpack 26 values into output
	// Values are 19-bit unsigned
	// Skip 3 bits, read 494 bits of data.
	// Input must be at least 63 bytes long

	uint32_t value;

	// read output[0]: from bit 3 to 21
	value = ((uint32_t)(input[0] & 0x1f) << 27) |
			((uint32_t)input[1] << 19) |
			((uint32_t)(input[2] & 0xfc) << 11);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 22 to 40
	value = ((uint32_t)(input[2] & 0x03) << 30) |
			((uint32_t)input[3] << 22) |
			((uint32_t)input[4] << 14) |
			((uint32_t)(input[5] & 0x80) << 6);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 41 to 59
	value = ((uint32_t)(input[5] & 0x7f) << 25) |
			((uint32_t)input[6] << 17) |
			((uint32_t)(input[7] & 0xf0) << 9);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 60 to 78
	value = ((uint32_t)(input[7] & 0x0f) << 28) |
			((uint32_t)input[8] << 20) |
			((uint32_t)(input[9] & 0xfe) << 12);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 79 to 97
	value = ((uint32_t)(input[9] & 0x01) << 31) |
			((uint32_t)input[10] << 23) |
			((uint32_t)input[11] << 15) |
			((uint32_t)(input[12] & 0xc0) << 7);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 98 to 116
	value = ((uint32_t)(input[12] & 0x3f) << 26) |
			((uint32_t)input[13] << 18) |
			((uint32_t)(input[14] & 0xf8) << 10);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 117 to 135
	value = ((uint32_t)(input[14] & 0x07) << 29) |
			((uint32_t)input[15] << 21) |
			((uint32_t)input[16] << 13);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 136 to 154
	value = ((uint32_t)input[17] << 24) |
			((uint32_t)input[18] << 16) |
			((uint32_t)(input[19] & 0xe0) << 8);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 155 to 173
	value = ((uint32_t)(input[19] & 0x1f) << 27) |
			((uint32_t)input[20] << 19) |
			((uint32_t)(input[21] & 0xfc) << 11);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 174 to 192
	value = ((uint32_t)(input[21] & 0x03) << 30) |
			((uint32_t)input[22] << 22) |
			((uint32_t)input[23] << 14) |
			((uint32_t)(input[24] & 0x80) << 6);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 193 to 211
	value = ((uint32_t)(input[24] & 0x7f) << 25) |
			((uint32_t)input[25] << 17) |
			((uint32_t)(input[26] & 0xf0) << 9);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 212 to 230
	value = ((uint32_t)(input[26] & 0x0f) << 28) |
			((uint32_t)input[27] << 20) |
			((uint32_t)(input[28] & 0xfe) << 12);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 231 to 249
	value = ((uint32_t)(input[28] & 0x01) << 31) |
			((uint32_t)input[29] << 23) |
			((uint32_t)input[30] << 15) |
			((uint32_t)(input[31] & 0xc0) << 7);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 250 to 268
	value = ((uint32_t)(input[31] & 0x3f) << 26) |
			((uint32_t)input[32] << 18) |
			((uint32_t)(input[33] & 0xf8) << 10);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 269 to 287
	value = ((uint32_t)(input[33] & 0x07) << 29) |
			((uint32_t)input[34] << 21) |
			((uint32_t)input[35] << 13);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 288 to 306
	value = ((uint32_t)input[36] << 24) |
			((uint32_t)input[37] << 16) |
			((uint32_t)(input[38] & 0xe0) << 8);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 307 to 325
	value = ((uint32_t)(input[38] & 0x1f) << 27) |
			((uint32_t)input[39] << 19) |
			((uint32_t)(input[40] & 0xfc) << 11);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 326 to 344
	value = ((uint32_t)(input[40] & 0x03) << 30) |
			((uint32_t)input[41] << 22) |
			((uint32_t)input[42] << 14) |
			((uint32_t)(input[43] & 0x80) << 6);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 345 to 363
	value = ((uint32_t)(input[43] & 0x7f) << 25) |
			((uint32_t)input[44] << 17) |
			((uint32_t)(input[45] & 0xf0) << 9);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 364 to 382
	value = ((uint32_t)(input[45] & 0x0f) << 28) |
			((uint32_t)input[46] << 20) |
			((uint32_t)(input[47] & 0xfe) << 12);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 383 to 401
	value = ((uint32_t)(input[47] & 0x01) << 31) |
			((uint32_t)input[48] << 23) |
			((uint32_t)input[49] << 15) |
			((uint32_t)(input[50] & 0xc0) << 7);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 402 to 420
	value = ((uint32_t)(input[50] & 0x3f) << 26) |
			((uint32_t)input[51] << 18) |
			((uint32_t)(input[52] & 0xf8) << 10);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 421 to 439
	value = ((uint32_t)(input[52] & 0x07) << 29) |
			((uint32_t)input[53] << 21) |
			((uint32_t)input[54] << 13);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 440 to 458
	value = ((uint32_t)input[55] << 24) |
			((uint32_t)input[56] << 16) |
			((uint32_t)(input[57] & 0xe0) << 8);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 459 to 477
	value = ((uint32_t)(input[57] & 0x1f) << 27) |
			((uint32_t)input[58] << 19) |
			((uint32_t)(input[59] & 0xfc) << 11);
	output[24] = (double)(value >> 13);

	// read output[25]: from bit 478 to 496
	value = ((uint32_t)(input[59] & 0x03) << 30) |
			((uint32_t)input[60] << 22) |
			((uint32_t)input[61] << 14) |
			((uint32_t)(input[62] & 0x80) << 6);
	output[25] = (double)(value >> 13);
}

static void unpack_26_19bit_signed_4off(const uint8_t * input, double * output) {
	// Unpack 26 values into output
	// Values are 19-bit signed
	// Skip 4 bits, read 494 bits of data.
	// Input must be at least 63 bytes long

	int32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 289 to 307
	value = ((uint32_t)(input[36] & 0x7f) << 25) |
			((uint32_t)input[37] << 17) |
			((uint32_t)(input[38] & 0xf0) << 9);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 308 to 326
	value = ((uint32_t)(input[38] & 0x0f) << 28) |
			((uint32_t)input[39] << 20) |
			((uint32_t)(input[40] & 0xfe) << 12);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 327 to 345
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)(input[43] & 0xc0) << 7);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 346 to 364
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)(input[45] & 0xf8) << 10);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 365 to 383
	value = ((uint32_t)(input[45] & 0x07) << 29) |
			((uint32_t)input[46] << 21) |
			((uint32_t)input[47] << 13);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 384 to 402
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)(input[50] & 0xe0) << 8);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 403 to 421
	value = ((uint32_t)(input[50] & 0x1f) << 27) |
			((uint32_t)input[51] << 19) |
			((uint32_t)(input[52] & 0xfc) << 11);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 422 to 440
	value = ((uint32_t)(input[52] & 0x03) << 30) |
			((uint32_t)input[53] << 22) |
			((uint32_t)input[54] << 14) |
			((uint32_t)(input[55] & 0x80) << 6);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 441 to 459
	value = ((uint32_t)(input[55] & 0x7f) << 25) |
			((uint32_t)input[56] << 17) |
			((uint32_t)(input[57] & 0xf0) << 9);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 460 to 478
	value = ((uint32_t)(input[57] & 0x0f) << 28) |
			((uint32_t)input[58] << 20) |
			((uint32_t)(input[59] & 0xfe) << 12);
	output[24] = (double)(value >> 13);

	// read output[25]: from bit 479 to 497
	value = ((uint32_t)(input[59] & 0x01) << 31) |
			((uint32_t)input[60] << 23) |
			((uint32_t)input[61] << 15) |
			((uint32_t)(input[62] & 0xc0) << 7);
	output[25] = (double)(value >> 13);
}

static void unpack_26_19bit_unsigned_4off(const uint8_t * input, double * output) {
	// Unpack 26 values into output
	// Values are 19-bit unsigned
	// Skip 4 bits, read 494 bits of data.
	// Input must be at least 63 bytes long

	uint32_t value;

	// read output[0]: from bit 4 to 22
	value = ((uint32_t)(input[0] & 0x0f) << 28) |
			((uint32_t)input[1] << 20) |
			((uint32_t)(input[2] & 0xfe) << 12);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 23 to 41
	value = ((uint32_t)(input[2] & 0x01) << 31) |
			((uint32_t)input[3] << 23) |
			((uint32_t)input[4] << 15) |
			((uint32_t)(input[5] & 0xc0) << 7);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 42 to 60
	value = ((uint32_t)(input[5] & 0x3f) << 26) |
			((uint32_t)input[6] << 18) |
			((uint32_t)(input[7] & 0xf8) << 10);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 61 to 79
	value = ((uint32_t)(input[7] & 0x07) << 29) |
			((uint32_t)input[8] << 21) |
			((uint32_t)input[9] << 13);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 80 to 98
	value = ((uint32_t)input[10] << 24) |
			((uint32_t)input[11] << 16) |
			((uint32_t)(input[12] & 0xe0) << 8);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 99 to 117
	value = ((uint32_t)(input[12] & 0x1f) << 27) |
			((uint32_t)input[13] << 19) |
			((uint32_t)(input[14] & 0xfc) << 11);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 118 to 136
	value = ((uint32_t)(input[14] & 0x03) << 30) |
			((uint32_t)input[15] << 22) |
			((uint32_t)input[16] << 14) |
			((uint32_t)(input[17] & 0x80) << 6);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 137 to 155
	value = ((uint32_t)(input[17] & 0x7f) << 25) |
			((uint32_t)input[18] << 17) |
			((uint32_t)(input[19] & 0xf0) << 9);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 156 to 174
	value = ((uint32_t)(input[19] & 0x0f) << 28) |
			((uint32_t)input[20] << 20) |
			((uint32_t)(input[21] & 0xfe) << 12);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 175 to 193
	value = ((uint32_t)(input[21] & 0x01) << 31) |
			((uint32_t)input[22] << 23) |
			((uint32_t)input[23] << 15) |
			((uint32_t)(input[24] & 0xc0) << 7);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 194 to 212
	value = ((uint32_t)(input[24] & 0x3f) << 26) |
			((uint32_t)input[25] << 18) |
			((uint32_t)(input[26] & 0xf8) << 10);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 213 to 231
	value = ((uint32_t)(input[26] & 0x07) << 29) |
			((uint32_t)input[27] << 21) |
			((uint32_t)input[28] << 13);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 232 to 250
	value = ((uint32_t)input[29] << 24) |
			((uint32_t)input[30] << 16) |
			((uint32_t)(input[31] & 0xe0) << 8);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 251 to 269
	value = ((uint32_t)(input[31] & 0x1f) << 27) |
			((uint32_t)input[32] << 19) |
			((uint32_t)(input[33] & 0xfc) << 11);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 270 to 288
	value = ((uint32_t)(input[33] & 0x03) << 30) |
			((uint32_t)input[34] << 22) |
			((uint32_t)input[35] << 14) |
			((uint32_t)(input[36] & 0x80) << 6);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 289 to 307
	value = ((uint32_t)(input[36] & 0x7f) << 25) |
			((uint32_t)input[37] << 17) |
			((uint32_t)(input[38] & 0xf0) << 9);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 308 to 326
	value = ((uint32_t)(input[38] & 0x0f) << 28) |
			((uint32_t)input[39] << 20) |
			((uint32_t)(input[40] & 0xfe) << 12);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 327 to 345
	value = ((uint32_t)(input[40] & 0x01) << 31) |
			((uint32_t)input[41] << 23) |
			((uint32_t)input[42] << 15) |
			((uint32_t)(input[43] & 0xc0) << 7);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 346 to 364
	value = ((uint32_t)(input[43] & 0x3f) << 26) |
			((uint32_t)input[44] << 18) |
			((uint32_t)(input[45] & 0xf8) << 10);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 365 to 383
	value = ((uint32_t)(input[45] & 0x07) << 29) |
			((uint32_t)input[46] << 21) |
			((uint32_t)input[47] << 13);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 384 to 402
	value = ((uint32_t)input[48] << 24) |
			((uint32_t)input[49] << 16) |
			((uint32_t)(input[50] & 0xe0) << 8);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 403 to 421
	value = ((uint32_t)(input[50] & 0x1f) << 27) |
			((uint32_t)input[51] << 19) |
			((uint32_t)(input[52] & 0xfc) << 11);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 422 to 440
	value = ((uint32_t)(input[52] & 0x03) << 30) |
			((uint32_t)input[53] << 22) |
			((uint32_t)input[54] << 14) |
			((uint32_t)(input[55] & 0x80) << 6);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 441 to 459
	value = ((uint32_t)(input[55] & 0x7f) << 25) |
			((uint32_t)input[56] << 17) |
			((uint32_t)(input[57] & 0xf0) << 9);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 460 to 478
	value = ((uint32_t)(input[57] & 0x0f) << 28) |
			((uint32_t)input[58] << 20) |
			((uint32_t)(input[59] & 0xfe) << 12);
	output[24] = (double)(value >> 13);

	// read output[25]: from bit 479 to 497
	value = ((uint32_t)(input[59] & 0x01) << 31) |
			((uint32_t)input[60] << 23) |
			((uint32_t)input[61] << 15) |
			((uint32_t)(input[62] & 0xc0) << 7);
	output[25] = (double)(value >> 13);
}

static void unpack_26_19bit_signed_5off(const uint8_t * input, double * output) {
	// Unpack 26 values into output
	// Values are 19-bit signed
	// Skip 5 bits, read 494 bits of data.
	// Input must be at least 63 bytes long

	int32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 290 to 308
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)(input[38] & 0xf8) << 10);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 309 to 327
	value = ((uint32_t)(input[38] & 0x07) << 29) |
			((uint32_t)input[39] << 21) |
			((uint32_t)input[40] << 13);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 328 to 346
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)(input[43] & 0xe0) << 8);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 347 to 365
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)(input[45] & 0xfc) << 11);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 366 to 384
	value = ((uint32_t)(input[45] & 0x03) << 30) |
			((uint32_t)input[46] << 22) |
			((uint32_t)input[47] << 14) |
			((uint32_t)(input[48] & 0x80) << 6);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 385 to 403
	value = ((uint32_t)(input[48] & 0x7f) << 25) |
			((uint32_t)input[49] << 17) |
			((uint32_t)(input[50] & 0xf0) << 9);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 404 to 422
	value = ((uint32_t)(input[50] & 0x0f) << 28) |
			((uint32_t)input[51] << 20) |
			((uint32_t)(input[52] & 0xfe) << 12);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 423 to 441
	value = ((uint32_t)(input[52] & 0x01) << 31) |
			((uint32_t)input[53] << 23) |
			((uint32_t)input[54] << 15) |
			((uint32_t)(input[55] & 0xc0) << 7);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 442 to 460
	value = ((uint32_t)(input[55] & 0x3f) << 26) |
			((uint32_t)input[56] << 18) |
			((uint32_t)(input[57] & 0xf8) << 10);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 461 to 479
	value = ((uint32_t)(input[57] & 0x07) << 29) |
			((uint32_t)input[58] << 21) |
			((uint32_t)input[59] << 13);
	output[24] = (double)(value >> 13);

	// read output[25]: from bit 480 to 498
	value = ((uint32_t)input[60] << 24) |
			((uint32_t)input[61] << 16) |
			((uint32_t)(input[62] & 0xe0) << 8);
	output[25] = (double)(value >> 13);
}

static void unpack_26_19bit_unsigned_5off(const uint8_t * input, double * output) {
	// Unpack 26 values into output
	// Values are 19-bit unsigned
	// Skip 5 bits, read 494 bits of data.
	// Input must be at least 63 bytes long

	uint32_t value;

	// read output[0]: from bit 5 to 23
	value = ((uint32_t)(input[0] & 0x07) << 29) |
			((uint32_t)input[1] << 21) |
			((uint32_t)input[2] << 13);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 24 to 42
	value = ((uint32_t)input[3] << 24) |
			((uint32_t)input[4] << 16) |
			((uint32_t)(input[5] & 0xe0) << 8);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 43 to 61
	value = ((uint32_t)(input[5] & 0x1f) << 27) |
			((uint32_t)input[6] << 19) |
			((uint32_t)(input[7] & 0xfc) << 11);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 62 to 80
	value = ((uint32_t)(input[7] & 0x03) << 30) |
			((uint32_t)input[8] << 22) |
			((uint32_t)input[9] << 14) |
			((uint32_t)(input[10] & 0x80) << 6);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 81 to 99
	value = ((uint32_t)(input[10] & 0x7f) << 25) |
			((uint32_t)input[11] << 17) |
			((uint32_t)(input[12] & 0xf0) << 9);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 100 to 118
	value = ((uint32_t)(input[12] & 0x0f) << 28) |
			((uint32_t)input[13] << 20) |
			((uint32_t)(input[14] & 0xfe) << 12);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 119 to 137
	value = ((uint32_t)(input[14] & 0x01) << 31) |
			((uint32_t)input[15] << 23) |
			((uint32_t)input[16] << 15) |
			((uint32_t)(input[17] & 0xc0) << 7);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 138 to 156
	value = ((uint32_t)(input[17] & 0x3f) << 26) |
			((uint32_t)input[18] << 18) |
			((uint32_t)(input[19] & 0xf8) << 10);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 157 to 175
	value = ((uint32_t)(input[19] & 0x07) << 29) |
			((uint32_t)input[20] << 21) |
			((uint32_t)input[21] << 13);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 176 to 194
	value = ((uint32_t)input[22] << 24) |
			((uint32_t)input[23] << 16) |
			((uint32_t)(input[24] & 0xe0) << 8);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 195 to 213
	value = ((uint32_t)(input[24] & 0x1f) << 27) |
			((uint32_t)input[25] << 19) |
			((uint32_t)(input[26] & 0xfc) << 11);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 214 to 232
	value = ((uint32_t)(input[26] & 0x03) << 30) |
			((uint32_t)input[27] << 22) |
			((uint32_t)input[28] << 14) |
			((uint32_t)(input[29] & 0x80) << 6);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 233 to 251
	value = ((uint32_t)(input[29] & 0x7f) << 25) |
			((uint32_t)input[30] << 17) |
			((uint32_t)(input[31] & 0xf0) << 9);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 252 to 270
	value = ((uint32_t)(input[31] & 0x0f) << 28) |
			((uint32_t)input[32] << 20) |
			((uint32_t)(input[33] & 0xfe) << 12);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 271 to 289
	value = ((uint32_t)(input[33] & 0x01) << 31) |
			((uint32_t)input[34] << 23) |
			((uint32_t)input[35] << 15) |
			((uint32_t)(input[36] & 0xc0) << 7);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 290 to 308
	value = ((uint32_t)(input[36] & 0x3f) << 26) |
			((uint32_t)input[37] << 18) |
			((uint32_t)(input[38] & 0xf8) << 10);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 309 to 327
	value = ((uint32_t)(input[38] & 0x07) << 29) |
			((uint32_t)input[39] << 21) |
			((uint32_t)input[40] << 13);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 328 to 346
	value = ((uint32_t)input[41] << 24) |
			((uint32_t)input[42] << 16) |
			((uint32_t)(input[43] & 0xe0) << 8);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 347 to 365
	value = ((uint32_t)(input[43] & 0x1f) << 27) |
			((uint32_t)input[44] << 19) |
			((uint32_t)(input[45] & 0xfc) << 11);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 366 to 384
	value = ((uint32_t)(input[45] & 0x03) << 30) |
			((uint32_t)input[46] << 22) |
			((uint32_t)input[47] << 14) |
			((uint32_t)(input[48] & 0x80) << 6);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 385 to 403
	value = ((uint32_t)(input[48] & 0x7f) << 25) |
			((uint32_t)input[49] << 17) |
			((uint32_t)(input[50] & 0xf0) << 9);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 404 to 422
	value = ((uint32_t)(input[50] & 0x0f) << 28) |
			((uint32_t)input[51] << 20) |
			((uint32_t)(input[52] & 0xfe) << 12);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 423 to 441
	value = ((uint32_t)(input[52] & 0x01) << 31) |
			((uint32_t)input[53] << 23) |
			((uint32_t)input[54] << 15) |
			((uint32_t)(input[55] & 0xc0) << 7);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 442 to 460
	value = ((uint32_t)(input[55] & 0x3f) << 26) |
			((uint32_t)input[56] << 18) |
			((uint32_t)(input[57] & 0xf8) << 10);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 461 to 479
	value = ((uint32_t)(input[57] & 0x07) << 29) |
			((uint32_t)input[58] << 21) |
			((uint32_t)input[59] << 13);
	output[24] = (double)(value >> 13);

	// read output[25]: from bit 480 to 498
	value = ((uint32_t)input[60] << 24) |
			((uint32_t)input[61] << 16) |
			((uint32_t)(input[62] & 0xe0) << 8);
	output[25] = (double)(value >> 13);
}

static void unpack_26_19bit_signed_6off(const uint8_t * input, double * output) {
	// Unpack 26 values into output
	// Values are 19-bit signed
	// Skip 6 bits, read 494 bits of data.
	// Input must be at least 63 bytes long

	int32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 291 to 309
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)(input[38] & 0xfc) << 11);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 310 to 328
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)(input[41] & 0x80) << 6);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 329 to 347
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)(input[43] & 0xf0) << 9);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 348 to 366
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)(input[45] & 0xfe) << 12);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 367 to 385
	value = ((uint32_t)(input[45] & 0x01) << 31) |
			((uint32_t)input[46] << 23) |
			((uint32_t)input[47] << 15) |
			((uint32_t)(input[48] & 0xc0) << 7);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 386 to 404
	value = ((uint32_t)(input[48] & 0x3f) << 26) |
			((uint32_t)input[49] << 18) |
			((uint32_t)(input[50] & 0xf8) << 10);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 405 to 423
	value = ((uint32_t)(input[50] & 0x07) << 29) |
			((uint32_t)input[51] << 21) |
			((uint32_t)input[52] << 13);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 424 to 442
	value = ((uint32_t)input[53] << 24) |
			((uint32_t)input[54] << 16) |
			((uint32_t)(input[55] & 0xe0) << 8);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 443 to 461
	value = ((uint32_t)(input[55] & 0x1f) << 27) |
			((uint32_t)input[56] << 19) |
			((uint32_t)(input[57] & 0xfc) << 11);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 462 to 480
	value = ((uint32_t)(input[57] & 0x03) << 30) |
			((uint32_t)input[58] << 22) |
			((uint32_t)input[59] << 14) |
			((uint32_t)(input[60] & 0x80) << 6);
	output[24] = (double)(value >> 13);

	// read output[25]: from bit 481 to 499
	value = ((uint32_t)(input[60] & 0x7f) << 25) |
			((uint32_t)input[61] << 17) |
			((uint32_t)(input[62] & 0xf0) << 9);
	output[25] = (double)(value >> 13);
}

static void unpack_26_19bit_unsigned_6off(const uint8_t * input, double * output) {
	// Unpack 26 values into output
	// Values are 19-bit unsigned
	// Skip 6 bits, read 494 bits of data.
	// Input must be at least 63 bytes long

	uint32_t value;

	// read output[0]: from bit 6 to 24
	value = ((uint32_t)(input[0] & 0x03) << 30) |
			((uint32_t)input[1] << 22) |
			((uint32_t)input[2] << 14) |
			((uint32_t)(input[3] & 0x80) << 6);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 25 to 43
	value = ((uint32_t)(input[3] & 0x7f) << 25) |
			((uint32_t)input[4] << 17) |
			((uint32_t)(input[5] & 0xf0) << 9);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 44 to 62
	value = ((uint32_t)(input[5] & 0x0f) << 28) |
			((uint32_t)input[6] << 20) |
			((uint32_t)(input[7] & 0xfe) << 12);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 63 to 81
	value = ((uint32_t)(input[7] & 0x01) << 31) |
			((uint32_t)input[8] << 23) |
			((uint32_t)input[9] << 15) |
			((uint32_t)(input[10] & 0xc0) << 7);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 82 to 100
	value = ((uint32_t)(input[10] & 0x3f) << 26) |
			((uint32_t)input[11] << 18) |
			((uint32_t)(input[12] & 0xf8) << 10);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 101 to 119
	value = ((uint32_t)(input[12] & 0x07) << 29) |
			((uint32_t)input[13] << 21) |
			((uint32_t)input[14] << 13);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 120 to 138
	value = ((uint32_t)input[15] << 24) |
			((uint32_t)input[16] << 16) |
			((uint32_t)(input[17] & 0xe0) << 8);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 139 to 157
	value = ((uint32_t)(input[17] & 0x1f) << 27) |
			((uint32_t)input[18] << 19) |
			((uint32_t)(input[19] & 0xfc) << 11);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 158 to 176
	value = ((uint32_t)(input[19] & 0x03) << 30) |
			((uint32_t)input[20] << 22) |
			((uint32_t)input[21] << 14) |
			((uint32_t)(input[22] & 0x80) << 6);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 177 to 195
	value = ((uint32_t)(input[22] & 0x7f) << 25) |
			((uint32_t)input[23] << 17) |
			((uint32_t)(input[24] & 0xf0) << 9);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 196 to 214
	value = ((uint32_t)(input[24] & 0x0f) << 28) |
			((uint32_t)input[25] << 20) |
			((uint32_t)(input[26] & 0xfe) << 12);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 215 to 233
	value = ((uint32_t)(input[26] & 0x01) << 31) |
			((uint32_t)input[27] << 23) |
			((uint32_t)input[28] << 15) |
			((uint32_t)(input[29] & 0xc0) << 7);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 234 to 252
	value = ((uint32_t)(input[29] & 0x3f) << 26) |
			((uint32_t)input[30] << 18) |
			((uint32_t)(input[31] & 0xf8) << 10);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 253 to 271
	value = ((uint32_t)(input[31] & 0x07) << 29) |
			((uint32_t)input[32] << 21) |
			((uint32_t)input[33] << 13);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 272 to 290
	value = ((uint32_t)input[34] << 24) |
			((uint32_t)input[35] << 16) |
			((uint32_t)(input[36] & 0xe0) << 8);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 291 to 309
	value = ((uint32_t)(input[36] & 0x1f) << 27) |
			((uint32_t)input[37] << 19) |
			((uint32_t)(input[38] & 0xfc) << 11);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 310 to 328
	value = ((uint32_t)(input[38] & 0x03) << 30) |
			((uint32_t)input[39] << 22) |
			((uint32_t)input[40] << 14) |
			((uint32_t)(input[41] & 0x80) << 6);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 329 to 347
	value = ((uint32_t)(input[41] & 0x7f) << 25) |
			((uint32_t)input[42] << 17) |
			((uint32_t)(input[43] & 0xf0) << 9);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 348 to 366
	value = ((uint32_t)(input[43] & 0x0f) << 28) |
			((uint32_t)input[44] << 20) |
			((uint32_t)(input[45] & 0xfe) << 12);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 367 to 385
	value = ((uint32_t)(input[45] & 0x01) << 31) |
			((uint32_t)input[46] << 23) |
			((uint32_t)input[47] << 15) |
			((uint32_t)(input[48] & 0xc0) << 7);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 386 to 404
	value = ((uint32_t)(input[48] & 0x3f) << 26) |
			((uint32_t)input[49] << 18) |
			((uint32_t)(input[50] & 0xf8) << 10);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 405 to 423
	value = ((uint32_t)(input[50] & 0x07) << 29) |
			((uint32_t)input[51] << 21) |
			((uint32_t)input[52] << 13);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 424 to 442
	value = ((uint32_t)input[53] << 24) |
			((uint32_t)input[54] << 16) |
			((uint32_t)(input[55] & 0xe0) << 8);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 443 to 461
	value = ((uint32_t)(input[55] & 0x1f) << 27) |
			((uint32_t)input[56] << 19) |
			((uint32_t)(input[57] & 0xfc) << 11);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 462 to 480
	value = ((uint32_t)(input[57] & 0x03) << 30) |
			((uint32_t)input[58] << 22) |
			((uint32_t)input[59] << 14) |
			((uint32_t)(input[60] & 0x80) << 6);
	output[24] = (double)(value >> 13);

	// read output[25]: from bit 481 to 499
	value = ((uint32_t)(input[60] & 0x7f) << 25) |
			((uint32_t)input[61] << 17) |
			((uint32_t)(input[62] & 0xf0) << 9);
	output[25] = (double)(value >> 13);
}

static void unpack_26_19bit_signed_7off(const uint8_t * input, double * output) {
	// Unpack 26 values into output
	// Values are 19-bit signed
	// Skip 7 bits, read 494 bits of data.
	// Input must be at least 63 bytes long

	int32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 292 to 310
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)(input[38] & 0xfe) << 12);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 311 to 329
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)(input[41] & 0xc0) << 7);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 330 to 348
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)(input[43] & 0xf8) << 10);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 349 to 367
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 368 to 386
	value = ((uint32_t)input[46] << 24) |
			((uint32_t)input[47] << 16) |
			((uint32_t)(input[48] & 0xe0) << 8);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 387 to 405
	value = ((uint32_t)(input[48] & 0x1f) << 27) |
			((uint32_t)input[49] << 19) |
			((uint32_t)(input[50] & 0xfc) << 11);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 406 to 424
	value = ((uint32_t)(input[50] & 0x03) << 30) |
			((uint32_t)input[51] << 22) |
			((uint32_t)input[52] << 14) |
			((uint32_t)(input[53] & 0x80) << 6);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 425 to 443
	value = ((uint32_t)(input[53] & 0x7f) << 25) |
			((uint32_t)input[54] << 17) |
			((uint32_t)(input[55] & 0xf0) << 9);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 444 to 462
	value = ((uint32_t)(input[55] & 0x0f) << 28) |
			((uint32_t)input[56] << 20) |
			((uint32_t)(input[57] & 0xfe) << 12);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 463 to 481
	value = ((uint32_t)(input[57] & 0x01) << 31) |
			((uint32_t)input[58] << 23) |
			((uint32_t)input[59] << 15) |
			((uint32_t)(input[60] & 0xc0) << 7);
	output[24] = (double)(value >> 13);

	// read output[25]: from bit 482 to 500
	value = ((uint32_t)(input[60] & 0x3f) << 26) |
			((uint32_t)input[61] << 18) |
			((uint32_t)(input[62] & 0xf8) << 10);
	output[25] = (double)(value >> 13);
}

static void unpack_26_19bit_unsigned_7off(const uint8_t * input, double * output) {
	// Unpack 26 values into output
	// Values are 19-bit unsigned
	// Skip 7 bits, read 494 bits of data.
	// Input must be at least 63 bytes long

	uint32_t value;

	// read output[0]: from bit 7 to 25
	value = ((uint32_t)(input[0] & 0x01) << 31) |
			((uint32_t)input[1] << 23) |
			((uint32_t)input[2] << 15) |
			((uint32_t)(input[3] & 0xc0) << 7);
	output[0] = (double)(value >> 13);

	// read output[1]: from bit 26 to 44
	value = ((uint32_t)(input[3] & 0x3f) << 26) |
			((uint32_t)input[4] << 18) |
			((uint32_t)(input[5] & 0xf8) << 10);
	output[1] = (double)(value >> 13);

	// read output[2]: from bit 45 to 63
	value = ((uint32_t)(input[5] & 0x07) << 29) |
			((uint32_t)input[6] << 21) |
			((uint32_t)input[7] << 13);
	output[2] = (double)(value >> 13);

	// read output[3]: from bit 64 to 82
	value = ((uint32_t)input[8] << 24) |
			((uint32_t)input[9] << 16) |
			((uint32_t)(input[10] & 0xe0) << 8);
	output[3] = (double)(value >> 13);

	// read output[4]: from bit 83 to 101
	value = ((uint32_t)(input[10] & 0x1f) << 27) |
			((uint32_t)input[11] << 19) |
			((uint32_t)(input[12] & 0xfc) << 11);
	output[4] = (double)(value >> 13);

	// read output[5]: from bit 102 to 120
	value = ((uint32_t)(input[12] & 0x03) << 30) |
			((uint32_t)input[13] << 22) |
			((uint32_t)input[14] << 14) |
			((uint32_t)(input[15] & 0x80) << 6);
	output[5] = (double)(value >> 13);

	// read output[6]: from bit 121 to 139
	value = ((uint32_t)(input[15] & 0x7f) << 25) |
			((uint32_t)input[16] << 17) |
			((uint32_t)(input[17] & 0xf0) << 9);
	output[6] = (double)(value >> 13);

	// read output[7]: from bit 140 to 158
	value = ((uint32_t)(input[17] & 0x0f) << 28) |
			((uint32_t)input[18] << 20) |
			((uint32_t)(input[19] & 0xfe) << 12);
	output[7] = (double)(value >> 13);

	// read output[8]: from bit 159 to 177
	value = ((uint32_t)(input[19] & 0x01) << 31) |
			((uint32_t)input[20] << 23) |
			((uint32_t)input[21] << 15) |
			((uint32_t)(input[22] & 0xc0) << 7);
	output[8] = (double)(value >> 13);

	// read output[9]: from bit 178 to 196
	value = ((uint32_t)(input[22] & 0x3f) << 26) |
			((uint32_t)input[23] << 18) |
			((uint32_t)(input[24] & 0xf8) << 10);
	output[9] = (double)(value >> 13);

	// read output[10]: from bit 197 to 215
	value = ((uint32_t)(input[24] & 0x07) << 29) |
			((uint32_t)input[25] << 21) |
			((uint32_t)input[26] << 13);
	output[10] = (double)(value >> 13);

	// read output[11]: from bit 216 to 234
	value = ((uint32_t)input[27] << 24) |
			((uint32_t)input[28] << 16) |
			((uint32_t)(input[29] & 0xe0) << 8);
	output[11] = (double)(value >> 13);

	// read output[12]: from bit 235 to 253
	value = ((uint32_t)(input[29] & 0x1f) << 27) |
			((uint32_t)input[30] << 19) |
			((uint32_t)(input[31] & 0xfc) << 11);
	output[12] = (double)(value >> 13);

	// read output[13]: from bit 254 to 272
	value = ((uint32_t)(input[31] & 0x03) << 30) |
			((uint32_t)input[32] << 22) |
			((uint32_t)input[33] << 14) |
			((uint32_t)(input[34] & 0x80) << 6);
	output[13] = (double)(value >> 13);

	// read output[14]: from bit 273 to 291
	value = ((uint32_t)(input[34] & 0x7f) << 25) |
			((uint32_t)input[35] << 17) |
			((uint32_t)(input[36] & 0xf0) << 9);
	output[14] = (double)(value >> 13);

	// read output[15]: from bit 292 to 310
	value = ((uint32_t)(input[36] & 0x0f) << 28) |
			((uint32_t)input[37] << 20) |
			((uint32_t)(input[38] & 0xfe) << 12);
	output[15] = (double)(value >> 13);

	// read output[16]: from bit 311 to 329
	value = ((uint32_t)(input[38] & 0x01) << 31) |
			((uint32_t)input[39] << 23) |
			((uint32_t)input[40] << 15) |
			((uint32_t)(input[41] & 0xc0) << 7);
	output[16] = (double)(value >> 13);

	// read output[17]: from bit 330 to 348
	value = ((uint32_t)(input[41] & 0x3f) << 26) |
			((uint32_t)input[42] << 18) |
			((uint32_t)(input[43] & 0xf8) << 10);
	output[17] = (double)(value >> 13);

	// read output[18]: from bit 349 to 367
	value = ((uint32_t)(input[43] & 0x07) << 29) |
			((uint32_t)input[44] << 21) |
			((uint32_t)input[45] << 13);
	output[18] = (double)(value >> 13);

	// read output[19]: from bit 368 to 386
	value = ((uint32_t)input[46] << 24) |
			((uint32_t)input[47] << 16) |
			((uint32_t)(input[48] & 0xe0) << 8);
	output[19] = (double)(value >> 13);

	// read output[20]: from bit 387 to 405
	value = ((uint32_t)(input[48] & 0x1f) << 27) |
			((uint32_t)input[49] << 19) |
			((uint32_t)(input[50] & 0xfc) << 11);
	output[20] = (double)(value >> 13);

	// read output[21]: from bit 406 to 424
	value = ((uint32_t)(input[50] & 0x03) << 30) |
			((uint32_t)input[51] << 22) |
			((uint32_t)input[52] << 14) |
			((uint32_t)(input[53] & 0x80) << 6);
	output[21] = (double)(value >> 13);

	// read output[22]: from bit 425 to 443
	value = ((uint32_t)(input[53] & 0x7f) << 25) |
			((uint32_t)input[54] << 17) |
			((uint32_t)(input[55] & 0xf0) << 9);
	output[22] = (double)(value >> 13);

	// read output[23]: from bit 444 to 462
	value = ((uint32_t)(input[55] & 0x0f) << 28) |
			((uint32_t)input[56] << 20) |
			((uint32_t)(input[57] & 0xfe) << 12);
	output[23] = (double)(value >> 13);

	// read output[24]: from bit 463 to 481
	value = ((uint32_t)(input[57] & 0x01) << 31) |
			((uint32_t)input[58] << 23) |
			((uint32_t)input[59] << 15) |
			((uint32_t)(input[60] & 0xc0) << 7);
	output[24] = (double)(value >> 13);

	// read output[25]: from bit 482 to 500
	value = ((uint32_t)(input[60] & 0x3f) << 26) |
			((uint32_t)input[61] << 18) |
			((uint32_t)(input[62] & 0xf8) << 10);
	output[25] = (double)(value >> 13);
}


unpack_func_t unpack_19bit[UNPACK_19BIT_MAX_COUNT][8][2] = {
	{
		{
			unpack_1_19bit_unsigned_0off,
			unpack_1_19bit_signed_0off,
		},
		{
			unpack_1_19bit_unsigned_1off,
			unpack_1_19bit_signed_1off,
		},
		{
			unpack_1_19bit_unsigned_2off,
			unpack_1_19bit_signed_2off,
		},
		{
			unpack_1_19bit_unsigned_3off,
			unpack_1_19bit_signed_3off,
		},
		{
			unpack_1_19bit_unsigned_4off,
			unpack_1_19bit_signed_4off,
		},
		{
			unpack_1_19bit_unsigned_5off,
			unpack_1_19bit_signed_5off,
		},
		{
			unpack_1_19bit_unsigned_6off,
			unpack_1_19bit_signed_6off,
		},
		{
			unpack_1_19bit_unsigned_7off,
			unpack_1_19bit_signed_7off,
		},
	},
	{
		{
			unpack_2_19bit_unsigned_0off,
			unpack_2_19bit_signed_0off,
		},
		{
			unpack_2_19bit_unsigned_1off,
			unpack_2_19bit_signed_1off,
		},
		{
			unpack_2_19bit_unsigned_2off,
			unpack_2_19bit_signed_2off,
		},
		{
			unpack_2_19bit_unsigned_3off,
			unpack_2_19bit_signed_3off,
		},
		{
			unpack_2_19bit_unsigned_4off,
			unpack_2_19bit_signed_4off,
		},
		{
			unpack_2_19bit_unsigned_5off,
			unpack_2_19bit_signed_5off,
		},
		{
			unpack_2_19bit_unsigned_6off,
			unpack_2_19bit_signed_6off,
		},
		{
			unpack_2_19bit_unsigned_7off,
			unpack_2_19bit_signed_7off,
		},
	},
	{
		{
			unpack_3_19bit_unsigned_0off,
			unpack_3_19bit_signed_0off,
		},
		{
			unpack_3_19bit_unsigned_1off,
			unpack_3_19bit_signed_1off,
		},
		{
			unpack_3_19bit_unsigned_2off,
			unpack_3_19bit_signed_2off,
		},
		{
			unpack_3_19bit_unsigned_3off,
			unpack_3_19bit_signed_3off,
		},
		{
			unpack_3_19bit_unsigned_4off,
			unpack_3_19bit_signed_4off,
		},
		{
			unpack_3_19bit_unsigned_5off,
			unpack_3_19bit_signed_5off,
		},
		{
			unpack_3_19bit_unsigned_6off,
			unpack_3_19bit_signed_6off,
		},
		{
			unpack_3_19bit_unsigned_7off,
			unpack_3_19bit_signed_7off,
		},
	},
	{
		{
			unpack_4_19bit_unsigned_0off,
			unpack_4_19bit_signed_0off,
		},
		{
			unpack_4_19bit_unsigned_1off,
			unpack_4_19bit_signed_1off,
		},
		{
			unpack_4_19bit_unsigned_2off,
			unpack_4_19bit_signed_2off,
		},
		{
			unpack_4_19bit_unsigned_3off,
			unpack_4_19bit_signed_3off,
		},
		{
			unpack_4_19bit_unsigned_4off,
			unpack_4_19bit_signed_4off,
		},
		{
			unpack_4_19bit_unsigned_5off,
			unpack_4_19bit_signed_5off,
		},
		{
			unpack_4_19bit_unsigned_6off,
			unpack_4_19bit_signed_6off,
		},
		{
			unpack_4_19bit_unsigned_7off,
			unpack_4_19bit_signed_7off,
		},
	},
	{
		{
			unpack_5_19bit_unsigned_0off,
			unpack_5_19bit_signed_0off,
		},
		{
			unpack_5_19bit_unsigned_1off,
			unpack_5_19bit_signed_1off,
		},
		{
			unpack_5_19bit_unsigned_2off,
			unpack_5_19bit_signed_2off,
		},
		{
			unpack_5_19bit_unsigned_3off,
			unpack_5_19bit_signed_3off,
		},
		{
			unpack_5_19bit_unsigned_4off,
			unpack_5_19bit_signed_4off,
		},
		{
			unpack_5_19bit_unsigned_5off,
			unpack_5_19bit_signed_5off,
		},
		{
			unpack_5_19bit_unsigned_6off,
			unpack_5_19bit_signed_6off,
		},
		{
			unpack_5_19bit_unsigned_7off,
			unpack_5_19bit_signed_7off,
		},
	},
	{
		{
			unpack_6_19bit_unsigned_0off,
			unpack_6_19bit_signed_0off,
		},
		{
			unpack_6_19bit_unsigned_1off,
			unpack_6_19bit_signed_1off,
		},
		{
			unpack_6_19bit_unsigned_2off,
			unpack_6_19bit_signed_2off,
		},
		{
			unpack_6_19bit_unsigned_3off,
			unpack_6_19bit_signed_3off,
		},
		{
			unpack_6_19bit_unsigned_4off,
			unpack_6_19bit_signed_4off,
		},
		{
			unpack_6_19bit_unsigned_5off,
			unpack_6_19bit_signed_5off,
		},
		{
			unpack_6_19bit_unsigned_6off,
			unpack_6_19bit_signed_6off,
		},
		{
			unpack_6_19bit_unsigned_7off,
			unpack_6_19bit_signed_7off,
		},
	},
	{
		{
			unpack_7_19bit_unsigned_0off,
			unpack_7_19bit_signed_0off,
		},
		{
			unpack_7_19bit_unsigned_1off,
			unpack_7_19bit_signed_1off,
		},
		{
			unpack_7_19bit_unsigned_2off,
			unpack_7_19bit_signed_2off,
		},
		{
			unpack_7_19bit_unsigned_3off,
			unpack_7_19bit_signed_3off,
		},
		{
			unpack_7_19bit_unsigned_4off,
			unpack_7_19bit_signed_4off,
		},
		{
			unpack_7_19bit_unsigned_5off,
			unpack_7_19bit_signed_5off,
		},
		{
			unpack_7_19bit_unsigned_6off,
			unpack_7_19bit_signed_6off,
		},
		{
			unpack_7_19bit_unsigned_7off,
			unpack_7_19bit_signed_7off,
		},
	},
	{
		{
			unpack_8_19bit_unsigned_0off,
			unpack_8_19bit_signed_0off,
		},
		{
			unpack_8_19bit_unsigned_1off,
			unpack_8_19bit_signed_1off,
		},
		{
			unpack_8_19bit_unsigned_2off,
			unpack_8_19bit_signed_2off,
		},
		{
			unpack_8_19bit_unsigned_3off,
			unpack_8_19bit_signed_3off,
		},
		{
			unpack_8_19bit_unsigned_4off,
			unpack_8_19bit_signed_4off,
		},
		{
			unpack_8_19bit_unsigned_5off,
			unpack_8_19bit_signed_5off,
		},
		{
			unpack_8_19bit_unsigned_6off,
			unpack_8_19bit_signed_6off,
		},
		{
			unpack_8_19bit_unsigned_7off,
			unpack_8_19bit_signed_7off,
		},
	},
	{
		{
			unpack_9_19bit_unsigned_0off,
			unpack_9_19bit_signed_0off,
		},
		{
			unpack_9_19bit_unsigned_1off,
			unpack_9_19bit_signed_1off,
		},
		{
			unpack_9_19bit_unsigned_2off,
			unpack_9_19bit_signed_2off,
		},
		{
			unpack_9_19bit_unsigned_3off,
			unpack_9_19bit_signed_3off,
		},
		{
			unpack_9_19bit_unsigned_4off,
			unpack_9_19bit_signed_4off,
		},
		{
			unpack_9_19bit_unsigned_5off,
			unpack_9_19bit_signed_5off,
		},
		{
			unpack_9_19bit_unsigned_6off,
			unpack_9_19bit_signed_6off,
		},
		{
			unpack_9_19bit_unsigned_7off,
			unpack_9_19bit_signed_7off,
		},
	},
	{
		{
			unpack_10_19bit_unsigned_0off,
			unpack_10_19bit_signed_0off,
		},
		{
			unpack_10_19bit_unsigned_1off,
			unpack_10_19bit_signed_1off,
		},
		{
			unpack_10_19bit_unsigned_2off,
			unpack_10_19bit_signed_2off,
		},
		{
			unpack_10_19bit_unsigned_3off,
			unpack_10_19bit_signed_3off,
		},
		{
			unpack_10_19bit_unsigned_4off,
			unpack_10_19bit_signed_4off,
		},
		{
			unpack_10_19bit_unsigned_5off,
			unpack_10_19bit_signed_5off,
		},
		{
			unpack_10_19bit_unsigned_6off,
			unpack_10_19bit_signed_6off,
		},
		{
			unpack_10_19bit_unsigned_7off,
			unpack_10_19bit_signed_7off,
		},
	},
	{
		{
			unpack_11_19bit_unsigned_0off,
			unpack_11_19bit_signed_0off,
		},
		{
			unpack_11_19bit_unsigned_1off,
			unpack_11_19bit_signed_1off,
		},
		{
			unpack_11_19bit_unsigned_2off,
			unpack_11_19bit_signed_2off,
		},
		{
			unpack_11_19bit_unsigned_3off,
			unpack_11_19bit_signed_3off,
		},
		{
			unpack_11_19bit_unsigned_4off,
			unpack_11_19bit_signed_4off,
		},
		{
			unpack_11_19bit_unsigned_5off,
			unpack_11_19bit_signed_5off,
		},
		{
			unpack_11_19bit_unsigned_6off,
			unpack_11_19bit_signed_6off,
		},
		{
			unpack_11_19bit_unsigned_7off,
			unpack_11_19bit_signed_7off,
		},
	},
	{
		{
			unpack_12_19bit_unsigned_0off,
			unpack_12_19bit_signed_0off,
		},
		{
			unpack_12_19bit_unsigned_1off,
			unpack_12_19bit_signed_1off,
		},
		{
			unpack_12_19bit_unsigned_2off,
			unpack_12_19bit_signed_2off,
		},
		{
			unpack_12_19bit_unsigned_3off,
			unpack_12_19bit_signed_3off,
		},
		{
			unpack_12_19bit_unsigned_4off,
			unpack_12_19bit_signed_4off,
		},
		{
			unpack_12_19bit_unsigned_5off,
			unpack_12_19bit_signed_5off,
		},
		{
			unpack_12_19bit_unsigned_6off,
			unpack_12_19bit_signed_6off,
		},
		{
			unpack_12_19bit_unsigned_7off,
			unpack_12_19bit_signed_7off,
		},
	},
	{
		{
			unpack_13_19bit_unsigned_0off,
			unpack_13_19bit_signed_0off,
		},
		{
			unpack_13_19bit_unsigned_1off,
			unpack_13_19bit_signed_1off,
		},
		{
			unpack_13_19bit_unsigned_2off,
			unpack_13_19bit_signed_2off,
		},
		{
			unpack_13_19bit_unsigned_3off,
			unpack_13_19bit_signed_3off,
		},
		{
			unpack_13_19bit_unsigned_4off,
			unpack_13_19bit_signed_4off,
		},
		{
			unpack_13_19bit_unsigned_5off,
			unpack_13_19bit_signed_5off,
		},
		{
			unpack_13_19bit_unsigned_6off,
			unpack_13_19bit_signed_6off,
		},
		{
			unpack_13_19bit_unsigned_7off,
			unpack_13_19bit_signed_7off,
		},
	},
	{
		{
			unpack_14_19bit_unsigned_0off,
			unpack_14_19bit_signed_0off,
		},
		{
			unpack_14_19bit_unsigned_1off,
			unpack_14_19bit_signed_1off,
		},
		{
			unpack_14_19bit_unsigned_2off,
			unpack_14_19bit_signed_2off,
		},
		{
			unpack_14_19bit_unsigned_3off,
			unpack_14_19bit_signed_3off,
		},
		{
			unpack_14_19bit_unsigned_4off,
			unpack_14_19bit_signed_4off,
		},
		{
			unpack_14_19bit_unsigned_5off,
			unpack_14_19bit_signed_5off,
		},
		{
			unpack_14_19bit_unsigned_6off,
			unpack_14_19bit_signed_6off,
		},
		{
			unpack_14_19bit_unsigned_7off,
			unpack_14_19bit_signed_7off,
		},
	},
	{
		{
			unpack_15_19bit_unsigned_0off,
			unpack_15_19bit_signed_0off,
		},
		{
			unpack_15_19bit_unsigned_1off,
			unpack_15_19bit_signed_1off,
		},
		{
			unpack_15_19bit_unsigned_2off,
			unpack_15_19bit_signed_2off,
		},
		{
			unpack_15_19bit_unsigned_3off,
			unpack_15_19bit_signed_3off,
		},
		{
			unpack_15_19bit_unsigned_4off,
			unpack_15_19bit_signed_4off,
		},
		{
			unpack_15_19bit_unsigned_5off,
			unpack_15_19bit_signed_5off,
		},
		{
			unpack_15_19bit_unsigned_6off,
			unpack_15_19bit_signed_6off,
		},
		{
			unpack_15_19bit_unsigned_7off,
			unpack_15_19bit_signed_7off,
		},
	},
	{
		{
			unpack_16_19bit_unsigned_0off,
			unpack_16_19bit_signed_0off,
		},
		{
			unpack_16_19bit_unsigned_1off,
			unpack_16_19bit_signed_1off,
		},
		{
			unpack_16_19bit_unsigned_2off,
			unpack_16_19bit_signed_2off,
		},
		{
			unpack_16_19bit_unsigned_3off,
			unpack_16_19bit_signed_3off,
		},
		{
			unpack_16_19bit_unsigned_4off,
			unpack_16_19bit_signed_4off,
		},
		{
			unpack_16_19bit_unsigned_5off,
			unpack_16_19bit_signed_5off,
		},
		{
			unpack_16_19bit_unsigned_6off,
			unpack_16_19bit_signed_6off,
		},
		{
			unpack_16_19bit_unsigned_7off,
			unpack_16_19bit_signed_7off,
		},
	},
	{
		{
			unpack_17_19bit_unsigned_0off,
			unpack_17_19bit_signed_0off,
		},
		{
			unpack_17_19bit_unsigned_1off,
			unpack_17_19bit_signed_1off,
		},
		{
			unpack_17_19bit_unsigned_2off,
			unpack_17_19bit_signed_2off,
		},
		{
			unpack_17_19bit_unsigned_3off,
			unpack_17_19bit_signed_3off,
		},
		{
			unpack_17_19bit_unsigned_4off,
			unpack_17_19bit_signed_4off,
		},
		{
			unpack_17_19bit_unsigned_5off,
			unpack_17_19bit_signed_5off,
		},
		{
			unpack_17_19bit_unsigned_6off,
			unpack_17_19bit_signed_6off,
		},
		{
			unpack_17_19bit_unsigned_7off,
			unpack_17_19bit_signed_7off,
		},
	},
	{
		{
			unpack_18_19bit_unsigned_0off,
			unpack_18_19bit_signed_0off,
		},
		{
			unpack_18_19bit_unsigned_1off,
			unpack_18_19bit_signed_1off,
		},
		{
			unpack_18_19bit_unsigned_2off,
			unpack_18_19bit_signed_2off,
		},
		{
			unpack_18_19bit_unsigned_3off,
			unpack_18_19bit_signed_3off,
		},
		{
			unpack_18_19bit_unsigned_4off,
			unpack_18_19bit_signed_4off,
		},
		{
			unpack_18_19bit_unsigned_5off,
			unpack_18_19bit_signed_5off,
		},
		{
			unpack_18_19bit_unsigned_6off,
			unpack_18_19bit_signed_6off,
		},
		{
			unpack_18_19bit_unsigned_7off,
			unpack_18_19bit_signed_7off,
		},
	},
	{
		{
			unpack_19_19bit_unsigned_0off,
			unpack_19_19bit_signed_0off,
		},
		{
			unpack_19_19bit_unsigned_1off,
			unpack_19_19bit_signed_1off,
		},
		{
			unpack_19_19bit_unsigned_2off,
			unpack_19_19bit_signed_2off,
		},
		{
			unpack_19_19bit_unsigned_3off,
			unpack_19_19bit_signed_3off,
		},
		{
			unpack_19_19bit_unsigned_4off,
			unpack_19_19bit_signed_4off,
		},
		{
			unpack_19_19bit_unsigned_5off,
			unpack_19_19bit_signed_5off,
		},
		{
			unpack_19_19bit_unsigned_6off,
			unpack_19_19bit_signed_6off,
		},
		{
			unpack_19_19bit_unsigned_7off,
			unpack_19_19bit_signed_7off,
		},
	},
	{
		{
			unpack_20_19bit_unsigned_0off,
			unpack_20_19bit_signed_0off,
		},
		{
			unpack_20_19bit_unsigned_1off,
			unpack_20_19bit_signed_1off,
		},
		{
			unpack_20_19bit_unsigned_2off,
			unpack_20_19bit_signed_2off,
		},
		{
			unpack_20_19bit_unsigned_3off,
			unpack_20_19bit_signed_3off,
		},
		{
			unpack_20_19bit_unsigned_4off,
			unpack_20_19bit_signed_4off,
		},
		{
			unpack_20_19bit_unsigned_5off,
			unpack_20_19bit_signed_5off,
		},
		{
			unpack_20_19bit_unsigned_6off,
			unpack_20_19bit_signed_6off,
		},
		{
			unpack_20_19bit_unsigned_7off,
			unpack_20_19bit_signed_7off,
		},
	},
	{
		{
			unpack_21_19bit_unsigned_0off,
			unpack_21_19bit_signed_0off,
		},
		{
			unpack_21_19bit_unsigned_1off,
			unpack_21_19bit_signed_1off,
		},
		{
			unpack_21_19bit_unsigned_2off,
			unpack_21_19bit_signed_2off,
		},
		{
			unpack_21_19bit_unsigned_3off,
			unpack_21_19bit_signed_3off,
		},
		{
			unpack_21_19bit_unsigned_4off,
			unpack_21_19bit_signed_4off,
		},
		{
			unpack_21_19bit_unsigned_5off,
			unpack_21_19bit_signed_5off,
		},
		{
			unpack_21_19bit_unsigned_6off,
			unpack_21_19bit_signed_6off,
		},
		{
			unpack_21_19bit_unsigned_7off,
			unpack_21_19bit_signed_7off,
		},
	},
	{
		{
			unpack_22_19bit_unsigned_0off,
			unpack_22_19bit_signed_0off,
		},
		{
			unpack_22_19bit_unsigned_1off,
			unpack_22_19bit_signed_1off,
		},
		{
			unpack_22_19bit_unsigned_2off,
			unpack_22_19bit_signed_2off,
		},
		{
			unpack_22_19bit_unsigned_3off,
			unpack_22_19bit_signed_3off,
		},
		{
			unpack_22_19bit_unsigned_4off,
			unpack_22_19bit_signed_4off,
		},
		{
			unpack_22_19bit_unsigned_5off,
			unpack_22_19bit_signed_5off,
		},
		{
			unpack_22_19bit_unsigned_6off,
			unpack_22_19bit_signed_6off,
		},
		{
			unpack_22_19bit_unsigned_7off,
			unpack_22_19bit_signed_7off,
		},
	},
	{
		{
			unpack_23_19bit_unsigned_0off,
			unpack_23_19bit_signed_0off,
		},
		{
			unpack_23_19bit_unsigned_1off,
			unpack_23_19bit_signed_1off,
		},
		{
			unpack_23_19bit_unsigned_2off,
			unpack_23_19bit_signed_2off,
		},
		{
			unpack_23_19bit_unsigned_3off,
			unpack_23_19bit_signed_3off,
		},
		{
			unpack_23_19bit_unsigned_4off,
			unpack_23_19bit_signed_4off,
		},
		{
			unpack_23_19bit_unsigned_5off,
			unpack_23_19bit_signed_5off,
		},
		{
			unpack_23_19bit_unsigned_6off,
			unpack_23_19bit_signed_6off,
		},
		{
			unpack_23_19bit_unsigned_7off,
			unpack_23_19bit_signed_7off,
		},
	},
	{
		{
			unpack_24_19bit_unsigned_0off,
			unpack_24_19bit_signed_0off,
		},
		{
			unpack_24_19bit_unsigned_1off,
			unpack_24_19bit_signed_1off,
		},
		{
			unpack_24_19bit_unsigned_2off,
			unpack_24_19bit_signed_2off,
		},
		{
			unpack_24_19bit_unsigned_3off,
			unpack_24_19bit_signed_3off,
		},
		{
			unpack_24_19bit_unsigned_4off,
			unpack_24_19bit_signed_4off,
		},
		{
			unpack_24_19bit_unsigned_5off,
			unpack_24_19bit_signed_5off,
		},
		{
			unpack_24_19bit_unsigned_6off,
			unpack_24_19bit_signed_6off,
		},
		{
			unpack_24_19bit_unsigned_7off,
			unpack_24_19bit_signed_7off,
		},
	},
	{
		{
			unpack_25_19bit_unsigned_0off,
			unpack_25_19bit_signed_0off,
		},
		{
			unpack_25_19bit_unsigned_1off,
			unpack_25_19bit_signed_1off,
		},
		{
			unpack_25_19bit_unsigned_2off,
			unpack_25_19bit_signed_2off,
		},
		{
			unpack_25_19bit_unsigned_3off,
			unpack_25_19bit_signed_3off,
		},
		{
			unpack_25_19bit_unsigned_4off,
			unpack_25_19bit_signed_4off,
		},
		{
			unpack_25_19bit_unsigned_5off,
			unpack_25_19bit_signed_5off,
		},
		{
			unpack_25_19bit_unsigned_6off,
			unpack_25_19bit_signed_6off,
		},
		{
			unpack_25_19bit_unsigned_7off,
			unpack_25_19bit_signed_7off,
		},
	},
	{
		{
			unpack_26_19bit_unsigned_0off,
			unpack_26_19bit_signed_0off,
		},
		{
			unpack_26_19bit_unsigned_1off,
			unpack_26_19bit_signed_1off,
		},
		{
			unpack_26_19bit_unsigned_2off,
			unpack_26_19bit_signed_2off,
		},
		{
			unpack_26_19bit_unsigned_3off,
			unpack_26_19bit_signed_3off,
		},
		{
			unpack_26_19bit_unsigned_4off,
			unpack_26_19bit_signed_4off,
		},
		{
			unpack_26_19bit_unsigned_5off,
			unpack_26_19bit_signed_5off,
		},
		{
			unpack_26_19bit_unsigned_6off,
			unpack_26_19bit_signed_6off,
		},
		{
			unpack_26_19bit_unsigned_7off,
			unpack_26_19bit_signed_7off,
		},
	},
};
